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


PHP Piwik_Common::isValidFilename方法代码示例

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


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

示例1: getTranslationPath

 /**
  * Get translation file path
  *
  * @param string $lang ISO 639-1 alpha-2 language code
  * @param string $base Optional base directory (either 'lang' or 'tmp')
  * @throws Exception
  * @return string path
  */
 public static function getTranslationPath($lang, $base = 'lang')
 {
     if (!Piwik_Common::isValidFilename($lang) || $base !== 'lang' && $base !== 'tmp') {
         throw new Exception(Piwik_TranslateException('General_ExceptionLanguageFileNotFound', array($lang)));
     }
     return PIWIK_INCLUDE_PATH . '/' . $base . '/' . $lang . '.php';
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:15,代码来源:TranslationWriter.php

示例2: getLanguageToLoad

 /**
  * Enter description here...
  *
  * @return string the language filename prefix, eg "en" for english
  * @throws exception if the language set in the config file is not a valid filename
  */
 public function getLanguageToLoad()
 {
     $language = Zend_Registry::get('config')->Language->current;
     if (Piwik_Common::isValidFilename($language)) {
         return $language;
     } else {
         throw new Exception("The language selected ('{$language}') is not a valid language file ");
     }
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:15,代码来源:Translate.php

示例3: loadTranslation

 private function loadTranslation($language)
 {
     $path = PIWIK_INCLUDE_PATH . '/lang/' . $language . '.php';
     if (!Piwik_Common::isValidFilename($language) || !is_readable($path)) {
         throw new Exception(Piwik_TranslateException('General_ExceptionLanguageFileNotFound', array($language)));
     }
     require $path;
     $this->mergeTranslationArray($translations);
     $this->setLocale();
     $this->loadedLanguage = $language;
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:11,代码来源:Translate.php

示例4: factory

 /**
  * Returns the DataTable associated to the output format $name
  * 
  * @throws exception If the renderer is unknown
  * @return Piwik_DataTable_Renderer
  */
 public static function factory($name)
 {
     $name = ucfirst(strtolower($name));
     $path = "DataTable/Renderer/" . $name . ".php";
     $className = 'Piwik_DataTable_Renderer_' . $name;
     if (Piwik_Common::isValidFilename($name) && Zend_Loader::isReadable($path)) {
         require_once $path;
         return new $className();
     } else {
         throw new Exception("Renderer format '{$name}' not valid. Try 'xml' or 'json' or 'csv' or 'html' or 'php' or 'original' instead.");
     }
 }
开发者ID:klando,项目名称:pgpiwik,代码行数:18,代码来源:Renderer.php

示例5: getLanguageToLoad

 /**
  * @return string the language filename prefix, eg 'en' for english
  * @throws exception if the language set is not a valid filename
  */
 public function getLanguageToLoad()
 {
     static $language = null;
     if (!is_null($language)) {
         return $language;
     }
     Piwik_PostEvent('Translate.getLanguageToLoad', $language);
     if (is_null($language) || empty($language)) {
         $language = Zend_Registry::get('config')->General->default_language;
     }
     if (Piwik_Common::isValidFilename($language)) {
         return $language;
     } else {
         throw new Exception("The language selected ('{$language}') is not a valid language file ");
     }
 }
开发者ID:klando,项目名称:pgpiwik,代码行数:20,代码来源:Translate.php

示例6: loadPlugin

 /**
  * Loads the plugin filename and instanciates the plugin with the given name, eg. UserCountry
  * Do NOT give the class name ie. Piwik_UserCountry, but give the plugin name ie. UserCountry 
  *
  * @param Piwik_Plugin $pluginName
  */
 public function loadPlugin($pluginName)
 {
     if (isset($this->loadedPlugins[$pluginName])) {
         return $this->loadedPlugins[$pluginName];
     }
     $pluginFileName = $pluginName . '/' . $pluginName . ".php";
     $pluginClassName = "Piwik_" . $pluginName;
     if (!Piwik_Common::isValidFilename($pluginName)) {
         throw new Exception("The plugin filename '{$pluginFileName}' is not a valid filename");
     }
     $path = PIWIK_INCLUDE_PATH . '/plugins/' . $pluginFileName;
     if (!file_exists($path)) {
         throw new Exception("The plugin '{$pluginName}' is enabled, but the file '{$path}' couldn't be found.\n\t\t\t\t\t\t\tTo continue, please disable the plugin manually by removing the line \n\t\t\t\t\t\t\t<pre>Plugins[] = {$pluginName}</pre>\n\t\t\t\t\t\t\tin the configuration file <code>config/config.ini.php</code>");
     }
     require_once $path;
     if (!class_exists($pluginClassName)) {
         throw new Exception("The class {$pluginClassName} couldn't be found in the file '{$path}'");
     }
     $newPlugin = new $pluginClassName();
     if (!$newPlugin instanceof Piwik_Plugin) {
         throw new Exception("The plugin {$pluginClassName} in the file {$path} must inherit from Piwik_Plugin.");
     }
     return $newPlugin;
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:30,代码来源:PluginsManager.php

示例7: test_isValidFilenameNotValidValues

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

示例8: 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 && Piwik_Common::isValidFilename($languageCode) && in_array($languageCode, $this->getAvailableLanguages());
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:10,代码来源:API.php

示例9: loadPlugin

 /**
  * Loads the plugin filename and instantiates the plugin with the given name, eg. UserCountry
  * Do NOT give the class name ie. Piwik_UserCountry, but give the plugin name ie. UserCountry
  *
  * @param string  $pluginName
  * @throws Exception
  * @return Piwik_Plugin|null
  */
 public function loadPlugin($pluginName)
 {
     if (isset($this->loadedPlugins[$pluginName])) {
         return $this->loadedPlugins[$pluginName];
     }
     $pluginFileName = $pluginName . '/' . $pluginName . '.php';
     $pluginClassName = 'Piwik_' . $pluginName;
     if (!Piwik_Common::isValidFilename($pluginName)) {
         throw new Exception("The plugin filename '{$pluginFileName}' is not a valid filename");
     }
     $path = PIWIK_INCLUDE_PATH . '/plugins/' . $pluginFileName;
     if (!file_exists($path)) {
         //			Piwik::log("Unable to load plugin '$pluginName' because '$path' couldn't be found.");
         return null;
     }
     // Don't remove this.
     // Our autoloader can't find plugins/PluginName/PluginName.php
     require_once $path;
     // prefixed by PIWIK_INCLUDE_PATH
     if (!class_exists($pluginClassName, false)) {
         throw new Exception("The class {$pluginClassName} couldn't be found in the file '{$path}'");
     }
     $newPlugin = new $pluginClassName();
     if (!$newPlugin instanceof Piwik_Plugin) {
         throw new Exception("The plugin {$pluginClassName} in the file {$path} must inherit from Piwik_Plugin.");
     }
     $this->addLoadedPlugin($pluginName, $newPlugin);
     return $newPlugin;
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:37,代码来源:PluginsManager.php

示例10: loadPlugin

 /**
  * Loads the plugin filename and instanciates the plugin with the given name, eg. UserCountry
  * Do NOT give the class name ie. Piwik_UserCountry, but give the plugin name ie. UserCountry 
  *
  * @param Piwik_Plugin $pluginName
  */
 public function loadPlugin($pluginName)
 {
     if (isset($this->loadedPlugins[$pluginName])) {
         return $this->loadedPlugins[$pluginName];
     }
     $pluginFileName = $pluginName . '/' . $pluginName . '.php';
     $pluginClassName = 'Piwik_' . $pluginName;
     if (!Piwik_Common::isValidFilename($pluginName)) {
         throw new Exception("The plugin filename '{$pluginFileName}' is not a valid filename");
     }
     $path = PIWIK_INCLUDE_PATH . '/plugins/' . $pluginFileName;
     if (!file_exists($path)) {
         throw new Exception("Unable to load plugin '{$pluginName}' because '{$path}' couldn't be found.\n\t\t\tYou can manually uninstall the plugin by removing the line <code>Plugins[] = {$pluginName}</code> from the Piwik config file.");
     }
     // Don't remove this.
     // Our autoloader can't find plugins/PluginName/PluginName.php
     require_once $path;
     // prefixed by PIWIK_INCLUDE_PATH
     if (!class_exists($pluginClassName, false)) {
         throw new Exception("The class {$pluginClassName} couldn't be found in the file '{$path}'");
     }
     $newPlugin = new $pluginClassName();
     if (!$newPlugin instanceof Piwik_Plugin) {
         throw new Exception("The plugin {$pluginClassName} in the file {$path} must inherit from Piwik_Plugin.");
     }
     return $newPlugin;
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:33,代码来源:PluginsManager.php

示例11: loadPlugin

 /**
  * Loads the plugin filename and instantiates the plugin with the given name, eg. UserCountry
  * Do NOT give the class name ie. Piwik_UserCountry, but give the plugin name ie. UserCountry
  *
  * @param string $pluginName
  * @throws Exception
  * @return Piwik_Plugin|null
  */
 public function loadPlugin($pluginName)
 {
     if (isset($this->loadedPlugins[$pluginName])) {
         return $this->loadedPlugins[$pluginName];
     }
     $pluginFileName = sprintf("%s/%s.php", $pluginName, $pluginName);
     $pluginClassName = sprintf('Piwik_%s', $pluginName);
     if (!Piwik_Common::isValidFilename($pluginName)) {
         throw new Exception(sprintf("The plugin filename '%s' is not a valid filename", $pluginFileName));
     }
     $path = PIWIK_INCLUDE_PATH . '/plugins/' . $pluginFileName;
     if (!file_exists($path)) {
         // ToDo: We should log this - but this will crash in Tracker mode since core/Piwik is not loaded
         //Piwik::log(sprintf("Unable to load plugin '%s' because '%s' couldn't be found.", $pluginName, $path));
         throw new Exception(sprintf("Unable to load plugin '%s' because '%s' couldn't be found.", $pluginName, $path));
     }
     // Don't remove this.
     // Our autoloader can't find plugins/PluginName/PluginName.php
     require_once $path;
     // prefixed by PIWIK_INCLUDE_PATH
     if (!class_exists($pluginClassName, false)) {
         throw new Exception("The class {$pluginClassName} couldn't be found in the file '{$path}'");
     }
     $newPlugin = new $pluginClassName();
     if (!$newPlugin instanceof Piwik_Plugin) {
         throw new Exception("The plugin {$pluginClassName} in the file {$path} must inherit from Piwik_Plugin.");
     }
     $this->addLoadedPlugin($pluginName, $newPlugin);
     return $newPlugin;
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:38,代码来源:PluginsManager.php

示例12: get


//.........这里部分代码省略.........
         if ($reportHasDimension) {
             $reportMetadata = $processedReport['reportMetadata']->getRows();
             $i = 0;
             // $reportData instanceof Piwik_DataTable
             foreach ($reportData->getRows() as $row) {
                 // $row instanceof Piwik_DataTable_Row
                 $rowData = $row->getColumns();
                 // Associative Array
                 $abscissaSerie[] = Piwik_Common::unsanitizeInputValue($rowData[$abscissaColumn]);
                 $parsedOrdinateValue = $this->parseOrdinateValue($rowData[$ordinateColumn]);
                 $hasData = true;
                 if ($parsedOrdinateValue != 0) {
                     $hasNonZeroValue = true;
                 }
                 $ordinateSerie[] = $parsedOrdinateValue;
                 if (isset($reportMetadata[$i])) {
                     $rowMetadata = $reportMetadata[$i]->getColumns();
                     if (isset($rowMetadata['logo'])) {
                         $ordinateLogos[$i] = $rowMetadata['logo'];
                     }
                 }
                 $i++;
             }
         } else {
             // $reportData instanceof Piwik_DataTable_Array
             $periodsMetadata = array_values($reportData->metadata);
             // $periodsData instanceof Piwik_DataTable_Simple[]
             $periodsData = array_values($reportData->getArray());
             $periodsCount = count($periodsMetadata);
             for ($i = 0; $i < $periodsCount; $i++) {
                 // $periodsData[$i] instanceof Piwik_DataTable_Simple
                 // $rows instanceof Piwik_DataTable_Row[]
                 $rows = $periodsData[$i]->getRows();
                 if (array_key_exists(0, $rows)) {
                     $rowData = $rows[0]->getColumns();
                     // associative Array
                     $ordinateValue = $rowData[$ordinateColumn];
                     $parsedOrdinateValue = $this->parseOrdinateValue($ordinateValue);
                     $hasData = true;
                     if ($parsedOrdinateValue != 0) {
                         $hasNonZeroValue = true;
                     }
                 } else {
                     $parsedOrdinateValue = 0;
                 }
                 $rowId = $periodsMetadata[$i]['period']->getLocalizedShortString();
                 $abscissaSerie[] = Piwik_Common::unsanitizeInputValue($rowId);
                 $ordinateSerie[] = $parsedOrdinateValue;
             }
         }
         if (!$hasData || !$hasNonZeroValue) {
             throw new Exception(Piwik_Translate('General_NoDataForGraph'));
         }
         //Setup the graph
         $graph = Piwik_ImageGraph_StaticGraph::factory($graphType);
         $graph->setWidth($width);
         $graph->setHeight($height);
         $graph->setFont($font);
         $graph->setFontSize($fontSize);
         $graph->setMetricTitle($ordinateLabel);
         $graph->setShowMetricTitle($showMetricTitle);
         $graph->setAliasedGraph($aliasedGraph);
         $graph->setAbscissaSerie($abscissaSerie);
         $graph->setOrdinateSerie($ordinateSerie);
         $graph->setOrdinateLogos($ordinateLogos);
         $graph->setColors(!empty($colors) ? explode(',', $colors) : array());
         // render graph
         $graph->renderGraph();
     } catch (Exception $e) {
         $graph = new Piwik_ImageGraph_StaticGraph_Exception();
         $graph->setWidth($width);
         $graph->setHeight($height);
         $graph->setFont($font);
         $graph->setFontSize($fontSize);
         $graph->setException($e);
         $graph->renderGraph();
     }
     // restoring get parameters
     $_GET = $savedGET;
     switch ($outputType) {
         case self::GRAPH_OUTPUT_FILE:
             // adding the idGoal to the filename
             $idGoal = Piwik_Common::getRequestVar('idGoal', '', 'string');
             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 (!Piwik_Common::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:0h546f6f78696342756e4e59,项目名称:piwik,代码行数:101,代码来源:API.php

示例13: loadPlugin

 /**
  * Loads the plugin filename and instanciates the plugin with the given name, eg. UserCountry
  * Do NOT give the class name ie. Piwik_UserCountry, but give the plugin name ie. UserCountry 
  *
  * @param Piwik_Plugin $pluginName
  */
 public function loadPlugin($pluginName)
 {
     if (isset($this->loadedPlugins[$pluginName])) {
         return $this->loadedPlugins[$pluginName];
     }
     $pluginFileName = $pluginName . '/' . $pluginName . ".php";
     $pluginClassName = "Piwik_" . $pluginName;
     if (!Piwik_Common::isValidFilename($pluginName)) {
         throw new Exception("The plugin filename '{$pluginFileName}' is not a valid filename");
     }
     $path = 'plugins/' . $pluginFileName;
     // case LogStats, we don't throw the exception, we don't want to add the Zend overhead
     if (class_exists('Zend_Loader') && !Zend_Loader::isReadable($path)) {
         throw new Exception("The plugin file {$path} couldn't be found.");
     }
     require_once $path;
     if (!class_exists($pluginClassName)) {
         throw new Exception("The class {$pluginClassName} couldn't be found in the file '{$path}'");
     }
     $newPlugin = new $pluginClassName();
     if (!$newPlugin instanceof Piwik_Plugin) {
         throw new Exception("The plugin {$pluginClassName} in the file {$path} must inherit from Piwik_Plugin.");
     }
     return $newPlugin;
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:31,代码来源:PluginsManager.php

示例14: getLanguageToLoad

	/**
	 * @return string the language filename prefix, eg 'en' for english
	 * @throws exception if the language set is not a valid filename
	 */
	public function getLanguageToLoad()
	{
		static $language = null;
		if(!is_null($language))
		{
			return $language;
		}

		Piwik_PostEvent('Translate.getLanguageToLoad', $language);
		
		$language = Piwik_Common::getRequestVar('language', is_null($language) ? '' : $language, 'string');
		if(empty($language))
		{
			$language = $this->getLanguageDefault();
		}
		if( Piwik_Common::isValidFilename($language))
		{
			return $language;
		}
		else
		{
			throw new Exception("The language selected ('$language') is not a valid language file ");
		}
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:28,代码来源:Translate.php

示例15: get


//.........这里部分代码省略.........
                     $ordinateSeries[$column][] = $parsedOrdinateValue;
                 }
                 if (isset($reportMetadata[$i])) {
                     $rowMetadata = $reportMetadata[$i]->getColumns();
                     if (isset($rowMetadata['logo'])) {
                         $absoluteLogoPath = self::getAbsoluteLogoPath($rowMetadata['logo']);
                         if (file_exists($absoluteLogoPath)) {
                             $abscissaLogos[$i] = $absoluteLogoPath;
                         }
                     }
                 }
                 $i++;
             }
         } else {
             // $reportData instanceof Piwik_DataTable_Array
             $periodsMetadata = array_values($reportData->metadata);
             // $periodsData instanceof Piwik_DataTable_Simple[]
             $periodsData = array_values($reportData->getArray());
             $periodsCount = count($periodsMetadata);
             for ($i = 0; $i < $periodsCount; $i++) {
                 // $periodsData[$i] instanceof Piwik_DataTable_Simple
                 // $rows instanceof Piwik_DataTable_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 = $periodsMetadata[$i]['period']->getLocalizedShortString();
                 $abscissaSeries[] = Piwik_Common::unsanitizeInputValue($rowId);
             }
         }
         if (!$hasData || !$hasNonZeroValue) {
             throw new Exception(Piwik_Translate('General_NoDataForGraph'));
         }
         //Setup the graph
         $graph = Piwik_ImageGraph_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());
         if ($period == 'day') {
             $graph->setForceSkippedLabels(6);
         }
         // render graph
         $graph->renderGraph();
     } catch (Exception $e) {
         $graph = new Piwik_ImageGraph_StaticGraph_Exception();
         $graph->setWidth($width);
         $graph->setHeight($height);
         $graph->setFont($font);
         $graph->setFontSize($fontSize);
         $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 (!Piwik_Common::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:nomoto-ubicast,项目名称:piwik,代码行数:101,代码来源:API.php


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