Page 2 of 2

FCKeditor

Posted: Sat Jan 22, 2005 7:43 pm
by megabob3
Not incredible :D

It's a my BIG mistake :P

Thx Greg, with you i founded my errors :)

donwload this and try this new connector:
www.awakening.it/uploads/greg.zip
there also 3 javascript file.

In particular my error was on function "strrpos", because it don't find a string inside another string, but find only a char ;)

The right function is "strripos", but i don't use it, because it is a function of PHP5, so i added some lines that surely will function also on PHP3.

Thx again Greg, and i hope that this now go well :)

FCKeditor

Posted: Sat Jan 22, 2005 8:00 pm
by megabob3
Pls Greg after test also this other connector

and post the two LOG files.
/////////////////
log("GetRootPath():".$STR);

$config["uploads_path"] = trim(str_replace( '\\', '/', $config["uploads_path"] ));
$Log->log("uploads_path | ".$config["uploads_path"]);


$pos = strrpos($STR, "/");
$ult = trim(substr($STR, $pos+1, strlen($STR)-$pos));
$Log->log("ultima | ".$ult);

if (function_exists('strripos')) {
$pos = strripos($config["uploads_path"], $ult);
$Log->log("strripos THEN");
} else {
$posi = 0;
$tok = strtok($config["uploads_path"], '/');
while ($tok) {
$Log->log($tok);
if (strcmp($tok,$ult)==0)
$pos = $posi+strlen($tok)-1;
else
$posi += strlen($tok)+1;

$tok = strtok("/");
}
$Log->log("strripos ELSE");
}

$Log->log("Pos | TOKTOK | ".$pos." --- config[uploads_path][pos] |".$config["uploads_path"][$pos]);


$Log->log("+++++++++++++++++++++++++++");

while (($config["uploads_path"][$pos] != "/")&&($pos log("Pos | dentro | ".$pos." --- config[uploads_path][pos] |".$config["uploads_path"][$pos]);
$pos++;
}

$Log->log("+++++++++++++++++++++++++++");
$Log->log("Pos | dopo | ".$pos." --- config[uploads_path][pos] |".$config["uploads_path"][$pos]);
$Log->log("uploads_path[pos] ".$config["uploads_path"][$pos]);


$usrfp = trim(substr($config["uploads_path"], $pos)."/");

$GLOBALS["UserFilesPath"] = $usrfp ;

$GLOBALS["UserFilesDirectory"] = trim(str_replace( '\\', '/', GetRootPath() ) . str_replace( '\\', '/', $GLOBALS["UserFilesPath"] )) ;
$Log->log("UserFilesPath | ".$GLOBALS["UserFilesPath"]);
$Log->log("UserFilesDirectory | ".$GLOBALS["UserFilesDirectory"]);
$Log->close();
}

// Map the "UserFiles" path to a local directory.
$GLOBALS["UserFilesDirectory"] = trim(str_replace( '\\', '/', GetRootPath() ).str_replace( '\\', '/', $GLOBALS["UserFilesPath"] )) ;


DoResponse() ;

function DoResponse()
{
if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) )
return ;

// Get the main request informaiton.
$sCommand = $_GET['Command'] ;
$sResourceType = $_GET['Type'] ;
$sCurrentFolder = $_GET['CurrentFolder'] ;

// Check the current folder syntax (must begin and start with a slash).
if ( ! ereg( '/$', $sCurrentFolder ) ) $sCurrentFolder .= '/' ;
if ( strpos( $sCurrentFolder, '/' ) !== 0 ) $sCurrentFolder = '/' . $sCurrentFolder ;

// File Upload doesn't have to Return XML, so it must be intercepted before anything.
if ( $sCommand == 'FileUpload' )
{
FileUpload( $sResourceType, $sCurrentFolder ) ;
return ;
}

// Prevent the browser from caching the result.
// Date in the past
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT') ;
// always modified
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT') ;
// HTTP/1.1
header('Cache-Control: no-store, no-cache, must-revalidate') ;
header('Cache-Control: post-check=0, pre-check=0', false) ;
// HTTP/1.0
header('Pragma: no-cache') ;

// Set the response format.
header( 'Content-Type:text/xml; charset=utf-8' ) ;

CreateXmlHeader( $sCommand, $sResourceType, $sCurrentFolder ) ;

// Execute the required command.
switch ( $sCommand )
{
case 'GetFolders' :
GetFolders( $sResourceType, $sCurrentFolder ) ;
break ;
case 'GetFoldersAndFiles' :
GetFoldersAndFiles( $sResourceType, $sCurrentFolder ) ;
break ;
case 'CreateFolder' :
CreateFolder( $sResourceType, $sCurrentFolder ) ;
break ;
}

CreateXmlFooter() ;

exit ;
}
?>
///////////////////


Bye and infinite thx :)

FCKeditor

Posted: Sat Jan 22, 2005 10:44 pm
by Greg
Hi megabob3
Here is the log results from the test with the connector from the zip file
GetRootPath():d:/aaawebsites
uploads_path | d:/aaawebsites/websites/gregbloorcms/uploads
ultima | aaawebsites
d:
aaawebsites
websites
gregbloorcms
uploads
Pos | TOKTOK | 13 --- config[uploads_path][pos] |s
+++++++++++++++++++++++++++
Pos | dentro | 13 --- config[uploads_path][pos] |s
+++++++++++++++++++++++++++
Pos | dopo | 14 --- config[uploads_path][pos] |/
uploads_path[pos] /
UserFilesPath | /websites/gregbloorcms/uploads/
UserFilesDirectory | d:/aaawebsites/websites/gregbloorcms/uploads/
And from the last posted connector
GetRootPath():d:/aaawebsites
uploads_path | d:/aaawebsites/websites/gregbloorcms/uploads
ultima | aaawebsites
d:
aaawebsites
websites
gregbloorcms
uploads
strripos ELSE
Pos | TOKTOK | 13 --- config[uploads_path][pos] |s
+++++++++++++++++++++++++++
Pos | dentro | 13 --- config[uploads_path][pos] |s
+++++++++++++++++++++++++++
Pos | dopo | 14 --- config[uploads_path][pos] |/
uploads_path[pos] /
UserFilesPath | /websites/gregbloorcms/uploads/
UserFilesDirectory | d:/aaawebsites/websites/gregbloorcms/uploads/
I think you got it. Both connectors pick up the correct directory :D

FCKeditor

Posted: Sun Jan 23, 2005 9:56 am
by megabob3
I am happy.

Tried on upload and create directory??

:D

FCKeditor

Posted: Sun Jan 23, 2005 11:23 am
by megabob3
Sincerely i don't know why i am using a strange solution :P


Wishy it's possible have an uploads_path different from formula

uploads_path = GetRootPath() . "/websites/gregbloorcms/uploads"

where:

GetRootPath() = d:/aaawebsites

I wanna say, that uploads_path could be equal only with that formula.

So my solution it's a bit stupid.


Because it's enough only two lines instruction
$config["uploads_path"] = trim(str_replace( '\\', '/', $config["uploads_path"] ));
$GLOBALS["UserFilesPath"] = substr($config["uploads_path"], strlen(GetRootPath()))."/";

I lost alot of time :P, and time of Greg, sorry :(.

///////////

//////////

FCKeditor

Posted: Sun Jan 23, 2005 5:59 pm
by Greg
No problem meagabob3

What about the changes to the javascript .. are they necessary?

FCKeditor

Posted: Sun Jan 23, 2005 10:13 pm
by megabob3
Greg wrote:No problem meagabob3

What about the changes to the javascript .. are they necessary?
Yep they are necessary, for choose "images" directory instead of "image".

And the problem of quot character.

If you don't change js file, " char will be changed on "


Bye and thx.