PHP is_file Examples

PHP is_file - 30 examples found. These are the top rated real world PHP examples of is_file extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
1
function qqwb_env()
{
    $msgs = array();
    $files = array(ROOT_PATH . 'include/ext/qqwb/qqoauth.php', ROOT_PATH . 'include/ext/qqwb/oauth.php', ROOT_PATH . 'modules/qqwb.mod.php');
    foreach ($files as $f) {
        if (!is_file($f)) {
            $msgs[] = "文件<b>{$f}</b>不存在";
        }
    }
    $funcs = array('version_compare', array('fsockopen', 'pfsockopen'), 'preg_replace', array('iconv', 'mb_convert_encoding'), array("hash_hmac", "mhash"));
    foreach ($funcs as $func) {
        if (!is_array($func)) {
            if (!function_exists($func)) {
                $msgs[] = "函数<b>{$func}</b>不可用";
            }
        } else {
            $t = false;
            foreach ($func as $f) {
                if (function_exists($f)) {
                    $t = true;
                    break;
                }
            }
            if (!$t) {
                $msgs[] = "函数<b>" . implode(" , ", $func) . "</b>都不可用";
            }
        }
    }
    return $msgs;
}
Example #2
0
 /**
  * Returns a reference to a Format object, only creating it
  * if it doesn't already exist.
  *
  * @param   string  $type  The format to load
  *
  * @return  object  Registry format handler
  *
  * @since   11.1
  * @throws  JException
  */
 public static function getInstance($type)
 {
     // Initialize static variable.
     static $instances;
     if (!isset($instances)) {
         $instances = array();
     }
     // Sanitize format type.
     $type = strtolower(preg_replace('/[^A-Z0-9_]/i', '', $type));
     // Only instantiate the object if it doesn't already exist.
     if (!isset($instances[$type])) {
         // Only load the file the class does not exist.
         $class = 'JRegistryFormat' . $type;
         if (!class_exists($class)) {
             $path = dirname(__FILE__) . '/format/' . $type . '.php';
             if (is_file($path)) {
                 require_once $path;
             } else {
                 throw new JException(JText::_('JLIB_REGISTRY_EXCEPTION_LOAD_FORMAT_CLASS'), 500, E_ERROR);
             }
         }
         $instances[$type] = new $class();
     }
     return $instances[$type];
 }
 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);
     }
 }
Example #4
0
function entry(&$argv)
{
    if (is_file($argv[0])) {
        if (0 === substr_compare($argv[0], '.class.php', -10)) {
            $uri = realpath($argv[0]);
            if (null === ($cl = \lang\ClassLoader::getDefault()->findUri($uri))) {
                throw new \Exception('Cannot load ' . $uri . ' - not in class path');
            }
            return $cl->loadUri($uri)->literal();
        } else {
            if (0 === substr_compare($argv[0], '.xar', -4)) {
                $cl = \lang\ClassLoader::registerPath($argv[0]);
                if (!$cl->providesResource('META-INF/manifest.ini')) {
                    throw new \Exception($cl->toString() . ' does not provide a manifest');
                }
                $manifest = parse_ini_string($cl->getResource('META-INF/manifest.ini'));
                return strtr($manifest['main-class'], '.', '\\');
            } else {
                array_unshift($argv, 'eval');
                return 'xp\\runtime\\Evaluate';
            }
        }
    } else {
        return strtr($argv[0], '.', '\\');
    }
}
Example #5
0
 protected function bootstrap()
 {
     if (is_file('package.json')) {
         $this->comment(' -> Installing npm dependencies (with yarn)...');
         $this->executeCommand($this->input->getOption('sudo') ? 'sudo yarn' : 'yarn');
     }
     if (is_file('bower.json')) {
         $this->comment(' -> Installing bower dependencies...');
         $this->executeCommand('bower install');
     }
     if (is_file('composer.json')) {
         $this->comment(' -> Installing composer dependencies...');
         $this->executeCommand('composer install');
     }
     if (is_dir('storage')) {
         $this->comment(' -> Dando permissão de escrita no diretório storage...');
         $this->executeCommand('chmod -R 777 storage');
     }
     if (is_dir('app/storage')) {
         $this->comment(' -> Dando permissão de escrita no diretório storage...');
         $this->executeCommand('chmod -R 777 app/storage');
     }
     if (is_file('.env.example')) {
         $this->comment(' -> Criando o arquivo .env');
         $this->executeCommand('cp .env.example .env');
     }
 }
Example #6
0
 /**
  * 加载语言定义(不区分大小写)
  * @param string $file 语言文件
  * @param string $range 作用域
  * @return mixed
  */
 public static function load($file, $range = '')
 {
     $range = $range ? $range : self::$range;
     $lang = is_file($file) ? include $file : [];
     // 批量定义
     return self::$lang[$range] = array_merge(self::$lang[$range], array_change_key_case($lang));
 }
Example #7
0
function cimy_um_download_database()
{
    global $cum_upload_path;
    if (!empty($_POST["cimy_um_filename"])) {
        if (strpos($_SERVER['HTTP_REFERER'], admin_url('users.php?page=cimy_user_manager')) !== false) {
            // not whom we are expecting? exit!
            if (!check_admin_referer('cimy_um_download', 'cimy_um_downloadnonce')) {
                return;
            }
            $cimy_um_filename = $_POST["cimy_um_filename"];
            // sanitize the file name
            $cimy_um_filename = sanitize_file_name($cimy_um_filename);
            $cimy_um_fullpath_file = $cum_upload_path . $cimy_um_filename;
            // does not exist? exit!
            if (!is_file($cimy_um_fullpath_file)) {
                return;
            }
            header("Pragma: ");
            // Leave blank for issues with IE
            header("Expires: 0");
            header('Vary: User-Agent');
            header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
            header("Content-Type: text/csv");
            header("Content-Type: application/force-download");
            header("Content-Type: application/download");
            header("Content-Disposition: attachment; filename=\"" . esc_html($cimy_um_filename) . "\";");
            // cannot use esc_url any more because prepends 'http' (doh)
            header("Content-Transfer-Encoding: binary");
            header("Content-Length: " . filesize($cimy_um_fullpath_file));
            readfile($cimy_um_fullpath_file);
            exit;
        }
    }
}
Example #8
0
 /**
  * Writes a default configuration file to $path if there is none
  * @param string $path
  * @param string $type
  */
 public static function ensureConfigFile($path, $type)
 {
     if (!is_file($path)) {
         $content = self::getExampleConfiguration($type);
         file_put_contents($path, $content);
     }
 }
Example #9
0
 /**
  * Parses YAML into a PHP array.
  *
  * The parse method, when supplied with a YAML stream (string or file),
  * will do its best to convert YAML in a file into a PHP array.
  *
  *  Usage:
  *  <code>
  *   $array = Yaml::parse('config.yml');
  *   print_r($array);
  *  </code>
  *
  * @param string $input Path to a YAML file or a string containing YAML
  *
  * @return array The YAML converted to a PHP array
  *
  * @throws \InvalidArgumentException If the YAML is not valid
  *
  * @api
  */
 public static function parse($input)
 {
     // if input is a file, process it
     $file = '';
     if (strpos($input, "\n") === false && is_file($input)) {
         if (false === is_readable($input)) {
             throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input));
         }
         $file = $input;
         if (self::$enablePhpParsing) {
             ob_start();
             $retval = (include $file);
             $content = ob_get_clean();
             // if an array is returned by the config file assume it's in plain php form else in YAML
             $input = is_array($retval) ? $retval : $content;
             // if an array is returned by the config file assume it's in plain php form else in YAML
             if (is_array($input)) {
                 return $input;
             }
         } else {
             $input = file_get_contents($file);
         }
     }
     $yaml = new Parser();
     try {
         return $yaml->parse($input);
     } catch (ParseException $e) {
         if ($file) {
             $e->setParsedFile($file);
         }
         throw $e;
     }
 }
Example #10
0
/**
 * Function used to auto load the framework classes
 * 
 * It imlements PSR-0 and PSR-4 autoloading standards
 * The required class name should be prefixed with a namespace
 * This lowercaser of the namespace should match the folder name of the class 
 * 
 * @since 1.0.0
 * @param string $class_name name of the class that needs to be included
 */
function autoload_framework_classes($class_name)
{
    error_reporting(E_ALL);
    ini_set('display_errors', true);
    ini_set('display_startup_errors', true);
    /** If the required class is in the global namespace then no need to autoload the class */
    if (strpos($class_name, "\\") === false) {
        return false;
    }
    /** The namespace seperator is replaced with directory seperator */
    $class_name = str_replace("\\", DIRECTORY_SEPARATOR, $class_name);
    /** The class name is split into namespace and short class name */
    $path_info = explode(DIRECTORY_SEPARATOR, $class_name);
    /** The namepsace is extracted */
    $namespace = implode(DIRECTORY_SEPARATOR, array_slice($path_info, 0, count($path_info) - 1));
    /** The class name is extracted */
    $class_name = $path_info[count($path_info) - 1];
    /** The namespace is converted to lower case */
    $namespace_folder = trim(strtolower($namespace), DIRECTORY_SEPARATOR);
    /** .php is added to class name */
    $class_name = $class_name . ".php";
    /** The applications folder name */
    $framework_folder_path = realpath(dirname(__FILE__));
    /** The application folder is checked for file name */
    $file_name = $framework_folder_path . DIRECTORY_SEPARATOR . $namespace_folder . DIRECTORY_SEPARATOR . $class_name;
    if (is_file($file_name)) {
        include_once $file_name;
    }
}
Example #11
0
function template($filename, $flag = TEMPLATE_DISPLAY)
{
    global $_W;
    $source = IA_ROOT . "/web/themes/{$_W['template']}/{$filename}.html";
    $compile = IA_ROOT . "/data/tpl/web/{$_W['template']}/{$filename}.tpl.php";
    if (!is_file($source)) {
        $source = IA_ROOT . "/web/themes/default/{$filename}.html";
        $compile = IA_ROOT . "/data/tpl/web/default/{$filename}.tpl.php";
    }
    if (!is_file($source)) {
        exit("Error: template source '{$filename}' is not exist!");
    }
    if (DEVELOPMENT || !is_file($compile) || filemtime($source) > filemtime($compile)) {
        template_compile($source, $compile);
    }
    switch ($flag) {
        case TEMPLATE_DISPLAY:
        default:
            extract($GLOBALS, EXTR_SKIP);
            include $compile;
            break;
        case TEMPLATE_FETCH:
            extract($GLOBALS, EXTR_SKIP);
            ob_clean();
            ob_start();
            include $compile;
            $contents = ob_get_contents();
            ob_clean();
            return $contents;
            break;
        case TEMPLATE_INCLUDEPATH:
            return $compile;
            break;
    }
}
Example #12
0
 /** Constructor
  *
  * @param str name
  * @param RootDoc root
  */
 function packageDoc($name, &$root)
 {
     $this->_name = $name;
     $this->_root =& $root;
     $phpdoctor =& $root->phpdoctor();
     // parse overview file
     $packageCommentDir = $phpdoctor->getOption('packageCommentDir');
     $packageCommentFilename = strtolower(str_replace('/', '.', $this->_name)) . '.html';
     if (isset($packageCommentDir) && is_file($packageCommentDir . $packageCommentFilename)) {
         $overviewFile = $packageCommentDir . $packageCommentFilename;
     } else {
         $pos = strrpos(str_replace('\\', '/', $phpdoctor->_currentFilename), '/');
         if ($pos !== FALSE) {
             $overviewFile = substr($phpdoctor->_currentFilename, 0, $pos) . '/package.html';
         } else {
             $overviewFile = $phpdoctor->sourcePath() . $this->_name . '.html';
         }
     }
     if (is_file($overviewFile)) {
         $phpdoctor->message("\n" . 'Reading package overview file "' . $overviewFile . '".');
         if ($html = $this->getHTMLContents($overviewFile)) {
             $this->_data = $phpdoctor->processDocComment('/** ' . $html . ' */', $this->_root);
             $this->mergeData();
         }
     }
 }
 /**
 +----------------------------------------------------------
 * 检查缓存文件是否有效
 * 如果无效则需要重新编译
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $tmplTemplateFile  模板文件名
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 protected function checkCache($tmplTemplateFile)
 {
     if (!C('TMPL_CACHE_ON')) {
         // 优先对配置设定检测
         return false;
     }
     $tmplCacheFile = C('CACHE_PATH') . md5($tmplTemplateFile) . C('TMPL_CACHFILE_SUFFIX');
     if (!is_file($tmplCacheFile)) {
         return false;
     } elseif (filemtime($tmplTemplateFile) > filemtime($tmplCacheFile)) {
         // 模板文件如果有更新则缓存需要更新
         return false;
     } elseif (C('TMPL_CACHE_TIME') != 0 && time() > filemtime($tmplCacheFile) + C('TMPL_CACHE_TIME')) {
         // 缓存是否在有效期
         return false;
     }
     // 开启布局模板
     if (C('LAYOUT_ON')) {
         $layoutFile = THEME_PATH . C('LAYOUT_NAME') . C('TMPL_TEMPLATE_SUFFIX');
         if (filemtime($layoutFile) > filemtime($tmplCacheFile)) {
             return false;
         }
     }
     // 缓存有效
     return true;
 }
Example #14
0
 public function __set($strName, $mixValue)
 {
     switch ($strName) {
         case "HtmlIncludeFilePath":
             // Passed-in value is null -- use the "default" path name of file".tpl.php"
             if (!$mixValue) {
                 $strPath = realpath(substr(QApplication::$ScriptFilename, 0, strrpos(QApplication::$ScriptFilename, '.php')) . '.tpl.php');
             } else {
                 $strPath = realpath($mixValue);
             }
             // Verify File Exists, and if not, throw exception
             if (is_file($strPath)) {
                 $this->strHtmlIncludeFilePath = $strPath;
                 return $strPath;
             } else {
                 throw new QCallerException('Accompanying HTML Include File does not exist: "' . $mixValue . '"');
             }
             break;
         case "CssClass":
             try {
                 return $this->strCssClass = QType::Cast($mixValue, QType::String);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         default:
             try {
                 return parent::__set($strName, $mixValue);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
 public function find()
 {
     if (defined('HHVM_VERSION') && false !== ($hhvm = getenv('PHP_BINARY'))) {
         return $hhvm;
     }
     if (defined('PHP_BINARY') && PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server')) && is_file(PHP_BINARY)) {
         return PHP_BINARY;
     }
     if ($php = getenv('PHP_PATH')) {
         if (!is_executable($php)) {
             return false;
         }
         return $php;
     }
     if ($php = getenv('PHP_PEAR_PHP_BIN')) {
         if (is_executable($php)) {
             return $php;
         }
     }
     $dirs = array(PHP_BINDIR);
     if (defined('PHP_WINDOWS_VERSION_BUILD')) {
         $dirs[] = 'C:\\xampp\\php\\';
     }
     return $this->executableFinder->find('php', false, $dirs);
 }
Example #16
0
 public function logQuery(Nette\Database\Connection $connection, $result)
 {
     if ($this->disabled) {
         return;
     }
     $this->count++;
     $source = NULL;
     $trace = $result instanceof \PDOException ? $result->getTrace() : debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
     foreach ($trace as $row) {
         if (isset($row['file']) && is_file($row['file']) && !Tracy\Debugger::getBluescreen()->isCollapsed($row['file'])) {
             if (isset($row['function']) && strpos($row['function'], 'call_user_func') === 0 || isset($row['class']) && is_subclass_of($row['class'], '\\Nette\\Database\\Connection')) {
                 continue;
             }
             $source = [$row['file'], (int) $row['line']];
             break;
         }
     }
     if ($result instanceof Nette\Database\ResultSet) {
         $this->totalTime += $result->getTime();
         if ($this->count < $this->maxQueries) {
             $this->queries[] = [$connection, $result->getQueryString(), $result->getParameters(), $source, $result->getTime(), $result->getRowCount(), NULL];
         }
     } elseif ($result instanceof \PDOException && $this->count < $this->maxQueries) {
         $this->queries[] = [$connection, $result->queryString, NULL, $source, NULL, NULL, $result->getMessage()];
     }
 }
Example #17
0
File: lib.php Project: LeonB/site
function findFilesHelper($additional, &$files, $term = '', $extensions = array())
{
    $basefolder = __DIR__ . '/../../files/';
    $currentfolder = realpath($basefolder . '/' . $additional);
    $dir = dir($currentfolder);
    $ignored = array('.', '..', '.DS_Store', '.gitignore', '.htaccess');
    while (false !== ($entry = $dir->read())) {
        if (in_array($entry, $ignored) || substr($entry, 0, 2) == '._') {
            continue;
        }
        if (is_file($currentfolder . '/' . $entry) && is_readable($currentfolder . '/' . $entry)) {
            // Check for 'term'..
            if (!empty($term) && strpos(strtolower($currentfolder . '/' . $entry), $term) === false) {
                continue;
                // skip this one..
            }
            // Check for correct extensions..
            if (!empty($extensions) && !in_array(getExtension($entry), $extensions)) {
                continue;
                // Skip files without correct extension..
            }
            if (!empty($additional)) {
                $filename = $additional . '/' . $entry;
            } else {
                $filename = $entry;
            }
            $files[] = $filename;
        }
        if (is_dir($currentfolder . '/' . $entry)) {
            findFilesHelper($additional . '/' . $entry, $files, $term, $extensions);
        }
    }
    $dir->close();
}
 /**
  * Конструктор
  * @param  $filename Имя файла лога
  */
 public function __construct($filename)
 {
     $this->filename = $filename;
     if (!is_file($filename)) {
         $this->CreateLogFile();
     }
 }
Example #19
0
/**
 * Advanced pagination. Differenced between simple and advanced paginations is that 
 * advanced pagination uses template so its output can be changed in a great number of ways.
 * 
 * All variables are just passed to the template, nothing is done inside the function!
 *
 * @access public
 * @param DataPagination $pagination Pagination object
 * @param string $url_base Base URL in witch we will insert current page number
 * @param string $template Template that will be used. It can be absolute path to existing file
 *   or template name that used with get_template_path will return real template path
 * @param string $page_placeholder Short string inside of $url_base that will be replaced with
 *   current page numer
 * @return null
 */
function advanced_pagination(DataPagination $pagination, $url_base, $template = 'advanced_pagination', $page_placeholder = '#PAGE#')
{
    tpl_assign(array('advanced_pagination_object' => $pagination, 'advanced_pagination_url_base' => $url_base, 'advanced_pagination_page_placeholder' => urlencode($page_placeholder)));
    // tpl_assign
    $template_path = is_file($template) ? $template : get_template_path($template);
    return tpl_fetch($template_path);
}
/**
 * Smarty debug_console function plugin
 *
 * Type:     core<br>
 * Name:     display_debug_console<br>
 * Purpose:  display the javascript debug console window
 * @param array Format: null
 * @param Smarty
 */
function smarty_core_display_debug_console($params, &$smarty)
{
    // we must force compile the debug template in case the environment
    // changed between separate applications.
    if (empty($smarty->debug_tpl)) {
        // set path to debug template from SMARTY_DIR
        $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl';
        if ($smarty->security && is_file($smarty->debug_tpl)) {
            $smarty->secure_dir[] = realpath($smarty->debug_tpl);
        }
        $smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl';
    }
    $_ldelim_orig = $smarty->left_delimiter;
    $_rdelim_orig = $smarty->right_delimiter;
    $smarty->left_delimiter = '{';
    $smarty->right_delimiter = '}';
    $_compile_id_orig = $smarty->_compile_id;
    $smarty->_compile_id = null;
    $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl);
    if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path)) {
        ob_start();
        $smarty->_include($_compile_path);
        $_results = ob_get_contents();
        ob_end_clean();
    } else {
        $_results = '';
    }
    $smarty->_compile_id = $_compile_id_orig;
    $smarty->left_delimiter = $_ldelim_orig;
    $smarty->right_delimiter = $_rdelim_orig;
    return $_results;
}
Example #21
0
 protected function rmFile($file)
 {
     if (is_file($file)) {
         chmod(dirname($file), 0777);
         unlink($file);
     }
 }
Example #22
0
 /**
  * 首页
  */
 public function index()
 {
     $file = FCPATH . 'cache/index/home-' . ($this->template->mobile ? 'mb-' : '') . SITE_ID . '.html';
     // 系统开启静态首页、静态文件不存在时,才生成文件
     //zjp添加,动态显示日期天气温度
     if ($_SESSION["de_json"] == '') {
         $city = "宜春";
         $content = file_get_contents("http://api.map.baidu.com/telematics/v3/weather?location=宜春&output=json&ak=i8GFDZTM22uqICZbtioaVbnk");
         $de_json = json_decode($content, TRUE);
         $_SESSION["de_json"] = $de_json;
     }
     /*zjp 0819 添加调取最新的调查问卷start*/
     //echo APP_DIR;
     //echo 1;
     //$this->load->model('category_model');
     //$question_id = $this->category_model->get_question_id();
     /*zjp 0819 添加调取最新的调查问卷end  */
     if (SITE_HOME_INDEX && !is_file($file)) {
         ob_start();
         $this->template->assign(array('indexc' => 1, 'meta_title' => SITE_TITLE, 'meta_keywords' => SITE_KEYWORDS, 'meta_description' => SITE_DESCRIPTION, 'de_json' => $_SESSION["de_json"]));
         $this->template->display('index.html');
         $html = ob_get_clean();
         @file_put_contents($file, $html, LOCK_EX);
         echo $html;
         exit;
     } else {
         $this->template->assign(array('indexc' => 1, 'meta_title' => SITE_TITLE, 'meta_keywords' => SITE_KEYWORDS, 'meta_description' => SITE_DESCRIPTION, 'de_json' => $de_json));
         $this->template->display('index.html');
     }
 }
Example #23
0
 protected function setUp()
 {
     $file = sys_get_temp_dir() . '/phinx.yml';
     if (is_file($file)) {
         unlink($file);
     }
 }
Example #24
0
 protected function getGraphsFromFiles(array $files, array $exclude, CFGParser $parser)
 {
     $excludeParts = [];
     foreach ($exclude as $part) {
         $excludeParts[] = preg_quote($part);
     }
     $part = implode('|', $excludeParts);
     $excludeRegex = "(((\\.({$part})(\$|/))|((^|/)({$part})(\$|/))))";
     $graphs = [];
     foreach ($files as $file) {
         if (is_file($file)) {
             $local = [$file];
         } elseif (is_dir($file)) {
             $it = new \CallbackFilterIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($file)), function ($file) use($excludeRegex) {
                 if (preg_match($excludeRegex, $file->getPathName())) {
                     return false;
                 }
                 return $file->isFile();
             });
             $local = [];
             foreach ($it as $file) {
                 $local[] = $file->getPathName();
                 // since __toString would be too difficult...
             }
         } else {
             throw new \RuntimeException("Error: {$file} is not a file or directory");
         }
         foreach ($local as $file) {
             echo "Analyzing {$file}\n";
             $graphs[$file] = $parser->parse(file_get_contents($file), $file);
         }
     }
     return $graphs;
 }
function batch_find_images()
{
    $log = elgg_get_config('mfp_log');
    $logtime = elgg_get_config('mfp_logtime');
    // only search
    $options = array('type' => 'object', 'subtype' => 'image', 'limit' => 0);
    $images = new ElggBatch('elgg_get_entities', $options);
    $count = 0;
    $bad_images = 0;
    $total = elgg_get_entities(array_merge($options, array('count' => true)));
    file_put_contents($log, "Starting scan of {$total} images" . "\n", FILE_APPEND);
    foreach ($images as $image) {
        $count++;
        // don't use ->exists() because of #5207.
        if (!is_file($image->getFilenameOnFilestore())) {
            $bad_images++;
            $image->mfp_delete_check = $logtime;
        }
        if ($count == 1 || !($count % 25)) {
            $time = date('Y-m-d g:ia');
            $message = "Checked {$count} of {$total} images as of {$time}";
            file_put_contents($log, $message . "\n", FILE_APPEND);
        }
    }
    $message = '<div class="done"><a href="#" id="elgg-tidypics-broken-images-delete" data-time="' . $logtime . '">Delete ' . $bad_images . ' broken images</a></div>';
    file_put_contents($log, $message . "\n", FILE_APPEND);
}
Example #26
0
 private function setCert($cert)
 {
     if (!is_file($cert)) {
         return;
     }
     $this->mCert = $cert;
 }
Example #27
0
 /**
  * Constructor.
  *
  * @param FileLocatorInterface $locator  A FileLocatorInterface instance
  * @param string               $cacheDir The cache path
  */
 public function __construct(FileLocatorInterface $locator, $cacheDir = null)
 {
     if (null !== $cacheDir && is_file($cache = $cacheDir . '/templates.php')) {
         $this->cache = (require $cache);
     }
     $this->locator = $locator;
 }
Example #28
0
 /**
  * Returns if the file can be rendered.
  *
  * @return bool
  */
 public function canRender()
 {
     if (!is_dir($this->getTemplateDir() . $this->getTemplateFile())) {
         return false;
     }
     return is_file($this->getTemplateDir() . $this->getTemplateFile() . DIRECTORY_SEPARATOR . self::FILE_HTML) || is_file($this->getTemplateDir() . $this->getTemplateFile() . DIRECTORY_SEPARATOR . self::FILE_PHTML);
 }
Example #29
0
 function onls()
 {
     $logdir = UC_ROOT . 'data/logs/';
     $dir = opendir($logdir);
     $logs = $loglist = array();
     while ($entry = readdir($dir)) {
         if (is_file($logdir . $entry) && strpos($entry, '.php') !== FALSE) {
             $logs = array_merge($logs, file($logdir . $entry));
         }
     }
     closedir($dir);
     $logs = array_reverse($logs);
     foreach ($logs as $k => $v) {
         if (count($v = explode("\t", $v)) > 1) {
             $v[3] = $this->date($v[3]);
             $v[4] = $this->lang[$v[4]];
             $loglist[$k] = $v;
         }
     }
     $page = max(1, intval($_GET['page']));
     $start = ($page - 1) * UC_PPP;
     $num = count($loglist);
     $multipage = $this->page($num, UC_PPP, $page, 'admin.php?m=log&a=ls');
     $loglist = array_slice($loglist, $start, UC_PPP);
     $this->view->assign('loglist', $loglist);
     $this->view->assign('multipage', $multipage);
     $this->view->display('admin_log');
 }
 /**
  * Returns the initial HTML view for the admin interface.
  *
  * @param \Illuminate\Http\Request $request Laravel request object
  * @return \Illuminate\Contracts\View\View View for rendering the output
  */
 public function indexAction(Request $request)
 {
     if (config('shop.authorize', true)) {
         $this->authorize('admin');
     }
     $site = Route::input('site', 'default');
     $lang = Input::get('lang', config('app.locale', 'en'));
     $aimeos = app('\\Aimeos\\Shop\\Base\\Aimeos')->get();
     $cntlPaths = $aimeos->getCustomPaths('controller/extjs');
     $context = app('\\Aimeos\\Shop\\Base\\Context')->get(false);
     $context = $this->setLocale($context, $site, $lang);
     $controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths);
     $cssFiles = array();
     foreach ($aimeos->getCustomPaths('admin/extjs') as $base => $paths) {
         foreach ($paths as $path) {
             $jsbAbsPath = $base . '/' . $path;
             if (!is_file($jsbAbsPath)) {
                 throw new \Exception(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath));
             }
             $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($path));
             $cssFiles = array_merge($cssFiles, $jsb2->getUrls('css'));
         }
     }
     $jqadmUrl = route('aimeos_shop_jqadm_search', array('site' => $site, 'resource' => 'product'));
     $jsonUrl = route('aimeos_shop_extadm_json', array('site' => $site, '_token' => csrf_token()));
     $adminUrl = route('aimeos_shop_extadm', array('site' => '<site>', 'lang' => '<lang>', 'tab' => '<tab>'));
     $vars = array('lang' => $lang, 'cssFiles' => $cssFiles, 'languages' => $this->getJsonLanguages($context), 'config' => $this->getJsonClientConfig($context), 'site' => $this->getJsonSiteItem($context, $site), 'i18nContent' => $this->getJsonClientI18n($aimeos->getI18nPaths(), $lang), 'searchSchemas' => $controller->getJsonSearchSchemas(), 'itemSchemas' => $controller->getJsonItemSchemas(), 'smd' => $controller->getJsonSmd($jsonUrl), 'urlTemplate' => str_replace(['<', '>'], ['{', '}'], urldecode($adminUrl)), 'uploaddir' => config('shop::uploaddir'), 'activeTab' => Input::get('tab', 0), 'version' => $this->getVersion(), 'jqadmurl' => $jqadmUrl);
     return View::make('shop::admin.extadm-index', $vars);
 }