本文整理汇总了PHP中addslashes函数的典型用法代码示例。如果您正苦于以下问题:PHP addslashes函数的具体用法?PHP addslashes怎么用?PHP addslashes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了addslashes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action
function action()
{
if (isset($_POST['action']['save'])) {
$fields = $_POST['fields'];
$permissions = $fields['permissions'];
$name = trim($fields['name']);
$page_access = $fields['page_access'];
if (strlen($name) == 0) {
$this->_errors['name'] = 'This is a required field';
return;
} elseif ($this->_driver->roleExists($name)) {
$this->_errors['name'] = 'A role with the name <code>' . $name . '</code> already exists.';
return;
}
$sql = "INSERT INTO `tbl_members_roles` VALUES (NULL, \n\t\t\t\t\t\t\t\t\t\t\t\t'{$name}', \n\t\t\t\t\t\t\t\t\t\t\t\t" . (strlen(trim($fields['email_subject'])) > 0 ? "'" . addslashes($fields['email_subject']) . "'" : 'NULL') . ", \n\t\t\t\t\t\t\t\t\t\t\t\t" . (strlen(trim($fields['email_body'])) > 0 ? "'" . addslashes($fields['email_body']) . "'" : 'NULL') . ")";
$this->_Parent->Database->query($sql);
$role_id = $this->_Parent->Database->getInsertID();
if (is_array($page_access) && !empty($page_access)) {
foreach ($page_access as $page_id) {
$this->_Parent->Database->query("INSERT INTO `tbl_members_roles_page_permissions` VALUES (NULL, {$role_id}, {$page_id}, 'yes')");
}
}
if (is_array($permissions) && !empty($permissions)) {
$sql = "INSERT INTO `tbl_members_roles_event_permissions` VALUES ";
foreach ($permissions as $event_handle => $p) {
foreach ($p as $action => $allow) {
$sql .= "(NULL, {$role_id}, '{$event_handle}', '{$action}', '{$allow}'),";
}
}
$this->_Parent->Database->query(trim($sql, ','));
}
redirect(extension_members::baseURL() . 'edit/' . $role_id . '/created/');
}
}
示例2: toOptionArray
/**
* @return array
*/
public function toOptionArray()
{
$fields = [];
$fields[] = ['value' => '0', 'label' => '-- Please Select --'];
$apiEnabled = $this->helper->isEnabled($this->helper->getWebsite());
if ($apiEnabled) {
$savedCampaigns = $this->registry->registry('campaigns');
if (is_array($savedCampaigns)) {
$campaigns = $savedCampaigns;
} else {
//grab the datafields request and save to register
$client = $this->helper->getWebsiteApiClient();
$campaigns = $client->getCampaigns();
$this->registry->register('campaigns', $campaigns);
}
//set the api error message for the first option
if (isset($campaigns->message)) {
//message
$fields[] = ['value' => 0, 'label' => $campaigns->message];
} elseif (!empty($campaigns)) {
//loop for all campaing options
foreach ($campaigns as $campaign) {
if (isset($campaign->name)) {
//@codingStandardsIgnoreStart
$fields[] = ['value' => $campaign->id, 'label' => addslashes($campaign->name)];
//@codingStandardsIgnoreEnd
}
}
}
}
return $fields;
}
示例3: onAfterBackendUsersList
public function onAfterBackendUsersList( $listId, &$rows, &$pageNav, &$search, &$lists, $option, $selectTagAttribs ) {
global $_CB_framework;
$plugin = cbgjClass::getPlugin();
$_CB_framework->document->addHeadStyleSheet( $plugin->livePath . '/admin.' . $plugin->element . '.css' );
$url = cbgjClass::getPluginURL( array( 'users', 'edit' ), null, false );
$toolbar = '<a href="#" id="gjaddgroup" class="cbtoolbar cbtoolbaraction">'
. '<span class="cbicon-32-gjplugin" title="' . htmlspecialchars( CBTxt::T( 'Join GJ Group' ) ) . '"></span>'
. CBTxt::T( 'Join GJ Group' )
. '</a>'
. '<span class="cbtoolbarspacer" style="width:20px;"> </span>';
$js = "$( '.cbtoolbaractions' ).delegate( '#gjaddgroup', 'click', function() {"
. "var usersChecked = new Array();"
. "$( '#cbshowusersform input[name=\"cid[]\"]:checked' ).each( function() {"
. "usersChecked.push( $( this ).val() );"
. "});"
. "if ( ! usersChecked.length ) {"
. "alert( '" . addslashes( CBTxt::T( 'Please select a user from the list to add a CB GroupJive Group to.' ) ) . "' );"
. "} else {"
. "window.location = '" . addslashes( $url ) . "&users=' + usersChecked.join( '|*|' );"
. "}"
. "});"
. "$( '.cbtoolbaractions' ).prepend( '" . addslashes( $toolbar ) . "' );";
$_CB_framework->outputCbJQuery( $js );
}
示例4: updateBilling
function updateBilling($Billing) {
global $adb;
global $table_prefix;
$firstname = addslashes($Billing->firstname);
$lastname = addslashes($Billing->lastname);
$address = addslashes($Billing->address);
$address1 = addslashes($Billing->address1);
$city = addslashes($Billing->city);
$query="UPDATE ".$table_prefix."_tblBilling SET ".
"fldBillingLastname='$lastname',".
"fldBillingFirstName='$firstname',".
"fldBillingEmail='$Billing->email',".
"fldBillingAddress='$address',".
"fldBillingAddress1='$address1',".
"fldBillingCity='$Billing->city',".
"fldBillingState='$Billing->state',".
"fldBillingCountry='$Billing->country',".
"fldBillingZip='$Billing->zip',".
"fldBillingPhoneNo='$Billing->phone'".
" WHERE fldBillingID=$Billing->Id";
$adb->query($query);
return true;
}
示例5: getFromTables
/**
* @return string
*/
private function getFromTables()
{
$return = "";
foreach ($this->tables as $table) {
if (is_array($table)) {
$table = $table[0];
}
$result = $this->pdo->prepare('SELECT * FROM ' . $table);
$result->execute();
$num_fields = $result->columnCount();
$return .= 'DROP TABLE IF EXISTS ' . $table . ';';
$result2 = $this->pdo->prepare('SHOW CREATE TABLE ' . $table);
$result2->execute();
$row2 = $result2->fetch();
$return .= "\n\n" . $row2[1] . ";\n\n";
foreach ($result as $row) {
$return .= 'INSERT INTO ' . $table . ' VALUES(';
for ($j = 0; $j < $num_fields; $j++) {
$row[$j] = addslashes($row[$j]);
// $row[$j] = preg_replace("\n", "\\n", $row[$j]);
if (isset($row[$j])) {
$return .= '"' . $row[$j] . '"';
} else {
$return .= '""';
}
if ($j < $num_fields - 1) {
$return .= ',';
}
}
$return .= ");\n";
}
$return .= "\n\n\n";
}
return $return;
}
示例6: send
static function send($destinataire) {
$expediteur = CBdd::select_one("SELECT email FROM user WHERE type = 2", "email");
$id_texte = CConfiguration::get_valeur('WELCOME_TEXT_ID');
$sql_texte_select = "SELECT * FROM texte WHERE id = " . $id_texte;
$texte = CBdd::select_row($sql_texte_select);
$sql_user = "SELECT * FROM user WHERE email = '" . $destinataire . "'";
$user = CBdd::select_row($sql_user);
$message = str_replace('$NOM', $user['nom'], $texte['text']);
$message = str_replace('$PRENOM', $user['prenom'], $message);
//echo $message;
$sujet = $texte['nom'];
$sql_unicite_message = "SELECT id FROM email WHERE destinataire = '" . addslashes($destinataire) . "' AND nom = '" . addslashes($sujet) . "'";
// echo $sql_unicite_message;
if(CBdd::select_one($sql_unicite_message, 'id')) {
return 1;
}
$sql_email_insert = "INSERT INTO email(expediteur, destinataire, nom, text, etat) VALUES ('" . addslashes($expediteur) . "', '" . addslashes($destinataire) . "', '" . addslashes($sujet) . "', '" . addslashes($message) . "', '2')";
CBdd::insert($sql_email_insert);
return CMail::send_mail($destinataire, CFonction::force_stripslashes($sujet), CFonction::force_stripslashes($message), $expediteur, array(), 'Bcc: ' . $expediteur);
}
示例7: on_submit
function on_submit()
{
$email_list = Url::get('email_list');
$count = 0;
if ($email_list) {
$arr = explode("\n", $email_list);
$arr_tmp = array();
$email_list = '';
if ($arr) {
foreach ($arr as $email) {
$email = str_replace(array(chr(13), chr(10)), '', stripslashes($email));
if (eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\\.[A-Z]{2,6}\$", $email) && !isset($arr_tmp[$email])) {
$email_list .= ($email_list ? "\n" : '') . $email;
$arr_tmp[$email] = 1;
$count++;
}
}
}
}
$this->email_list = array('email_list' => addslashes($email_list), 'time' => TIME_NOW, 'time_modify' => TIME_NOW);
$this->checkFormInput('Danh sách email', 'email_list', $email_list, 'str', true, '', 1);
if ($count > 50) {
$this->setFormError('', "Bạn đã nhập vào {$count} email, số mail nhập vào phải <=50!");
}
if (!$this->errNum) {
$id = DB::insert('spam_mail', $this->email_list);
if ($id) {
Url::redirect_current(array('cmd' => 'email_list'));
} else {
$this->setFormError('', 'Không cập nhật được CSDL!');
}
}
}
示例8: update
function update($new_instance, $old_instance)
{
$instance = $old_instance;
$instance['title'] = sanitize_text_field($new_instance['title']);
$instance['adsenseCode'] = wp_filter_post_kses(addslashes($new_instance['adsenseCode']));
return $instance;
}
示例9: EditUserjs
function EditUserjs($add, $userid, $username)
{
global $empire, $dbtbpre;
$jsid = (int) $add['jsid'];
$jstempid = (int) $add['jstempid'];
if (!$jsid || !$add[jsname] || !$jstempid || !$add[jssql] || !$add[jsfilename]) {
printerror("EmptyUserJsname", "history.go(-1)");
}
$query_first = substr($add['jssql'], 0, 7);
if (!($query_first == "select " || $query_first == "SELECT ")) {
printerror("JsSqlError", "history.go(-1)");
}
//验证权限
CheckLevel($userid, $username, $classid, "userjs");
//删除旧js文件
if ($add['oldjsfilename'] != $add['jsfilename']) {
DelFiletext($add['oldjsfilename']);
}
$add[jssql] = ClearAddsData($add[jssql]);
$sql = $empire->query("update {$dbtbpre}enewsuserjs set jsname='{$add['jsname']}',jssql='" . addslashes($add[jssql]) . "',jstempid={$jstempid},jsfilename='{$add['jsfilename']}' where jsid={$jsid}");
//刷新js
$add[jssql] = addslashes($add[jssql]);
ReUserjs($add, "../");
if ($sql) {
//操作日志
insert_dolog("jsid={$jsid}&jsname={$add['jsname']}");
printerror("EditUserjsSuccess", "ListUserjs.php");
} else {
printerror("DbError", "history.go(-1)");
}
}
示例10: save
function save()
{
// Check for request forgeries
JRequest::checkToken() or die('COM_JOOMLEAGUE_GLOBAL_INVALID_TOKEN');
$cid = JRequest::getInt("cid", 0);
$post = JRequest::get('post');
if ($cid > 0) {
$club =& JTable::getInstance("Club", "Table");
$club->load($cid);
$club->bind($post);
$params =& JComponentHelper::getParams('com_joomleague');
if ($club->store() && $params->get('cfg_edit_club_info_update_notify') == "1") {
$db = JFactory::getDBO();
$user = JFactory::getUser();
$query = "SELECT email\n FROM #__users \n WHERE usertype = 'Super Administrator' \n OR usertype = 'Administrator'";
$db->setQuery($query);
$to = $db->loadResultArray();
$subject = addslashes(sprintf(JText::_("COM_JOOMLEAGUE_ADMIN_EDIT_CLUB_INFO_SUBJECT"), $club->name));
$message = addslashes(sprintf(JText::_("COM_JOOMLEAGUE_ADMIN_EDIT_CLUB_INFO_MESSAGE"), $user->name, $club->name));
$message .= $this->_getShowClubInfoLink();
JUtility::sendMail('', '', $to, $subject, $message);
}
}
$this->setRedirect($this->_getShowClubInfoLink());
}
示例11: backslash
function backslash(&$arr, $escape)
{
$magic_on = get_magic_quotes_gpc();
if ($escape && !$magic_on) {
foreach ($arr as $k => $v) {
switch (gettype($v)) {
case 'string':
$arr[$k] = addslashes($v);
break;
case 'array':
backslash($arr[$k], true);
}
}
}
if (!$escape && $magic_on) {
foreach ($arr as $k => $v) {
switch (gettype($v)) {
case 'string':
$arr[$k] = stripslashes($v);
break;
case 'array':
backslash($arr[$k], false);
}
}
}
}
示例12: content_53ae6fd99a3c76_13439061
function content_53ae6fd99a3c76_13439061($_smarty_tpl)
{
?>
<script type="text/javascript">
var favorite_products_url_add = '<?php
echo addslashes($_smarty_tpl->tpl_vars['link']->value->getModuleLink('favoriteproducts', 'actions', array('process' => 'add'), false));
?>
';
var favorite_products_url_remove = '<?php
echo addslashes($_smarty_tpl->tpl_vars['link']->value->getModuleLink('favoriteproducts', 'actions', array('process' => 'remove'), false));
?>
';
<?php
if (isset($_GET['id_product'])) {
?>
var favorite_products_id_product = '<?php
echo intval($_GET['id_product']);
?>
';
<?php
}
?>
</script>
<?php
}
开发者ID:jicheng17,项目名称:vipinsg,代码行数:26,代码来源:e1519fab2e7d723e19297433e8f0316eabc91310.file.favoriteproducts-header.tpl.php
示例13: update
function update($new_instance, $old_instance)
{
$instance = $old_instance;
$instance['title'] = sanitize_text_field($new_instance['title']);
$instance['adsenseCode'] = current_user_can('unfiltered_html') ? $new_instance['adsenseCode'] : stripslashes(wp_filter_post_kses(addslashes($new_instance['adsenseCode'])));
return $instance;
}
示例14: tag_options
private function tag_options($options, $prefix = "")
{
$attributes = array();
$html_content = array();
if (is_array($options)) {
foreach ($options as $option_key => $option_value) {
if (is_array($option_value)) {
if ($option_key == "data") {
$attributes[] = $this->tag_options($option_value, $option_key . "-");
} else {
$html_content[] = $prefix . $option_key . "=" . "\"" . addslashes(json_encode($option_value)) . "\"";
}
} else {
if (is_null($option_value) || empty($option_value) || $option_value == $option_key) {
$html_content[] = $prefix . $option_key;
} elseif (is_bool($option_value) && $option_value == true) {
$html_content[] = $prefix . $option_key . "=" . "\"" . $prefix . $option_key . "\"";
} else {
$html_content[] = $prefix . $option_key . "=" . "\"" . $option_value . "\"";
}
}
}
} else {
//We have only a simple string and not an array
$html_content[] = $options;
}
return join(" ", $html_content);
}
示例15: listFlags
function listFlags($params)
{
$sql = "SELECT content.migtitle,content.id FROM content WHERE content.templateid='4'";
$resultList = array();
if ($result = queryDatabase($sql)) {
while ($row = $result->fetch(PDO::FETCH_OBJ)) {
array_push($resultList, $row);
//print_r(mixed expression [, bool return])
}
}
$names = array();
foreach ($resultList as $row) {
$sql = "SELECT media.id,media.name FROM media WHERE media.name LIKE '%" . strtolower(addslashes($row->migtitle)) . "%'";
//echo $sql;
if ($result = queryDatabase($sql)) {
while ($row2 = $result->fetch(PDO::FETCH_OBJ)) {
$r = array();
$r["name"] = $row->migtitle;
$r["contentid"] = $row->id;
$r["mediaid"] = $row2->id;
$r["file"] = $row2->name;
array_push($names, $r);
}
}
}
/*
header("Content-type: application/json; charset=UTF-8");
echo json_encode($names);
*/
$sql = "INSERT INTO content_media (contentid,mediaid,statusid) VALUES ";
foreach ($names as $r) {
$sql .= "(" . $r["contentid"] . "," . $r["mediaid"] . ",4),";
}
echo $sql;
}