private function getFileArray($subDir)
 {
     $result = array();
     $dir = TL_ROOT . '/system/modules/con4gis_maps3/assets/css/themes/' . $subDir . '/';
     if (is_dir($dir)) {
         $file = \scan($dir);
         $getLastFile = $file;
         $lastFile = max(array_keys($getLastFile));
         $hiddenName = array('.', '..', '.DS_Store');
         $x = 0;
         while ($x <= $lastFile) {
             if (!in_array($file[$x], $hiddenName)) {
                 $pathinfo = pathinfo($file[$x]);
                 if (strtolower($pathinfo['extension']) != "css") {
                     continue;
                 }
                 $fileobj = new \File($file[$x], true);
                 //needed for $file[$x] too!
                 $result[] = $file[$x];
             }
             $x++;
         }
     }
     return $result;
 }
Example #2
0
 /**
  * List download files
  * @param   array
  * @return  string
  * @see     https://contao.org/de/manual/3.1/data-container-arrays.html#label_callback
  */
 public function listRows($row)
 {
     $objDownload = Download::findByPk($row['id']);
     $icon = '';
     if (null === $objDownload || null === $objDownload->getRelated('singleSRC')) {
         return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['invalidName'] . '</p>';
     }
     $path = $objDownload->getRelated('singleSRC')->path;
     if ($objDownload->getRelated('singleSRC')->type == 'folder') {
         $arrDownloads = array();
         foreach (scan(TL_ROOT . '/' . $path) as $file) {
             if (is_file(TL_ROOT . '/' . $path . '/' . $file)) {
                 $objFile = new \File($path . '/' . $file);
                 $icon = 'background:url(' . TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon . ') left center no-repeat; padding-left: 22px';
                 $arrDownloads[] = sprintf('<div style="margin-bottom:5px;height:16px;%s">%s</div>', $icon, $path . '/' . $file);
             }
         }
         if (empty($arrDownloads)) {
             return $GLOBALS['TL_LANG']['ERR']['emptyDownloadsFolder'];
         }
         return '<div style="margin-bottom:5px;height:16px;font-weight:bold">' . $path . '</div>' . implode("\n", $arrDownloads);
     }
     if (is_file(TL_ROOT . '/' . $path)) {
         $objFile = new \File($path);
         $icon = 'background: url(' . TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon . ') left center no-repeat; padding-left: 22px';
     }
     return sprintf('<div style="height: 16px;%s">%s</div>', $icon, $path);
 }
Example #3
0
function scan($dir)
{
    $files = array();
    // Is there actually such a folder/file?
    if (file_exists($dir)) {
        $scanned = scandir($dir);
        //get a directory listing
        $scanned = array_diff(scandir($dir), array('.', '..', '.DS_Store', 'Thumbs.db'));
        //sort folders first, then by type, then alphabetically
        usort($scanned, create_function('$a,$b', '
			return	is_dir ($a)
				? (is_dir ($b) ? strnatcasecmp ($a, $b) : -1)
				: (is_dir ($b) ? 1 : (
					strcasecmp (pathinfo ($a, PATHINFO_EXTENSION), pathinfo ($b, PATHINFO_EXTENSION)) == 0
					? strnatcasecmp ($a, $b)
					: strcasecmp (pathinfo ($a, PATHINFO_EXTENSION), pathinfo ($b, PATHINFO_EXTENSION))
				))
			;
		'));
        foreach ($scanned as $f) {
            if (!$f || $f[0] == '.') {
                continue;
                // Ignore hidden files
            }
            if (is_dir($dir . '/' . $f)) {
                // The path is a folder
                $files[] = array("name" => $f, "type" => "folder", "path" => $dir . '/' . $f, "items" => scan($dir . '/' . $f));
            } else {
                // It is a file
                $files[] = array("name" => $f, "type" => "file", "ext" => pathinfo($f, PATHINFO_EXTENSION), "path" => $dir . '/' . $f, "size" => filesize($dir . '/' . $f));
            }
        }
    }
    return $files;
}
Example #4
0
 /**
  * Run the controller
  */
 public function run()
 {
     // Check if shop has been installed
     $blnInstalled = \Database::getInstance()->tableExists(Config::getTable());
     foreach (scan(TL_ROOT . '/system/modules/isotope/library/Isotope/Upgrade') as $strFile) {
         $strVersion = pathinfo($strFile, PATHINFO_FILENAME);
         if (preg_match('/To[0-9]{10}/', $strVersion)) {
             $strClass = 'Isotope\\Upgrade\\' . $strVersion;
             $strStep = 'Version ' . RepositoryVersion::format(substr($strVersion, 2));
             try {
                 $objUpgrade = new $strClass();
                 $objUpgrade->run($blnInstalled);
             } catch (\Exception $e) {
                 $this->handleException($strStep, $e);
             }
         }
     }
     if ($blnInstalled) {
         try {
             $this->verifySystemIntegrity();
             $this->purgeCaches();
         } catch (\Exception $e) {
             $this->handleException('Finalization', $e);
         }
     }
 }
Example #5
0
function scan($dir)
{
    $dir = new DirectoryIterator($dir);
    foreach ($dir as $po) {
        if ($po->isDir() && !$po->isDot()) {
            scan($po->getPathname());
        } elseif ($po->isFile() && '.po' == substr($po->getFilename(), -3)) {
            try {
                $file_po = $po->getPathname();
                $file_mo = substr($po->getPathname(), 0, -3) . '.mo';
                @mkdir(dirname($file_mo), 0777, true);
                @chmod(dirname($file_mo), 0777);
                print "Processing file: {$file_po} ";
                if (false === system("msgfmt {$file_po} -o {$file_mo}")) {
                    throw new Exception('Can\'t process file');
                }
                if (!file_exists($file_mo)) {
                    touch($file_mo);
                }
                @chmod($file_mo, 0777);
                print '[ OK ]';
            } catch (Exception $e) {
                print '[ ERROR ]';
            }
            print "<br />\n";
        }
    }
}
Example #6
0
 /**
  * Update all style sheets in the scripts folder
  */
 public function updateStyleSheets()
 {
     $objStyleSheets = $this->Database->execute("SELECT * FROM tl_style_sheet");
     $arrStyleSheets = $objStyleSheets->fetchEach('name');
     // Make sure the dcaconfig.php file is loaded
     @(include TL_ROOT . '/system/config/dcaconfig.php');
     // Delete old style sheets
     foreach (scan(TL_ROOT . '/system/scripts', true) as $file) {
         // Skip directories
         if (is_dir(TL_ROOT . '/system/scripts/' . $file)) {
             continue;
         }
         // Preserve root files (is this still required now that scripts are in system/scripts?)
         if (is_array($GLOBALS['TL_CONFIG']['rootFiles']) && in_array($file, $GLOBALS['TL_CONFIG']['rootFiles'])) {
             continue;
         }
         // Do not delete the combined files (see #3605)
         if (preg_match('/^[a-f0-9]{12}\\.css$/', $file)) {
             continue;
         }
         $objFile = new File('system/scripts/' . $file);
         // Delete the old style sheet
         if ($objFile->extension == 'css' && !in_array($objFile->filename, $arrStyleSheets)) {
             $objFile->delete();
         }
     }
     $objStyleSheets->reset();
     // Create the new style sheets
     while ($objStyleSheets->next()) {
         $this->writeStyleSheet($objStyleSheets->row());
         $this->log('Generated style sheet "' . $objStyleSheets->name . '.css"', 'StyleSheets updateStyleSheets()', TL_CRON);
     }
 }
Example #7
0
 /**
  * Update all style sheets in the scripts folder
  */
 public function updateStyleSheets()
 {
     $objStyleSheets = $this->Database->execute("SELECT * FROM tl_style_sheet");
     $arrStyleSheets = $objStyleSheets->fetchEach('name');
     // Make sure the dcaconfig.php file is loaded
     include TL_ROOT . '/system/config/dcaconfig.php';
     // Delete old style sheets
     foreach (scan(TL_ROOT . '/system/scripts', true) as $file) {
         if (is_dir(TL_ROOT . '/system/scripts/' . $file)) {
             continue;
         }
         if (is_array($GLOBALS['TL_CONFIG']['rootFiles']) && in_array($file, $GLOBALS['TL_CONFIG']['rootFiles'])) {
             continue;
         }
         $objFile = new File('system/scripts/' . $file);
         if ($objFile->extension == 'css' && !in_array($objFile->filename, $arrStyleSheets)) {
             $objFile->delete();
         }
     }
     $objStyleSheets->reset();
     // Create the new style sheets
     while ($objStyleSheets->next()) {
         $this->writeStyleSheet($objStyleSheets->row());
         $this->log('Generated style sheet "' . $objStyleSheets->name . '.css"', 'StyleSheets updateStyleSheets()', TL_CRON);
     }
 }
function reason_write()
{
    extract($_REQUEST);
    $sql = "UPDATE cubit.pslip_scans SET reason='{$double_reason}' WHERE id='{$scan_id}'";
    db_exec($sql) or errDie("Unable to record scan reason.");
    return scan();
}
Example #9
0
function scan($dir)
{
    $accessableFiles = dbClass::getAccessableFiles($_COOKIE['userId']);
    $folder = [];
    foreach ($accessableFiles as $index => $code) {
        if (strpos($code['file'], '/') !== false) {
            $code['file'] = explode('/', $code['file'])[1];
        }
        $folder[] = $code['file'];
    }
    $files = array();
    // Is there actually such a folder/file?
    if (file_exists($dir)) {
        $allowedFolder = $accessableFiles[0]['file'];
        foreach (scandir($dir) as $f) {
            if (!$f || $f[0] == '.') {
                continue;
                // Ignore hidden files
            }
            if (is_dir($dir . '/' . $f)) {
                // The path is a folder
                for ($i = 0; $i < count($folder); $i++) {
                    if ($f == $folder[$i]) {
                        $files[] = array("name" => $f, "type" => "folder", 'checked' => false, "path" => $dir . '/' . $f, "items" => scan($dir . '/' . $f));
                    }
                }
            } else {
                // It is a file
                $files[] = array("name" => $f, "type" => "file", 'checked' => false, "path" => $dir . '/' . $f, "size" => filesize($dir . '/' . $f));
            }
        }
    }
    return $files;
}
Example #10
0
 /**
  * Update the inactive modules
  * @param mixed
  * @return mixed
  */
 public function updateInactiveModules($varValue)
 {
     $arrModules = deserialize($varValue);
     if (!is_array($arrModules)) {
         $arrModules = array();
     }
     foreach (scan(TL_ROOT . '/system/modules') as $strModule) {
         if (strncmp($strModule, '.', 1) === 0) {
             continue;
         }
         // Add the .skip file to disable the module
         if (in_array($strModule, $arrModules)) {
             if (!file_exists(TL_ROOT . '/system/modules/' . $strModule . '/.skip')) {
                 $objFile = new File('system/modules/' . $strModule . '/.skip');
                 $objFile->write('As long as this file exists, the module will be ignored.');
                 $objFile->close();
             }
         } else {
             if (file_exists(TL_ROOT . '/system/modules/' . $strModule . '/.skip')) {
                 $objFile = new File('system/modules/' . $strModule . '/.skip');
                 $objFile->delete();
             }
         }
     }
     return $varValue;
 }
Example #11
0
 /**
  * Return all excluded fields as HTML drop down menu
  *
  * @return array
  */
 public function getExcludedFields()
 {
     $included = array();
     foreach (ModuleLoader::getActive() as $strModule) {
         $strDir = 'system/modules/' . $strModule . '/dca';
         if (!is_dir(TL_ROOT . '/' . $strDir)) {
             continue;
         }
         foreach (scan(TL_ROOT . '/' . $strDir) as $strFile) {
             // Ignore non PHP files and files which have been included before
             if (substr($strFile, -4) != '.php' || in_array($strFile, $included)) {
                 continue;
             }
             $included[] = $strFile;
             $strTable = substr($strFile, 0, -4);
             System::loadLanguageFile($strTable);
             $this->loadDataContainer($strTable);
         }
     }
     $arrReturn = array();
     // Get all excluded fields
     foreach ($GLOBALS['TL_DCA'] as $k => $v) {
         if (is_array($v['fields'])) {
             foreach ($v['fields'] as $kk => $vv) {
                 if ($vv['exclude'] || $vv['orig_exclude']) {
                     $arrReturn[$k][specialchars($k . '::' . $kk)] = $vv['label'][0] ?: $kk;
                 }
             }
         }
     }
     ksort($arrReturn);
     return $arrReturn;
 }
Example #12
0
function scan($dir)
{
    global $skipping, $startFile, $accountId, $accounts, $basePath;
    $cdir = scandir($dir);
    foreach ($cdir as $key => $value) {
        if (!in_array($value, [".", ".."])) {
            if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                if (!$skipping) {
                    if (!isset($accounts[$accountId])) {
                        echo "Account #{$accountId} not exitst!\n\n";
                        return;
                    }
                    $EMAIL = $accounts[$accountId]['email'];
                    $PASS = $accounts[$accountId]['pass'];
                    $relativeDir = str_replace($basePath, '', $dir . DIRECTORY_SEPARATOR . $value);
                    `/usr/bin/megamkdir -u "{$EMAIL}" -p "{$PASS}" /Root/{$relativeDir}`;
                }
                scan($dir . DIRECTORY_SEPARATOR . $value);
            } else {
                if ($skipping) {
                    if ($startFile == $dir . DIRECTORY_SEPARATOR . $value) {
                        $skipping = false;
                        //                        processFile($dir . DIRECTORY_SEPARATOR .$value);
                    }
                    continue;
                }
                processFile($dir . DIRECTORY_SEPARATOR . $value);
            }
        }
    }
}
Example #13
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     \System::loadLanguageFile('tl_autoload');
     // Process the request
     if (\Input::post('FORM_SUBMIT') == 'tl_autoload') {
         $this->createAutoloadFiles();
         $this->reload();
     }
     $arrModules = array();
     // List all modules
     foreach (scan(TL_ROOT . '/system/modules') as $strFile) {
         if (strncmp($strFile, '.', 1) === 0 || !is_dir(TL_ROOT . '/system/modules/' . $strFile)) {
             continue;
         }
         $arrModules[] = $strFile;
     }
     $this->Template->modules = $arrModules;
     $this->Template->messages = \Message::generate();
     $this->Template->href = $this->getReferer(true);
     $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']);
     $this->Template->button = $GLOBALS['TL_LANG']['MSC']['backBT'];
     $this->Template->headline = $GLOBALS['TL_LANG']['tl_autoload']['headline'];
     $this->Template->action = ampersand(\Environment::get('request'));
     $this->Template->available = $GLOBALS['TL_LANG']['tl_autoload']['available'];
     $this->Template->xplAvailable = $GLOBALS['TL_LANG']['tl_autoload']['xplAvailable'];
     $this->Template->selectAll = $GLOBALS['TL_LANG']['MSC']['selectAll'];
     $this->Template->override = $GLOBALS['TL_LANG']['tl_autoload']['override'];
     $this->Template->xplOverride = $GLOBALS['TL_LANG']['tl_autoload']['xplOverride'];
     $this->Template->submitButton = specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
     $this->Template->autoload = $GLOBALS['TL_LANG']['tl_autoload']['autoload'];
     $this->Template->ideCompat = $GLOBALS['TL_LANG']['tl_autoload']['ideCompat'];
 }
Example #14
0
function scan($dir, $ext, $callback, $find = array(), $replace = array())
{
    $result = array();
    if (!is_dir($dir)) {
        return $result;
    }
    $args = func_get_args();
    //    print_r($args);
    $args = array_slice($args, 3, null, true);
    //    print_r($args);exit;
    $fp = scandir($dir);
    if ($fp) {
        foreach ($fp as $v) {
            if ($v == '.' || $v == '..') {
                continue;
            }
            if (is_dir($dir . '/' . $v)) {
                $end = scan($dir . '/' . $v, $ext, $callback, $find, $replace);
                if ($end) {
                    $result = array_merge($result, $end);
                }
            } else {
                if (check_file($dir . '/' . $v, $ext)) {
                    $args = array($dir . '/' . $v, $find, $replace);
                    $end = call_user_func_array($callback, $args);
                    if ($end) {
                        $result[] = $end;
                    }
                }
            }
        }
    }
    return $result;
}
Example #15
0
function scan($dir, $durl = '', $min_size = "3000")
{
    static $seen = array();
    global $return;
    $files = array();
    $dir = realpath($dir);
    if (isset($seen[$dir])) {
        return $files;
    }
    $seen[$dir] = TRUE;
    $dh = @opendir($dir);
    while ($dh && ($file = readdir($dh))) {
        if ($file !== '.' && $file !== '..') {
            $path = realpath($dir . '/' . $file);
            $url = $durl . '/' . $file;
            if (preg_match("/.svn|lang/", $path)) {
                continue;
            }
            if (is_dir($path)) {
                scan($path);
            } elseif (is_file($path)) {
                if (!preg_match("/\\.js\$/", $path) || filesize($path) < $min_size) {
                    continue;
                }
                $return[] = $path;
            }
        }
    }
    @closedir($dh);
    return $files;
}
Example #16
0
function scan($dir, $durl = '')
{
    global $include, $exclude, $dirinclude, $direxclude;
    static $seen = array();
    $files = array();
    $dir = realpath($dir);
    if (isset($seen[$dir])) {
        return $files;
    }
    $seen[$dir] = TRUE;
    $dh = @opendir($dir);
    while ($dh && ($file = readdir($dh))) {
        if ($file !== '.' && $file !== '..') {
            $path = realpath($dir . '/' . $file);
            $url = $durl . '/' . $file;
            if ($dirinclude && !preg_match($dirinclude, $url) || $direxclude && preg_match($direxclude, $url)) {
                continue;
            }
            if (is_dir($path)) {
                if ($subdir = scan($path, $url)) {
                    $files[] = array('url' => $url, 'children' => $subdir);
                }
            } elseif (is_file($path)) {
                if ($include && !preg_match($include, $url) || $exclude && preg_match($exclude, $url)) {
                    continue;
                }
                $files[] = array('url' => $url);
            }
        }
    }
    @closedir($dh);
    return dirsort($files);
}
Example #17
0
 /**
  * Return all excluded fields as HTML drop down menu
  * @return array
  */
 public function getExcludedFields()
 {
     $included = array();
     foreach ($this->Config->getActiveModules() as $strModule) {
         $strDir = sprintf('%s/system/modules/%s/dca/', TL_ROOT, $strModule);
         if (!is_dir($strDir)) {
             continue;
         }
         foreach (scan($strDir) as $strFile) {
             if (in_array($strFile, $included)) {
                 continue;
             }
             $included[] = $strFile;
             $strTable = str_replace('.php', '', $strFile);
             $this->loadLanguageFile($strTable);
             $this->loadDataContainer($strTable);
         }
     }
     $arrReturn = array();
     // Get all excluded fields
     foreach ($GLOBALS['TL_DCA'] as $k => $v) {
         if (is_array($v['fields'])) {
             foreach ($v['fields'] as $kk => $vv) {
                 if ($vv['exclude'] || $vv['orig_exclude']) {
                     $arrReturn[$k][specialchars($k . '::' . $kk)] = $vv['label'][0] ?: $kk;
                 }
             }
         }
     }
     ksort($arrReturn);
     return $arrReturn;
 }
Example #18
0
function get_folder($address)
{
    if (\is_folder_exist($address)) {
        return \scan($address);
    } else {
        return false;
    }
}
function scan($iterator, $level = '')
{
    foreach ($iterator as $index => $value) {
        echo $level, $value, PHP_EOL;
        if ($iterator->hasChildren()) {
            scan($iterator->getChildren(), $level . "\t");
        }
    }
}
Example #20
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     $images = array();
     foreach ($this->multiSRC as $file) {
         if (strncmp($file, '.', 1) === 0) {
             continue;
         }
         // Directory
         if (is_dir(TL_ROOT . '/' . $file)) {
             $subfiles = scan(TL_ROOT . '/' . $file);
             $this->parseMetaFile($file);
             foreach ($subfiles as $subfile) {
                 if (strncmp($subfile, '.', 1) === 0 || is_dir(TL_ROOT . '/' . $file . '/' . $subfile)) {
                     continue;
                 }
                 $objFile = new File($file . '/' . $subfile);
                 if ($objFile->isGdImage) {
                     $images[] = $file . '/' . $subfile;
                 }
             }
             continue;
         }
         // File
         if (is_file(TL_ROOT . '/' . $file)) {
             $objFile = new File($file);
             $this->parseMetaFile(dirname($file), true);
             if ($objFile->isGdImage) {
                 $images[] = $file;
             }
         }
     }
     $images = array_unique($images);
     if (!is_array($images) || empty($images)) {
         return;
     }
     $i = mt_rand(0, count($images) - 1);
     $objImage = new File($images[$i]);
     $arrMeta = $this->arrMeta[$objImage->basename];
     if ($arrMeta[0] == '') {
         $arrMeta[0] = str_replace('_', ' ', preg_replace('/^[0-9]+_/', '', $objImage->filename));
     }
     $arrImage = array();
     $arrImage['size'] = $this->imgSize;
     $arrImage['singleSRC'] = $objImage->value;
     $arrImage['alt'] = specialchars($arrMeta[0]);
     $arrImage['imageUrl'] = $arrMeta[1];
     $arrImage['fullsize'] = $this->fullsize;
     // Image caption
     if ($this->useCaption) {
         if ($arrMeta[2] == '') {
             $arrMeta[2] = $arrMeta[0];
         }
         $arrImage['caption'] = $arrMeta[2];
     }
     $this->addImageToTemplate($this->Template, $arrImage);
 }
 function fba($path, $sub)
 {
     // Menentukan absolute URL yang menuju ke $path. Output: http://ibacor.com/download/
     $link = dirname($path) . '/';
     // Menentukan direktori yang akan di scan. Output: file
     $realpath = explode('/', $path);
     $dir = $realpath[sizeof($realpath) - 1] . $sub;
     // Jalankan fungsi scan
     return scan($dir, $link, $sub);
 }
Example #22
0
 public function device_exists()
 {
     $array = scan('client/templates');
     foreach ($array as &$value) {
         $reference = $value;
         $reference = explode('.', $reference);
         $value = array_shift($reference);
     }
     return in_array($_SESSION['device'], array_filter($array)) ? 1 : implode('" or "', array_filter($array));
 }
Example #23
0
 public function getGeoLookUpServices()
 {
     $arrReturn = array();
     $arrFile = scan(TL_ROOT . "/system/modules/geolocation");
     foreach ($arrFile as $value) {
         if (preg_match("/GeoLookUp.*\\.php/", $value) && !preg_match("/.*(Factory|Interface).*/", $value)) {
             $objService = GeoLookUpFactory::getEngine($value);
             if ($objService->getType() == GeoLookUpInterface::GEO || $objService->getType() == GeoLookUpInterface::BOTH) {
                 $arrReturn[$value] = $objService->getName();
             }
         }
     }
     return $arrReturn;
 }
Example #24
0
 /**
  * Load all data containers
  */
 protected function loadDataContainers()
 {
     foreach (\ModuleLoader::getActive() as $module) {
         $dir = 'system/modules/' . $module . '/dca';
         if (!is_dir(TL_ROOT . '/' . $dir)) {
             continue;
         }
         foreach (scan(TL_ROOT . '/' . $dir) as $file) {
             if (substr($file, -4) != '.php') {
                 continue;
             }
             \Controller::loadDataContainer(substr($file, 0, -4));
         }
     }
 }
Example #25
0
function scan($dir, $subdirs)
{
    $hDir = opendir($dir);
    if ($hDir !== false) {
        while (($file = readdir($hDir)) !== false) {
            $path = $dir . '/' . $file;
            if (is_dir($path) && substr($file, 0, 1) !== '.' && $subdirs) {
                scan($path, $subdirs);
            } else {
                if (is_file($path) && (substr($file, -4) === '.tpl' || substr($file, -4) === '.php')) {
                    testforbom($path);
                }
            }
        }
        closedir($hDir);
    }
}
Example #26
0
function show()
{
    if (isset($_GET['filename'])) {
        if (is_dir($_GET['filename'])) {
            scan($_GET['filename']);
            ?>

            <form action="" method="post">
                <textarea name="dir_edit" cols="100" rows="1"><?php 
            echo $_GET['filename'];
            ?>
</textarea>
                <input type="submit" name="edit" class="right" value="Изменить имя директории">
                <input type="hidden" name="dirName" value=<?php 
            echo $_GET['filename'];
            ?>
>
            </form>
            <?php 
            if (isset($_POST['edit'])) {
                rename($_POST['dirName'], $_POST['dir_edit']);
            }
        } else {
            scan(dirname($_GET['filename']));
            ?>

            <form action="" method="post">
                <textarea name="file_edit" cols="100" rows="30"><?php 
            echo file_get_contents($_GET['filename']);
            ?>
</textarea>
                <input type="submit" name="edit" class="right" value="Изменить">
                <input type="hidden" name="filename" value=<?php 
            echo $_GET['filename'];
            ?>
>
            </form>
            <?php 
            if (isset($_POST['edit'])) {
                file_put_contents($_POST['filename'], $_POST['file_edit']);
            }
        }
    } else {
        scan();
    }
}
Example #27
0
 /**
  * Return all modules as array
  * @return array
  */
 public function getModules()
 {
     $arrReturn = array();
     $arrInactiveModules = deserialize($GLOBALS['TL_CONFIG']['inactiveModules']);
     $blnCheckInactiveModules = is_array($arrInactiveModules);
     $arrModules = scan(TL_ROOT . '/system/modules');
     foreach ($arrModules as $strModule) {
         if (substr($strModule, 0, 1) == '.' || substr($strModule, -5, 5) == 'debug' || !is_dir(TL_ROOT . '/system/modules/' . $strModule) || $blnCheckInactiveModules && in_array($strModule, $arrInactiveModules)) {
             continue;
         }
         $label = array_key_exists($strModule, $GLOBALS['TL_LANG']['MOD']) && is_array($GLOBALS['TL_LANG']['MOD'][$strModule]) ? $GLOBALS['TL_LANG']['MOD'][$strModule][0] : (array_key_exists($strModule, $GLOBALS['TL_LANG']['MOD']) && $GLOBALS['TL_LANG']['MOD'][$strModule] ? $GLOBALS['TL_LANG']['MOD'][$strModule] : '');
         $arrReturn[$strModule] = strlen($label) ? $label : $strModule;
     }
     natcasesort($arrReturn);
     $arrReturn = array('core' => 'Core') + $arrReturn;
     return $arrReturn;
 }
function scan($path)
{
    if ($dp = opendir($path)) {
        while ($dir = readdir($dp)) {
            if ($dir == "." || $dir == "..") {
                continue;
            }
            if (is_dir("{$path}/{$dir}")) {
                $arDir[$dir] = scan("{$path}/{$dir}");
            }
            if (is_file("{$path}/{$dir}")) {
                $arDir[$dir] = "";
            }
        }
        closedir($dp);
    }
    return isset($arDir) ? $arDir : '';
}
Example #29
0
function scan($path = '.', $class)
{
    $ignore = array('.', '..');
    $dh = opendir($path);
    while (false !== ($file = readdir($dh))) {
        if (!in_array($file, $ignore)) {
            if (is_dir($path . DIRECTORY_SEPARATOR . $file)) {
                scan($path . DIRECTORY_SEPARATOR . $file, $class);
            } else {
                if ($file === 'class.' . $class . '.php') {
                    require_once $path . DIRECTORY_SEPARATOR . $file;
                    return;
                }
            }
        }
    }
    closedir($dh);
}
Example #30
0
/**
 * Class autoloader
 *
 * Include classes automatically when they are instantiated.
 * @param string
 */
function __autoload($strClassName)
{
    $objCache = FileCache::getInstance('autoload');
    // Try to load the class name from the session cache
    if (!$GLOBALS['TL_CONFIG']['debugMode'] && isset($objCache->{$strClassName})) {
        if (@(include_once TL_ROOT . '/' . $objCache->{$strClassName})) {
            return;
            // The class could be loaded
        } else {
            unset($objCache->{$strClassName});
            // The class has been removed
        }
    }
    $strLibrary = TL_ROOT . '/system/libraries/' . $strClassName . '.php';
    // Check for libraries first
    if (file_exists($strLibrary)) {
        include_once $strLibrary;
        $objCache->{$strClassName} = 'system/libraries/' . $strClassName . '.php';
        return;
    }
    // Then check the modules folder
    foreach (scan(TL_ROOT . '/system/modules/') as $strFolder) {
        if (substr($strFolder, 0, 1) == '.') {
            continue;
        }
        $strModule = TL_ROOT . '/system/modules/' . $strFolder . '/' . $strClassName . '.php';
        if (file_exists($strModule)) {
            include_once $strModule;
            $objCache->{$strClassName} = 'system/modules/' . $strFolder . '/' . $strClassName . '.php';
            return;
        }
    }
    // HOOK: include Swift classes
    if (class_exists('Swift', false)) {
        Swift::autoload($strClassName);
        return;
    }
    // HOOK: include DOMPDF classes
    if (function_exists('DOMPDF_autoload')) {
        DOMPDF_autoload($strClassName);
        return;
    }
    trigger_error(sprintf('Could not load class %s', $strClassName), E_USER_ERROR);
}