Hi everybody,
Excuse me to resend the same question again and again, but I'm looking for a solution since one month and I've not founded clear answers.
I'm using Fckeditor 2.5 (the last release, not the 'pre-beta') in PHP context.
I've tried using $_SESSION variables to set custom user file path:
- I add "session_start();" in all PHP files of the PHP connector
- I set a $_SESSION['CustomUserFilePath'] variable in my file that call the Fckeditor instance
- I get this session variable in config.php, like: "$Config['UserFilesPath'] = $_SESSION['CustomUserFilePath']";
That doesn't work!
The "DoResponse()" function, which is called in connector.php, return allways a "/" for $sCurrentFolder value... because DoResponse() call GetCurrentFolder() another function that is in "io.php" file and GetCurrentFolder() doesn't use "$Config['UserFilesPath']" but "$_GET[''CurrentFolder]" instead of.
So where can I setting the $_GET['CurrentFolder'] in my application? Or how can I use $_SESSION variables to configures my dynamic user files path?
There are a many questions about this problem in the forum, but no answers or answers for older versions of Fck where "config.php" is different from the 2.5 version.
I think it's a big problem for everybody...
Thank's by advance and sorry for my simple frenchy English!
BR
Avairet
Excuse me to resend the same question again and again, but I'm looking for a solution since one month and I've not founded clear answers.
I'm using Fckeditor 2.5 (the last release, not the 'pre-beta') in PHP context.
I've tried using $_SESSION variables to set custom user file path:
- I add "session_start();" in all PHP files of the PHP connector
- I set a $_SESSION['CustomUserFilePath'] variable in my file that call the Fckeditor instance
- I get this session variable in config.php, like: "$Config['UserFilesPath'] = $_SESSION['CustomUserFilePath']";
That doesn't work!
The "DoResponse()" function, which is called in connector.php, return allways a "/" for $sCurrentFolder value... because DoResponse() call GetCurrentFolder() another function that is in "io.php" file and GetCurrentFolder() doesn't use "$Config['UserFilesPath']" but "$_GET[''CurrentFolder]" instead of.
So where can I setting the $_GET['CurrentFolder'] in my application? Or how can I use $_SESSION variables to configures my dynamic user files path?
There are a many questions about this problem in the forum, but no answers or answers for older versions of Fck where "config.php" is different from the 2.5 version.
I think it's a big problem for everybody...
Thank's by advance and sorry for my simple frenchy English!
BR
Avairet
Re: Dynamic UserFilePath again and again !!
Why nobody in the Fck Team can clarify this point?
Because nobody has answer?
Because answer is really simple and you consider it's not necessary to explain that in the Support forum?
OK, so where is the explanation for this in Fck editor doc or API or manual?
The only thing we can read in the manual is to change the "config.php" file in the PHP connector... but this is work for only one "user files path", not for dynamical.
In another way : how to get and set dynamical variables in a PHP Fck instance?
Thank's in advance to the comprehensive guys will try to explain that.
BR
Avairet
Re: Dynamic UserFilePath again and again !!
Re: Dynamic UserFilePath again and again !!
=> modify your config.php as like under :
start a session just after the "<?" tag
Use a session variable like $_SESSION['userfilepath'] (i assumed that session variable have been declare before calling the fckeditor)
so you should have a config file like that :
<?php
session_start();
...
...
...
// Path to user files relative to the document root.
$Config['UserFilesPath'] = '/Upload/' ; //<= Here i put a static path because i use my dynamic path under
...
...
...
//I put here only one section, but you should update each section for each type of file
//Example for File section
$Config['AllowedExtensions']['File'] = array('7z', 'aiff', 'asf', 'avi', 'bmp', 'csv', 'doc', 'fla', 'flv', 'gif', 'gz', 'gzip', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'ods', 'odt', 'pdf', 'png', 'ppt', 'pxd', 'qt', 'ram', 'rar', 'rm', 'rmi', 'rmvb', 'rtf', 'sdc', 'sitd', 'swf', 'sxc', 'sxw', 'tar', 'tgz', 'tif', 'tiff', 'txt', 'vsd', 'wav', 'wma', 'wmv', 'xls', 'xml', 'zip') ;
$Config['DeniedExtensions']['File'] = array() ;
$Config['FileTypesPath']['File'] = $Config['UserFilesPath'].$_SESSION['userfilepath'].'/';
$Config['FileTypesAbsolutePath']['File']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].$_SESSION['userfilepath'].'/file/';
$Config['QuickUploadPath']['File'] = $Config['UserFilesPath'] ;
$Config['QuickUploadAbsolutePath']['File']= $Config['UserFilesAbsolutePath'] ;
?>
DONT Forget to register and assigned the $_SESSION['userfilepath'] before calling fckeditor
Re: Dynamic UserFilePath again and again !!
I'm sorry but your solution doesn't work with 2.5 release...
I've already try this method.
The $_SESSION['userfilepath'] is not available in Fck context, even I put "session_start()" at the top of 'config.php' and register/assigned the $_SESSION['userfilepath'] before calling fckeditor!
Can you explain more?
Sorry for my simple English.
Avairet
Re: Dynamic UserFilePath again and again !!
Anyway, I'm running into the same problem trying to set an upload/browse path dynamically.
I'm trying to set as much as possible from a php subclass without touching fckeditor source files so stuff doesn't break when I upgrade it. Most things are working fine - sizes, toolbar sets, skins, but the UserFilePath setting doesn't propagate to the file browser from the editor instance, which makes things unnecessarily complex as you end up trying (and in my case, failing) to recreate the context in the file browser.
Surely there's some simple, sensible way of doing this?
Re: Dynamic UserFilePath again and again !!
Hello Synchro,
Sorry, I don't understand very well your answer...
Are you saying that you have the same problems and no solutions?
In my opinion, there's possible solution by using Javascript... but I'm not a master in js and I want solve it in PHP!
Maybe we could make a sit-in and peaceful protest in front of Fred CK office to get answers
BR
Avairet
Re: Dynamic UserFilePath again and again !!
Re: Dynamic UserFilePath again and again !!
FCKeditor doesn't dictate anything.
There's a config.php file, and you must set the values of certain variables in that file. Those are all the requirements.
You can choose to leave them hardcoded, use session variables, application, do some cookie check, use a database, include another file, whatever you want, it's just up to you how you want to configure it.
Re: Dynamic UserFilePath again and again !!
Have you try the Shwems solution?
Because this type of answer is always written in Fckeditor's forums or discussions, but with the v2.5 files structures of the PHP connector, it doesn't work!
So you can't say "if it doesn't work for you then sorry, there's no special magic involved", it's ridiculous, because I've not modified original files, I've read the API, the manual, the forums, the examples like Shwems, etc. but nothings work. And I'm not the only guy who can't do that!
A lot of my collegues (see Synchro answer for example) have the same problem.
So either it's impossible to configure a UserFilePAth dynamically or either there are a bug in the PHP implementation...
Excuse me for my simple frenchy English.
Avairet
Re: Dynamic UserFilePath again and again !!
I've written my post while you create yours...
I know that! But using session variables or something else to configure that dynamically doesn't work! I'm not crazy and I've testing all solutions to pass a variable to my Fck instance!
If you're sure this is effective, so can you tell me an example of PHP code that produce this thing and how you overwrite the $config in the "config.php"?
Thanks by advance and sorry again for my simple English
Avairet
Re: Dynamic UserFilePath again and again !!
Well, it's just not very helpful. What I'm suggesting is that such settings should be accessible from an editor instance (and thus a subclass), failing that an elegant override system like the CustomConfigurationsPath property does for the editor. As it stands, the editor has perfectly good context information in hand, but firing up an image browser just throws it all away and requires me to write more code just to get back to the same point.
Far as I'm aware, most of the point of a library is that it can be treated as a black box - it should not require twiddling with its internals to make it do basic functionality.
Having to hard-code stuff into source files also makes it difficult to a) upgrade fckeditor when new versions are released and b) use a single copy in more than one app, as might be common in a hosting context.
Re: Dynamic UserFilePath again and again !!
Specially about two points:
- "it should not require twiddling with its internals to make it do basic functionality."
- "Having to hard-code stuff into source files also makes it difficult"
And in case of Fckeditor, create dynamic folders for images storage is very important to avoid errors, crashes or to preserve anonymity of users.
For example : a simple user should not have an access to the admin images folder via the File Browser.
We can create custom "config.js" or "fckstyles.xml", so why can't we create a custom "connector/config.php" which handle, for example, session variables?
I've tried to create class, subclass, simple PHP script. I've tried to modify "config.php" with "session_start" and "$_SESSION[CustomUserFilePath]".
I've tried to modify the "GetCurrentFolder" function in "io.php"...
So I would like to view an example of code which work with v.2.5 release and PHP connector.
Avairet
Avairet
Re: Dynamic UserFilePath again and again !!
Re: Dynamic UserFilePath again and again !!
Re: Dynamic UserFilePath again and again !!
First, open the config.php, and find this line:
Put the base of your dynamic directory tree between the quotes; a la:
You have to do this anyway, or FCK won't save anything.
Now, in your editor page, add this line:
This goes before the Create() or ReplaceTextarea() function call. $user_dir can be any valid directory under the base directory specified above.
I think this is relatively safe, since the base directory is hidden, and you only show the final part of the directory path, which you can make as cryptic as you want.
This works fine for me; however, it doesn't pass this directory name to the system browser. I'm still working on that part.
-garison
Re: Dynamic UserFilePath again and again !!
This is currently the only thing stopping me from switching to FCKEditor. I don't see how any multi-user CMS can use it without this functionality.
Re: Dynamic UserFilePath again and again !!
/userfiles/1/images/ (where 1 is their user id)
This is what i did:
/php/config.php
I hope that would help.. i spent two days only to find out that i need to start the session to make it work T_T.
My next task is to make the non-login member not able to go to the upload screen at all. Now the code prevent this but user still be able to see upload options but only show error when try to upload. I don't think it's professional.
Perhaps I might disable the image icon completely for the non-login users.
Re: Dynamic UserFilePath again and again !!
Re: Dynamic UserFilePath again and again !!
@avairet: first of all, no one here is required to reply to your request. Things like your comments in the second post of this thread just invite others to be aggressive and less interested on helping you.
Frederico Knabben
CKEditor Project Lead and CKSource Owner
--
Follow us on: Twitter | Facebook | Google+ | LinkedIn
Re: Dynamic UserFilePath again and again !!
Then I create an instance of this class and generate an editor using CreateHTML(). The editor appears perfectly (very nice too), and I can see that it's using these overridden values. When I try to insert an image, it becomes clear that the image selector is not using the same config - and it's just looking in the default location. Do I need to do similar (but separate) overrides for the image selector class too? If so, where exactly, and how do I convince fck to use that class when it's not me that creates the file selector instance (e.g. can I pass a class name through the CustomConfigurationsPath file)?
The reason I'm using a subclass is so that I can upgrade FCKEditor in future without having to reapply edits to its own code (the usual reason for using a library).
Also, can you explain why the 'Enable' config doesn't let the connector work?
The cookie idea mentioned above is not much use as it's not secure - I don't want my users to be able to browse images belonging to other users by editing their cookies. As far as my users are concerned, their images are in / (which should work with UserFilesPath and UserFilesAbsolutePath as far as I can see).
Thanks
Re: Dynamic UserFilePath again and again !!
It does indeed look like the editor does not pass through these config values, and the file manager does not implement its config as a class I can override (I guess the editor class would need an overridable property to identify the file/class to use for the file manager), so it's apparently impossible to implement this without touching the fck source files.
Any other ideas? Should I post this as a feature request / bug report?
Re: Dynamic UserFilePath again and again !!
I too was not able to get the Session or passing of PHP or JS variables working. Session various were constantly reset or cleared throughout the maze of php files being access in the fckeditor files. Cookies seemed to be my best option too.
I created a session variable above the fckeditor.php call in the file that was going to display the editor, like so:
setcookie('fckfilepath', '/mypath/', time()+86400*30, '/');
include_once("../fckeditor/fckeditor.php");
Then in the config.php file I did this, as you suggested:
if (!empty($_COOKIE['fckfilepath'])){
$Config['UserFilesPath'] = $_COOKIE['fckfilepath'];
}else{
$Config['UserFilesPath'] = '/defaultpath/'; //only needed for config file to continue working.
}
Interestingly I still needed to have a hard coded path (in the else clause), even though it was ignoring it and reading the first bit of the if statement. I'm not entirely sure why, but either way, this worked for me too.
Lastly, I cleared my cookie at the end of my original file.
setcookie('fckfilepath','',time()-3600)
So once again, thank you for finally figuring out how to do this. I just wish fckeditor's developer guide explained this better. It wouldn't have taken me so long to get it working them.