当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::isValidFilename方法代码示例

本文整理汇总了PHP中Piwik\Filesystem::isValidFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::isValidFilename方法的具体用法?PHP Filesystem::isValidFilename怎么用?PHP Filesystem::isValidFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\Filesystem的用法示例。


在下文中一共展示了Filesystem::isValidFilename方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPluginName

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return array
  * @throws \RunTimeException
  */
 protected function getPluginName(InputInterface $input, OutputInterface $output)
 {
     $self = $this;
     $validate = function ($pluginName) use($self) {
         if (empty($pluginName)) {
             throw new \RunTimeException('You have to enter a plugin name');
         }
         if (!Filesystem::isValidFilename($pluginName)) {
             throw new \RunTimeException(sprintf('The plugin name %s is not valid', $pluginName));
         }
         $pluginPath = $self->getPluginPath($pluginName);
         if (file_exists($pluginPath)) {
             throw new \RunTimeException('A plugin with this name already exists');
         }
         return $pluginName;
     };
     $pluginName = $input->getOption('name');
     if (empty($pluginName)) {
         $dialog = $this->getHelperSet()->get('dialog');
         $pluginName = $dialog->askAndValidate($output, 'Enter a plugin name: ', $validate);
     } else {
         $validate($pluginName);
     }
     $pluginName = ucfirst($pluginName);
     return $pluginName;
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:32,代码来源:GeneratePlugin.php

示例2: cleanupId

 protected function cleanupId($id)
 {
     if (!Filesystem::isValidFilename($id)) {
         throw new Exception("Invalid cache ID request {$id}");
     }
     return $id;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:7,代码来源:CacheFile.php

示例3: __construct

 public function __construct($outputId)
 {
     if (!Filesystem::isValidFilename($outputId)) {
         throw new \Exception('The given output id has an invalid format');
     }
     $dir = CliMulti::getTmpPath();
     Filesystem::mkdir($dir);
     $this->tmpFile = $dir . '/' . $outputId . '.output';
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:9,代码来源:Output.php

示例4: __construct

 public function __construct($pid)
 {
     if (!Filesystem::isValidFilename($pid)) {
         throw new \Exception('The given pid has an invalid format');
     }
     $pidDir = CliMulti::getTmpPath();
     Filesystem::mkdir($pidDir);
     $this->isSupported = self::isSupported();
     $this->pidFile = $pidDir . '/' . $pid . '.pid';
     $this->timeCreation = time();
     $this->markAsNotStarted();
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:12,代码来源:Process.php

示例5: loadCoreTranslationFile

 private static function loadCoreTranslationFile($language)
 {
     $path = PIWIK_INCLUDE_PATH . '/lang/' . $language . '.json';
     if (!Filesystem::isValidFilename($language) || !is_readable($path)) {
         throw new Exception(Piwik::translate('General_ExceptionLanguageFileNotFound', array($language)));
     }
     $data = file_get_contents($path);
     $translations = json_decode($data, true);
     self::mergeTranslationArray($translations);
     self::setLocale();
     self::$loadedLanguage = $language;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:12,代码来源:Translate.php

示例6: validateOwner

 function validateOwner()
 {
     $prefix = $this->owner->getValue();
     return empty($prefix) || Filesystem::isValidFilename($prefix);
 }
开发者ID:imreFitos,项目名称:piwik,代码行数:5,代码来源:FormDatabaseSetup.php

示例7: makePluginClass

 /**
  * @param $pluginName
  * @return Plugin
  * @throws \Exception
  */
 protected function makePluginClass($pluginName)
 {
     $pluginFileName = sprintf("%s/%s.php", $pluginName, $pluginName);
     $pluginClassName = $pluginName;
     if (!Filesystem::isValidFilename($pluginName)) {
         throw new \Exception(sprintf("The plugin filename '%s' is not a valid filename", $pluginFileName));
     }
     $path = self::getPluginsDirectory() . $pluginFileName;
     if (!file_exists($path)) {
         // Create the smallest minimal Piwik Plugin
         // Eg. Used for Morpheus default theme which does not have a Morpheus.php file
         return new Plugin($pluginName);
     }
     require_once $path;
     $namespacedClass = $this->getClassNamePlugin($pluginName);
     if (!class_exists($namespacedClass, false)) {
         throw new \Exception("The class {$pluginClassName} couldn't be found in the file '{$path}'");
     }
     $newPlugin = new $namespacedClass();
     if (!$newPlugin instanceof Plugin) {
         throw new \Exception("The plugin {$pluginClassName} in the file {$path} must inherit from Plugin.");
     }
     return $newPlugin;
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:29,代码来源:Manager.php

示例8: testIsValidFilenameNotValidValues

 public function testIsValidFilenameNotValidValues()
 {
     $notvalid = array("../test", "/etc/htpasswd", '$var', ';test', '[bizarre]', '', false, ".htaccess", "very long long eogaioge ageja geau ghaeihieg heiagie aiughaeui hfilename", "WHITE SPACE");
     foreach ($notvalid as $toTest) {
         $this->assertFalse(Filesystem::isValidFilename($toTest), $toTest . " valid but shouldn't!");
     }
 }
开发者ID:cemo,项目名称:piwik,代码行数:7,代码来源:CommonTest.php

示例9: forceUsageOfLocalHostnameConfig

 /**
  * If set, Piwik will use the hostname config no matter if it exists or not. Useful for instance if you want to
  * create a new hostname config:
  *
  *     $config = Config::getInstance();
  *     $config->forceUsageOfHostnameConfig('piwik.example.com');
  *     $config->save();
  *
  * @param string $hostname eg piwik.example.com
  *
  * @throws \Exception In case the domain contains not allowed characters
  */
 public function forceUsageOfLocalHostnameConfig($hostname)
 {
     $hostConfig = static::getLocalConfigInfoForHostname($hostname);
     if (!Filesystem::isValidFilename($hostConfig['file'])) {
         throw new Exception('Hostname is not valid');
     }
     $this->pathLocal = $hostConfig['path'];
     $this->configLocal = array();
     $this->initialized = false;
     return $this->pathLocal;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:23,代码来源:Config.php

示例10: isLanguageAvailable

 /**
  * Returns true if specified language is available
  *
  * @param string $languageCode
  * @return bool true if language available; false otherwise
  */
 public function isLanguageAvailable($languageCode)
 {
     return $languageCode !== false && Filesystem::isValidFilename($languageCode) && in_array($languageCode, $this->getAvailableLanguages());
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:10,代码来源:API.php

示例11: get


//.........这里部分代码省略.........
                         $absoluteLogoPath = self::getAbsoluteLogoPath($rowMetadata['logo']);
                         if (file_exists($absoluteLogoPath)) {
                             $abscissaLogos[$i] = $absoluteLogoPath;
                         }
                     }
                 }
                 $i++;
             }
         } else {
             // $periodsData instanceof Simple[]
             $periodsData = array_values($reportData->getDataTables());
             $periodsCount = count($periodsData);
             for ($i = 0; $i < $periodsCount; $i++) {
                 // $periodsData[$i] instanceof Simple
                 // $rows instanceof Row[]
                 if (empty($periodsData[$i])) {
                     continue;
                 }
                 $rows = $periodsData[$i]->getRows();
                 if (array_key_exists(0, $rows)) {
                     $rowData = $rows[0]->getColumns();
                     // associative Array
                     foreach ($ordinateColumns as $column) {
                         $ordinateValue = $rowData[$column];
                         $parsedOrdinateValue = $this->parseOrdinateValue($ordinateValue);
                         $hasData = true;
                         if (!empty($parsedOrdinateValue)) {
                             $hasNonZeroValue = true;
                         }
                         $ordinateSeries[$column][] = $parsedOrdinateValue;
                     }
                 } else {
                     foreach ($ordinateColumns as $column) {
                         $ordinateSeries[$column][] = 0;
                     }
                 }
                 $rowId = $periodsData[$i]->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getLocalizedShortString();
                 $abscissaSeries[] = Common::unsanitizeInputValue($rowId);
             }
         }
         if (!$hasData || !$hasNonZeroValue) {
             throw new Exception(Piwik::translate('General_NoDataForGraph'));
         }
         //Setup the graph
         $graph = StaticGraph::factory($graphType);
         $graph->setWidth($width);
         $graph->setHeight($height);
         $graph->setFont($font);
         $graph->setFontSize($fontSize);
         $graph->setLegendFontSize($legendFontSize);
         $graph->setOrdinateLabels($ordinateLabels);
         $graph->setShowLegend($showLegend);
         $graph->setAliasedGraph($aliasedGraph);
         $graph->setAbscissaSeries($abscissaSeries);
         $graph->setAbscissaLogos($abscissaLogos);
         $graph->setOrdinateSeries($ordinateSeries);
         $graph->setOrdinateLogos($ordinateLogos);
         $graph->setColors(!empty($colors) ? explode(',', $colors) : array());
         $graph->setTextColor($textColor);
         $graph->setBackgroundColor($backgroundColor);
         $graph->setGridColor($gridColor);
         // when requested period is day, x-axis unit is time and all date labels can not be displayed
         // within requested width, force labels to be skipped every 6 days to delimit weeks
         if ($period == 'day' && $isMultiplePeriod) {
             $graph->setForceSkippedLabels(6);
         }
         // render graph
         $graph->renderGraph();
     } catch (\Exception $e) {
         $graph = new \Piwik\Plugins\ImageGraph\StaticGraph\Exception();
         $graph->setWidth($width);
         $graph->setHeight($height);
         $graph->setFont($font);
         $graph->setFontSize($fontSize);
         $graph->setBackgroundColor($backgroundColor);
         $graph->setTextColor($textColor);
         $graph->setException($e);
         $graph->renderGraph();
     }
     // restoring get parameters
     $_GET = $savedGET;
     switch ($outputType) {
         case self::GRAPH_OUTPUT_FILE:
             if ($idGoal != '') {
                 $idGoal = '_' . $idGoal;
             }
             $fileName = self::$DEFAULT_PARAMETERS[$graphType][self::FILENAME_KEY] . '_' . $apiModule . '_' . $apiAction . $idGoal . ' ' . str_replace(',', '-', $date) . ' ' . $idSite . '.png';
             $fileName = str_replace(array(' ', '/'), '_', $fileName);
             if (!Filesystem::isValidFilename($fileName)) {
                 throw new Exception('Error: Image graph filename ' . $fileName . ' is not valid.');
             }
             return $graph->sendToDisk($fileName);
         case self::GRAPH_OUTPUT_PHP:
             return $graph->getRenderedImage();
         case self::GRAPH_OUTPUT_INLINE:
         default:
             $graph->sendToBrowser();
             exit;
     }
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:101,代码来源:API.php

示例12: forceUsageOfLocalHostnameConfig

 /**
  * If set, Piwik will use the hostname config no matter if it exists or not. Useful for instance if you want to
  * create a new hostname config:
  *
  *     $config = Config::getInstance();
  *     $config->forceUsageOfHostnameConfig('piwik.example.com');
  *     $config->save();
  *
  * @param string $hostname eg piwik.example.com
  * @return string
  * @throws \Exception In case the domain contains not allowed characters
  * @internal
  */
 public function forceUsageOfLocalHostnameConfig($hostname)
 {
     $hostConfig = self::getLocalConfigInfoForHostname($hostname);
     $filename = $hostConfig['file'];
     if (!Filesystem::isValidFilename($filename)) {
         throw new Exception('Piwik domain is not a valid looking hostname (' . $filename . ').');
     }
     $pathLocal = $hostConfig['path'];
     try {
         $this->reload($pathLocal);
     } catch (Exception $ex) {
         // pass (not required for local file to exist at this point)
     }
     return $pathLocal;
 }
开发者ID:piwik,项目名称:piwik,代码行数:28,代码来源:Config.php

示例13: forceUsageOfLocalHostnameConfig

 /**
  * If set, Piwik will use the hostname config no matter if it exists or not. Useful for instance if you want to
  * create a new hostname config:
  *
  *     $config = Config::getInstance();
  *     $config->forceUsageOfHostnameConfig('piwik.example.com');
  *     $config->save();
  *
  * @param string $hostname eg piwik.example.com
  * @return string
  * @throws \Exception In case the domain contains not allowed characters
  */
 public function forceUsageOfLocalHostnameConfig($hostname)
 {
     $hostConfig = self::getLocalConfigInfoForHostname($hostname);
     $filename = $hostConfig['file'];
     if (!Filesystem::isValidFilename($filename)) {
         throw new Exception('Piwik domain is not a valid looking hostname (' . $filename . ').');
     }
     $this->pathLocal = $hostConfig['path'];
     $this->configLocal = array();
     $this->initialized = false;
     return $this->pathLocal;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:24,代码来源:Config.php


注:本文中的Piwik\Filesystem::isValidFilename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。