本文整理汇总了PHP中add_magic_quotes函数的典型用法代码示例。如果您正苦于以下问题:PHP add_magic_quotes函数的具体用法?PHP add_magic_quotes怎么用?PHP add_magic_quotes使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_magic_quotes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_execute
public function do_execute()
{
$variables = array();
// Handle updating of theme options.
if (isset($_POST[Ai1ec_View_Theme_Options::SUBMIT_ID])) {
$_POST = stripslashes_deep($_POST);
$lessphp = $this->_registry->get('less.lessphp');
$variables = $lessphp->get_saved_variables();
foreach ($variables as $variable_name => $variable_params) {
if (isset($_POST[$variable_name])) {
// Avoid problems for those who are foolish enough to leave php.ini
// settings at their defaults, which has magic quotes enabled.
if (get_magic_quotes_gpc()) {
$_POST[$variable_name] = stripslashes($_POST[$variable_name]);
}
if (Ai1ec_Less_Variable_Font::CUSTOM_FONT === $_POST[$variable_name]) {
$_POST[$variable_name] = $_POST[$variable_name . Ai1ec_Less_Variable_Font::CUSTOM_FONT_ID_SUFFIX];
}
// update the original array
$variables[$variable_name]['value'] = $_POST[$variable_name];
}
}
$_POST = add_magic_quotes($_POST);
} elseif (isset($_POST[Ai1ec_View_Theme_Options::RESET_ID])) {
$option = $this->_registry->get('model.option');
$option->delete('ai1ec_less_variables');
$option->delete('ai1ec_render_css');
do_action('ai1ec_reset_less_variables');
}
$css = $this->_registry->get('css.frontend');
$css->update_variables_and_compile_css($variables, isset($_POST[Ai1ec_View_Theme_Options::RESET_ID]));
return array('url' => ai1ec_admin_url('edit.php?post_type=ai1ec_event&page=all-in-one-event-calendar-edit-css'), 'query_args' => array());
}
示例2: test_edit_post
/**
* Tests the controller function that expects slashed data
*
*/
function test_edit_post()
{
$id = $this->factory->post->create();
$_POST = array();
$_POST['post_ID'] = $id;
$_POST['post_title'] = $this->slash_1;
$_POST['content'] = $this->slash_5;
$_POST['excerpt'] = $this->slash_7;
$_POST = add_magic_quotes($_POST);
// the edit_post() function will strip slashes
$post_id = edit_post();
$post = get_post($post_id);
$this->assertEquals($this->slash_1, $post->post_title);
$this->assertEquals($this->slash_5, $post->post_content);
$this->assertEquals($this->slash_7, $post->post_excerpt);
$_POST = array();
$_POST['post_ID'] = $id;
$_POST['post_title'] = $this->slash_2;
$_POST['content'] = $this->slash_4;
$_POST['excerpt'] = $this->slash_6;
$_POST = add_magic_quotes($_POST);
$post_id = edit_post();
$post = get_post($post_id);
$this->assertEquals($this->slash_2, $post->post_title);
$this->assertEquals($this->slash_4, $post->post_content);
$this->assertEquals($this->slash_6, $post->post_excerpt);
}
示例3: wp_update_user
function wp_update_user($userdata)
{
global $wpdb, $current_user;
$ID = (int) $userdata['ID'];
// First, get all of the original fields
$user = get_userdata($ID);
// Escape data pulled from DB.
$user = add_magic_quotes(get_object_vars($user));
// If password is changing, hash it now.
if (!empty($userdata['user_pass'])) {
$plaintext_pass = $userdata['user_pass'];
$userdata['user_pass'] = md5($userdata['user_pass']);
}
// Merge old and new fields with new fields overwriting old ones.
$userdata = array_merge($user, $userdata);
$user_id = wp_insert_user($userdata);
// Update the cookies if the password changed.
if ($current_user->id == $ID) {
if (isset($plaintext_pass)) {
wp_clearcookie();
wp_setcookie($userdata['user_login'], $plaintext_pass);
}
}
return $user_id;
}
示例4: test_edit_comment
/**
* Tests the controller function that expects slashed data
*
*/
function test_edit_comment()
{
$post_id = self::factory()->post->create();
$comment_id = self::factory()->comment->create(array('comment_post_ID' => $post_id));
// not testing comment_author_email or comment_author_url
// as slashes are not permitted in that data
$_POST = array();
$_POST['comment_ID'] = $comment_id;
$_POST['comment_status'] = '';
$_POST['newcomment_author'] = $this->slash_1;
$_POST['newcomment_author_url'] = '';
$_POST['newcomment_author_email'] = '';
$_POST['content'] = $this->slash_7;
$_POST = add_magic_quotes($_POST);
edit_comment();
$comment = get_comment($comment_id);
$this->assertEquals($this->slash_1, $comment->comment_author);
$this->assertEquals($this->slash_7, $comment->comment_content);
$_POST = array();
$_POST['comment_ID'] = $comment_id;
$_POST['comment_status'] = '';
$_POST['newcomment_author'] = $this->slash_2;
$_POST['newcomment_author_url'] = '';
$_POST['newcomment_author_email'] = '';
$_POST['content'] = $this->slash_4;
$_POST = add_magic_quotes($_POST);
edit_comment();
$comment = get_comment($comment_id);
$this->assertEquals($this->slash_2, $comment->comment_author);
$this->assertEquals($this->slash_4, $comment->comment_content);
}
示例5: add_magic_quotes
function add_magic_quotes($string)
{
if (!is_array($string)) {
return addslashes($string);
}
foreach ($string as $key => $val) {
$string[$key] = add_magic_quotes($val);
}
return $string;
}
示例6: add_magic_quotes
function add_magic_quotes($array)
{
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
示例7: import
/**
* @param array $current_import
*/
function import(array $current_import)
{
try {
$imscc = new IMSCCParser($current_import['file']);
} catch (\Exception $e) {
return FALSE;
}
$items = $imscc->manifestGetItems();
$match_ids = array_flip(array_keys($current_import['chapters']));
$total = 0;
if (!empty($items)) {
$current_post_parent = -1;
foreach ($items as $id => $item) {
// Skip
if (!$this->flaggedForImport($id)) {
continue;
}
if (!isset($match_ids[$id])) {
continue;
}
$post_type = $this->determinePostType($id);
$new_post = array('post_title' => wp_strip_all_tags($item['title']), 'post_type' => $post_type, 'post_status' => 'part' == $post_type ? 'publish' : 'draft');
if ('part' != $post_type) {
$new_post['post_content'] = $imscc->getContent($id);
}
if ('chapter' == $post_type) {
if ($current_post_parent == -1) {
$new_post['post_parent'] = $this->getChapterParent();
} else {
$new_post['post_parent'] = $current_post_parent;
}
}
$pid = wp_insert_post(add_magic_quotes($new_post));
//store part post ID to use as parent for subsequent chapters
if ('part' == $post_type) {
$current_post_parent = $pid;
}
// @todo postmeta like author
update_post_meta($pid, 'pb_show_title', 'on');
update_post_meta($pid, 'pb_export', 'on');
if ('part' == $post_type && $imscc->getContent($id)) {
update_post_meta($pid, 'pb_part_content', $imscc->getContent($id));
}
Book::consolidatePost($pid, get_post($pid));
++$total;
}
}
// Done
$_SESSION['pb_notices'][] = sprintf(__('Imported %d chapters.', 'pressbooks'), $total);
$imscc->cleanUp();
return $this->revokeCurrentImport();
}
示例8: DreamCMS_plugins
function DreamCMS_plugins($arguments, &$DreamCMS)
{
add_magic_quotes($arguments);
strpos($arguments['name'], '..') !== false && exit('Forbidden');
$fn = 'DreamCMS_plugins_' . $arguments['name'];
if (!function_exists($fn)) {
$funpath = DC_PLUGINS_PATH . "/{$arguments['name']}.php";
if (file_exists($funpath)) {
require_once $funpath;
}
}
return call_user_func_array($fn, array($arguments, $DreamCMS));
}
示例9: add_magic_quotes
function add_magic_quotes($array)
{
if (empty($array)) {
return NULL;
}
foreach ((array) $array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
示例10: wp_magic_quotes
function wp_magic_quotes()
{
// If already slashed, strip.
if (get_magic_quotes_gpc()) {
$_GET = stripslashes_deep($_GET);
$_POST = stripslashes_deep($_POST);
$_COOKIE = stripslashes_deep($_COOKIE);
}
// Escape with wpdb.
$_GET = add_magic_quotes($_GET);
$_POST = add_magic_quotes($_POST);
$_COOKIE = add_magic_quotes($_COOKIE);
$_SERVER = add_magic_quotes($_SERVER);
// Force REQUEST to be GET + POST.
$_REQUEST = array_merge($_GET, $_POST);
}
示例11: test_edit_post
/**
* Tests the controller function that expects slashed data
*
*/
function test_edit_post()
{
$id = self::factory()->post->create();
if (function_exists('wp_add_post_meta')) {
$meta_1 = wp_add_post_meta($id, 'slash_test_1', 'foo');
$meta_2 = wp_add_post_meta($id, 'slash_test_2', 'foo');
$meta_3 = wp_add_post_meta($id, 'slash_test_3', 'foo');
} else {
// expects slashed data
$meta_1 = add_post_meta($id, 'slash_test_1', addslashes('foo'));
$meta_2 = add_post_meta($id, 'slash_test_2', addslashes('foo'));
$meta_3 = add_post_meta($id, 'slash_test_3', addslashes('foo'));
}
$_POST = array();
$_POST['post_ID'] = $id;
$_POST['metakeyselect'] = '#NONE#';
$_POST['metakeyinput'] = 'slash_test_0';
$_POST['metavalue'] = $this->slash_6;
$_POST['meta'] = array($meta_1 => array('key' => 'slash_test_1', 'value' => $this->slash_1), $meta_2 => array('key' => 'slash_test_2', 'value' => $this->slash_3), $meta_3 => array('key' => 'slash_test_3', 'value' => $this->slash_4));
$_POST = add_magic_quotes($_POST);
// the edit_post() function will strip slashes
edit_post();
$post = get_post($id);
$this->assertEquals($this->slash_6, get_post_meta($id, 'slash_test_0', true));
$this->assertEquals($this->slash_1, get_post_meta($id, 'slash_test_1', true));
$this->assertEquals($this->slash_3, get_post_meta($id, 'slash_test_2', true));
$this->assertEquals($this->slash_4, get_post_meta($id, 'slash_test_3', true));
$_POST = array();
$_POST['post_ID'] = $id;
$_POST['metakeyselect'] = '#NONE#';
$_POST['metakeyinput'] = 'slash_test_0';
$_POST['metavalue'] = $this->slash_7;
$_POST['meta'] = array($meta_1 => array('key' => 'slash_test_1', 'value' => $this->slash_2), $meta_2 => array('key' => 'slash_test_2', 'value' => $this->slash_4), $meta_3 => array('key' => 'slash_test_3', 'value' => $this->slash_5));
$_POST = add_magic_quotes($_POST);
// the edit_post() function will strip slashes
edit_post();
$post = get_post($id);
$this->assertEquals($this->slash_2, get_post_meta($id, 'slash_test_1', true));
$this->assertEquals($this->slash_4, get_post_meta($id, 'slash_test_2', true));
$this->assertEquals($this->slash_5, get_post_meta($id, 'slash_test_3', true));
}
示例12: insert
function insert($token)
{
// Avoid duplicates by checking to see if this exists already
$found = get_posts(array('numberposts' => 1, 'post_type' => 'kr_' . $token->type() . '_token', 'meta_key' => 'service', 'meta_value' => $token->get_name(), 'author' => get_current_user_id(), 's' => serialize($token->token), 'exact' => true));
if ($found) {
$token->unique_id = $found[0]->ID;
return $this->update($token);
}
$post = array('post_type' => 'kr_' . $token->type() . '_token', 'post_status' => 'publish', 'post_content' => serialize($token->token));
$id = wp_insert_post(add_magic_quotes($post));
if ($id) {
// Always record what service this token is for
update_post_meta($id, 'service', $token->get_name());
// Optionally include any meta related to this token
foreach ((array) $token->get_meta(false, true) as $key => $val) {
update_post_meta($id, $key, $val);
}
return $id;
}
return false;
}
示例13: iCMS_plugins
function iCMS_plugins($arguments, &$iCMS)
{
add_magic_quotes($arguments);
$plugName = $arguments['name'];
strpos($plugName, '..') !== false && exit('Forbidden');
$plugins = $iCMS->getCache('system/plugins', $plugName);
//!$plugins['status'] && $iCMS->trigger_error("'" . $plugName . "' plugins status is 0 ", E_USER_ERROR,__FILE__,__LINE__);
if (!$plugins['status'] || !$plugins['isSetup']) {
return;
}
$fn = 'iCMS_plugins_' . $plugName;
if (!function_exists($fn)) {
!plugin::fn($plugName) && $iCMS->trigger_error("function '" . $fn . "' does not exist in iCMS plugins", E_USER_ERROR, __FILE__, __LINE__);
}
$iCMS->pluginName = $plugName;
$rs = $fn($arguments, $iCMS);
$iCMS->value($plugName, $rs);
return $rs;
// $iCMS->output($plugName,plugin::path($plugName,'templates/'.$plugName),'file:');
// return call_user_func_array($fn,array($arguments,$iCMS));
}
示例14: iCMS_plugins
/**
* @package iCMS V3.1
* @copyright 2007-2009, iDreamSoft
* @license http://www.idreamsoft.cn iDreamSoft
* @author coolmoo <idreamsoft@qq.com>
*/
function iCMS_plugins($arguments, &$iCMS)
{
add_magic_quotes($arguments);
strpos($arguments['name'], '..') !== false && exit('Forbidden');
$fn = 'iCMS_plugins_' . $arguments['name'];
if (!function_exists($fn)) {
$plugpath = iCMS_PLUGINS_PATH . '/' . $arguments['name'];
$confpath = $plugpath . '/config.php';
$funpath = $plugpath . '/function.php';
$arguments['tpl'] = $plugpath . '/templates';
if (file_exists($funpath)) {
// $arguments['config']= $iCMS->cache('config',"plugins/".$arguments['name'],0,true);
require_once $confpath;
require_once $funpath;
// $iCMS->output($arguments['name'],$arguments['tpl']);
} else {
$iCMS->trigger_error("function '" . $fn . "' does not exist in iCMS plugins", E_USER_ERROR, __FILE__, __LINE__);
}
}
return $fn($arguments, $iCMS);
// return call_user_func_array($fn,array($arguments,$iCMS));
}
示例15: kneadandInsert
/**
* Pummel then insert HTML into our database
*
* @param string $href
* @param string $post_type
* @param int $chapter_parent
* @param string $domain domain name of the webpage
*/
function kneadandInsert($html, $post_type, $chapter_parent, $domain)
{
$matches = array();
$meta = $this->getLicenseAttribution($html);
$author = isset($meta['authors']) ? $meta['authors'] : $this->getAuthors($html);
$license = isset($meta['license']) ? $this->extractCCLicense($meta['license']) : '';
// get the title, preference to title set by PB
preg_match('/<h2 class="entry-title">(.*)<\\/h2>/', $html, $matches);
if (!empty($matches[1])) {
$title = wp_strip_all_tags($matches[1]);
} else {
preg_match('/<title>(.+)<\\/title>/', $html, $matches);
$title = !empty($matches[1]) ? wp_strip_all_tags($matches[1]) : '__UNKNOWN__';
}
// just get the body
preg_match('/(?:<body[^>]*>)(.*)<\\/body>/isU', $html, $matches);
// get rid of stuff we don't need
$body = $this->regexSearchReplace($matches[1]);
// clean it up
$xhtml = $this->tidy($body);
$body = $this->kneadHtml($xhtml, $post_type, $domain);
$new_post = array('post_title' => $title, 'post_content' => $body, 'post_type' => $post_type, 'post_status' => 'draft');
if ('chapter' == $post_type) {
$new_post['post_parent'] = $chapter_parent;
}
$pid = wp_insert_post(add_magic_quotes($new_post));
if (!empty($author)) {
update_post_meta($pid, 'pb_section_author', $author);
}
if (!empty($license)) {
update_post_meta($pid, 'pb_section_license', $license);
}
update_post_meta($pid, 'pb_show_title', 'on');
update_post_meta($pid, 'pb_export', 'on');
Book::consolidatePost($pid, get_post($pid));
// Reorder
}