本文整理汇总了PHP中safe_update函数的典型用法代码示例。如果您正苦于以下问题:PHP safe_update函数的具体用法?PHP safe_update怎么用?PHP safe_update使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了safe_update函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: discuss_save
function discuss_save()
{
extract(doSlash(gpsa(array('email', 'name', 'web', 'message', 'discussid', 'ip', 'visible', 'parentid'))));
safe_update("txp_discuss", "email = '{$email}',\n\t\t\t name = '{$name}',\n\t\t\t web = '{$web}',\n\t\t\t message = '{$message}',\n\t\t\t visible = '{$visible}'", "discussid = {$discussid}");
update_comments_count($parentid);
discuss_list(messenger('message', $discussid, 'updated'));
}
示例2: tree_rebuild
function tree_rebuild($table, $parent, $left, $where = '1=1', $sortby = 'name')
{
$right = $left + 1;
$result = safe_column("id", $table, "parent='" . doSlash($parent) . "' and {$where} order by {$sortby}");
foreach ($result as $row) {
$right = tree_rebuild($table, $row, $right, $where, $sortby);
}
safe_update($table, "lft={$left}, rgt={$right}", "id='{$parent}' and {$where}");
return $right + 1;
}
示例3: mentionInsert
function mentionInsert($array)
{
extract(doSlash($array));
$chk = fetch('article_id', 'txp_log_mention', 'refpage', $refpage);
if (!$chk) {
safe_insert("txp_log_mention", "article_id = '{$id}', \n\t\t\t\trefpage = '{$refpage}', \n\t\t\t\treftitle = '{$reftitle}', \n\t\t\t\texcerpt = '{$excerpt}', \n\t\t\t\tcount = 1");
} else {
safe_update("textpattern", "count=count+1", "refpage='{$refpage}'");
}
}
示例4: section_save
function section_save()
{
$in = psa(array('name', 'page', 'css', 'is_default', 'on_frontpage', 'in_rss', 'searchable', 'old_name'));
extract(doSlash($in));
if ($is_default) {
safe_update("txp_section", "is_default=0", "name!='{$old_name}'");
}
safe_update("txp_section", "name = '{$name}',\n\t\t\tpage = '{$page}',\n\t\t\tcss = '{$css}',\n\t\t\tis_default = '{$is_default}',\n\t\t\ton_frontpage = '{$on_frontpage}',\n\t\t\tin_rss = '{$in_rss}',\n\t\t\tsearchable = '{$searchable}'", "name = '{$old_name}'");
safe_update("textpattern", "Section='{$name}'", "Section='{$old_name}'");
section_list(messenger('section', $name, 'updated'));
}
示例5: txp_validate
function txp_validate($user, $password)
{
$safe_user = strtr(addslashes($user), array('_' => '\\_', '%' => '\\%'));
$r = safe_field("name", "txp_users", "name = '{$safe_user}'\n\t\t\t\t\t\t\tand pass = password(lower('{$password}')) and privs > 0");
if ($r) {
// update the last access time
safe_update("txp_users", "last_access = now()", "name = '{$safe_user}'");
return true;
}
return false;
}
示例6: doTxpValidate
function doTxpValidate()
{
global $logout, $txpcfg, $txp_user;
$p_userid = ps('p_userid');
$p_password = ps('p_password');
$logout = gps('logout');
$stay = ps('stay');
if ($logout) {
setcookie('txp_login', '', time() - 3600);
}
if (!empty($_COOKIE['txp_login']) and !$logout) {
@(list($c_userid, $cookie_hash) = split(',', cs('txp_login')));
$nonce = safe_field('nonce', 'txp_users', "name='" . doSlash($c_userid) . "'");
if ($nonce && $nonce === md5($c_userid . pack('H*', $cookie_hash))) {
// cookie is good, create $txp_user
$txp_user = $c_userid;
return '';
} else {
// something's gone wrong
$txp_user = '';
setcookie('txp_login', '', time() - 3600);
return gTxt('bad_cookie');
}
} elseif ($p_userid and $p_password) {
sleep(3);
// should grind dictionary attacks to a halt
if (txp_validate($p_userid, $p_password)) {
$cookie_hash = md5(uniqid(rand()));
safe_update('txp_users', "nonce = '" . doSlash(md5($p_userid . pack('H*', $cookie_hash))) . "'", "name = '" . doSlash($p_userid) . "'");
if ($stay) {
setcookie('txp_login', $p_userid . ',' . $cookie_hash, time() + 3600 * 24 * 365);
// expires in 1 year
if (cs('txp_nostay')) {
setcookie('txp_nostay', '', time() - 3600);
}
} else {
setcookie('txp_login', $p_userid . ',' . $cookie_hash);
setcookie('txp_nostay', '1', time() + 3600 * 24 * 365);
// remember nostay for 1 year
}
$txp_user = $p_userid;
// login is good, create $txp_user
return '';
} else {
$txp_user = '';
return gTxt('could_not_log_in');
}
} else {
$txp_user = '';
return gTxt('login_to_textpattern');
}
}
示例7: jmd_sitemap
function jmd_sitemap($event, $step)
{
global $prefs;
$sitemap = new JMD_Sitemap();
// Generate sitemap
if ($step == ('create' || 'edit' || 'update')) {
$excluded = gps('exclude');
if ($excluded) {
$excluded = serialize($excluded);
$prefs['jmd_sitemap_exclude'] = $excluded;
safe_update("txp_prefs", "val = '{$excluded}'", "name = 'jmd_sitemap_exclude'");
}
$sitemap->writeSitemap();
}
// Extensions tab
if ($event == 'jmd_sitemap') {
pageTop('jmd_sitemap', $step ? _jmd_sitemap_gtxt('sitemap_updated') : '');
echo '<div id="jmd_sitemap" style="width: 350px; margin: 0 auto">';
// File errors
if (file_exists($sitemap->filename)) {
if (!is_writable($sitemap->filename)) {
$fileError = _jmd_sitemap_gtxt('error_not_writable');
}
} else {
$fileError = _jmd_sitemap_gtxt('error_doesnt_exist');
}
if (isset($fileError)) {
echo tag($sitemap->filename . ' ' . $fileError, 'p', ' class="not-ok"');
}
$out = '<label for="exclude">' . _jmd_sitemap_gtxt('exclude_sections') . ':</label><br/>
<select id="exclude" name="exclude[]" multiple="multiple"
size="5" style="width: 150px; margin: 3px 0 10px">';
// Exclude sections
$exclude = $prefs['jmd_sitemap_exclude'];
$exclude = unserialize($exclude);
$sections = safe_column("name", "txp_section", "name != 'default'");
foreach ($sections as $section) {
$out .= '<option name="' . $section . '"';
// Select excluded
if (in_array($section, $exclude)) {
$out .= ' selected="selected"';
}
$out .= ">{$section}</option>";
}
$out .= '</select><br/>';
echo form($out . tag(_jmd_sitemap_gtxt('update_sitemap'), 'button') . eInput('jmd_sitemap') . sInput('update'));
echo '</div><!--//jmd_sitemap-->';
}
}
示例8: reset_author_pass
function reset_author_pass($name)
{
$email = safe_field('email', 'txp_users', "name = '" . doSlash($name) . "'");
$new_pass = doSlash(generate_password(6));
$rs = safe_update('txp_users', "pass = password(lower('{$new_pass}'))", "name = '" . doSlash($name) . "'");
if ($rs) {
if (send_new_password($new_pass, $email, $name)) {
return gTxt('password_sent_to') . ' ' . $email;
} else {
return gTxt('could_not_mail') . ' ' . $email;
}
} else {
return gTxt('could_not_update_author') . ' ' . htmlspecialchars($name);
}
}
示例9: reset_author_pass
function reset_author_pass($name)
{
$email = safe_field('email', 'txp_users', "name = '" . doSlash($name) . "'");
$new_pass = generate_password(PASSWORD_LENGTH);
$hash = doSlash(txp_hash_password($new_pass));
$rs = safe_update('txp_users', "pass = '{$hash}'", "name = '" . doSlash($name) . "'");
if ($rs) {
if (send_new_password($new_pass, $email, $name)) {
return gTxt('password_sent_to') . ' ' . $email;
} else {
return gTxt('could_not_mail') . ' ' . $email;
}
} else {
return gTxt('could_not_update_author') . ' ' . txpspecialchars($name);
}
}
示例10: txp_validate
function txp_validate($user, $password)
{
$safe_user = addslashes($user);
$r = safe_field("name", "txp_users", "name = '{$safe_user}'\n\t\t\tand (pass = password(lower('" . doSlash($password) . "')) or pass = password('" . doSlash($password) . "')) and privs > 0");
if ($r) {
// update the last access time
safe_update("txp_users", "last_access = now()", "name = '{$safe_user}'");
return true;
} else {
// try old_password mysql hash
$r_old = safe_field("name", "txp_users", "name = '{$safe_user}'\n\t\t\t\tand (pass = old_password(lower('" . doSlash($password) . "')) or pass = old_password('" . doSlash($password) . "')) and privs > 0");
if ($r_old) {
safe_update("txp_users", "last_access = now()", "name = '{$safe_user}'");
return true;
}
}
return false;
}
示例11: section_del
function section_del($id)
{
$s = safe_row('*', 'txp_section', "id='" . doSlash($id) . "'");
// can't delete the default section
if (!$s or empty($s['parent'])) {
return false;
}
# FIXME: move articles to the parent section first?
# what if the parent is 'default'?
$res = safe_delete('txp_section', "id='" . doSlash($id) . "'");
if ($res and $s['rgt'] - $s['lft'] > 1) {
// section has children, so reconnect them to the parent
safe_update('txp_section', "parent='" . $s['parent'] . "'", "parent='" . $s['id'] . "'");
// children might have to inherit from the new parent
section_resolve_inheritance($s['parent']);
}
return $res;
}
示例12: txp_validate
function txp_validate($user, $password)
{
$safe_user = doSlash($user);
$passwords = array();
$passwords[] = "password(lower('" . doSlash($password) . "'))";
$passwords[] = "password('" . doSlash($password) . "')";
if (version_compare(mysql_get_server_info(), '4.1.0', '>=')) {
$passwords[] = "old_password(lower('" . doSlash($password) . "'))";
$passwords[] = "old_password('" . doSlash($password) . "')";
}
$r = safe_field("name", "txp_users", "name = '{$safe_user}' and (pass = " . join(' or pass = ', $passwords) . ") and privs > 0");
if ($r) {
// update the last access time
safe_update("txp_users", "last_access = now()", "name = '{$safe_user}'");
return true;
}
return false;
}
示例13: change_pass
function change_pass()
{
global $txp_user;
$message = '';
$themail = fetch('email', 'txp_users', 'name', $txp_user);
if (!empty($_POST["new_pass"])) {
$NewPass = $_POST["new_pass"];
$rs = safe_update("txp_users", "pass = password(lower('{$NewPass}'))", "name='{$txp_user}'");
if ($rs) {
$message .= gTxt('password_changed');
if ($_POST['mailpassword'] == 1) {
send_new_password($NewPass, $themail);
$message .= sp . gTxt('and_mailed_to') . sp . $themail;
}
$message .= ".";
} else {
echo comment(mysql_error());
}
admin($message);
}
}
示例14: change_pass
function change_pass()
{
global $txp_user;
extract(doSlash(psa(array('new_pass', 'mail_password'))));
if (empty($new_pass)) {
admin(gTxt('password_required'));
return;
}
$rs = safe_update('txp_users', "pass = password(lower('{$new_pass}'))", "name = '" . doSlash($txp_user) . "'");
if ($rs) {
$message = gTxt('password_changed');
if ($mail_password) {
$email = fetch('email', 'txp_users', 'name', $txp_user);
send_new_password($new_pass, $email, $txp_user);
$message .= sp . gTxt('and_mailed_to') . sp . $email;
} else {
echo comment(mysql_error());
}
$message .= '.';
admin($message);
}
}
示例15: rss_admin_editlink
function rss_admin_editlink($event, $step)
{
global $rss_ae_cookie;
include txpath . '/include/txp_prefs.php';
if (!isset($rss_ae_cookie)) {
$rss_ae_cookie = "rss_article_edit";
$rs = safe_insert('txp_prefs', "name='rss_ae_cookie', val='{$rss_ae_cookie}', prefs_id='1'");
}
if (gps("add")) {
safe_update("txp_prefs", "val = '" . addslashes(ps('rss_ae_cookie')) . "'", "name = 'rss_ae_cookie' and prefs_id ='1'");
setcookie($rss_ae_cookie, $rss_ae_cookie, time() + 31536000, "/");
header("Location: index.php?event=editlink");
} else {
if (gps("rem")) {
safe_update("txp_prefs", "val = '" . addslashes(ps('rss_ae_cookie')) . "'", "name = 'rss_ae_cookie' and prefs_id ='1'");
setcookie($rss_ae_cookie, $rss_ae_cookie, time() - 3600, "/");
header("Location: index.php?event=editlink");
}
}
pagetop("Edit Link");
$aeset = isset($_COOKIE[$rss_ae_cookie]) ? "" : " not";
$tdaStyle = ' style="text-align:right;vertical-align:middle"';
echo form(startTable("list") . tr(tdcs(hed("Add/Remove Public Site Article Edit Link", 1), 2)) . tr(tda(graf('Cookie ' . $rss_ae_cookie . ' is' . $aeset . ' set.', ' align="center"'), ' colspan="2"')) . tr(tda(gTxt('Cookie Name:'), ' style="text-align:right;vertical-align:middle"') . tda(text_input("rss_ae_cookie", $rss_ae_cookie, '20'), ' ')) . tr(tda(graf(fInput("submit", "add", gTxt("Add Edit Link"), "publish") . fInput("submit", "rem", gTxt("Remove Edit Link"), "publish") . eInput("editlink"), ' align="center"'), ' colspan="2"')) . endTable());
}