Exemplo n.º 1
2
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     if (!file_exists($path)) {
         $output->writeln("{$path} is not a file or a path");
     }
     $filePaths = [];
     if (is_file($path)) {
         $filePaths = [realpath($path)];
     } elseif (is_dir($path)) {
         $filePaths = array_diff(scandir($path), array('..', '.'));
     } else {
         $output->writeln("{$path} is not known.");
     }
     $generator = new StopwordGenerator($filePaths);
     if ($input->getArgument('type') === 'json') {
         echo json_encode($this->toArray($generator->getStopwords()), JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);
         echo json_last_error_msg();
         die;
         $output->write(json_encode($this->toArray($generator->getStopwords())));
     } else {
         $stopwords = $generator->getStopwords();
         $stdout = fopen('php://stdout', 'w');
         echo 'token,freq' . PHP_EOL;
         foreach ($stopwords as $token => $freq) {
             fputcsv($stdout, [utf8_encode($token), $freq]) . PHP_EOL;
         }
         fclose($stdout);
     }
 }
Exemplo n.º 2
1
 /**
  * 
  * @return string
  */
 public static function fileTree()
 {
     $root = JchPlatformPaths::rootPath();
     $dir = urldecode(JchPlatformUtility::get('dir', '', 'string', 'post'));
     $dir = JchPlatformUtility::decrypt($dir);
     $response = '';
     if (file_exists($root . $dir)) {
         $files = scandir($root . $dir);
         natcasesort($files);
         if (count($files) > 2) {
             /* The 2 accounts for . and .. */
             $response .= '<ul class="jqueryFileTree" style="display: none; ">';
             // All dirs
             foreach ($files as $file) {
                 if (file_exists($root . $dir . $file) && $file != '.' && $file != '..' && is_dir($root . $dir . $file)) {
                     $response .= '<li class="directory collapsed"><a href="#" rel="' . JchPlatformUtility::encrypt($dir . $file . '/') . '">' . htmlentities($file) . '</a></li>';
                 }
             }
             // All files
             foreach ($files as $file) {
                 if (file_exists($root . $dir . $file) && $file != '.' && $file != '..' && !is_dir($root . $dir . $file)) {
                     $ext = preg_replace('/^.*\\./', '', $file);
                     $response .= '<li class="file ext_' . $ext . '"><a href="#" rel="' . JchPlatformUtility::encrypt($dir . $file) . '">' . htmlentities($file) . '</a></li>';
                 }
             }
             $response .= '</ul>';
         }
     }
     return $response;
 }
Exemplo n.º 3
0
/**
 * Recursively processes a path and extracts JSDoc comment data from
 * every .js file it finds.
 * @param $path
 */
function recurse($path)
{
    $fList = scandir($path);
    foreach ($fList as $key => $val) {
        switch ($val) {
            case '.':
            case '..':
                // Ignore these entries
                break;
            default:
                if (is_dir($path . '/' . $val)) {
                    // The entry is a folder so recurse it
                    recurse($path . '/' . $val);
                } else {
                    // The entry is a file, check if it's a .js file
                    if (substr($val, strlen($val) - 3, 3) === '.js') {
                        // Process the JS file
                        echo 'Processing JavaScript file: ' . $path . '/' . $val . '<BR>';
                        $data = parseFile($path . '/' . $val);
                        processData($data, $path . '/' . $val, $val);
                    }
                }
                break;
        }
    }
}
 public static function saveCorrectDataWithReflection()
 {
     $defaultControllerPath = "controllers\\defaultControllers\\";
     $controllerFileNames = scandir($defaultControllerPath, 1);
     $settingsArrayWithAllControllersAndActions = [];
     $num = 0;
     foreach ($controllerFileNames as $item) {
         $fileName = "controllers\\defaultControllers\\" . $item;
         if (strpos($item, "Controller")) {
             $clasFileName = substr($fileName, 0, -4);
             require_once $fileName;
             $currentClass = new $clasFileName();
             $reflection = new \ReflectionClass($currentClass);
             $methods = $reflection->getMethods();
             foreach ($methods as $i => $method) {
                 $docBlock = $method->getDocComment();
                 $pattern = "/Route\\(([A-Za-z]+)\\/([A-Za-z]+)\\)/";
                 preg_match($pattern, $docBlock, $routeMatch);
                 if (count($routeMatch) > 0) {
                     $objectToSave = (object) array("Controller" => $reflection->getName(), "Action" => $method->getName(), "CustomController" => $routeMatch[1], "CustomAction" => $routeMatch[2]);
                     $num++;
                     array_push($settingsArrayWithAllControllersAndActions, $objectToSave);
                     //echo '<pre>'; print_r($objectToSave); echo '</pre>';
                 }
             }
         }
     }
     $fp = fopen('config/customRoutes.json', 'w');
     fwrite($fp, json_encode($settingsArrayWithAllControllersAndActions));
     fclose($fp);
     //        echo '<pre>';
     //        print_r( json_encode($objectToSave));
     //        echo '</pre>';
 }
Exemplo n.º 5
0
 protected function loadAll()
 {
     $files = array_diff(scandir(JS_PATH . 'classes/'), array('..', '.'));
     foreach ($files as $file) {
         $this->template .= file_get_contents(JS_PATH . 'classes/' . $file);
     }
 }
Exemplo n.º 6
0
 function _recurseFolders($path)
 {
     if ($this->showsearch) {
         echo '<li>' . basename(realpath($path)) . '<ul>';
     }
     $files = scandir($path);
     static $s_count = 0;
     foreach ($files as $file) {
         if ($file == '.' || $file == '..') {
             continue;
         }
         $file_path = $path . '/' . $file;
         if (is_dir($file_path)) {
             if ($file != 'CVS' && !in_array($file_path, $this->ignorefolders)) {
                 $this->_recurseFolders($file_path);
             }
         } elseif (preg_match('/simpletest(\\/|\\\\)test.*\\.php$/', $file_path) || $this->thorough && preg_match('/simpletest(\\/|\\\\)slowtest.*\\.php$/', $file_path)) {
             $s_count++;
             // OK, found: this shows as a 'Notice' for any 'simpletest/test*.php' file.
             $this->addTestCase(new FindFileNotice($file_path, 'Found unit test file, ' . $s_count));
             // addTestFile: Unfortunately this doesn't return fail/success (bool).
             $this->addTestFile($file_path, true);
         }
     }
     if ($this->showsearch) {
         echo '</ul></li>';
     }
     return $s_count;
 }
function w_rmdir_recursive_inner($path)
{
    # avoid opening a handle on the dir in case that impacts
    # delete latency on windows
    if (@rmdir($path) || @unlink($path)) {
        return true;
    }
    clearstatcache();
    if (is_dir($path)) {
        # most likely failure reason is that the dir is not empty
        $kids = @scandir($path);
        if (is_array($kids)) {
            foreach ($kids as $kid) {
                if ($kid == '.' || $kid == '..') {
                    continue;
                }
                w_rmdir_recursive($path . DIRECTORY_SEPARATOR . $kid);
            }
        }
        if (is_dir($path)) {
            return @rmdir($path);
        }
    }
    if (is_file($path)) {
        return unlink($path);
    }
    return !file_exists($path);
}
Exemplo n.º 8
0
function file_upload($html)
{
    // Define wp upload folder
    $main_path = wp_upload_dir();
    $current_path = '';
    // Instaniate Post_Get class
    $get = new Post_Get();
    // Check if GET variable has value
    $get->exists('GET');
    $current_path = $get->get('upload_dir');
    // Define the folder directory that will hold the content
    $container = $main_path['basedir'] . '/upload_dir';
    // Create upload_dir folder to hold the documents that will be uploaded
    if (!file_exists($container)) {
        mkdir($container, 0755, true);
    }
    // Define current url
    $current_url = $main_path['baseurl'] . '/upload_dir/';
    // Scan current directory
    $current_dir = scandir($main_path['basedir'] . '/upload_dir/' . $current_path);
    // Wrap the retusts in unordered list
    $html .= "<ul>";
    // Loop throught current folder
    foreach ($current_dir as $file) {
        if (stripos($file, '.') !== 0) {
            if (strpos($file, '.html') > -1) {
                $html .= '<li><a href="' . $current_url . $current_path . '/' . $file . '">' . $file . '</a></li>';
            } else {
                $html .= '<li><a href="?upload_dir=' . $current_path . '/' . $file . '">' . $file . '</a></li>';
            }
        }
    }
    $html .= '</ul>';
    return $html;
}
Exemplo n.º 9
0
 public function delete($path)
 {
     if (!is_dir($path)) {
         return false;
     }
     $path = self::path($path);
     $items = scandir($path);
     if (!is_array($items)) {
         return true;
     }
     foreach ($items as $v) {
         if ($v == '.' || $v == '..') {
             continue;
         }
         $v = $path . $v;
         if (is_dir($v)) {
             self::delete($v);
         } else {
             if (!@unlink($v)) {
                 throw new RuntimeException(sprintf('Folder::delete can not delete file %s', $v));
             }
         }
     }
     if (!@rmdir($path)) {
         throw new RuntimeException(sprintf('Folder::delete can not rmdir %s', $path));
     }
     return true;
 }
Exemplo n.º 10
0
function build_mod_list()
{
    $sel_modules = array(array('id' => 'all', 'text' => TEXT_ALL), array('id' => 'install', 'text' => 'install'), array('id' => 'soap', 'text' => 'soap'));
    $dirs = scandir(DIR_FS_MODULES);
    foreach ($dirs as $value) {
        if ($value == '.' || $value == '..') {
            continue;
        }
        if (is_dir(DIR_FS_MODULES . $value . '/dashboards')) {
            // there are dashboards to load languages
            $meths = scandir(DIR_FS_MODULES . $value . '/dashboards');
            foreach ($meths as $val) {
                if ($val == '.' || $val == '..') {
                    continue;
                }
                $sel_modules[] = array('id' => $value . '-' . $val, 'text' => $value . '-' . $val);
            }
        }
        if (is_dir(DIR_FS_MODULES . $value . '/methods')) {
            // there are methods to load languages
            $meths = scandir(DIR_FS_MODULES . $value . '/methods');
            foreach ($meths as $val) {
                if ($val == '.' || $val == '..') {
                    continue;
                }
                $sel_modules[] = array('id' => $value . '-' . $val, 'text' => $value . '-' . $val);
            }
        }
        $sel_modules[] = array('id' => $value, 'text' => $value);
    }
    return $sel_modules;
}
Exemplo n.º 11
0
 public static function get_files($path, $mask = NULL, $appendPath = false)
 {
     // objects
     $files = array();
     //$path		= preg_replace('%/+$%', '/', $path . '/'); // add trailing slash
     $objects = array_diff(scandir($path), array('.', '..'));
     // mask
     if ($mask != NULL) {
         // regular expression for detecing a regular expression
         $rxIsRegExp = '/^([%|\\/]|{).+(\\1|})[imsxeADSUXJu]*$/';
         // an array of file extenstions
         if (is_array($mask)) {
             $mask = '%\\.(' . implode('|', $mask) . ')$%i';
         } else {
             if (!preg_match($rxIsRegExp, $mask)) {
                 $mask = "/\\.{$mask}\$/i";
             }
         }
     }
     // match
     foreach ($objects as $object) {
         if (is_file($path . $object) && ($mask != NULL ? preg_match($mask, $object) : TRUE)) {
             array_push($files, $appendPath ? $path . $object : $object);
         }
     }
     // return
     return $files;
 }
Exemplo n.º 12
0
 public static function collectFiles($directory, $files)
 {
     $listings = scandir($directory);
     foreach ($listings as $listing) {
         $path = "{$directory}/{$listing}";
         if ($listing == '.' || $listing == '..') {
             continue;
         }
         // no hidden files or directories
         if (strpos($listing, ".") === 0) {
             continue;
         }
         // recursively scan directories
         if (is_dir($path)) {
             $files = Appcelerator_Service::collectFiles($path, $files);
         }
         // service files must be named [^.](.+)Service.php
         if (!stristr($listing, 'Service')) {
             continue;
         }
         // this is a valid service source file - record path and file name
         $files[$path] = Appcelerator_Service::fileToClassName($listing);
     }
     return $files;
 }
Exemplo n.º 13
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;
}
Exemplo n.º 14
0
/**
 * gets all the files in a directory
 * @param $directory    the directory to scan
 * @param $dl           i actually don't know?????? sorry been a while lol
 * @return              a list of html div elements (class=fileicon) 
 * @return              "There are no files in directory" if no files are in directory
 */
function get_file($directory, $dl)
{
    $files_list = "";
    $dir = $directory;
    // the directory you want to check
    $exclude = array(".", "..");
    // you don't want these entries in your files array
    $files = scandir($dir);
    $files = array_diff($files, $exclude);
    // delete the entries in exclude array from your files array
    if (!empty($files) and $dl) {
        foreach ($files as $file) {
            // print every file in the files array
            $files_list .= "<div class='fileicon'>\n\t\t<a href='{$directory}/{$file}' download>\n\t\t<p class='filetext'>{$file}</p>\n\t\t</a>\n\t\t</div>";
        }
    } else {
        if (!empty($files)) {
            foreach ($files as $file) {
                // print every file in the files array
                $files_list .= " <div class='fileicon'>\n\t<a href='{$directory}{$file}'>\n\t<p class='filetext'>{$file}</p>\n\t</a>\n\t</div>";
            }
        } else {
            $files_list .= "There are no files in directory";
            // print error message if there are no files
        }
    }
    return $files_list;
}
Exemplo n.º 15
0
/**
 * Scan the exports directory, return the files grouped into intervals of 3 minutes, newest first.
 *
 * @param string $dir fullpath to the Exports folder. (optional)
 * @return array
 */
function group_exports($dir = null)
{
    $ignored = array('.', '..', '.svn', '.git', '.htaccess');
    if (!$dir) {
        $dir = \PressBooks\Modules\Export\Export::getExportFolder();
    } else {
        $dir = rtrim($dir, '/') . '/';
    }
    $files = array();
    foreach (scandir($dir) as $file) {
        if (in_array($file, $ignored)) {
            continue;
        }
        $files[$file] = filemtime($dir . $file);
    }
    arsort($files);
    $interval = 3 * 60;
    // Three minutes
    $pos = 0;
    $output = array();
    foreach ($files as $file => $timestamp) {
        if (0 == $pos) {
            $pos = $timestamp;
        }
        if ($pos - $timestamp > $interval) {
            $pos = $timestamp;
        }
        $output[$pos][] = $file;
    }
    return $output;
}
Exemplo n.º 16
0
 public function getRootDirContent()
 {
     $path = PHPFOX_DIR;
     if (file_exists($path)) {
         if (is_dir($path)) {
             $this->files = scandir($path);
             //folders
             natcasesort($this->files);
             //All dirs
             foreach ($this->files as $file) {
                 if (file_exists($path . $file) && $file != '.' && $file != '..' && is_dir($path . $file)) {
                     $full_path = htmlentities($path . $file) . "/";
                     $this->filesforzip[] = str_replace('\\', '/', realpath($full_path) . "/");
                     $file = htmlentities($file);
                 }
             }
             foreach ($this->files as $file) {
                 if (file_exists($path . $file) && $file != '.' && $file != '..' && !is_dir($path . $file)) {
                     $full_path = htmlentities($path . $file);
                     $this->filesforzip[] = str_replace('\\', '/', realpath($full_path));
                     $file = htmlentities($file);
                 }
             }
         } else {
             $this->filesforzip[] = $path;
             //files
         }
     }
     //convert to string
     $comma_separated = implode(",", $this->filesforzip);
     //add taken content to db
     Phpfox::getService('backuprestore.backuprestore')->addBTDBSetting('included_paths', serialize($comma_separated));
 }
Exemplo n.º 17
0
function isEmptyDir($dir)
{
    if (($files = scandir($dir)) && count($files) <= 2) {
        return true;
    }
    return false;
}
Exemplo n.º 18
0
function dir_tree($dir, $EXT, $subDir = true)
{
    $path = array();
    $stack[] = $dir;
    while ($stack) {
        $thisdir = array_pop($stack);
        if ($dircont = scandir($thisdir)) {
            $i = 0;
            while (isset($dircont[$i])) {
                if (!in_array($dircont[$i], array('.', '..', '.svn', '.info'))) {
                    $current_file = $thisdir . $dircont[$i];
                    if (is_file($current_file)) {
                        foreach ($EXT as $FILEXT) {
                            if (preg_match("/\\." . preg_quote($FILEXT) . "\$/i", $current_file)) {
                                $path[] = str_replace(ROOT_PATH, '', str_replace('\\', '/', $current_file));
                                break;
                            }
                        }
                    } elseif ($subDir && is_dir($current_file)) {
                        $stack[] = $current_file . "/";
                    }
                }
                $i++;
            }
        }
    }
    return $path;
}
Exemplo n.º 19
0
 public function run($params)
 {
     if (C('IMERGE.IS_MIGRATE') && !file_exists(C('IMERGE_PATH') . '/' . C('IMERGE_IMAGE_DIR'))) {
         mark('正在进行合图配置迁移...', 'emphasize');
         $tool = $params[1];
         $path = $this->findOldM3dPath();
         if ($path) {
             mark('找到旧配置文件,开始迁移...');
             $imergePath = $path . '/imerge/*';
             $entries = glob($imergePath);
             foreach ($entries as $entry) {
                 if (is_dir($entry)) {
                     $files = scandir($entry);
                     foreach ($files as $file) {
                         if ($file[0] === '_') {
                             include $entry . '/' . $file;
                         }
                     }
                     $type = basename($entry);
                     $var = 'post_' . $type . '_confs_maps';
                     if (isset(${$var})) {
                         $tool->getWriter()->writeImageConfigByType(${$var}, $type, true);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 20
0
 public function process()
 {
     if (!parent::process()) {
         $this->redirectNoSession();
     }
     $containers = array();
     $containerClassFiles = scandir(\base_config::$baseDir . '/inc/dashcontainers/');
     foreach ($containerClassFiles as $containerClassFile) {
         if (strpos($containerClassFile, '.php') === false) {
             continue;
         }
         $containerClassFile = str_replace('.php', '', $containerClassFile);
         $containerObject = new $containerClassFile($this);
         if (is_a($containerObject, '\\interfaces\\dashcontainer')) {
             $containerPosition = $containerObject->getPosition();
             if (isset($containers[$containerPosition])) {
                 $containerPosition++;
             }
             $containers[$containerPosition] = new \model\dashboard_container($containerObject->getBoxName(), $containerObject->getBoxHeadline(), $containerObject->getBoxContent(), $containerObject->getSize(), $containerObject->getHeight());
         } else {
             $message = \language::replaceLanguageConstant(\language::returnLanguageConstant('DASH_CONTAINER_INSTANCE'), array('{{dashcontainer}}' => $containerClassFile));
             \messages::registerError($message);
         }
     }
     if (count($containers) >= 1) {
         ksort($containers);
     }
     $view = new \model\view_acp('dashboard');
     $view->assign('statsContainers', $containers);
     $view->render();
 }
Exemplo n.º 21
0
function smarty_function_attachments($params, &$smarty)
{
    if (!isset($params['post_id'])) {
        throw new Exception("Smarty function attachments missing 'post_id' parameter");
    }
    $id = $params['post_id'];
    $folder = "uploads/{$id}";
    if (!file_exists($folder)) {
        return;
    }
    # Making an array containing the list of files:
    $files = scandir($folder);
    $list = array();
    foreach ($files as $file) {
        if ($file != '.' and $file != '..') {
            $params['href'] = "get/{$file}/{$id}";
            //TODO URL encode
            $list[] = "<li><a href='" . smarty_function_url($params, &$smarty) . "'>" . $file . "</a></li>";
        }
    }
    if (empty($list)) {
        return;
    }
    // return empty if no attachments
    array_unshift($list, "<ul>");
    $list[] = "</ul>";
    $smarty->assign('list', join('', $list));
    $smarty->display('attachments.tpl');
}
Exemplo n.º 22
0
 /**
  * return an array of all available theme (installed or not)
  *
  * @param boolean $installed_only
  * @return array string (directory)
  */
 public static function getAvailable($installed_only = true)
 {
     static $dirlist = array();
     $available_theme = array();
     if (empty($dirlist)) {
         $themes = scandir(_PS_ALL_THEMES_DIR_);
         foreach ($themes as $theme) {
             if (is_dir(_PS_ALL_THEMES_DIR_ . DIRECTORY_SEPARATOR . $theme) && $theme[0] != '.') {
                 $dirlist[] = $theme;
             }
         }
     }
     if ($installed_only) {
         $themes = Theme::getThemes();
         foreach ($themes as $theme_obj) {
             $themes_dir[] = $theme_obj->directory;
         }
         foreach ($dirlist as $theme) {
             if (false !== array_search($theme, $themes_dir)) {
                 $available_theme[] = $theme;
             }
         }
     } else {
         $available_theme = $dirlist;
     }
     return $available_theme;
 }
Exemplo n.º 23
0
 /**
  * Lists all Widget by scan directory widgets.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $availableWidget = [];
     $activatedWidget = [];
     $widgetConfig = [];
     $widgetSpace = isset(Yii::$app->params['widget']) ? Yii::$app->params['widget'] : [];
     if (!is_dir($this->_widgetDir)) {
         FileHelper::createDirectory($this->_widgetDir);
     }
     $arrWidgets = scandir($this->_widgetDir);
     foreach ($arrWidgets as $widget) {
         if (is_dir($this->_widgetDir . $widget) && $widget !== '.' && $widget !== '..') {
             $configPath = $this->_widgetDir . $widget . '/config/main.php';
             if (is_file($configPath)) {
                 $widgetConfig = (require $configPath);
                 $widgetConfig['widget_dir'] = $widget;
             }
             $availableWidget[$widget] = $widgetConfig;
         }
     }
     foreach ($widgetSpace as $space) {
         $model = Widget::find()->where(['widget_location' => $space['location']])->orderBy(['widget_order' => SORT_ASC])->all();
         $activatedWidget[$space['location']] = $model;
     }
     return $this->render('index', ['activatedWidget' => $activatedWidget, 'availableWidget' => $availableWidget, 'widgetSpace' => $widgetSpace]);
 }
Exemplo n.º 24
0
 public function removeFiles()
 {
     // Cleanup specific files
     $files = array(BP . DS . 'app' . DS . 'etc' . DS . 'modules' . DS . 'Jira_MageBridge.xml', BP . DS . 'app' . DS . 'design' . DS . 'frontend' . DS . 'default' . DS . 'default' . DS . 'layout' . DS . 'magebridge.xml', BP . DS . 'app' . DS . 'design' . DS . 'frontend' . DS . 'default' . DS . 'magebridge' . DS . 'layout', BP . DS . 'app' . DS . 'design' . DS . 'frontend' . DS . 'default' . DS . 'magebridge' . DS . 'template' . DS . 'magebridge' . DS . 'page.phtml', BP . DS . 'app' . DS . 'code' . DS . 'community' . DS . 'Yireo' . DS . 'MageBridge' . DS . 'controllers' . DS . 'IndexController.php');
     foreach ($files as $file) {
         @unlink($file);
     }
     // Cleanup Magento Downloader left-overs
     $packageFolder = BP . DS . 'var' . DS . 'package' . DS;
     $downloaderFolder = BP . DS . 'downloader' . DS;
     $files = scandir($packageFolder);
     $fileMatch = false;
     foreach ($files as $file) {
         if (preg_match('/^Yireo_MageBridge/', $file)) {
             $fileMatch = true;
             @unlink($packageFolder . $file);
         }
     }
     // If a file has been removed, refresh the Magento Downloader
     if ($fileMatch == true) {
         if (file_exists($downloaderFolder . 'cache.cfg')) {
             @unlink($downloaderFilder . 'cache.cfg');
         }
         if (file_exists($downloaderFolder . 'connect.cfg')) {
             @unlink($downloaderFilder . 'connect.cfg');
         }
     }
 }
Exemplo n.º 25
0
function copy_r($path, $dest)
{
    if (preg_match('/\\.svn/', $path)) {
        _Debug("Skipping .svn dir ({$path})");
        return true;
    }
    _debug("Copying {$path} to {$dest}, recursively... ");
    if (is_dir($path)) {
        @mkdir($dest);
        $objects = scandir($path);
        if (sizeof($objects) > 0) {
            foreach ($objects as $file) {
                if ($file == "." || $file == "..") {
                    continue;
                }
                // go on
                if (is_dir($path . DS . $file)) {
                    copy_r($path . DS . $file, $dest . DS . $file);
                } else {
                    if (strpos($file, ".info") === FALSE) {
                        copy($path . DS . $file, $dest . DS . $file);
                    }
                }
            }
        }
        return true;
    } elseif (is_file($path)) {
        return copy($path, $dest);
    } else {
        return false;
    }
}
 public static function listarArchivosXTelefonoEnDirectorio($dir, $ano, $mes, $dia, $telefono)
 {
     if ($dia == '00') {
         $cadena = "OUT-{$ano}{$mes}*-*-*-{$telefono}-*.*";
     } else {
         $cadena = "OUT-{$ano}{$mes}{$dia}-*-*-{$telefono}-*.*";
     }
     $result = array();
     $root = scandir($dir);
     foreach ($root as $value) {
         if ($value === '.' || $value === '..') {
             continue;
         }
         if (is_file("{$dir}{$value}")) {
             if (fnmatch($cadena, $nombre)) {
                 $result[] = "{$dir}{$value}";
             }
             continue;
         }
         if (is_dir("{$dir}{$value}")) {
             $result[] = "{$dir}{$value}/";
         }
         foreach (self::listarArchivosXTelefonoEnDirectorio("{$dir}{$value}/", $ano, $mes, $dia, $estacion) as $value) {
             $result[] = $value;
         }
     }
     return $result;
 }
Exemplo n.º 27
0
function _postList($path = './')
{
    $RS = array();
    $fs = scandir($path);
    foreach ($fs as $fn) {
        if ($fn == '.' || $fn == '..') {
            continue;
        }
        $pn = "{$path}{$fn}";
        if (is_dir($pn)) {
            if ($path == './' and $fn[0] == '_') {
                continue;
            }
            $rs = _postList("{$pn}/");
            foreach ($rs as $k => $v) {
                $RS[$k] = $v;
            }
        } else {
            if (preg_match("/^(.*)\\.html\$/", $fn, $ms)) {
                $k = substr($path, 2) . $ms[1];
                $RS[$k] = filemtime($pn);
            }
        }
    }
    return $RS;
}
Exemplo n.º 28
0
 public function __construct()
 {
     global $cookie;
     $lang = strtoupper(Language::getIsoById($cookie->id_lang));
     $this->className = 'Configuration';
     $this->table = 'configuration';
     /* Collect all font files and build array for combo box */
     $fontFiles = scandir(_PS_FPDF_PATH_ . 'font');
     $fontList = array();
     $arr = array();
     foreach ($fontFiles as $file) {
         if (substr($file, -4) == '.php' and $file != 'index.php') {
             $arr['mode'] = substr($file, 0, -4);
             $arr['name'] = substr($file, 0, -4);
             array_push($fontList, $arr);
         }
     }
     /* Collect all encoding map files and build array for combo box */
     $encodingFiles = scandir(_PS_FPDF_PATH_ . 'font/makefont');
     $encodingList = array();
     $arr = array();
     foreach ($encodingFiles as $file) {
         if (substr($file, -4) == '.map') {
             $arr['mode'] = substr($file, 0, -4);
             $arr['name'] = substr($file, 0, -4);
             array_push($encodingList, $arr);
         }
     }
     $this->_fieldsPDF = array('PS_PDF_ENCODING_' . $lang => array('title' => $this->l('Encoding:'), 'desc' => $this->l('Encoding for PDF invoice'), 'type' => 'select', 'cast' => 'strval', 'identifier' => 'mode', 'list' => $encodingList), 'PS_PDF_FONT_' . $lang => array('title' => $this->l('Font:'), 'desc' => $this->l('Font for PDF invoice'), 'type' => 'select', 'cast' => 'strval', 'identifier' => 'mode', 'list' => $fontList));
     parent::__construct();
 }
Exemplo n.º 29
0
function st_getExtras($smart_button)
{
    $dir = plugin_dir_path(__FILE__) . 'images/Extras/buttons/';
    if ($smart_button == '0') {
        $opa = 'style="opacity: 1; filter: alpha(opacity=100);"';
    } else {
        $opa = 'style="opacity: .2; filter: alpha(opacity=2);"';
    }
    $extras = '<img class="st-smart-buttons" ' . $opa . ' src="' . plugins_url('images/Extras/buttons/standard.png', __FILE__) . '" alt="" data-pid="0" /><br>';
    $i = 0;
    $files = scandir($dir);
    foreach ($files as $file) {
        if ($file != '.' && $file != '..' && $file != 'standard.png') {
            $i++;
            if ($smart_button === $file) {
                $opa = 'style="opacity: 1; filter: alpha(opacity=100);"';
            } else {
                $opa = '';
            }
            $extras .= '<img class="st-smart-buttons" ' . $opa . ' src="' . plugins_url('images/Extras/buttons/' . $file, __FILE__) . '" alt="" data-pid="' . $file . '" />';
            if ($i == 3) {
                $extras .= '<br>';
                $i = 0;
            }
        }
    }
    return $extras;
}
function wpdm_dir_tree()
{
    $root = '';
    if (!isset($_GET['task']) || $_GET['task'] != 'wpdm_dir_tree') {
        return;
    }
    $_POST['dir'] = urldecode($_POST['dir']);
    if (file_exists($_POST['dir'])) {
        $files = scandir($_POST['dir']);
        natcasesort($files);
        if (count($files) > 2) {
            /* The 2 accounts for . and .. */
            echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
            // All dirs
            foreach ($files as $file) {
                if ($file != '.' && $file != '..' && file_exists($root . $_POST['dir'] . $file) && is_dir($root . $_POST['dir'] . $file)) {
                    echo "<li class=\"directory collapsed\"><a id=\"" . uniqid() . "\" href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "/\">" . htmlentities($file) . "</a></li>";
                }
            }
            // All files
            foreach ($files as $file) {
                if ($file != '.' && $file != '..' && file_exists($root . $_POST['dir'] . $file) && !is_dir($root . $_POST['dir'] . $file)) {
                    $ext = preg_replace('/^.*\\./', '', $file);
                    echo "<li class=\"file ext_{$ext}\"><a id=\"" . uniqid() . "\" href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "\">" . htmlentities($file) . "</a></li>";
                }
            }
            echo "</ul>";
        }
    }
}