Ruby on Rails - FCKEditor Absolute Image Path Ruby - ruby-on-rails

I am using the FCKEditor wysiwyg editor, and was wondering if anyone figured out how to use the absolute path instead of relative path after you add an image in the editor?
And if so, how.

Search for this code in fckeditor\editor\filemanager\browser\default\connectors\php\basexml.php:
echo '<CurrentFolder path="' . ConvertToXmlAttribute( $currentFolder ) . '" url="' . ConvertToXmlAttribute( GetUrlFromPath( $resourceType, $currentFolder ) ) . '" />' ;
Replace it with this:
echo '<CurrentFolder path="' . ConvertToXmlAttribute( $currentFolder ) . '" url="'.'http://www.YOURDOMAINHERE.com' .ConvertToXmlAttribute( GetUrlFromPath( $resourceType, $currentFolder ) ) . '" />' ;

Related

Converting using ImageMagick creates 2 images of the same

I'm converting images into different sizes using ImageMagick. The conversion works OK, but there are some files that are converted twice.
For example, i'm converting a filename rj54c124a4cb96b3.56843124.tif into jpg using the suffix small.
The conversion works OK but i'm getting two of the same, like so: rj54c124a4cb96b3.56843124_small-0.jpg and rj54c124a4cb96b3.56843124_small-1.jpg
It adds a number after the suffix! Why? Like i've said, out of 3000 files, it only does that to a couple.
EDIT:
As per Keith Thompson question, here's the script im using in PHP
$file = 'c:/website_gallery/rj54c124a4cb96b3.56843124.tif';
$output = 'c:/public_html/gallery/files/4/2/rj54c124a4cb96b3.56843124_small.jpg';
$operator = '-resize'; // in some cases i will use -thumbnail
$width = 125;
$height = 125;
$flag = '^>'; // for localhost; use \> for live host server
exec('convert' . ' ' . $file . ' ' . $operator . ' ' . $width . 'x' . $height . $flag . ' ' . $output, $debug, $return);

HTML5_Builder Upload Component PHP Upload

Using Upload component from HTML5 Builder Embarcadero
Upload is a submit enabled button on the form. But the documentation doesn't tell me where the actual file goes. When this function is called after the supposed successful upload all the names of the upload do come out. I can see the temp file name, file name, file size, etc in the memo box. But when I try this from HTML 5 Builder in Windows 10 or on the server the uploaded target file seems to be no where. I must be missing something.
function UploadClick($sender, $params)
{
//upload the file
$this->UploadStatus->Caption = 'BtnUploadClick ' . $this->Upload1->FileName;
$this->Memo1->AddLine('FileTmpName: ' . $this->Upload1->FileTmpName);
$this->Memo1->AddLine('FileName: ' . $this->Upload1->FileName);
$this->Memo1->AddLine('FileSize: ' . $this->Upload1->FileSize);
$this->Memo1->AddLine('FileType: ' . $this->Upload1->FileType);
$this->Memo1->AddLine('FileSubType : ' . $this->Upload1->FileSubType);
$this->Memo1->AddLine('GraphicWidth: ' . $this->Upload1->GraphicWidth);
$this->Memo1->AddLine('GraphicHeihgt: ' . $this->Upload1->GraphicHeight);
if($this->Upload1->isGIF ())
$tmp = ' is gif';
if($this->Upload1->isJPEG())
$tmp = ' is jpeg';
if($this->Upload1->isPNG())
$tmp = ' is png';
$this->Memo1->AddLine('File Ext: ' . $this->Upload1->FileExt . $tmp);
}
What is not shown in the example is you need to collect the file from the server temp directory and then place it where you want:
if(move_uploaded_file($this->Upload1->FileTmpName, $this->Upload1->FileName))
{
echo "File is valid, and was successfully uploaded.\n";
}
else
{
echo "Possible file upload attack!\n";
}
Just add to the previous code and the file is saved to the server at the script location.

ZF2 XML Creation

I am new to zend framework 2 . Can any one describe me how to create XML files using ZF2 .
I need to access remote server via sending data through XML file . So I need to create a xml file with lot of sub divisions by creating and appending XML file . Please somebody describe me how to do it . Thanks in advance .
Please use php xml functions
$doc = new \DOMDocument('1.0', 'UTF-8');
$elm = $doc->createElement("NCScript");
$elm->setAttribute('xmlns', 'http://yourpath:NStd');
$elm->setAttribute('xmlns:NStd', 'http://yourpath');
$elm->setAttribute('xmlns:xsi', 'http://yourpath');
$doc->appendChild($elm);
$b = $doc->createElement("Auth");
$partnerName = $doc->createElement("partnerName");
$partnerName->appendChild(
$doc->createTextNode('Partnername')
);
$b->appendChild($partnerName);
$name = $doc->createElement("name");
$name->appendChild(
$doc->createTextNode('username')
);
use this we can create xml file and use $xml = $doc->saveXML(); to return the xml file

retrieve id3 informations from remote mp3 file

I need to get these information not from a file located on my machine, but on another one.
In general I'm able to get these infos in this way:
TagLib::MPEG::File.open("myfile.mp3") do |file|
tag = file.tag
"Artist: " + tag.artist + " " +
"Title: " + tag.title + " " +
"Album: " + tag.album + " "
end
... but if I open a link to the file like "http:// .../myfile.mp3" It doesn't work. Why?
Is there a different way to resolve it?
TagLib only works on files on the local filesystem. To retrieve tags from remote files, you'd first have to download that file to your local disk.
So a path to the file system should be given to the TagLib::MPEG::File.open param, not a url.

CopyFile Vbscript

I need to join any files (2GB) without read their content. I have tried to use CopyFile method but it doesn't work.
My code is that:
Public Function UnificarCRIs(ByVal path, ByVal FICRIEC, ByVal sessio, ByVal CIBAA)
Dim objFile, objCurrentFolder, filesys, origenFitxers
Dim FileName, WshShell
On error resume next
Set filesys = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objCurrentFolder = filesys.getFolder(path)
origenFitxers = " "
For Each objFile In objCurrentFolder.Files
FileName = objFile
If (right(FileName, 4) = ".cri") Then
origenFitxers = FileName
'Wscript.Echo FileName
If filesys.FileExists(path & FICRIEC & sessio) Then
'Wscript.Echo "If"
Wscript.Echo path & FICRIEC & sessio & "+" & FileName
filesys.CopyFile path & FICRIEC & sessio & "+" & FileName, path & FICRIEC & sessio
'WshShell.Run ("copy " & path & FICRIEC & sessio & "+" & FileName & " " & path & FICRIEC & sessio & "_tmp")
'filesys.DeleteFile path & FICRIEC & sessio
'filesys.MoveFile path & FICRIEC & sessio & "_tmp", path & FICRIEC & sessio
Else
Wscript.Echo "Else"
WshShell.Run ("copy " & FileName & " " & path & FICRIEC & sessio)
'filesys.CopyFile FileName,path & FICRIEC & sessio
End If
End If
Next
End Function
Are there some way to join two files using Vbscript?
Thanks
To join two files, 'someone' has to to read (and write) the contents of both files. This 'someone' could be copy [/B] f1 + f2 f3. So use your loop to build the correct file specs and WshShell.Run/.Exec the suitabe commands.
Depends which COM objects you have access to and where the code is running.
1) If you have access to the Shell, then use the copy command of the DOS prompt. This example shows the excecution of the Dir command but it's the same technique.
Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
' Note the True value means wait to complete...
' And the 0 value means do not display any window...
oShell.run "cmd /K CD C:\ & Dir", 0, True
Set oShell = Nothing
And maybe also take a look here http://ss64.com/vb/shellexecute.html. Don't know if that method will help.
2) If you have no shell then if you can make COM objects then make one with C++ or Delphi or VB6 etc. Then use that COM object to execute the DOS command to do the merging.
3) Otherwise you will have to read the data from the file. If it is text files then that is easy because there are simple commands to do that with in the Vbs. If it is binary data then that requires more work to get at the binary data and use the "LenB" and "AscB" style functions to access the raw bytes of the Unicode. But you really do not want to do that.
Any upload handling script for ASP should show you the technique for working with raw bytes from the strings.
You can combine VBScript with Windows Copy command to join files.
You can see the document on appending binary files using Copy here
https://support.microsoft.com/en-us/kb/71161
Here's the example of the technique:
JoinFiles "c:\test\", "c:\test\mergedfile.cri"
Function JoinFiles (inPath, outPath)
Dim objShell, objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")
Dim strFilenames, objFile, intFilecount, intExitCode
strFilenames = ""
intFilecount = 0
intExitCode = 0
' If the input folder exists, proceed to listing the files
If objFSO.FolderExists (inPath) Then
' List the files in the folder and join the files which has cri extension
For Each objFile In objFSO.GetFolder(inPath).Files
If LCase (objFSO.GetExtensionName (objFile.Path)) = "cri" Then
intFilecount = intFilecount+1
strFilenames = strFilenames & """" & objFile.Path & """ + "
End If
Next
' If there're more than one file, proceed to join the file
If (intFilecount > 1) Then
' join the files. Remove the last 3 characters from strFilenames (" + ").
intExitCode = objShell.Run ("%COMSPEC% /C COPY /B " & Left (strFilenames, Len (strFilenames)-3) _
& " """ & outPath & """ /Y", 0, True)
Else
' Not enough file to join
End If
Else
' Can't find folder, exit.
End If
End Function

Resources