function copy_directory($directory, $destination)
 {
     $destination = $destination . basename($directory);
     # The directory will be created
     if (!file_exists($destination)) {
         if (!mkdir($destination)) {
             return false;
         }
     }
     $directory_list = @scandir($directory);
     # Directory scanning
     if (!$directory_list) {
         return false;
     }
     foreach ($directory_list as $item_name) {
         $item = $directory . DIRECTORY_SEPARATOR . $item_name;
         if ($item_name == '.' || $item_name == '..') {
             continue;
         }
         if (filetype($item) == 'dir') {
             copy_directory($item, $destination . DIRECTORY_SEPARATOR);
         } else {
             var_dump($item);
             var_dump($destination . DIRECTORY_SEPARATOR . $item_name);
             if (!copy($item, $destination . DIRECTORY_SEPARATOR . $item_name)) {
                 return false;
             }
         }
     }
     return true;
 }
 /**
  * @param string $path
  * @throws \Exception
  */
 public function setPath($path)
 {
     if (!(filter_var($path, FILTER_VALIDATE_IP) || filter_var($path, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) && (!file_exists($path) || filetype($path) !== 'socket')) {
         throw new \Exception('Ruta o archivo no válido');
     }
     $this->path = $path;
 }
Пример #3
0
function transfer_templates($dir, $root_dir, $level = 0)
{
	if (!$dh = @opendir($dir))
		die("ERROR! Unable to open directory " . $dir . ".\n");
	while ($file = readdir($dh)) {
		if ($file == "." || $file == "..")
			continue;

		$full_path = $dir . "/" . $file;
		$filetype = filetype($full_path);
		if ($filetype == "dir") {
			transfer_templates($full_path, $root_dir, $level + 1);
			continue;
		}

		if ($filetype != "file") // ignore special files and links
			continue;
		$ending = substr($file, strlen($file) - 4);
		if ($ending != ".tpl") // ignore files that are not templates (end in .tpl)
			continue;

		$rel_path = substr($full_path, strlen($root_dir) + 1);
		$sql = "INSERT IGNORE INTO Templates (Name, Level) values('"
		     . $rel_path . "', " . $level . ")";
		if (!mysql_query($sql))
			die("Unable to insert template " . $rel_path . ".\n");
	}
}
Пример #4
0
 public static function files_identical($fn1, $fn2, array $exclude = [])
 {
     if (filetype($fn1) !== filetype($fn2)) {
         return FALSE;
     }
     /* if (filesize($fn1) !== filesize($fn2))
        return FALSE; */
     if (!($fp1 = @fopen($fn1, 'r'))) {
         return FALSE;
     }
     if (!($fp2 = @fopen($fn2, 'r'))) {
         fclose($fp1);
         return FALSE;
     }
     $same = TRUE;
     $count = 1;
     while (($bufer1 = fgets($fp1, 4096)) !== false && ($bufer2 = fgets($fp2, 4096)) !== false) {
         if (!in_array($count, $exclude)) {
             if ($bufer1 !== $bufer2) {
                 $same = FALSE;
                 break;
             }
         }
         $count++;
     }
     fclose($fp1);
     fclose($fp2);
     return $same;
 }
Пример #5
0
function drawAdminTools_Tools($domain)
{
    global $adm_login;
    global $adm_pass;
    global $addrlink;
    global $lang;
    global $htaccess_edit_flag_selected_subdomain;
    $out = "";
    $out .= subdomainSelector($domain);
    if ($htaccess_edit_flag_selected_subdomain == "yes") {
        if (isset($_REQUEST["edit_folder"]) && $_REQUEST["edit_folder"] == "/") {
            $link1 = "";
            $link2 = "";
        } else {
            $link1 = "<a href=\"" . $_SERVER["PHP_SELF"] . "?adm_login={$adm_login}&adm_pass={$adm_pass}&addrlink={$addrlink}&edit_subdomain=" . $domain["subdomains"][$i]["name"] . "&edit_folder=/\">";
            $link2 = "</a>";
        }
        $out .= "{$link1} / {$link2}";
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    $out .= "fichier : {$file} : type : " . filetype($dir . $file);
                }
                closedir($dh);
            }
        }
    }
    return $out;
}
Пример #6
0
function dircrawl($dir, $hash_array, $extension_exclusions)
{
    $dir = rtrim($dir, "\\/");
    $return = "";
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if ($file != "." and $file != "..") {
                if (filetype($dir . "\\" . $file) == "dir") {
                    $return .= dircrawl($dir . "\\" . $file, $hash_array, $extension_exclusions);
                } else {
                    if (filetype($dir . "\\" . $file) == "file") {
                        if (!in_array(pathinfo($dir . "\\" . $file, PATHINFO_EXTENSION), $extension_exclusions)) {
                            $hash_output = "";
                            foreach ($hash_array as $hash_type) {
                                $hash_output .= ",\"" . hash_file($hash_type, $dir . "\\" . $file) . "\"";
                            }
                            $return .= "\"" . dirname($dir . "\\" . $file) . "\",\"" . basename($dir . "\\" . $file) . "\",\"" . filesize($dir . "\\" . $file) . "\"" . $hash_output . "\n";
                        }
                    }
                }
            }
        }
    }
    return $return;
}
Пример #7
0
function loadRanksets()
{
    global $ranksetData, $ranksetNames;
    if (isset($ranksetNames)) {
        return;
    }
    $ranksetData = array();
    $ranksetNames = array();
    $dir = "ranksets/";
    if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
            while (($file = readdir($dh)) !== false) {
                if (filetype($dir . $file) != "dir") {
                    continue;
                }
                if ($file == ".." || $file == ".") {
                    continue;
                }
                $infofile = $dir . $file . "/rankset.php";
                if (file_exists($infofile)) {
                    include $infofile;
                }
            }
            closedir($dh);
        }
    }
}
Пример #8
0
 function fetch_data()
 {
     global $msg;
     global $PMBuserid;
     $this->error = "";
     $this->info = array();
     $i = 0;
     if (!is_dir($this->path)) {
         $this->error = $msg["admin_files_gestion_error_is_no_path"] . $this->path;
         $this->path = "";
         return;
     }
     if (($objects = @scandir($this->path)) !== false) {
         foreach ($objects as $object) {
             if ($object != '.' && $object != '..') {
                 if (filetype($this->path . "/" . $object) != "dir") {
                     $this->info[$i]['name'] = $object;
                     $this->info[$i]['path'] = $this->path;
                     $this->info[$i]['type'] = filetype($this->path . $object);
                     $i++;
                 }
             }
         }
     }
 }
Пример #9
0
 function getFiles($path, $filter = '*', $recursive = false)
 {
     //Ajusta os filtros
     $filter = strtolower($filter);
     //Ajusta o nome da pasta
     if (substr($path, -1, 1) != '/') {
         $path .= '/';
     }
     //Se o caminho informado nao for um diretorio, pula fora
     if (!is_dir($path)) {
         return array();
     }
     $files = array();
     $dir = opendir($path);
     while (($file = readdir($dir)) !== false) {
         if ($file != '.' && $file != '..' && strtolower($file) != '.ds_store') {
             //Se for um diretorio e estiver ativo a recursividade
             if (is_dir($path . $file) && $recursive) {
                 //Busca os arquivos de dentro do diretorio
                 $files[] = array('file' => $file, 'path' => $path, 'full' => $path . $file . '/', 'type' => filetype($path . $file), 'ext' => '');
                 $files = array_merge($files, $this->getFiles($path . $file, $filter, true));
             } else {
                 //Adiciona um arquivo na lista
                 $ext = explode('.', $file);
                 $ext = strtolower(end($ext));
                 if ($filter == '*' || strpos('|' . $filter, $ext)) {
                     $files[] = array('file' => utf8_encode($file), 'name' => substr($file, 0, strlen($file) - 1 - strlen($ext)), 'path' => utf8_encode($path), 'full' => utf8_encode($path . $file), 'type' => filetype($path . $file), 'ext' => $ext);
                 }
             }
         }
     }
     return $files;
 }
Пример #10
0
/** 
* 遍历指定的目录以及子目录,将符合条件的文件加入XML 
* $p 指定的目录 
*/ 
function DealFP($p){ 
  $FilterDir = $GLOBALS["FilterDir"]; 
  $IndexFileExt = $GLOBALS["IndexFileExt"]; 
   
  $handle=opendir($p); 
  if ($p==".") $path = ""; 
  else $path = $p."/"; 
  while ($file = readdir($handle)) 
  { 
    $d = filetype($path.$file); 
    if ((($d=='file')||($d=='dir'))&&($file!='.')&&($file!='..')) 
    { 
        $pf = $path.$file; 
        //echo "[".$d."]".$pf."<br>"; 
        if ($d=='dir') 
        { 
          if (!(strpos($FilterDir, "|".$pf."|"))) 
          { 
            DealFP($pf); 
          } 
        }else{ 
          $ext = "|".strtolower(substr($file, strrpos($file, ".")+1))."|"; 
           
          if (strpos($IndexFileExt, $ext)) 
          { 
            $d = filemtime($pf); 
            $dt = date("Y-m-d",$d)."T".date("H:i:s",$d)."+00:00"; 
            addToXML($pf, $dt); 
          } 
        } 
    } 
  } 
  closedir($handle);  
} 
Пример #11
0
function mailPdf($from, $to, $subject, $files)
{
    $_boundary = md5(uniqid(microtime(), TRUE));
    $_headers = 'From: ' . $from . "\r\n";
    $_headers .= 'Mime-Version: 1.0' . "\r\n" . 'Content-type: multipart/mixed; boundary=' . $_boundary . "\r\n";
    $_to = $to;
    $_subject = $subject;
    //message html
    $_message = '--' . $_boundary . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
    $_message .= 'Voici le rapport de supervision de la semaine dernière.';
    $_message .= "\r\n";
    foreach ($files as $key => $file) {
        if (file_exists($file["url"])) {
            $_fileType = filetype($file["url"]);
            $_fileContent = file_get_contents($file["url"]);
            if (!$_fileContent) {
                die('Impossible de lire le fichier ' . $file["url"]);
            }
            $_fileContent = chunk_split(base64_encode($_fileContent));
            $_message .= '--' . $_boundary . "\r\n" . 'Content-type: application/pdf' . '; name=' . $key . "\r\n" . 'Content-transfer-encoding: base64' . "\r\n";
            $_message .= $_fileContent . "\r\n";
        }
        $_message .= '--' . $_boundary . "\r\n";
    }
    mail($_to, $_subject, $_message, $_headers);
}
Пример #12
0
 /**
  * @param $dir
  *
  * @return array
  */
 private function getFileList($dir)
 {
     // array to hold return value
     $retval = array();
     // add trailing slash if missing
     if (substr($dir, -1) != '/') {
         $dir .= '/';
     }
     // open pointer to directory and read list of files
     $d = @dir($dir) or die("getFileList: Failed opening directory {$dir} for reading");
     while (false !== ($entry = $d->read())) {
         $info = pathinfo($entry);
         $ext = $info['extension'];
         // skip hidden files
         if ($entry[0] == '.') {
             continue;
         }
         if (is_dir("{$dir}{$entry}")) {
             $retval[] = array('name' => "{$entry}", 'fullpath' => "{$dir}/{$entry}", 'type' => filetype("{$dir}{$entry}"), 'size' => 0, 'lastmod' => filemtime("{$dir}{$entry}"), 'ext' => $ext);
         } elseif (is_readable("{$dir}{$entry}")) {
             $retval[] = array('name' => "{$entry}", 'fullpath' => "{$dir}/{$entry}", 'type' => mime_content_type("{$dir}{$entry}"), 'size' => filesize("{$dir}{$entry}"), 'lastmod' => filemtime("{$dir}{$entry}"), 'ext' => $ext);
         }
     }
     $d->close();
     return $this->aasort($retval, 'name');
 }
Пример #13
0
 public function __construct($cache_path = '', $plugin_dir = '')
 {
     if ($cache_path) {
         $this->cache_path = $cache_path;
     } else {
         $this->cache_path = CACHE_PATH;
     }
     if ($plugin_dir) {
         $this->plugin_dir = $plugin_dir;
     } else {
         $this->plugin_dir = PLUGIN_PATH . 'lezaz/plugin/';
     }
     // include all plugin
     if ($dh = opendir($this->plugin_dir)) {
         while (($file = readdir($dh)) !== false) {
             $ext = explode('.', $file);
             if ($file != '.' && $file != '..' && filetype($this->plugin_dir . $file) != 'dir' && $ext[1] == 'php') {
                 $this->element[] = $ext[0];
                 include $this->plugin_dir . $file;
             }
         }
         closedir($dh);
     }
     $this->translate['all'] = array('{{lng}}', '{{lnguage}}', '{{ltr}}');
     $this->translate['ar'] = array('ar', 'arabic', 'rtl');
     $this->translate['en'] = array('en', 'english', 'ltr');
 }
Пример #14
0
/**
 * getftpdir - ftp konyvtar beolvasasa
 *
 * @param	string	az ftp konyvtar eleresi utja
 * @param	string	a vizsgalt file-ok tipusa (picture vagy video lehet)
 * @access public
 * @return string
 */
function get_ftpdir($ftpdir, $type)
{
    $ret = array();
    if (!is_dir($ftpdir)) {
        return $ret;
    }
    if (($dir = opendir($ftpdir)) === FALSE) {
        return $ret;
    }
    $i = 0;
    while (($file = readdir($dir)) !== FALSE) {
        if ($type == "picture") {
            if (preg_match("/\\.(jpe?g|gif|png)\$/i", $file) && filetype($ftpdir . $file) == 'file') {
                $ret[$i] = $file;
                $i++;
            }
        }
        if ($type == "video") {
            if (preg_match("/\\.(mpe?g|avi|wmv)\$/i", $file) && filetype($ftpdir . $file) == 'file') {
                $ret[$i] = $file;
                $i++;
            }
        }
    }
    closedir($dir);
    return $ret;
}
 function stat($file, $md5 = true, $sha1 = true)
 {
     $rval = array();
     foreach (stat($file) as $i => $v) {
         if (is_numeric($i)) {
             continue;
         }
         $rval[$i] = $v;
     }
     $rval['type'] = filetype($file);
     if ($rval['type'] == 'file') {
         if ($md5) {
             $rval['md5'] = md5_file($file);
         }
         if ($sha1) {
             $rval['sha1'] = sha1_file($file);
         }
     }
     $dir = $this->dir;
     if (0 !== strpos($file, $dir) && 'wp-config.php' == basename($file)) {
         $dir = explode(DIRECTORY_SEPARATOR, $dir);
         array_pop($dir);
         $dir = implode(DIRECTORY_SEPARATOR, $dir);
     }
     $rval['path'] = str_replace($dir, '', $file);
     return $rval;
 }
Пример #16
0
function findFiles($dir)
{
    $dir = trim($dir);
    if (substr($dir, -1) != '/') {
        $dir .= "/";
    }
    $files = array();
    if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
            while (($file = readdir($dh)) !== false) {
                if ($file == "." || $file == "..") {
                    continue;
                }
                switch (filetype($dir . $file)) {
                    case "file":
                        if (substr($file, -4) == ".php") {
                            $files[] = $dir . $file;
                        }
                        break;
                    case "dir":
                        $files = array_merge($files, findFiles($dir . $file));
                        break;
                }
            }
            closedir($dh);
        }
    }
    return $files;
}
Пример #17
0
function delete_subdirectories($rootdir)
{
    $dir = opendir($rootdir);
    while (false !== ($file = readdir($dir))) {
        if ($file != '.' and $file != '..') {
            $fullfile = $rootdir . '/' . $file;
            if (filetype($fullfile) == 'dir') {
                delete_subdirectories($fullfile);
                echo 'Deleting ' . $fullfile . ' ... ';
                if (rmdir($fullfile)) {
                    echo 'Done.<br />';
                } else {
                    echo 'FAILED.<br />';
                }
            } else {
                echo 'Deleting ' . $fullfile . ' ... ';
                if (unlink($fullfile)) {
                    echo 'Done.<br />';
                } else {
                    echo 'FAILED.<br />';
                }
            }
        }
    }
    closedir($dir);
}
Пример #18
0
function getDirFiles($dir = './', $fileExt = '')
{
    $aRtn = array();
    $pos = strrchr($dir, DIRECTORY_SEPARATOR);
    if ($pos === false) {
        $dir .= DIRECTORY_SEPARATOR;
    }
    // Open a known directory, and proceed to read its contents
    if (is_dir($dir)) {
        if ($dirHandle = opendir($dir)) {
            while (($file = readdir($dirHandle)) !== false) {
                if (filetype($dir . $file) != 'dir') {
                    if ($fileExt) {
                        if ($fileExt == gfe($file)) {
                            array_push($aRtn, $file);
                        }
                        continue;
                    }
                    array_push($aRtn, $file);
                }
            }
            closedir($dirHandle);
        }
    }
    return $aRtn;
}
Пример #19
0
function list_dir($path, $level = 1)
{
    if ($d = dir($path)) {
        if (preg_match('/^(.*)\\/$/', $path)) {
            // удаляем / на конце, если есть
            $path = substr($path, 0, -1);
        }
        while (false !== ($entry = $d->read())) {
            if ($entry != '.' and $entry != '..') {
                if (is_dir("{$path}/{$entry}")) {
                    echo sprintf("%{$level}s", ' ') . "[{$path}/{$entry}]\n";
                    list_dir("{$path}/{$entry}", $level + 1);
                } else {
                    $level1 = 50 - $level;
                    echo sprintf("%{$level}s", ' ') . sprintf("%-{$level1}s", $entry);
                    echo sprintf("%10s", filesize("{$path}/{$entry}")) . "\t" . filetype("{$path}/{$entry}");
                    echo "\t" . fileowner("{$path}/{$entry}") . "\n";
                }
            }
        }
        // if
        $d->close();
    }
    // if
}
function deleteScssDir($catName)
{
    $catName = '../../scss/' . $catName;
    if (is_dir($catName)) {
        $objects = scandir($catName);
        foreach ($objects as $object) {
            if ($object != "." && $object != "..") {
                if (filetype($catName . "/" . $object) == "dir") {
                    deleteCompDir($catName . "/" . $object);
                } else {
                    unlink($catName . "/" . $object);
                }
            }
        }
        reset($objects);
        rmdir($catName);
    }
    /*if (is_dir('../../scss/'.$catName)) { 
        $objects = scandir('../../scss/'.$catName); 
        foreach ($objects as $object) { 
          if ($object != "." && $object != "..") { 
            if (filetype($catName."/".$object) == "dir") deleteScssDir('../../scss/'.$catName."/".$object); else unlink('../../scss/'.$catName."/".$object); 
          } 
        } 
        reset($objects); 
        rmdir('../../scss/'.$catName); 
      } */
}
Пример #21
0
 static function test_dir($dir, $recursive = false)
 {
     if (!file_exists($dir) or !($dh = opendir($dir))) {
         return false;
     }
     $dummy = rtrim($dir, '/') . '/' . uniqid();
     if (@file_put_contents($dummy, 'test')) {
         @unlink($dummy);
         if (!$recursive) {
             return true;
         }
     } elseif (!is_writable($dir)) {
         return false;
     }
     if ($recursive) {
         while (($file = readdir($dh)) !== false) {
             if (@filetype($dir . $file) == 'dir' and $file != '.' and $file != '..') {
                 if (!self::test_dir($dir . $file, true)) {
                     return false;
                 }
             }
         }
     }
     closedir($dh);
     return true;
 }
Пример #22
0
 public function deleteImage()
 {
     $id = $_POST['id'];
     $delete_original = IMG_UPLOAD_DIR . '/' . $id . '.jpg';
     $this->jsonSend['success'] = '0';
     if (file_exists($delete_original)) {
         if (unlink($delete_original)) {
             $this->jsonSend[] = 'DELETED: ' . $delete_original;
             $q = 'delete from images where image_id="' . $id . '"';
             tdb::getInstance()->queryNoResult($q);
             $this->jsonSend['success'] = '1';
             $this->jsonSend['q '] = $q;
         }
     }
     $dir = ABS_RESIZED_DIR . '/*';
     foreach (glob($dir) as $file) {
         if (filetype($file) == 'dir') {
             $delete_file = $file . '/' . $id . '.jpg';
             if (file_exists($delete_file)) {
                 unlink($delete_file);
             }
         }
     }
     $this->sendJson();
 }
 public function getContents()
 {
     $contents = array();
     if (is_dir($this->path)) {
         if ($dh = opendir($this->path)) {
             while (($file = readdir($dh)) !== false) {
                 //echo "filename: $file : filetype: " . filetype($this->path. $file) . "<br>";
                 if (filetype($this->path . $file) == 'file' && substr($file, 0, 1) != ".") {
                     // for each file found
                     $item = new eatStaticMediaLibraryFile();
                     $item->path = $this->path . $file;
                     $item->sub_path = $this->sub_path . $file;
                     $item->name = $file;
                     $item->setInfo();
                     $contents[$this->path . $file] = $item;
                 }
                 if (filetype($this->path . $file) == 'dir' && $file != '.' && $file != '..') {
                     // for each folder found
                     $item = new eatStaticMediaLibraryFolder();
                     $item->path = $this->path . $file;
                     $item->sub_path = $this->sub_path . $file . '/';
                     $item->name = $file;
                     //print_r($item);
                     $contents[$this->path . $file] = $item;
                 }
             }
             closedir($dh);
         }
     }
     return $contents;
 }
Пример #24
0
 public function index()
 {
     //加载用户配置文件信息
     require "../config.ini.php";
     $user_config = $array;
     //模板路径
     $templateDir = HOME_PATH . "Tpl/";
     $templateList = array();
     if (is_dir($templateDir)) {
         if ($dh = opendir($templateDir)) {
             while (($template = readdir($dh)) !== false) {
                 if ($template != "." && $template != ".." && filetype($templateDir . $template) == "dir") {
                     $templateList[$template] = $template;
                 }
             }
             closedir($dh);
         }
     }
     //登录安全设置
     $set = D('Set')->find();
     $this->set = $set;
     $this->user_config = $user_config;
     $this->templateList = $templateList;
     $this->display();
 }
 /**
  * collect all fileinformations of given file and
  * save them to the global fileinformation array
  *
  * @param string $file
  * @return boolean is valid file?
  */
 protected function setFileInformations($file)
 {
     $this->fileInfo = array();
     // reset previously information to have a cleaned object
     $this->file = $file instanceof \TYPO3\CMS\Core\Resource\File ? $file : NULL;
     if (is_string($file) && !empty($file)) {
         $this->fileInfo = TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($file);
         $this->fileInfo['mtime'] = filemtime($file);
         $this->fileInfo['atime'] = fileatime($file);
         $this->fileInfo['owner'] = fileowner($file);
         $this->fileInfo['group'] = filegroup($file);
         $this->fileInfo['size'] = filesize($file);
         $this->fileInfo['type'] = filetype($file);
         $this->fileInfo['perms'] = fileperms($file);
         $this->fileInfo['is_dir'] = is_dir($file);
         $this->fileInfo['is_file'] = is_file($file);
         $this->fileInfo['is_link'] = is_link($file);
         $this->fileInfo['is_readable'] = is_readable($file);
         $this->fileInfo['is_uploaded'] = is_uploaded_file($file);
         $this->fileInfo['is_writeable'] = is_writeable($file);
     }
     if ($file instanceof \TYPO3\CMS\Core\Resource\File) {
         $pathInfo = \TYPO3\CMS\Core\Utility\PathUtility::pathinfo($file->getName());
         $this->fileInfo = array('file' => $file->getName(), 'filebody' => $file->getNameWithoutExtension(), 'fileext' => $file->getExtension(), 'realFileext' => $pathInfo['extension'], 'atime' => $file->getCreationTime(), 'mtime' => $file->getModificationTime(), 'owner' => '', 'group' => '', 'size' => $file->getSize(), 'type' => 'file', 'perms' => '', 'is_dir' => FALSE, 'is_file' => $file->getStorage()->getDriverType() === 'Local' ? is_file($file->getForLocalProcessing(FALSE)) : TRUE, 'is_link' => $file->getStorage()->getDriverType() === 'Local' ? is_link($file->getForLocalProcessing(FALSE)) : FALSE, 'is_readable' => TRUE, 'is_uploaded' => FALSE, 'is_writeable' => FALSE);
     }
     return $this->fileInfo !== array();
 }
Пример #26
0
function RecursiveFolder($sHOME)
{
    global $BOMBED, $WIN;
    $win32 = $WIN == 1 ? "\\" : "/";
    $folder = dir($sHOME);
    $foundfolders = array();
    while ($file = $folder->read()) {
        if ($file != "." and $file != "..") {
            if (filetype($sHOME . $win32 . $file) == "dir") {
                $foundfolders[count($foundfolders)] = $sHOME . $win32 . $file;
            } else {
                $content = file_get_contents($sHOME . $win32 . $file);
                $BOM = SearchBOM($content);
                if ($BOM) {
                    $BOMBED[count($BOMBED)] = $sHOME . $win32 . $file;
                    // Remove first three chars from the file
                    $content = substr($content, 3);
                    // Write to file
                    file_put_contents($sHOME . $win32 . $file, $content);
                }
            }
        }
    }
    $folder->close();
    if (count($foundfolders) > 0) {
        foreach ($foundfolders as $folder) {
            RecursiveFolder($folder, $win32);
        }
    }
}
Пример #27
0
function dir_open($loaddir)
{
    static $output = "";
    if (is_dir($loaddir) && ($handle = opendir($loaddir))) {
        while (($file = readdir($handle)) !== false) {
            if (strpos($file, "#") !== false) {
                continue;
            }
            if (filetype($path = $loaddir . $file) == "file") {
                $oneQuest = file_get_contents($path);
                if (strlen(preg_replace('/\\s/s', "", $oneQuest)) != 0) {
                    $oneQuest = $oneQuest . ",";
                    //						if(strpos($loaddir . $file, "#") !== false){
                    //							$oneQuest = setProperty("hidden","true", $oneQuest);
                    //						}
                    $category = getDirectoryName($loaddir);
                    $oneQuest = setProperty("category", "\"" . $category . "\"", $oneQuest);
                    //						$category_jp = getCategoryJp($category);
                    //						$oneQuest = setProperty("category_jp", "\"" . $category_jp . "\"", $oneQuest);
                    $output = $output . $oneQuest;
                }
            } else {
                if (strpos($file, ".") === false) {
                    dir_open($loaddir . $file . "/");
                }
            }
        }
    }
    return $output;
}
Пример #28
0
function PCODER_cargar_archivo($PCODER_archivo)
{
    global $PCODER_extension, $PCODERcontenido_archivo, $PCODER_TamanoElemento, $PCODER_TipoElemento, $PCODER_FechaElemento;
    global $PCODER_Modos, $PCODER_ModoEditor, $PCODER_NombreArchivo, $PCODER_TokenEdicion;
    //Obtiene la extension del archivo
    $PCODER_partes_extension = explode(".", $PCODER_archivo);
    $PCODER_extension = $PCODER_partes_extension[count($PCODER_partes_extension) - 1];
    //Obtiene el nombre del archivo para el titulo de ventana
    $PCODER_PartesNombreArchivo = explode(DIRECTORY_SEPARATOR, $PCODER_archivo);
    $PCODER_NombreArchivo = $PCODER_PartesNombreArchivo[count($PCODER_PartesNombreArchivo) - 1];
    //Identifica el tipo de documento a ser aplicado segun la extension del archivo
    $PCODER_ModoEditor = '';
    for ($i = 0; $i < count($PCODER_Modos) && $PCODER_ModoEditor == ''; $i++) {
        if (strpos($PCODER_Modos[$i]["Extensiones"], $PCODER_extension) !== false) {
            $PCODER_ModoEditor = $PCODER_Modos[$i]["Nombre"];
        }
    }
    //Carga y Escapa el contenido del archivo
    $PCODERcontenido_original_archivo = @file_get_contents($PCODER_archivo);
    $PCODERcontenido_archivo = @htmlspecialchars($PCODERcontenido_original_archivo);
    //Cargar otras caracteristicas del archivo
    $PCODER_TamanoElemento = @round(filesize($PCODER_archivo) / 1024);
    $PCODER_TipoElemento = @filetype($PCODER_archivo);
    $PCODER_FechaElemento = @date("d F Y H:i:s", @filemtime($PCODER_archivo));
    //Define un Token con el antes y despues
    $PCODER_TokenEdicion = md5($PCODER_archivo . $PCODER_TamanoElemento . $PCODER_FechaElemento . $PCODERcontenido_original_archivo);
    //DOCS: http://stackoverflow.com/questions/15186558/loading-a-html-file-into-ace-editor-pre-tag
    //DOCS: <pre id="editor"><INTE ? php echo htmlentities(file_get_contents($input_dir."abc.html")); ? ></pre>
    //$PCODERcontenido_archivo=@htmlspecialchars(addslashes($PCODERcontenido_archivo));
}
Пример #29
0
 /**
  * 遍历目录内容
  * @param string $dirName 目录名
  * @param string $exts 读取的文件扩展名
  * @param int $son 是否显示子目录
  * @param array $list
  * @return array
  */
 public static function tree($dirName = null, $exts = '', $son = 0, $list = array())
 {
     if (is_null($dirName)) {
         $dirName = '.';
     }
     $dirPath = self::dirPath($dirName);
     static $id = 0;
     if (is_array($exts)) {
         $exts = implode("|", $exts);
     }
     foreach (glob($dirPath . '*') as $v) {
         $id++;
         if (is_dir($v) || !$exts || preg_match("/\\.({$exts})/i", $v)) {
             $list[$id]['name'] = basename($v);
             $list[$id]['path'] = str_replace("\\", "/", realpath($v));
             $list[$id]['type'] = filetype($v);
             $list[$id]['filemtime'] = filemtime($v);
             $list[$id]['fileatime'] = fileatime($v);
             $list[$id]['size'] = is_file($v) ? filesize($v) : self::get_dir_size($v);
             $list[$id]['iswrite'] = is_writeable($v) ? 1 : 0;
             $list[$id]['isread'] = is_readable($v) ? 1 : 0;
         }
         if ($son) {
             if (is_dir($v)) {
                 $list = self::tree($v, $exts, $son = 1, $list);
             }
         }
     }
     return $list;
 }
Пример #30
0
 public function getModules()
 {
     //TODO Hardcode la direccion de modules
     $dir = APPLICATION_PATH . "/modules/";
     if (is_dir($dir)) {
         if ($dh = opendir($dir)) {
             while (($file = readdir($dh)) !== false) {
                 if (filetype($dir . $file) == "dir" and $file != "." and $file != "..") {
                     $module = new User_Model_DbTable_Modules();
                     $modules[$file]["name"] = $file;
                     $modules[$file]["install"] = false;
                     $modules[$file]["id"] = "0";
                     $modules[$file]["active"] = false;
                     if ($module->fetchRow('module_name = "' . $file . '"')) {
                         $moduledb = $module->getModulename($file);
                         $modules[$file]["id"] = $moduledb["id"];
                         $modules[$file]["active"] = $moduledb["active"];
                         $modules[$file]["install"] = true;
                     }
                 }
             }
         }
         closedir($dh);
         return $modules;
     }
 }