Jump to content

neven

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

neven's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I have problem with elfinder file manager. The problem comes when I upload script on the server, then the text file preview does not work all text files are empty, newly created or old, edited or not. When in fact they are not empty. Strange thing is that when I try to edit the text, there I can see text but not in preview. On the local server all works normally. So please if someone is familiar with this problem let me know. Thanks. I have posted the connector script in witch is the root to the file. <?php error_reporting(0); // Set E_ALL for debuging if (function_exists('date_default_timezone_set')) { date_default_timezone_set('ce'); } include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinder.class.php'; $dbhost = '-----------'; $dbuser = '----------'; $dbpass = '-----------; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = '-----------'; mysql_select_db($dbname); session_start(); error_reporting(0); $number_dos = $_SESSION['dosje']; $q = "SELECT * FROM albums"; $results = mysql_query($q); $data = mysql_fetch_array($results); $diro = $data['dosjeid']; if($number_dos = $_SESSION['dosje']){ $dir_name = "store"; } $opts = array( 'root' => '../../'.$dir_name.'/'.$number_dos,// path to root directory 'URL' => 'http://www.next-it.co.cc/'.$dir_name.'/'.$number_dos.'/', // root directory URL 'rootAlias' => 'Home', // display this instead of root directory name //'uploadAllow' => array('images/*'), //'uploadDeny' => array('all'), //'uploadOrder' => 'deny,allow' // 'disabled' => array(), // list of not allowed commands // 'dotFiles' => false, // display dot files // 'dirSize' => true, // count total directories sizes // 'fileMode' => 0666, // new files mode // 'dirMode' => 0777, // new folders mode // 'mimeDetect' => 'internal', // files mimetypes detection method (finfo, mime_content_type, linux (file -ib), bsd (file -Ib), internal (by extensions)) // 'uploadAllow' => array(), // mimetypes which allowed to upload // 'uploadDeny' => array(), // mimetypes which not allowed to upload // 'uploadOrder' => 'deny,allow', // order to proccess uploadAllow and uploadAllow options // 'imgLib' => 'mogrify', // image manipulation library (imagick, mogrify, gd) // 'tmbDir' => '.tmb', // directory name for image thumbnails. Set to "" to avoid thumbnails generation // 'tmbCleanProb' => 1, // how frequiently clean thumbnails dir (0 - never, 100 - every init request) // 'tmbAtOnce' => 5, // number of thumbnails to generate per request // 'tmbSize' => 48, // images thumbnails size (px) // 'fileURL' => true, // display file URL in "get info" // 'dateFormat' => 'j M Y H:i', // file modification date format // 'logger' => null, // object logger // 'defaults' => array( // default permisions // 'read' => true, // 'write' => true, // 'rm' => true // ), // 'perms' => array(), // individual folders/files permisions // 'debug' => true, // send debug to client // 'archiveMimes' => array(), // allowed archive's mimetypes to create. Leave empty for all available types. // 'archivers' => array() // info about archivers to use. See example below. Leave empty for auto detect // 'archivers' => array( // 'create' => array( // 'application/x-gzip' => array( // 'cmd' => 'tar', // 'argc' => '-czf', // 'ext' => 'tar.gz' // ) // ), // 'extract' => array( // 'application/x-gzip' => array( // 'cmd' => 'tar', // 'argc' => '-xzf', // 'ext' => 'tar.gz' // ), // 'application/x-bzip2' => array( // 'cmd' => 'tar', // 'argc' => '-xjf', // 'ext' => 'tar.bz' // ) // ) // ) ); $fm = new elFinder($opts); $fm->run(); ?>
  2. I'm trying to generate a unique "dosieid" number for my web site.My web site is a human resources program solution, in that program users create dosie of their workers in their firm ...random dosieid needs me so when user createing dosie in field dosieid automaticly show the dosieid-s that are not used before...the dosieid that don't exist in database. In other case I would use auto increment but in this case dosie is not created yet. And in form dosieid must be option to change the number if random is not fine with a user. One more hint the numbers must bee from 1 to 9999. Can someone help mee? I have try many codes but i have not find something like one with this spec. This is what I have do so far. It gets the random number but I don't know how to compare that random number with database row "dosieid" ? <? $id_num = mt_rand(1,9999); $query = "SELECT dosjeid FROM albums"; $result = mysql_query($query) or die(mysql_error()); while($account = mysql_fetch_array($result)){ if ($id_num == $account['id']){ $id_num = mt_rand(1,9999); } } echo"$id_num<br>"; ?>
  3. U are right... Thanks .Unti now I haven't modify someone else script ...Lesson learned.
  4. Thanks man for the answers I am greatful . I have tried this. $diro is the name of the directory That name is also stored in the data base from where I am geting the variable, 'htdocs/store' is the real path to the $diro directory ....But no luck I don't get even the error with this ... define('FILE_ROOT', 'htdocs/store' . self::FOLDER_SEPARATOR . $diro);
  5. I have also tried to put the directory in front of the variable: define("FILE_ROOT", "store/".$diro."/Folder"); But then it say "store/65465/Folder is not a directory " ???????????? I'm confused :S You can not use a relative directory there "store". You need to provide a real path -> "/some/path/store". Also it works with this : define("FILE_ROOT", "store" ); But when I put the variable like this: define("FILE_ROOT", "store/".$variable ); Then it does't ... I'm wondering how to put the variable value in this FILE_ROOT or is ther some other way to doo that ??
  6. I have also tried to put the directory in front of the variable: define("FILE_ROOT", "store/".$diro."/Folder"); But then it say "store/65465/Folder is not a directory " ???????????? I'm confused :S You can not use a relative directory there "store". You need to provide a real path -> "/some/path/store". Ok I know that with real path it works ....Like this define("FILE_ROOT", "/Web server/xampp/htdocs/store/"); But WHAT IF I NEED THE VARIABLE $value that is stored in the data base ? Instead of the the real path ??? That is bothering mee I need the variable inside of the FILE_ROOT ...Becose the name of the directory is the value that is stored in the database ! Understand????
  7. Hi I am using this code for directory tree ...and it is working fine except the "define("FILE_ROOT", "$VARIABLE");" because I can't use variable in the define function ...but I need the variable as the file root in next code ... Not working: I need this define("FILE_ROOT", $diro); Working cod: define("FILE_ROOT", "store"); The index script that get the directorys and files in to the directory tree.. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta name="keywords" content="" /> <meta name="description" content="" /> <title>Editable jquery tree with php codes</title> <link rel="stylesheet" type="text/css" href="js/jquery/plugins/simpleTree/style.css" /> <link rel="stylesheet" type="text/css" href="styleis.css" /> <script type="text/javascript" src="js/jquery/jquery.min.js"></script> <script type="text/javascript" src="js/jquery/plugins/jquery.cookie.js"></script> <script type="text/javascript" src="js/jquery/plugins/simpleTree/jquery.simple.tree.js"></script> <script type="text/javascript" src="js/langManager.js" ></script> <script type="text/javascript" src="js/treeOperations.js"></script> <script type="text/javascript" src="js/init.js"></script> </head> <body> <table border='2' width='633'> <tr> <td> <div class="contextMenu" id="myMenu1"> <li class="addFolder"> <img src="js/jquery/plugins/simpleTree/images/folder_add.png" /> </li> <li class="addDoc"><img src="js/jquery/plugins/simpleTree/images/page_add.png" /> </li> <li class="edit"><img src="js/jquery/plugins/simpleTree/images/folder_edit.png" /> </li> <li class="delete"><img src="js/jquery/plugins/simpleTree/images/folder_delete.png" /> </li> <li class="expandAll"><img src="js/jquery/plugins/simpleTree/images/expand.png"/> </li> <li class="collapseAll"><img src="js/jquery/plugins/simpleTree/images/collapse.png"/> </li> </div> <div class="contextMenu" id="myMenu2"> <li class="edit"><img src="js/jquery/plugins/simpleTree/images/page_edit.png" /> </li> <li class="delete"><img src="js/jquery/plugins/simpleTree/images/page_delete.png" /> </li> </div> <div id="wrap"> <div id="annualWizard"> <ul class="simpleTree" id='pdfTree'> <li class="root" id='<?php echo $treeManager->getRootId(); ?>'><span><?php echo $rootName; ?></span> <ul><?php echo $treeElements; ?></ul> </li> </ul> </div> <div> </div> </div> <div id='processing'></div> </td> </tr> </table> </body> </html> This is the script that makes the directory config.php : <?php require('connecto.php'); session_start(); error_reporting(0); $id = $_GET['id']; $q = "SELECT * FROM albums WHERE $id = ideo"; $results = mysql_query($q); $data = mysql_fetch_array($results); $diro = $data['dosjeid']; $id = $data['ideo']; /************************************** * File Name: config.php * Begin: Thursday, June, 06, 2006 * Author: Ahmet Oguz Mermerkaya * Email: ahmetmermerkaya@hotmail.com ***************************************/ if (!defined("IN_PHP")) { die(); } /** * if you want to run in demo mode, enable the macro below * if it runs in demo mode, it doesn't care what TARGET_PLATFORM is */ //define("DEMO_MODE", true); /** target platform types * this script runs for both database(mysql) and file system. * database is supposed to be mysql */ define ("DATABASE_PLATFORM", 0); // Don't edit define ("FILE_SYSTEM_PLATFORM", 1); // Don't edit /** * choose target platform according to your needs * it may be DATABASE_PLATFORM or FILE_SYSTEM_PLATFORM */ define ("TARGET_PLATFORM", FILE_SYSTEM_PLATFORM); if (TARGET_PLATFORM == FILE_SYSTEM_PLATFORM) { /** * if FILE_SYSTEM_PLATFORM is selected as TARGET_PLATFORM, * then assign root folder adress to FILE_ROOT macro */ $dirko = ("store/".$diro); define("FILE_ROOT", $dirko); } else if (TARGET_PLATFORM == DATABASE_PLATFORM) { /** * if DATABASE_PLATFORM is selected as TARGET_PLATFORM, * set the variables to connect database and * set the TREE_TABLE_PREFIX if you want to * change the prefix of table name */ // set database host $dbHost = "localhost"; //set database user name $dbUsername = "root"; // set password to connect to database $dbPassword = "21236161"; // set database name $dbName = "php"; // set database table prefix define ("TREE_TABLE_PREFIX", "tree"); } else { die("No known target platform specified, in includes/config.php"); } define ("SUCCESS", 1); // Don't edit define ("FAILED", -1); // Don't edit define ("FAILED_FILE_WITH_SAME_NAME_EXIST", -2); // Don't edit, it is only used in FILE_SYSTEM_PLATFORM error_reporting(0); ?> And this is File tree menager.php script.... <?php require('connecto.php'); session_start(); error_reporting(0); $id = $_GET['id']; $q = "SELECT * FROM albums WHERE $id = ideo"; $results = mysql_query($q); $data = mysql_fetch_array($results); $diro = $data['dosjeid']; $id = $data['ideo']; /************************************** File Name: DemoTreeManager.php Begin: Wednesday, April, 15, 2009, 21:49 Author: Ozan Koroglu Ahmet Oguz Mermerkaya Email: koroglu.ozan@gmail.com ahmetmermerkaya@hotmail.com ***************************************/ require_once("ITreeManager.php"); class FileTreeManager implements ITreeManager { private $fileRoot; const FOLDER_SEPARATOR = "FOLDER_SEPARATOR"; const DEFAULT_FOLDER_SEPARATOR = "/"; public function __construct($fileRoot) { if (is_dir($fileRoot)) { $this->fileRoot = $fileRoot; //if ($this->fileRoot[strlen($this->fileRoot) - 1] != '/' ) { // $this->fileRoot .= '/'; //} } else { die($fileRoot .' is not a directory '); } } public function insertElement($name, $ownerEl, $slave) { $realOwnerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $ownerEl); $fullPath = $this->getFullPath($realOwnerEl. self::DEFAULT_FOLDER_SEPARATOR . $name); $out = FAILED; if (file_exists($fullPath) === true) { $out = FAILED_FILE_WITH_SAME_NAME_EXIST; } else { if ($slave == 1) { if (touch($fullPath) === true) { $out = '({ "elementId":"'. $ownerEl . self::FOLDER_SEPARATOR . $name . '", "elementName":"'.$name.'", "slave":"'.$slave.'"})'; } } else{ if (mkdir($fullPath, 0755)) { $out = '({ "elementId":"'. $ownerEl . self::FOLDER_SEPARATOR . $name .'", "elementName":"'.$name.'", "slave":"'.$slave.'"})'; } } } return $out; } private function getFullPath($relativePath) { return $this->fileRoot . self::DEFAULT_FOLDER_SEPARATOR . $relativePath; } public function getElementList($ownerEl, $pageName) { $realOwnerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $ownerEl); $fullPath = $this->getFullPath($realOwnerEl); $str = null; if (is_dir($fullPath) && $handle = opendir($fullPath)) { $fileStr = null; /* This is the correct way to loop over the directory. */ while (false !== ($file = readdir($handle))) { if ($file == '.' || $file == '..' || $file == 'Thumbs.db'){ continue; } $supp = NULL; if (is_dir($fullPath . "/" . $file)) { $supp = "<ul class='ajax'>" ."<li id='". $ownerEl. self::FOLDER_SEPARATOR . $file ."'>{url:".$pageName."?action=getElementList&ownerEl=". $ownerEl. self::FOLDER_SEPARATOR . $file ."}</li>" ."</ul>"; } $fileStr[] .= "<li class='text' id='". $ownerEl. self::FOLDER_SEPARATOR . $file."'>" ."<span>$file</span> <a href='".$fullPath."/".$file."'>View the file</a>" . $supp ."</li>"; } closedir($handle); if ($fileStr != null) { sort($fileStr); $str = implode($fileStr); } } return $str; } public function updateElementName($name, $elementId,$ownerEl) { $ownerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $ownerEl); $newElementId = $ownerEl . self::DEFAULT_FOLDER_SEPARATOR . $name; $elementId = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $elementId); $realElementId = $ownerEl . self::DEFAULT_FOLDER_SEPARATOR . substr($elementId, strrpos($elementId, "/"), strlen($elementId)); $fullPath = $this->getFullPath($realElementId); //$newElementId = substr($realElementId, 0, strrpos($realElementId, "/")). "/" . $name; $newFullPath = $this->getFullPath($newElementId); $out = FAILED; if (file_exists($newFullPath) === true && dirname($fullPath) != dirname($newFullPath) ) { $out = FAILED_FILE_WITH_SAME_NAME_EXIST; } else if (rename($fullPath, $newFullPath) == true) { $newRealElementId = str_replace(self::DEFAULT_FOLDER_SEPARATOR, self::FOLDER_SEPARATOR, $newElementId); $out = '({"elementName":"'.$name.'", "elementId":"'. $newRealElementId .'"})'; } return $out; } public function deleteElement($elementId, &$index = 0, $ownerEl) { $elementId = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $elementId); $elementId = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $ownerEl) . self::DEFAULT_FOLDER_SEPARATOR . substr($elementId, strrpos($elementId, "/"), strlen($elementId)); $fullPath = $this->getFullPath($elementId); $out = FAILED; if (is_dir($fullPath) && $this->delete_recursive_dirs($fullPath)) { $out = SUCCESS; } else if (unlink($fullPath)) { $out = SUCCESS; } return $out; } public function changeOrder($elementId, $oldOwnerEl, $destOwnerEl, $destPosition) { $oldOwnerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $oldOwnerEl); $elementId = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $elementId); $realElementId = $oldOwnerEl . self::DEFAULT_FOLDER_SEPARATOR . substr($elementId, strrpos($elementId, "/"), strlen($elementId)); $fullPath = $this->getFullPath($realElementId); $elementName = substr($realElementId, strrpos($realElementId, "/")+1); // plus 1 not to get / character $realDestOwnerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $destOwnerEl); $newFullPath = $this->getFullPath($realDestOwnerEl . "/". $elementName); $newElementId = $destOwnerEl . self::FOLDER_SEPARATOR . $elementName; $out = FAILED; if (file_exists($newFullPath) === true && dirname($fullPath) != dirname($newFullPath)) { $out = FAILED_FILE_WITH_SAME_NAME_EXIST; } else if (rename($fullPath, $newFullPath) == true) { $out = '({"oldElementId":"'. str_replace(self::DEFAULT_FOLDER_SEPARATOR, self::FOLDER_SEPARATOR, $elementId) .'", "elementId":"'. $newElementId .'"})';; } return $out; } public function getRootId(){ return self::FOLDER_SEPARATOR; } private function delete_recursive_dirs($dirname) { // recursive function to delete // all subdirectories and contents: if(is_dir($dirname)) { $dir_handle=opendir($dirname); } while($file=readdir($dir_handle)) { if($file!="." && $file!="..") { if(!is_dir($dirname."/".$file)){ unlink ($dirname."/".$file); } else { $this->delete_recursive_dirs($dirname."/".$file); } } } closedir($dir_handle); rmdir($dirname); return true; } } ?> Do someone have an concrete idea for this problem? Please LET ME KNOW I need this fast... Thanks .
  8. Do anyone have a IDEA how to go around this problem ? I don't know what can I use instead of this funcTion: define("FILE_ROOT", "store/".$diro."/Folder"); For this script: <?php require('connecto.php'); session_start(); error_reporting(0); $id = $_GET['id']; $q = "SELECT * FROM albums WHERE $id = ideo"; $results = mysql_query($q); $data = mysql_fetch_array($results); $diro = $data['dosjeid']; $id = $data['ideo']; /************************************** * File Name: config.php * Begin: Thursday, June, 06, 2006 * Author: Ahmet Oguz Mermerkaya * Email: ahmetmermerkaya@hotmail.com ***************************************/ if (!defined("IN_PHP")) { die(); } /** * if you want to run in demo mode, enable the macro below * if it runs in demo mode, it doesn't care what TARGET_PLATFORM is */ //define("DEMO_MODE", true); /** target platform types * this script runs for both database(mysql) and file system. * database is supposed to be mysql */ define ("DATABASE_PLATFORM", 0); // Don't edit define ("FILE_SYSTEM_PLATFORM", 1); // Don't edit /** * choose target platform according to your needs * it may be DATABASE_PLATFORM or FILE_SYSTEM_PLATFORM */ define ("TARGET_PLATFORM", FILE_SYSTEM_PLATFORM); if (TARGET_PLATFORM == FILE_SYSTEM_PLATFORM) { /** * if FILE_SYSTEM_PLATFORM is selected as TARGET_PLATFORM, * then assign root folder adress to FILE_ROOT macro */ $diro = $data['dosjeid']; //this is the problem with this I GET THIS MESAGE ---------"6546 IS NOT THE DIRECTORY" define("FILE_ROOT", $diro); } else if (TARGET_PLATFORM == DATABASE_PLATFORM) { /** * if DATABASE_PLATFORM is selected as TARGET_PLATFORM, * set the variables to connect database and * set the TREE_TABLE_PREFIX if you want to * change the prefix of table name */ // set database host $dbHost = "localhost"; //set database user name $dbUsername = "root"; // set password to connect to database $dbPassword = "21236161"; // set database name $dbName = "php"; // set database table prefix define ("TREE_TABLE_PREFIX", "tree"); } else { die("No known target platform specified, in includes/config.php"); } define ("SUCCESS", 1); // Don't edit define ("FAILED", -1); // Don't edit define ("FAILED_FILE_WITH_SAME_NAME_EXIST", -2); // Don't edit, it is only used in FILE_SYSTEM_PLATFORM error_reporting(0); ?> This is the second script from where I get the eror mesage!! <?php require('connecto.php'); session_start(); error_reporting(0); $id = $_GET['id']; $q = "SELECT * FROM albums WHERE $id = ideo"; $results = mysql_query($q); $data = mysql_fetch_array($results); $diro = $data['dosjeid']; $id = $data['ideo']; /************************************** File Name: DemoTreeManager.php Begin: Wednesday, April, 15, 2009, 21:49 Author: Ozan Koroglu Ahmet Oguz Mermerkaya Email: koroglu.ozan@gmail.com ahmetmermerkaya@hotmail.com ***************************************/ require_once("ITreeManager.php"); class FileTreeManager implements ITreeManager { private $fileRoot; const FOLDER_SEPARATOR = "FOLDER_SEPARATOR"; const DEFAULT_FOLDER_SEPARATOR = "/"; public function __construct($fileRoot) { if (is_dir($fileRoot)) { $this->fileRoot = $fileRoot; //if ($this->fileRoot[strlen($this->fileRoot) - 1] != '/' ) { // $this->fileRoot .= '/'; //} } else { die($fileRoot .' is not a directory '); } } public function insertElement($name, $ownerEl, $slave) { $realOwnerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $ownerEl); $fullPath = $this->getFullPath($realOwnerEl. self::DEFAULT_FOLDER_SEPARATOR . $name); $out = FAILED; if (file_exists($fullPath) === true) { $out = FAILED_FILE_WITH_SAME_NAME_EXIST; } else { if ($slave == 1) { if (touch($fullPath) === true) { $out = '({ "elementId":"'. $ownerEl . self::FOLDER_SEPARATOR . $name . '", "elementName":"'.$name.'", "slave":"'.$slave.'"})'; } } else{ if (mkdir($fullPath, 0755)) { $out = '({ "elementId":"'. $ownerEl . self::FOLDER_SEPARATOR . $name .'", "elementName":"'.$name.'", "slave":"'.$slave.'"})'; } } } return $out; } private function getFullPath($relativePath) { return $this->fileRoot . self::DEFAULT_FOLDER_SEPARATOR . $relativePath; } public function getElementList($ownerEl, $pageName) { $realOwnerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $ownerEl); $fullPath = $this->getFullPath($realOwnerEl); $str = null; if (is_dir($fullPath) && $handle = opendir($fullPath)) { $fileStr = null; /* This is the correct way to loop over the directory. */ while (false !== ($file = readdir($handle))) { if ($file == '.' || $file == '..' || $file == 'Thumbs.db'){ continue; } $supp = NULL; if (is_dir($fullPath . "/" . $file)) { $supp = "<ul class='ajax'>" ."<li id='". $ownerEl. self::FOLDER_SEPARATOR . $file ."'>{url:".$pageName."?action=getElementList&ownerEl=". $ownerEl. self::FOLDER_SEPARATOR . $file ."}</li>" ."</ul>"; } $fileStr[] .= "<li class='text' id='". $ownerEl. self::FOLDER_SEPARATOR . $file."'>" ."<span>$file</span> <a href='".$fullPath."/".$file."'>View the file</a>" . $supp ."</li>"; } closedir($handle); if ($fileStr != null) { sort($fileStr); $str = implode($fileStr); } } return $str; } public function updateElementName($name, $elementId,$ownerEl) { $ownerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $ownerEl); $newElementId = $ownerEl . self::DEFAULT_FOLDER_SEPARATOR . $name; $elementId = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $elementId); $realElementId = $ownerEl . self::DEFAULT_FOLDER_SEPARATOR . substr($elementId, strrpos($elementId, "/"), strlen($elementId)); $fullPath = $this->getFullPath($realElementId); //$newElementId = substr($realElementId, 0, strrpos($realElementId, "/")). "/" . $name; $newFullPath = $this->getFullPath($newElementId); $out = FAILED; if (file_exists($newFullPath) === true && dirname($fullPath) != dirname($newFullPath) ) { $out = FAILED_FILE_WITH_SAME_NAME_EXIST; } else if (rename($fullPath, $newFullPath) == true) { $newRealElementId = str_replace(self::DEFAULT_FOLDER_SEPARATOR, self::FOLDER_SEPARATOR, $newElementId); $out = '({"elementName":"'.$name.'", "elementId":"'. $newRealElementId .'"})'; } return $out; } public function deleteElement($elementId, &$index = 0, $ownerEl) { $elementId = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $elementId); $elementId = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $ownerEl) . self::DEFAULT_FOLDER_SEPARATOR . substr($elementId, strrpos($elementId, "/"), strlen($elementId)); $fullPath = $this->getFullPath($elementId); $out = FAILED; if (is_dir($fullPath) && $this->delete_recursive_dirs($fullPath)) { $out = SUCCESS; } else if (unlink($fullPath)) { $out = SUCCESS; } return $out; } public function changeOrder($elementId, $oldOwnerEl, $destOwnerEl, $destPosition) { $oldOwnerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $oldOwnerEl); $elementId = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $elementId); $realElementId = $oldOwnerEl . self::DEFAULT_FOLDER_SEPARATOR . substr($elementId, strrpos($elementId, "/"), strlen($elementId)); $fullPath = $this->getFullPath($realElementId); $elementName = substr($realElementId, strrpos($realElementId, "/")+1); // plus 1 not to get / character $realDestOwnerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $destOwnerEl); $newFullPath = $this->getFullPath($realDestOwnerEl . "/". $elementName); $newElementId = $destOwnerEl . self::FOLDER_SEPARATOR . $elementName; $out = FAILED; if (file_exists($newFullPath) === true && dirname($fullPath) != dirname($newFullPath)) { $out = FAILED_FILE_WITH_SAME_NAME_EXIST; } else if (rename($fullPath, $newFullPath) == true) { $out = '({"oldElementId":"'. str_replace(self::DEFAULT_FOLDER_SEPARATOR, self::FOLDER_SEPARATOR, $elementId) .'", "elementId":"'. $newElementId .'"})';; } return $out; } public function getRootId(){ return self::FOLDER_SEPARATOR; } private function delete_recursive_dirs($dirname) { // recursive function to delete // all subdirectories and contents: if(is_dir($dirname)) { $dir_handle=opendir($dirname); } while($file=readdir($dir_handle)) { if($file!="." && $file!="..") { if(!is_dir($dirname."/".$file)){ unlink ($dirname."/".$file); } else { $this->delete_recursive_dirs($dirname."/".$file); } } } closedir($dir_handle); rmdir($dirname); return true; } } ?> Can anyone HELP?
  9. I have also tried to put the directory in front of the variable: define("FILE_ROOT", "store/".$diro."/Folder"); But then it say "store/65465/Folder is not a directory " ???????????? I'm confused :S
  10. Jes I understand, I have tryed this: define("FILE_ROOT", "store/".$diro); But it does not show me the files in the folder of that user "$diro" he shows me only the folders... Do you have an idea have to go around that ....? If you understand what I am trying to do..
  11. Ok i understand what is the real path ... it works with real path and it shows me all directorys in that path ...but i need the variable. so that when user won't see the directory . He seas only one directory that he own by id or in this case $diro variable... UNDERSTAND ? so how can I doo that with this script ? If you can giv me some opinion ...please regards .
  12. Apologize for that ...I am new ...sou I'm getting used to ...
  13. This the second file : <?php require('connecto.php'); session_start(); error_reporting(0); $id = $_GET['id']; $q = "SELECT * FROM albums WHERE $id = ideo"; $results = mysql_query($q); $data = mysql_fetch_array($results); $diro = $data['dosjeid']; $id = $data['ideo']; /************************************** File Name: DemoTreeManager.php Begin: Wednesday, April, 15, 2009, 21:49 Author: Ozan Koroglu Ahmet Oguz Mermerkaya Email: koroglu.ozan@gmail.com ahmetmermerkaya@hotmail.com ***************************************/ require_once("ITreeManager.php"); class FileTreeManager implements ITreeManager { private $fileRoot; const FOLDER_SEPARATOR = "FOLDER_SEPARATOR"; const DEFAULT_FOLDER_SEPARATOR = "/"; public function __construct($fileRoot) { if (is_dir($fileRoot)) { $this->fileRoot = $fileRoot; //if ($this->fileRoot[strlen($this->fileRoot) - 1] != '/' ) { // $this->fileRoot .= '/'; //} } else { die($fileRoot .' is not a directory '); } } public function insertElement($name, $ownerEl, $slave) { $realOwnerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $ownerEl); $fullPath = $this->getFullPath($realOwnerEl. self::DEFAULT_FOLDER_SEPARATOR . $name); $out = FAILED; if (file_exists($fullPath) === true) { $out = FAILED_FILE_WITH_SAME_NAME_EXIST; } else { if ($slave == 1) { if (touch($fullPath) === true) { $out = '({ "elementId":"'. $ownerEl . self::FOLDER_SEPARATOR . $name . '", "elementName":"'.$name.'", "slave":"'.$slave.'"})'; } } else{ if (mkdir($fullPath, 0755)) { $out = '({ "elementId":"'. $ownerEl . self::FOLDER_SEPARATOR . $name .'", "elementName":"'.$name.'", "slave":"'.$slave.'"})'; } } } return $out; } private function getFullPath($relativePath) { return $this->fileRoot . self::DEFAULT_FOLDER_SEPARATOR . $relativePath; } public function getElementList($ownerEl, $pageName) { $realOwnerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $ownerEl); $fullPath = $this->getFullPath($realOwnerEl); $str = null; if (is_dir($fullPath) && $handle = opendir($fullPath)) { $fileStr = null; /* This is the correct way to loop over the directory. */ while (false !== ($file = readdir($handle))) { if ($file == '.' || $file == '..' || $file == 'Thumbs.db'){ continue; } $supp = NULL; if (is_dir($fullPath . "/" . $file)) { $supp = "<ul class='ajax'>" ."<li id='". $ownerEl. self::FOLDER_SEPARATOR . $file ."'>{url:".$pageName."?action=getElementList&ownerEl=". $ownerEl. self::FOLDER_SEPARATOR . $file ."}</li>" ."</ul>"; } $fileStr[] .= "<li class='text' id='". $ownerEl. self::FOLDER_SEPARATOR . $file."'>" ."<span>$file</span> <a href='".$fullPath."/".$file."'>View the file</a>" . $supp ."</li>"; } closedir($handle); if ($fileStr != null) { sort($fileStr); $str = implode($fileStr); } } return $str; } public function updateElementName($name, $elementId,$ownerEl) { $ownerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $ownerEl); $newElementId = $ownerEl . self::DEFAULT_FOLDER_SEPARATOR . $name; $elementId = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $elementId); $realElementId = $ownerEl . self::DEFAULT_FOLDER_SEPARATOR . substr($elementId, strrpos($elementId, "/"), strlen($elementId)); $fullPath = $this->getFullPath($realElementId); //$newElementId = substr($realElementId, 0, strrpos($realElementId, "/")). "/" . $name; $newFullPath = $this->getFullPath($newElementId); $out = FAILED; if (file_exists($newFullPath) === true && dirname($fullPath) != dirname($newFullPath) ) { $out = FAILED_FILE_WITH_SAME_NAME_EXIST; } else if (rename($fullPath, $newFullPath) == true) { $newRealElementId = str_replace(self::DEFAULT_FOLDER_SEPARATOR, self::FOLDER_SEPARATOR, $newElementId); $out = '({"elementName":"'.$name.'", "elementId":"'. $newRealElementId .'"})'; } return $out; } public function deleteElement($elementId, &$index = 0, $ownerEl) { $elementId = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $elementId); $elementId = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $ownerEl) . self::DEFAULT_FOLDER_SEPARATOR . substr($elementId, strrpos($elementId, "/"), strlen($elementId)); $fullPath = $this->getFullPath($elementId); $out = FAILED; if (is_dir($fullPath) && $this->delete_recursive_dirs($fullPath)) { $out = SUCCESS; } else if (unlink($fullPath)) { $out = SUCCESS; } return $out; } public function changeOrder($elementId, $oldOwnerEl, $destOwnerEl, $destPosition) { $oldOwnerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $oldOwnerEl); $elementId = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $elementId); $realElementId = $oldOwnerEl . self::DEFAULT_FOLDER_SEPARATOR . substr($elementId, strrpos($elementId, "/"), strlen($elementId)); $fullPath = $this->getFullPath($realElementId); $elementName = substr($realElementId, strrpos($realElementId, "/")+1); // plus 1 not to get / character $realDestOwnerEl = str_replace(self::FOLDER_SEPARATOR, self::DEFAULT_FOLDER_SEPARATOR, $destOwnerEl); $newFullPath = $this->getFullPath($realDestOwnerEl . "/". $elementName); $newElementId = $destOwnerEl . self::FOLDER_SEPARATOR . $elementName; $out = FAILED; if (file_exists($newFullPath) === true && dirname($fullPath) != dirname($newFullPath)) { $out = FAILED_FILE_WITH_SAME_NAME_EXIST; } else if (rename($fullPath, $newFullPath) == true) { $out = '({"oldElementId":"'. str_replace(self::DEFAULT_FOLDER_SEPARATOR, self::FOLDER_SEPARATOR, $elementId) .'", "elementId":"'. $newElementId .'"})';; } return $out; } public function getRootId(){ return self::FOLDER_SEPARATOR; } private function delete_recursive_dirs($dirname) { // recursive function to delete // all subdirectories and contents: if(is_dir($dirname)) { $dir_handle=opendir($dirname); } while($file=readdir($dir_handle)) { if($file!="." && $file!="..") { if(!is_dir($dirname."/".$file)){ unlink ($dirname."/".$file); } else { $this->delete_recursive_dirs($dirname."/".$file); } } } closedir($dir_handle); rmdir($dirname); return true; } } ?> So this is wher the file directory $diro can't pass.
  14. Ok this is one of the files: <?php require('connecto.php'); session_start(); error_reporting(0); $id = $_GET['id']; $q = "SELECT * FROM albums WHERE $id = ideo"; $results = mysql_query($q); $data = mysql_fetch_array($results); $diro = $data['dosjeid']; $id = $data['ideo']; /************************************** * File Name: config.php * Begin: Thursday, June, 06, 2006 * Author: Ahmet Oguz Mermerkaya * Email: ahmetmermerkaya@hotmail.com ***************************************/ if (!defined("IN_PHP")) { die(); } /** * if you want to run in demo mode, enable the macro below * if it runs in demo mode, it doesn't care what TARGET_PLATFORM is */ //define("DEMO_MODE", true); /** target platform types * this script runs for both database(mysql) and file system. * database is supposed to be mysql */ define ("DATABASE_PLATFORM", 0); // Don't edit define ("FILE_SYSTEM_PLATFORM", 1); // Don't edit /** * choose target platform according to your needs * it may be DATABASE_PLATFORM or FILE_SYSTEM_PLATFORM */ define ("TARGET_PLATFORM", FILE_SYSTEM_PLATFORM); if (TARGET_PLATFORM == FILE_SYSTEM_PLATFORM) { /** * if FILE_SYSTEM_PLATFORM is selected as TARGET_PLATFORM, * then assign root folder adress to FILE_ROOT macro */ define("FILE_ROOT", "store"); } else if (TARGET_PLATFORM == DATABASE_PLATFORM) { /** * if DATABASE_PLATFORM is selected as TARGET_PLATFORM, * set the variables to connect database and * set the TREE_TABLE_PREFIX if you want to * change the prefix of table name */ // set database host $dbHost = "localhost"; //set database user name $dbUsername = "root"; // set password to connect to database $dbPassword = "21236161"; // set database name $dbName = "php"; // set database table prefix define ("TREE_TABLE_PREFIX", "tree"); } else { die("No known target platform specified, in includes/config.php"); } define ("SUCCESS", 1); // Don't edit define ("FAILED", -1); // Don't edit define ("FAILED_FILE_WITH_SAME_NAME_EXIST", -2); // Don't edit, it is only used in FILE_SYSTEM_PLATFORM error_reporting(0); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.