本文整理汇总了PHP中validate_file_to_edit函数的典型用法代码示例。如果您正苦于以下问题:PHP validate_file_to_edit函数的具体用法?PHP validate_file_to_edit怎么用?PHP validate_file_to_edit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validate_file_to_edit函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wp_die
wp_die(__('The requested theme does not exist.'));
}
$allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']);
if (empty($file)) {
$file = $allowed_files[0];
} else {
$file = stripslashes($file);
if ('theme' == $dir) {
$file = dirname(dirname($themes[$theme]['Template Dir'])) . $file;
} else {
if ('style' == $dir) {
$file = dirname(dirname($themes[$theme]['Stylesheet Dir'])) . $file;
}
}
}
validate_file_to_edit($file, $allowed_files);
$scrollto = isset($_REQUEST['scrollto']) ? (int) $_REQUEST['scrollto'] : 0;
$file_show = basename($file);
switch ($action) {
case 'update':
check_admin_referer('edit-theme_' . $file . $theme);
$newcontent = stripslashes($_POST['newcontent']);
$theme = urlencode($theme);
if (is_writeable($file)) {
//is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable
$f = fopen($file, 'w+');
if ($f !== FALSE) {
fwrite($f, $newcontent);
fclose($f);
$location = "theme-editor.php?file={$file}&theme={$theme}&a=te&scrollto={$scrollto}";
} else {
示例2: get_plugins
if (empty($_GET["{$wpvar}"])) {
${$wpvar} = '';
} else {
${$wpvar} = $_GET["{$wpvar}"];
}
} else {
${$wpvar} = $_POST["{$wpvar}"];
}
}
}
$plugins = get_plugins();
$plugin_files = array_keys($plugins);
if (empty($file)) {
$file = $plugin_files[0];
}
$file = validate_file_to_edit($file, $plugin_files);
$real_file = get_real_file_to_edit("wp-content/plugins/{$file}");
switch ($action) {
case 'update':
check_admin_referer('edit-plugin_' . $file);
if (!current_user_can('edit_plugins')) {
die('<p>' . __('You have do not have sufficient permissions to edit templates for this blog.') . '</p>');
}
$newcontent = stripslashes($_POST['newcontent']);
if (is_writeable($real_file)) {
$f = fopen($real_file, 'w+');
fwrite($f, $newcontent);
fclose($f);
wp_redirect("plugin-editor.php?file={$file}&a=te");
} else {
wp_redirect("plugin-editor.php?file={$file}");
示例3: get_option
$$wpvar = $_POST["$wpvar"];
}
}
}
$recents = get_option('recently_edited');
if (empty($file)) {
if ($recents) {
$file = $recents[0];
} else {
$file = 'index.php';
}
}
$file = validate_file_to_edit($file);
$real_file = get_real_file_to_edit($file);
switch($action) {
case 'update':
if ($user_level < 5) {
die(__('<p>You have do not have sufficient permissions to edit templates for this blog.</p>'));
}
$newcontent = stripslashes($_POST['newcontent']);
if (is_writeable($real_file)) {
$f = fopen($real_file, 'w+');
fwrite($f, $newcontent);
fclose($f);
示例4: addThemesPage
public static function addThemesPage()
{
if (!current_user_can('edit_themes')) {
wp_die('<p>' . __('You do not have sufficient permissions to edit templates for this site.', 'wpeditor') . '</p>');
}
if (isset($_POST['create_theme_new']) && wp_verify_nonce($_POST['create_theme_new'], 'create_theme_new')) {
self::create_new_theme();
}
if (isset($_POST['download_theme'])) {
WPEditorBrowser::download_theme($_POST['file']);
}
if (isset($_POST['download_theme_file'])) {
WPEditorBrowser::download_file($_POST['file_path'], 'theme');
}
if (WP_34) {
$themes = wp_get_themes();
} else {
$themes = get_themes();
}
if (empty($themes)) {
wp_die('<p>' . __('There are no themes installed on this site.', 'wpeditor') . '</p>');
}
if (isset($_REQUEST['theme'])) {
$theme = stripslashes($_REQUEST['theme']);
}
if (isset($_REQUEST['file'])) {
$file = stripslashes($_REQUEST['file']);
$theme = $_REQUEST['file'];
}
if (empty($theme)) {
if (WP_34) {
$theme = wp_get_theme();
} else {
$theme = get_current_theme();
}
}
$stylesheet = '';
if ($theme && WP_34) {
$stylesheet = urldecode($theme);
if (is_object($theme)) {
$stylesheet = urldecode($theme->stylesheet);
}
} elseif (WP_34) {
$stylesheet = get_stylesheet();
}
if (WP_34) {
$wp_theme = wp_get_theme($stylesheet);
} else {
$wp_theme = '';
}
if (empty($file)) {
if (WP_34) {
$file = basename($wp_theme['Stylesheet Dir']) . '/style.css';
} else {
$file = basename($themes[$theme]['Stylesheet Dir']) . '/style.css';
}
} else {
$file = stripslashes($file);
}
if (WP_34) {
$tf = WPEditorBrowser::getFilesAndFolders(WPWINDOWS ? str_replace("/", "\\", $wp_theme['Theme Root'] . '/' . $file) : $wp_theme['Theme Root'] . '/' . $file, 0, 'theme');
} else {
$tf = WPEditorBrowser::getFilesAndFolders(WPWINDOWS ? str_replace("/", "\\", $themes[$theme]['Theme Root'] . '/' . $file) : $themes[$theme]['Theme Root'] . '/' . $file, 0, 'theme');
}
foreach ($tf as $theme_file) {
foreach ($theme_file as $k => $t) {
if ($k == 'file') {
$theme_files[] = $t;
}
}
}
$file = validate_file_to_edit(WPWINDOWS ? str_replace("/", "\\", $file) : $file, $theme_files);
if (WP_34) {
$current_theme_root = $wp_theme['Theme Root'] . '/' . dirname($file) . '/';
} else {
$current_theme_root = $themes[$theme]['Theme Root'] . '/' . dirname($file) . '/';
}
$real_file = $current_theme_root . basename($file);
if (isset($_POST['new-content']) && file_exists($real_file) && is_writable($real_file)) {
$new_content = stripslashes($_POST['new-content']);
if (file_get_contents($real_file) === $new_content) {
WPEditorLog::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Contents are the same");
} else {
$f = fopen($real_file, 'w+');
fwrite($f, $new_content);
fclose($f);
WPEditorLog::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] just wrote to {$real_file}");
}
}
$content = file_get_contents($real_file);
$content = esc_textarea($content);
$scroll_to = isset($_REQUEST['scroll_to']) ? (int) $_REQUEST['scroll_to'] : 0;
$data = array('themes' => $themes, 'theme' => $theme, 'wp_theme' => $wp_theme, 'stylesheet' => $stylesheet, 'theme_files' => $theme_files, 'current_theme_root' => $current_theme_root, 'real_file' => $real_file, 'content' => $content, 'scroll_to' => $scroll_to, 'file' => $file, 'content-type' => 'theme');
echo WPEditor::getView('views/theme-editor.php', $data);
}
示例5: _handle_fileaction
/**
* Handles file actions of page post
*
* TODO - FUTURE :
* - adding update_recently_edited of wp core?
* - reimplementing message handling
*
* @param $fileaction action to handle
* @param $file file to target
*
* @return $this|bool|int
*/
private function _handle_fileaction($fileaction, $file)
{
$files = Log_Viewer_Admin::getFiles();
validate_file_to_edit($file, $files);
$realfile = Log_Viewer_Admin::transformFilePath($file);
switch ($fileaction) {
case self::$_KEYS_FILEACTIONS_DUMP:
$dumped = $this->_dumpFile($realfile);
// BUG: better redirect but not working cause already present output
// wp_redirect( $this->getPageUrl() );
//exit();
// Workaround:
unset($_POST[self::$_KEYS_FILEACTION_ACTION], $_POST[self::$_KEYS_FILEACTION_FILE], $_POST[self::$_KEYS_FILEACTION_SUBMIT], $_POST[self::$_KEYS_FILEACTION_SCROLLTO], $_REQUEST['file']);
$this->_currentFile = false;
break;
case self::$_KEYS_FILEACTIONS_EMPTY:
$handle = $this->_emptyFile($realfile);
return $handle;
break;
case self::$_KEYS_FILEACTIONS_BREAK:
$handle = $this->_appendBreak($realfile);
return $handle;
break;
default:
break;
}
return $this;
}
示例6: read_tag
function read_tag($tag, $contents)
{
$theTag = strstr($contents, 'get_' . $tag . '(');
//when the tag doesnt exist, return nothing, or it will take the standard file
if (!$theTag) {
return '';
}
$theTag = str_replace('get_' . $tag . '(', '', $theTag);
if (strpos($theTag, ')') != 0) {
$theTag = substr($theTag, 0, strpos($theTag, ')'));
} else {
$theTag = '';
}
$theTag = str_replace('\'', '', $theTag);
//remove '
$theTag = str_replace('"', '', $theTag);
//remove "
$fileToRead = get_template_directory_uri() . '/';
$fileToRead .= $tag;
if ($theTag) {
$fileToRead .= '-' . $theTag;
}
$fileToRead .= '.php';
$fileToRead = strstr($fileToRead, '/themes/');
$fileToRead = validate_file_to_edit($fileToRead, $allowed_files);
$fileToRead = get_real_file_to_edit($fileToRead);
//first try to read the child theme, otherwise use the normal theme
$themes = get_themes();
$theme = $themes[get_current_theme()];
$current_theme_url = $theme['Template'];
$child_theme_url = str_replace('themes/', '', strstr(get_stylesheet_directory_uri(), 'themes/'));
if (fopen(str_replace($current_theme_url, $child_theme_url, $fileToRead), 'r')) {
//child theme exists
$fileToRead = str_replace($current_theme_url, $child_theme_url, $fileToRead);
$f = fopen($fileToRead, 'r');
} else {
$f = fopen($fileToRead, 'r');
}
$tagContents = fread($f, filesize($fileToRead));
$tagContents = htmlspecialchars($tagContents);
return $tagContents;
}
示例7: addPluginsPage
public static function addPluginsPage()
{
if (!current_user_can('edit_plugins')) {
wp_die('<p>' . __('You do not have sufficient permissions to edit plugins for this site.', 'wp-editor') . '</p>');
}
if (isset($_POST['create_plugin_new']) && wp_verify_nonce($_POST['create_plugin_new'], 'create_plugin_new')) {
self::create_new_plugin();
}
if (isset($_POST['download_plugin'])) {
WPEditorBrowser::download_plugin($_POST['file']);
}
if (isset($_POST['download_plugin_file'])) {
WPEditorBrowser::download_file($_POST['file_path'], 'plugin');
}
$plugins = get_plugins();
if (empty($plugins)) {
wp_die('<p>' . __('There are no plugins installed on this site.', 'wp-editor') . '</p>');
}
if (isset($_REQUEST['plugin'])) {
$plugin = stripslashes($_REQUEST['plugin']);
}
if (isset($_REQUEST['file'])) {
$file = stripslashes($_REQUEST['file']);
}
if (empty($plugin)) {
$plugin = array_keys($plugins);
$plugin = $plugin[0];
}
$plugin_files[] = $plugin;
if (empty($file)) {
$file = $plugin_files[0];
} else {
$file = stripslashes($file);
$plugin = $file;
}
$pf = WPEditorBrowser::getFilesAndFolders(WPWINDOWS ? str_replace("/", "\\", WP_PLUGIN_DIR . '/' . $file) : WP_PLUGIN_DIR . '/' . $file, 0, 'plugin');
foreach ($pf as $plugin_file) {
foreach ($plugin_file as $k => $p) {
if ($k == 'file') {
$plugin_files[] = $p;
}
}
}
$file = validate_file_to_edit(WPWINDOWS ? str_replace("/", "\\", $file) : $file, $plugin_files);
$current_plugin_root = WP_PLUGIN_DIR . '/' . dirname($file);
$real_file = WP_PLUGIN_DIR . '/' . $plugin;
if (isset($_POST['new-content']) && file_exists($real_file) && is_writable($real_file)) {
$new_content = stripslashes($_POST['new-content']);
if (file_get_contents($real_file) === $new_content) {
WPEditorLog::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Contents are the same");
} else {
$f = fopen($real_file, 'w+');
fwrite($f, $new_content);
fclose($f);
WPEditorLog::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] just wrote to {$real_file}");
}
}
$content = file_get_contents($real_file);
$content = esc_textarea($content);
$scroll_to = isset($_REQUEST['scroll_to']) ? (int) $_REQUEST['scroll_to'] : 0;
$data = array('plugins' => $plugins, 'plugin' => $plugin, 'plugin_files' => $plugin_files, 'current_plugin_root' => $current_plugin_root, 'real_file' => $real_file, 'content' => $content, 'scroll_to' => $scroll_to, 'file' => $file, 'content-type' => 'plugin');
echo WPEditor::getView('views/plugin-editor.php', $data);
}
示例8: onViewPage
public function onViewPage()
{
global $action, $file, $file2, $display, $autorefresh, $Apply;
wp_reset_vars(array('action', 'file', 'file2', 'display', 'autorefresh', 'Apply'));
$this->_loadUserSettings();
$file = $file2;
$newSettings = $this->_settings;
if ($Apply) {
!$autorefresh ? $newSettings["autorefresh"] = 0 : ($newSettings["autorefresh"] = 1);
!$display ? $newSettings["display"] = $this->_settings["display"] : ($newSettings["display"] = $display);
}
//var_dump($newSettings);echo"<br/>";
//var_dump($this->_settings);echo"<br/>";
if ($this->_settings["autorefresh"] === 1) {
?>
<script type="text/javascript">
setTimeout("window.location.replace(document.URL);", <?php
echo $this->_settings["refreshtime"] * 1000;
?>
);
</script>
<?php
}
if (is_user_logged_in()) {
$this->_updateUserSettings($newSettings);
}
$this->_draw_header();
if (!$this->_plugin->hasFiles()) {
?>
<div id="message" class="updated">
<p><?php
_e('No files found.');
?>
</p>
</div>
<?php
return;
}
$files = $this->_plugin->getFiles();
if (isset($_REQUEST['file'])) {
$file = stripslashes($_REQUEST['file']);
} else {
$file = $files[0];
}
$this->_currentFile = validate_file_to_edit($file, $this->_plugin->getFiles());
$realfile = ciLogViewer::transformFilePath($this->_currentFile);
$writeable = is_writeable($realfile);
// TODO: Scroll to like plugin-editor.php
//$scrollto = isset($_REQUEST['scrollto']) ? (int) $_REQUEST['scrollto'] : 0;
if (!$writeable) {
$action = false;
?>
<div id="message" class="updated">
<p><?php
_e('You can not edit file ( not writeable ).');
?>
</p>
</div>
<?php
}
switch ($action) {
case 'dump':
$dumped = unlink($realfile);
if ($dumped) {
?>
<div id="message" class="updated">
<p><?php
_e('File dumped successfully.');
?>
</p>
</div>
<?php
return;
} else {
?>
<div id="message" class="error">
<p><?php
_e('Could not dump file.');
?>
</p>
</div>
<?php
}
break;
case 'empty':
$handle = fopen($realfile, 'w');
if (!$handle) {
?>
<div id="message" class="error">
<p><?php
_e('Could not open file.');
?>
</p>
</div>
<?php
}
$handle = fclose($handle);
if (!$handle) {
?>
<div id="message" class="error">
//.........这里部分代码省略.........