本文整理汇总了PHP中Sanitize::pathFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Sanitize::pathFile方法的具体用法?PHP Sanitize::pathFile怎么用?PHP Sanitize::pathFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sanitize
的用法示例。
在下文中一共展示了Sanitize::pathFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildThemes
function buildThemes()
{
global $Site;
$themes = array();
$themesPaths = Filesystem::listDirectories(PATH_THEMES);
foreach ($themesPaths as $themePath) {
// Check if the theme is translated.
$languageFilename = $themePath . DS . 'languages' . DS . $Site->locale() . '.json';
if (!Sanitize::pathFile($languageFilename)) {
$languageFilename = $themePath . DS . 'languages' . DS . 'en_US.json';
}
if (Sanitize::pathFile($languageFilename)) {
$database = file_get_contents($languageFilename);
$database = json_decode($database, true);
$database = $database['theme-data'];
$database['dirname'] = basename($themePath);
// --- Metadata ---
$filenameMetadata = $themePath . DS . 'metadata.json';
if (Sanitize::pathFile($filenameMetadata)) {
$metadataString = file_get_contents($filenameMetadata);
$metadata = json_decode($metadataString, true);
$database = $database + $metadata;
// Theme data
array_push($themes, $database);
}
}
}
return $themes;
}
示例2: buildPlugins
function buildPlugins()
{
global $plugins;
global $pluginsEvents;
global $Language;
global $Site;
// List plugins directories
$list = Filesystem::listDirectories(PATH_PLUGINS);
// Get declared clasess before load plugins clasess, this list doesn't have the plugins clasess.
$currentDeclaredClasess = get_declared_classes();
// Load each plugin clasess
foreach ($list as $pluginPath) {
// Check if the directory has the plugin.php
if (file_exists($pluginPath . DS . 'plugin.php')) {
include $pluginPath . DS . 'plugin.php';
}
}
// Get plugins clasess loaded
$pluginsDeclaredClasess = array_diff(get_declared_classes(), $currentDeclaredClasess);
foreach ($pluginsDeclaredClasess as $pluginClass) {
$Plugin = new $pluginClass();
// Check if the plugin is translated.
$languageFilename = PATH_PLUGINS . $Plugin->directoryName() . DS . 'languages' . DS . $Site->locale() . '.json';
if (!Sanitize::pathFile($languageFilename)) {
$languageFilename = PATH_PLUGINS . $Plugin->directoryName() . DS . 'languages' . DS . 'en_US.json';
}
$database = file_get_contents($languageFilename);
$database = json_decode($database, true);
// Set name and description from the language file.
$Plugin->setMetadata('name', $database['plugin-data']['name']);
$Plugin->setMetadata('description', $database['plugin-data']['description']);
// Remove name and description, and add new words if there are.
unset($database['plugin-data']);
if (!empty($database)) {
$Language->add($database);
}
// Push Plugin to array all plugins installed and not installed.
$plugins['all'][$pluginClass] = $Plugin;
// If the plugin is installed, order by hooks.
if ($Plugin->installed()) {
foreach ($pluginsEvents as $event => $value) {
if (method_exists($Plugin, $event)) {
array_push($plugins[$event], $Plugin);
}
}
}
}
}
示例3: build_plugins
function build_plugins()
{
global $plugins;
global $pluginsEvents;
global $Language;
global $Site;
// List plugins directories
$list = Filesystem::listDirectories(PATH_PLUGINS);
// Get declared clasess before load plugins clasess, this list doesn't have the plugins clasess.
$currentDeclaredClasess = get_declared_classes();
// Load each plugin clasess
foreach ($list as $pluginPath) {
include $pluginPath . DS . 'plugin.php';
}
// Get plugins clasess loaded
$pluginsDeclaredClasess = array_diff(get_declared_classes(), $currentDeclaredClasess);
foreach ($pluginsDeclaredClasess as $pluginClass) {
$Plugin = new $pluginClass();
// Default language and meta data for the plugin
$tmpMetaData = array();
$languageFilename = PATH_PLUGINS . $Plugin->directoryName() . DS . 'languages' . DS . 'en_US.json';
$database = new dbJSON($languageFilename, false);
$tmpMetaData = $database->db['plugin-data'];
// Check if the plugin is translated.
$languageFilename = PATH_PLUGINS . $Plugin->directoryName() . DS . 'languages' . DS . $Site->locale() . '.json';
if (Sanitize::pathFile($languageFilename)) {
$database = new dbJSON($languageFilename, false);
$tmpMetaData = array_merge($tmpMetaData, $database->db['plugin-data']);
}
// Set plugin meta data
$Plugin->setData($tmpMetaData);
// Add words to language dictionary.
unset($database->db['plugin-data']);
$Language->add($database->db);
// Push Plugin to array all plugins installed and not installed.
$plugins['all'][$pluginClass] = $Plugin;
// If the plugin is installed, order by hooks.
if ($Plugin->installed()) {
foreach ($pluginsEvents as $event => $value) {
if (method_exists($Plugin, $event)) {
array_push($plugins[$event], $Plugin);
}
}
}
}
}
示例4: __construct
function __construct($locale)
{
$this->data = array();
$this->db = array();
$this->currentLocale = 'en_US';
// Default language en_US
$filename = PATH_LANGUAGES . 'en_US.json';
if (Sanitize::pathFile($filename)) {
$Tmp = new dbJSON($filename, false);
$this->db = array_merge($this->db, $Tmp->db);
}
// User language
$filename = PATH_LANGUAGES . $locale . '.json';
if (Sanitize::pathFile($filename) && $locale !== "en_US") {
$this->currentLocale = $locale;
$Tmp = new dbJSON($filename, false);
$this->db = array_merge($this->db, $Tmp->db);
}
$this->data = $this->db['language-data'];
unset($this->db['language-data']);
}
示例5: buildThemes
function buildThemes()
{
global $Site;
$themes = array();
$themesPaths = Filesystem::listDirectories(PATH_THEMES);
foreach ($themesPaths as $themePath) {
// Check if the theme is translated.
$languageFilename = $themePath . DS . 'languages' . DS . $Site->locale() . '.json';
if (!Sanitize::pathFile($languageFilename)) {
$languageFilename = $themePath . DS . 'languages' . DS . 'en_US.json';
}
if (Sanitize::pathFile($languageFilename)) {
$database = file_get_contents($languageFilename);
$database = json_decode($database, true);
if (empty($database)) {
Log::set('99.themes.php' . LOG_SEP . 'Language file error on theme ' . $themePath);
break;
}
$database = $database['theme-data'];
$database['dirname'] = basename($themePath);
// --- Metadata ---
$filenameMetadata = $themePath . DS . 'metadata.json';
if (Sanitize::pathFile($filenameMetadata)) {
$metadataString = file_get_contents($filenameMetadata);
$metadata = json_decode($metadataString, true);
$database['compatible'] = false;
if (!empty($metadata['compatible'])) {
$explode = explode(',', $metadata['compatible']);
if (in_array(BLUDIT_VERSION, $explode)) {
$database['compatible'] = true;
}
}
$database = $database + $metadata;
array_push($themes, $database);
}
}
}
return $themes;
}
示例6: build
private function build($path)
{
if (!Sanitize::pathFile($path . FILENAME)) {
return false;
}
$tmp = 0;
$lines = file($path . FILENAME);
foreach ($lines as $lineNumber => $line) {
$parts = array_map('trim', explode(':', $line, 2));
// Lowercase variable
$parts[0] = Text::lowercase($parts[0]);
// If variables is content then break the foreach and process the content after.
if ($parts[0] === 'content') {
$tmp = $lineNumber;
break;
}
if (!empty($parts[0]) && !empty($parts[1])) {
// Sanitize all fields, except Content.
$this->vars[$parts[0]] = Sanitize::html($parts[1]);
}
}
// Process the content.
if ($tmp !== 0) {
// Next line after "Content:" variable
$tmp++;
// Remove lines after Content
$output = array_slice($lines, $tmp);
if (!empty($parts[1])) {
array_unshift($output, "\n");
array_unshift($output, $parts[1]);
}
$implode = implode($output);
$this->vars['content'] = $implode;
// Sanitize content.
//$this->vars['content'] = Sanitize::html($implode);
}
}
示例7:
?>
</head>
<body class="uk-height-1-1">
<!-- Plugins -->
<?php
Theme::plugins('loginBodyBegin');
?>
<div class="uk-vertical-align uk-text-center uk-height-1-1">
<div class="uk-vertical-align-middle login-box">
<h1>BLUDIT</h1>
<?php
if (Alert::defined()) {
echo '<div class="uk-alert uk-alert-danger">' . Alert::get() . '</div>';
}
if (Sanitize::pathFile(PATH_ADMIN_VIEWS, $layout['view'] . '.php')) {
include PATH_ADMIN_VIEWS . $layout['view'] . '.php';
}
?>
</div>
</div>
<!-- Plugins -->
<?php
Theme::plugins('loginBodyEnd');
?>
</body>
</html>
示例8: array
Redirect::page('admin', 'dashboard');
}
// ============================================================================
// Main after POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
// ============================================================================
// Main after POST
// ============================================================================
$themes = array();
$themesPaths = Filesystem::listDirectories(PATH_THEMES);
foreach ($themesPaths as $themePath) {
$langLocaleFile = $themePath . DS . 'languages' . DS . $Site->locale() . '.json';
$langDefaultFile = $themePath . DS . 'languages' . DS . 'en_US.json';
// Check if exists default language
if (Sanitize::pathFile($langDefaultFile)) {
$database = new dbJSON($langDefaultFile, false);
$databaseArray = $database->db;
$themeMetaData = $database->db['theme-data'];
// Check if exists locale language
if (Sanitize::pathFile($langLocaleFile)) {
$database = new dbJSON($langLocaleFile, false);
$themeMetaData = array_merge($themeMetaData, $database->db['theme-data']);
}
$themeMetaData['dirname'] = basename($themePath);
// Theme data
array_push($themes, $themeMetaData);
}
}
示例9: defined
<?php
defined('BLUDIT') or die('Bludit CMS.');
header('Content-Type: application/json');
// Request $_POST
// $filename: Name of file to delete, just the filename
$filename = isset($_POST['filename']) ? $_POST['filename'] : '';
if (empty($filename)) {
echo json_encode(array('status' => 0, 'msg' => 'The filename is empty.'));
exit;
}
// Check if the filename exist and Sanitize::pathFile it's necesary for security reasons.
if (Sanitize::pathFile(PATH_UPLOADS . $filename)) {
// Delete the file.
Filesystem::rmfile(PATH_UPLOADS . $filename);
// Delete the thumnails.
Filesystem::rmfile(PATH_UPLOADS_THUMBNAILS . $filename);
echo json_encode(array('status' => 1, 'msg' => 'The file was deleted.'));
exit;
}
echo json_encode(array('status' => 0, 'msg' => 'The file does not exist.'));
示例10: array
Redirect::page('admin', 'dashboard');
}
// ============================================================================
// Main after POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
// ============================================================================
// Main after POST
// ============================================================================
$themes = array();
$themesPaths = Filesystem::listDirectories(PATH_THEMES);
// Load each plugin clasess
foreach ($themesPaths as $themePath) {
$langLocaleFile = $themePath . DS . 'languages' . DS . $Site->locale() . '.json';
$langDefaultFile = $themePath . DS . 'languages' . DS . 'en_US.json';
$database = false;
// Check if exists locale language
if (Sanitize::pathFile($langLocaleFile)) {
$database = new dbJSON($langLocaleFile, false);
} elseif (Sanitize::pathFile($langDefaultFile)) {
$database = new dbJSON($langDefaultFile, false);
}
if ($database !== false) {
$databaseArray = $database->db;
$databaseArray['theme-data']['dirname'] = basename($themePath);
// Theme data
array_push($themes, $databaseArray['theme-data']);
}
}
示例11: defined
<?php
defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Check role
// ============================================================================
if ($Login->role() !== 'admin') {
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
Redirect::page('admin', 'dashboard');
}
// ============================================================================
// Functions
// ============================================================================
// ============================================================================
// Main before POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
// ============================================================================
// Main after POST
// ============================================================================
$themeDirname = $layout['parameters'];
if (Sanitize::pathFile(PATH_THEMES . $themeDirname)) {
$Site->set(array('theme' => $themeDirname));
Alert::set($Language->g('The changes have been saved'));
} else {
Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying to install the theme: ' . $themeDirname);
}
Redirect::page('admin', 'themes');
示例12: cliMode
public function cliMode()
{
// LOG
Log::set('CLI MODE - PAGES - Starting...');
$pageList = array();
$pagesDirectories = Filesystem::listDirectories(PATH_PAGES);
foreach ($pagesDirectories as $directory) {
if (Sanitize::pathFile($directory . DS . FILENAME)) {
// The key is the directory name
$key = basename($directory);
// Add the page key to the list
$pageList[$key] = true;
// LOG
Log::set('CLI MODE - Page found, key: ' . $key);
// Search sub-pages
$subPaths = Filesystem::listDirectories($directory . DS);
foreach ($subPaths as $subDirectory) {
// The key of the sub-page
$subKey = basename($subDirectory);
if (Sanitize::pathFile($subDirectory . DS . FILENAME)) {
// Add the key of the sub-page, the key is composed by the directory/subdirectory
$pageList[$key . '/' . $subKey] = true;
// LOG
Log::set('CLI MODE - Page found, key: ' . $key);
}
}
}
}
foreach ($pageList as $key => $value) {
if (!isset($this->db[$key])) {
// LOG
Log::set('CLI MODE - The page is not in the database, key: ' . $key);
// Insert new post
$this->cliModeInsert($key);
} else {
$checksum = md5_file(PATH_PAGES . $key . DS . FILENAME);
// If checksum is different, update the post
if (!isset($this->db[$key]['md5file']) || $this->db[$key]['md5file'] !== $checksum) {
// LOG
Log::set('CLI MODE - Different md5 checksum, key: ' . $key);
// Update the post
$this->cliModeInsert($key, $update = true);
}
}
}
// LOG
Log::set('CLI MODE - Cleaning database...');
foreach (array_diff_key($this->db, $pageList) as $key => $data) {
// LOG
Log::set('CLI MODE - Removing page from database, key: ' . $key);
// Remove the page from database
unset($this->db[$key]);
}
// Save the database
$this->save();
// LOG
Log::set('CLI MODE - PAGES - Finishing...');
return true;
}
示例13: explode
// --- PHP Classes ---
include PATH_ABSTRACT . 'dbjson.class.php';
include PATH_HELPERS . 'sanitize.class.php';
include PATH_HELPERS . 'valid.class.php';
include PATH_HELPERS . 'text.class.php';
include PATH_HELPERS . 'log.class.php';
include PATH_HELPERS . 'date.class.php';
include PATH_KERNEL . 'dblanguage.class.php';
// --- LANGUAGE ---
// Try to detect language from HTTP
$explode = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$localeFromHTTP = empty($explode[0]) ? 'en_US' : str_replace('-', '_', $explode[0]);
if (isset($_GET['language'])) {
$localeFromHTTP = Sanitize::html($_GET['language']);
}
if (!Sanitize::pathFile(PATH_LANGUAGES . $localeFromHTTP . '.json')) {
$localeFromHTTP = 'en_US';
}
$Language = new dbLanguage($localeFromHTTP);
// --- LOCALE ---
setlocale(LC_ALL, $localeFromHTTP);
// --- TIMEZONE ---
// Check if timezone is defined in php.ini
$iniDate = ini_get('date.timezone');
if (empty($iniDate)) {
// Timezone not defined in php.ini, then UTC as default.
date_default_timezone_set('UTC');
}
// ============================================================================
// FUNCTIONS
// ============================================================================
示例14: defined
<?php
defined('BLUDIT') or die('Bludit CMS.');
// Boot rules
include PATH_RULES . '70.posts.php';
include PATH_RULES . '70.pages.php';
include PATH_RULES . '80.plugins.php';
include PATH_RULES . '99.header.php';
include PATH_RULES . '99.paginator.php';
include PATH_RULES . '99.themes.php';
// Plugins before site loaded
Theme::plugins('beforeSiteLoad');
// Theme init.php
if (Sanitize::pathFile(PATH_THEMES, $Site->theme() . DS . 'init.php')) {
include PATH_THEMES . $Site->theme() . DS . 'init.php';
}
// Theme HTML
if (Sanitize::pathFile(PATH_THEMES, $Site->theme() . DS . 'index.php')) {
include PATH_THEMES . $Site->theme() . DS . 'index.php';
} else {
$Language->p('Please check your theme configuration');
}
// Plugins after site loaded
Theme::plugins('afterSiteLoad');
示例15:
// User not logged.
// Slug is login.
// Slug is login-email.
if ($Url->notFound() || !$Login->isLogged() || $Url->slug() === 'login' || $Url->slug() === 'login-email') {
$layout['controller'] = 'login';
$layout['view'] = 'login';
$layout['template'] = 'login.php';
if ($Url->slug() === 'login-email') {
$layout['controller'] = 'login-email';
$layout['view'] = 'login-email';
}
// Generate the tokenCSRF for the user not logged, when the user log-in the token will be change.
$Security->generateTokenCSRF();
}
// Load plugins before the admin area will be load.
Theme::plugins('beforeAdminLoad');
// Load init.php if the theme has one.
if (Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme() . DS . 'init.php')) {
include PATH_ADMIN_THEMES . $Site->adminTheme() . DS . 'init.php';
}
// Load controller.
if (Sanitize::pathFile(PATH_ADMIN_CONTROLLERS, $layout['controller'] . '.php')) {
include PATH_ADMIN_CONTROLLERS . $layout['controller'] . '.php';
}
// Load view and theme.
if (Sanitize::pathFile(PATH_ADMIN_THEMES, $Site->adminTheme() . DS . $layout['template'])) {
include PATH_ADMIN_THEMES . $Site->adminTheme() . DS . $layout['template'];
}
// Load plugins after the admin area is loaded.
Theme::plugins('afterAdminLoad');
}