Please find below my first attempt at the connector
<? // root path to browsable/uploadable directory // e.g. <a href="http://www.mydomain.com/uploads" target="_blank">http://www.mydomain.com/uploads</a> $rootURL = "/uploads"; //prefix that appears before file name when browsed for e.g. localhost // e.g. <a href="http://$URLprefix/uploads/mypic.jpg" target="_blank">http://$URLprefix/uploads/mypic.jpg</a> $URLprefix = $_SERVER['SERVER_NAME']; // debug. if true also writes output to a file in executing directory $debug = false; //------------------------------------------------------------------------// // Hello // // This is my first attempt at helping with an open source project so // please bear with me. I've written this connector as i want to use the // FCKEditor in my site because it will be an excellent piece of software. // if this helps move things along, brilliant. // // This connector handles File browsing & uploading however it does not // check permissions or if the filename is valid. Please feel free to add // this yourself if required. // // I hope you find this useful. // // fatboy // // <a href="mailto:fatFCK@code247.com" target="_new">fatFCK@code247.com</a> // //------------------------------------------------------------------------// //------------------------------------------------------------------------// // START OF FUNCTIONS //------------------------------------------------------------------------// // returns xml folders node function list_folders($dir_name) { $dir_name = ".".$dir_name; $dir = opendir($dir_name); $dir_list = array(); while ($file_name = readdir($dir)) { if ( ($file_name != ".") && ($file_name != "..") ) { $find = $dir_name."/".$file_name; if(is_dir($find)) array_push($dir_list,$file_name); }; }; closedir($dir); sort($dir_list); $dirs = "<Folders>\n"; while (list($key,$value) = each($dir_list)) { $dirs .= "\t<Folder name=\"".$value."\"/>\n"; }; $dirs .= "</Folders>"; return $dirs; }; // returns xml files node function list_files($dir_name,$resourceType) { $allow_ext = "gif,jpeg,jpg,png,bmp,swf,wav,mp3,wma,xls,doc,txt,ppt,xml"; switch($resourceType){ case "Image": $allow_ext = "gif,jpeg,jpg,png,bmp"; break; case "Flash": $allow_ext = "swf"; break; case "Media": $allow_ext = "wav,mp3,wma"; break; } // switch $dir_name = ".".$dir_name; $dir = opendir($dir_name); $file_list = array(); while ($file_name = readdir($dir)) { if ( ($file_name != ".") && ($file_name != "..") ) { $find = $dir_name."/".$file_name; if(!is_dir($find)) { $add = false; $extension = pathinfo($find); $extension = $extension[extension]; $allowed_extensions = explode(",", $allow_ext); for($i = 0; $i < count($allowed_extensions); $i++) { if($allowed_extensions[$i] == "$extension") { $add = true; break; } } if($add) array_push($file_list,$file_name."^".(ceil(filesize($find)/1024))); } }; }; closedir($dir); sort($file_list); $files = "<Files>\n"; while (list($key,$value) = each($file_list)) { list($name,$size) = split('[\^]',$value); $files .= "\t<File name=\"".$name."\" size=\"$size\"/>\n"; }; $files .= "</Files>"; return $files; }; function GetFoldersAndFiles($dir, $baseURL, $resourcetype) { $xml = "<?xml version='1.0' encoding='utf-8'?>\n";
PHP Connector - sorry wrong version try this
ok slap me with a wet kipper i put the wrong version up. i can't edit my posts so try this one.
PHP Connector - first attempt
I've managed yo get the latest version up into some web space so you can now download it from
http://www.code247.com/connector
hopefully we can now have nice little sized posts
RE: PHP Connector - first attempt
Thanks for this nice peace of code. I'll take a look on it and I hope I can include it in the next beta.
Best regards,
FredCK
Frederico Knabben
CKEditor Project Lead and CKSource Owner
--
Follow us on: Twitter | Facebook | Google+ | LinkedIn
RE: PHP Connector - first attempt
I just got started with FCK and PHP. Managed to customize most of it to my wishes, but I understand that I need this PHP connector in order to get file uploads working. Seems like magic.
So, I am not really sure how to get started here. Here's what I did so far (without any results however): I put your connector.php in /fckeditor/editor/filemanager/browser/default/connectors/php. Next, in the fckconfig.js file I changed the lines under the comment 'Link Browsing' as follows:
FCKConfig.LinkBrowser = true ;
FCKConfig.LinkBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Connector=connectors/php/connector.php" ;
So far OK right?
Then, in connector.php, I set
$rootURL = "/kt/uploads";
(kt is an alias for a directory somewhere in the Win XP My Documents folder - a yes, I'm testing locally on XP, PHP 4.3 - but that alias should work fine I guess)
Next, when I enable debugging in your php file, I see an output.htm in the php directory. It says:
<Connector command="GetFoldersAndFiles" resourceType="Media" stamp="1087509449">
<CurrentFolder path="/" url="localhost/kt/uploads/" />
<Folders>
</Folders>
<Files>
</Files>
</Connector>
Could you give me any hints?
RE: PHP Connector - first attempt
... Filebrowser ... did i miss something? Allready in Version 1.x?
When i look at at the *.php in the filebrowser-Folder of Version 1.x, i see a simple litte Uploader-Script (and a FileLister ... )
What you have coded above is a great deal more!
But i'm missing a clear interface. It's just a bunch of Functions.
That's something i allready missed in Version 1.x. An Object oriented Approach in Creating, Configuring and Fetching the Editor. It was there, but it was too small. Too many thing were to be done elsewhere.
I'm planning on making a connector as element in PEAR::HTML_Quickform. I won't touch the Filebrowser, since you are doing some promising things here.
RE: PHP Connector - first attempt
>But i'm missing a clear interface. It's just a bunch of Functions.
thats not the whole thing ..
look at "FCKeditor_2.0b1\fckeditor\editor\filemanager\browser\default"
there is the interface ..
the connector communicate in XML/HTML with this interface ..
>I won't touch the Filebrowser, since you are doing some promising things here.
i think if you take a deeper look .. you will see thats things already "promising" good ideas
RE: PHP Connector - first attempt
Great work !
Thanx for this code worked perfectly.
rmz - bertbalcaen:
Your problem may be that the script does not have the correct rights to the uploadfolder. Try to rightclick the folder. Go to Securety then add Everyone to the list and give Full Control rights. (Be carefull with giving this type of right to any folder, it opens up you system to ... everyone )
BR
Martin Kronstad
RE: PHP Connector - first attempt
The reason was the dir_name variabel started with a .. and the code added another . so the folder was not found ... I added a handeler for this...
Replace:
$dir_name = ".".$dir_name;
With :
if(substr($dir_name,0,1) != ".") $dir_name = ".".$dir_name;
Do this on Line 41 and 74
And it works...
BR
Martin Kronstad
RE: PHP Connector - first attempt
Someone know why it's possible to upload PHP files? this is not safe
RE: PHP Connector - first attempt
Ok ... I done some more changes ... download new file here :
http://www.siteman.no/martin/connector.zip
Changes :
- Fixed problem with handeling ../ directories.
- Moved allow_ext to bottom, made global for phpfile
- Added control when uploading files. Only files in allow_ext uploaded.
- Added support for uppcase letters in extention
BR
Martin Kronstad
RE: PHP Connector - first attempt
Isnt that starange? Anyone else having this problem?
RE: [johannesf] PHP Connector - first attempt
chmod($uniqueName, 0644);
With this, ur files will be deletable under a linux/unix web shared system.
Hope this will help,
Simon [Fr] ^^
RE: PHP Connector - first attempt
I also tried this efter:
if (move_uploaded_file($_FILES['NewFile']['tmp_name'],$uniqueName) ) {
here:
$oldMask = umask(0);
chmod($uniqueName, 0644);
umask($oldMask);
but still I cant delete the files, I use Linux on the server.
Tip:
on row 166
if(!mkdir($newfldr, 0775))
to mekae me delete the folders
RE: PHP Connector - first attempt
I have no idea, what you wish to do with umask().
But sure ist: 0644 is not enough. Owner of file can read and write. Group and world can only read. The owner in this case is the creator==webserver.
Try chmod($uniqueName, 0666) instead. So everyone can read and write as written in thread http://sourceforge.net/forum/forum.php? ... _id=379487
Greetings,
Andreas.
RE: PHP Connector - first attempt
Well, I have doone a script that delete them som it ok for the moment, but still I cant understand why It wont work for mee.
It would be nice to have a "deletebotton" int the filemanager!
/jof
RE: PHP Connector - first attempt
Maybe 0775 is not enough for directory and you have to use 0777 to access to its content.
Greetings,
Andreas.
RE: PHP Connector - first attempt
Thanks
Jake
RE: PHP Connector - first attempt
I don't think you are missing the point. The resourcemanager is used to upload and maintain your images , and other files. But you need to use the Image toolbaritem(Witch does not seem to be done in v2.0 Beta 1). You may also use a custom image gallery for the images. You can see how I use my image gallery here : http://www.prosjektweb.net/imggallery .. This is a demo , you must drag'n drop images into the editor ... remeber there is a bug in v2.0 Beta 1 witch makes it impossible to drop it on any other line than one with text in it. If you or anyone else wants the sourcecode for my imagegallery I will gladly provide it. just send me an email.
BR Martin Kronstad
RE: PHP Connector - first attempt
I packed up a source with I tried to clean up a little ... please let me know if some part of the code is hard to understand http://www.prosjektweb.net/imggallery/imggallery.zip
My email is written in the readme.txt file in the zip.
BR Martin Kronstad
RE: PHP Connector - first attempt
RE: PHP Connector - first attempt