當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TextCleaner::addslashes方法代碼示例

本文整理匯總了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);
    }
}
開發者ID:laiello,項目名稱:bitcero-modules,代碼行數:39,代碼來源:works.php


注:本文中的TextCleaner::addslashes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。