本文整理汇总了PHP中TextCleaner::addslashes方法的典型用法代码示例。如果您正苦于以下问题:PHP TextCleaner::addslashes方法的具体用法?PHP TextCleaner::addslashes怎么用?PHP TextCleaner::addslashes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextCleaner
的用法示例。
在下文中一共展示了TextCleaner::addslashes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: works_save_meta
function works_save_meta()
{
global $xoopsSecurity;
$id = rmc_server_var($_POST, 'id', 0);
if ($id <= 0) {
redirectMsg('works.php', __('You must provide a work ID!', 'works'), 1);
die;
}
$work = new PWWork($id);
if ($work->isNew()) {
redirectMsg('works.php', __('Specified work does not exists!', 'works'), 1);
die;
}
if (!$xoopsSecurity->check()) {
redirectMsg('works.php?id=' . $id . '&op=meta', __('Session token expired!', 'works'), 1);
die;
}
$name = rmc_server_var($_POST, 'name', '');
$value = rmc_server_var($_POST, 'value', '');
if ($name == '' || $value == '') {
redirectMsg('works.php?id=' . $id . '&op=meta', __('Please, fill all data!', 'works'), 1);
die;
}
$name = TextCleaner::sweetstring($name);
$db = XoopsDatabaseFactory::getDatabaseConnection();
$sql = "SELECT COUNT(*) FROM " . $db->prefix("pw_meta") . " WHERE name='{$name}' AND work='{$id}'";
list($num) = $db->fetchRow($db->query($sql));
$value = TextCleaner::addslashes($value);
if ($num > 0) {
$sql = "UPDATE " . $db->prefix("pw_meta") . " SET value='{$value}' WHERE name='{$name}' AND work='{$id}'";
} else {
$sql = "INSERT INTO " . $db->prefix("pw_meta") . " (`value`,`name`,`work`) VALUES ('{$value}','{$name}','{$id}')";
}
if ($db->queryF($sql)) {
redirectMsg('works.php?id=' . $id . '&op=meta', __('Custom field added successfully!', 'works'), 0);
} else {
redirectMsg('works.php?id=' . $id . '&op=meta', __('Custom field could not be added. Please try again!', 'works') . '<br />' . $db->error(), 1);
}
}