本文整理汇总了PHP中safe_insert函数的典型用法代码示例。如果您正苦于以下问题:PHP safe_insert函数的具体用法?PHP safe_insert怎么用?PHP safe_insert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了safe_insert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: section_create
function section_create()
{
global $txpcfg;
$name = ps('name');
//Prevent non url chars on section names
include_once txpath . '/lib/classTextile.php';
$textile = new Textile();
$title = $textile->TextileThis($name, 1);
$name = strtolower(sanitizeForUrl($name));
$chk = fetch('name', 'txp_section', 'name', $name);
if (!$chk) {
if ($name) {
$default = doSlash(safe_row('page, css', 'txp_section', "name = 'default'"));
$rs = safe_insert("txp_section", "name = '" . doSlash($name) . "',\n\t\t\t\t\ttitle = '" . doSlash($title) . "',\n\t\t\t\t\tpage = '" . $default['page'] . "',\n\t\t\t\t\tcss = '" . $default['css'] . "',\n\t\t\t\t\tis_default = 0,\n\t\t\t\t\tin_rss = 1,\n\t\t\t\t\ton_frontpage = 1");
if ($rs) {
update_lastmod();
$message = gTxt('section_created', array('{name}' => $name));
sec_section_list($message);
}
} else {
sec_section_list();
}
} else {
$message = array(gTxt('section_name_already_exists', array('{name}' => $name)), E_ERROR);
sec_section_list($message);
}
}
示例2: insert_logit
function insert_logit($in)
{
global $DB;
$in = doSlash($in);
extract($in);
safe_insert("txp_log", "`time`=now(),page='{$uri}',ip='{$ip}',host='{$host}',refer='{$ref}',status='{$status}',method='{$method}'");
}
示例3: jmd_img_selector
/**
* jmd_img_selector preferences
*
* @param string $event
* @param string $step
*/
function jmd_img_selector($event, $step)
{
global $jmdImgSel, $path_to_site, $prefs;
$out = '<div id="jmd_img_selector" style="width: 500px; margin: 0 auto">';
if ($step === 'update') {
$settings = array('tbWidth' => gps('tbWidth'), 'tbHeight' => gps('tbHeight'), 'imgWidth' => gps('imgWidth'), 'imgHeight' => gps('imgHeight'));
foreach ($settings as $key => $value) {
$jmdImgSel->upsertPref($key, $value);
}
$msg = $jmdImgSel->gTxt('prefs_updated');
}
if ($step === 'css') {
$css = <<<CSS
//inc <img_sel.css>
CSS;
safe_insert("txp_css", "name='jmd_img_selector', css='" . base64_encode($css) . "'");
$msg = $jmdImgSel->gTxt('css_created');
}
pageTop($jmdImgSel->gTxt('prefs'), isset($msg) ? $msg : '');
// Preferences
$out .= form(fieldset(fieldset($jmdImgSel->input('pref_width', 'tbWidth') . $jmdImgSel->input('pref_height', 'tbHeight'), $jmdImgSel->gTxt('tb_legend')) . fieldset($jmdImgSel->input('pref_width', 'imgWidth') . $jmdImgSel->input('pref_height', 'imgHeight'), $jmdImgSel->gTxt('img_legend')) . fInput('submit', 'update', $jmdImgSel->gTxt('update')) . eInput('jmd_img_selector') . sInput('update'), $jmdImgSel->gTxt('prefs_legend')));
// Check if CSS file exists
$rs = safe_field('name', 'txp_css', 'name="jmd_img_selector"');
if (empty($rs)) {
$out .= form(fieldset(fInput('submit', 'submit', $jmdImgSel->gTxt('create_css')) . eInput('jmd_img_selector') . sInput('css'), $jmdImgSel->gTxt('css_legend')));
}
echo $out;
}
示例4: article_post
function article_post()
{
global $txp_user, $vars, $txpcfg, $prefs;
extract($prefs);
$incoming = psa($vars);
$message = '';
$incoming = textile_main_fields($incoming, $use_textile);
extract(doSlash($incoming));
extract(array_map('assert_int', psa(array('Status', 'textile_body', 'textile_excerpt'))));
$Annotate = (int) $Annotate;
if ($publish_now == 1) {
$when = 'now()';
} else {
$when = strtotime($year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $minute . ':' . $second) - tz_offset();
$when = "from_unixtime({$when})";
}
$Keywords = doSlash(trim(preg_replace('/( ?[\\r\\n\\t,])+ ?/s', ',', preg_replace('/ +/', ' ', ps('Keywords'))), ', '));
if ($Title or $Body or $Excerpt) {
if (!has_privs('article.publish') && $Status >= 4) {
$Status = 3;
}
if (empty($url_title)) {
$url_title = stripSpace($Title_plain, 1);
}
safe_insert("textpattern", "Title = '{$Title}',\n\t\t\t\tBody = '{$Body}',\n\t\t\t\tBody_html = '{$Body_html}',\n\t\t\t\tExcerpt = '{$Excerpt}',\n\t\t\t\tExcerpt_html = '{$Excerpt_html}',\n\t\t\t\tImage = '{$Image}',\n\t\t\t\tKeywords = '{$Keywords}',\n\t\t\t\tStatus = {$Status},\n\t\t\t\tPosted = {$when},\n\t\t\t\tLastMod = now(),\n\t\t\t\tAuthorID = '{$txp_user}',\n\t\t\t\tSection = '{$Section}',\n\t\t\t\tCategory1 = '{$Category1}',\n\t\t\t\tCategory2 = '{$Category2}',\n\t\t\t\ttextile_body = {$textile_body},\n\t\t\t\ttextile_excerpt = {$textile_excerpt},\n\t\t\t\tAnnotate = {$Annotate},\n\t\t\t\toverride_form = '{$override_form}',\n\t\t\t\turl_title = '{$url_title}',\n\t\t\t\tAnnotateInvite = '{$AnnotateInvite}',\n\t\t\t\tcustom_1 = '{$custom_1}',\n\t\t\t\tcustom_2 = '{$custom_2}',\n\t\t\t\tcustom_3 = '{$custom_3}',\n\t\t\t\tcustom_4 = '{$custom_4}',\n\t\t\t\tcustom_5 = '{$custom_5}',\n\t\t\t\tcustom_6 = '{$custom_6}',\n\t\t\t\tcustom_7 = '{$custom_7}',\n\t\t\t\tcustom_8 = '{$custom_8}',\n\t\t\t\tcustom_9 = '{$custom_9}',\n\t\t\t\tcustom_10 = '{$custom_10}',\n\t\t\t\tuid = '" . md5(uniqid(rand(), true)) . "',\n\t\t\t\tfeed_time = now()");
$GLOBALS['ID'] = mysql_insert_id();
if ($Status >= 4) {
do_pings();
update_lastmod();
}
article_edit(get_status_message($Status) . check_url_title($url_title));
} else {
article_edit();
}
}
示例5: 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}'");
}
}
示例6: page_save
function page_save()
{
extract(doSlash(gpsa(array('name', 'html', 'newname', 'copy'))));
if ($newname && $copy) {
safe_insert("txp_page", "name='{$newname}', user_html='{$html}'");
page_edit(messenger('page', $newname, 'created'));
} else {
safe_update("txp_page", "user_html='{$html}'", "name='{$name}'");
page_edit(messenger('page', $name, 'updated'));
}
}
示例7: author_save_new
function author_save_new()
{
extract(doSlash(psa(array('privs', 'name', 'email', 'RealName'))));
$pw = generate_password(6);
$nonce = md5(uniqid(rand(), true));
if ($name) {
$rs = safe_insert("txp_users", "privs = '{$privs}',\n\t\t\t\t name = '{$name}',\n\t\t\t\t email = '{$email}',\n\t\t\t\t RealName = '{$RealName}',\n\t\t\t\t pass = password(lower('{$pw}')),\n\t\t\t\t nonce = '{$nonce}'");
}
if ($rs) {
send_password($pw, $email);
admin(gTxt('password_sent_to') . sp . $email);
} else {
admin(gTxt('error_adding_new_author'));
}
}
示例8: section_create
function section_create()
{
$name = ps('name');
$name = trim(doSlash($name));
$chk = fetch('name', 'txp_section', 'name', $name);
if (!$chk) {
if ($name) {
$rs = safe_insert("txp_section", "name = '{$name}',\n\t\t\t\t\tpage = 'default',\n\t\t\t\t\tcss = 'default',\n\t\t\t\t\tis_default = 0,\n\t\t\t\t\tin_rss = 1,\n\t\t\t\t\ton_frontpage = 1");
if ($rs) {
section_list(messenger('section', $name, 'created'));
}
} else {
section_list();
}
} else {
section_list(gTxt('section_name_already_exists'));
}
}
示例9: jmd_dashboard
/**
* Parses the form "jmd_dashboard".
*
* @param string $event
* @param string $step
*/
function jmd_dashboard($event, $step)
{
pageTop(gTxt('jmd_dashboard_tab'));
include_once txpath . DS . 'publish.php';
if (empty($GLOBALS['pretext'])) {
$GLOBALS['pretext'] = array('id' => '', 'q' => '');
}
$contents = safe_field("Form", "txp_form", "name = 'jmd_dashboard'");
if ($contents === FALSE) {
$contents = <<<FORM
<h1 style="text-align:center">
Hey, you haven’t customized jmd_dashboard yet.
<a href="?event=form&step=form_edit&name=jmd_dashboard">
Do it now!
</a>
</h1>
<div style="margin: 0 auto; width: 400px;">
<h1>
<txp:site_name/>: Last modified on <txp:jmd_dashboard_lastmod/>
</h1>
<h2>Recently published articles</h2>
<txp:article_custom break="li" wraptag="ul">
<txp:title/> –
<txp:jmd_dashboard_edit>
edit #<txp:article_id/>
</txp:jmd_dashboard_edit>
</txp:article_custom>
<h2>Recent comments</h2>
<txp:recent_comments break="li" wraptag="ul">
<txp:comment_message/> – <txp:comment_name link="0"/>
(<txp:jmd_dashboard_edit type="comment">edit</txp:jmd_dashboard_edit>)
</txp:recent_comments>
</div>
FORM;
safe_insert("txp_form", "Form='" . doSlash($contents) . "',\n type='misc', name='jmd_dashboard'");
}
echo parse($contents);
}
示例10: install
/**
* Installer
* @param string $event Admin-side event.
* @param string $step Admin-side, plugin-lifecycle step.
*/
public static function install($event = '', $step = '')
{
global $prefs;
if ($step == 'deleted') {
safe_delete('txp_prefs', "name like 'rah\\_bitly\\_%'");
return;
}
if (isset($prefs['rah_bitly_version']) && $prefs['rah_bitly_version'] == self::$version) {
return;
}
$position = 250;
foreach (array('login', 'apikey', 'field') as $name) {
if (!isset($prefs['rah_bitly_' . $name])) {
$html = $name == 'field' ? 'rah_bitly_fields' : 'text_input';
safe_insert('txp_prefs', "prefs_id=1,\n\t\t\t\t\tname='rah_bitly_" . $name . "',\n\t\t\t\t\tval='',\n\t\t\t\t\ttype=1,\n\t\t\t\t\tevent='rah_bitly',\n\t\t\t\t\thtml='{$html}',\n\t\t\t\t\tposition=" . $position);
$prefs['rah_bitly_' . $name] = '';
}
$position++;
}
set_pref('rah_bitly_version', self::$version, 'rah_bitly', 2, '', 0);
$prefs['rah_bitly_version'] = self::$version;
}
示例11: page_save
function page_save()
{
extract(doSlash(gpsa(array('name', 'html', 'copy'))));
if ($copy) {
$newname = doSlash(trim(preg_replace('/[<>&"\']/', '', gps('newname'))));
if ($newname and safe_field('name', 'txp_page', "name = '{$newname}'")) {
$message = gTxt('page_already_exists', array('{name}' => $newname));
} elseif ($newname) {
safe_insert('txp_page', "name = '{$newname}', user_html = '{$html}'");
update_lastmod();
$message = gTxt('page_created', array('{name}' => $newname));
} else {
$message = gTxt('page_name_invalid');
}
page_edit($message);
} else {
safe_update('txp_page', "user_html = '{$html}'", "name = '{$name}'");
update_lastmod();
$message = gTxt('page_updated', array('{name}' => $name));
page_edit($message);
}
}
示例12: 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());
}
示例13: section_create
function section_create()
{
global $txpcfg;
$name = doSlash(ps('name'));
//Prevent non url chars on section names
include_once $txpcfg['txpath'] . '/lib/classTextile.php';
$textile = new Textile();
$title = $textile->TextileThis($name, 1);
$name = dumbDown($textile->TextileThis(trim(doSlash($name)), 1));
$name = preg_replace("/[^[:alnum:]\\-_]/", "", str_replace(" ", "-", $name));
$chk = fetch('name', 'txp_section', 'name', $name);
if (!$chk) {
if ($name) {
$rs = safe_insert("txp_section", "name = '{$name}',\n\t\t\t\t\ttitle = '{$title}', \n\t\t\t\t\tpage = 'default',\n\t\t\t\t\tcss = 'default',\n\t\t\t\t\tis_default = 0,\n\t\t\t\t\tin_rss = 1,\n\t\t\t\t\ton_frontpage = 1");
if ($rs) {
sec_section_list(messenger('section', $name, 'created'));
}
} else {
sec_section_list();
}
} else {
sec_section_list(gTxt('section_name_already_exists'));
}
}
示例14: install_lang_key
/**
* Writes a new language string to the database.
*
* The language is taken from a 'lang_code' HTTP POST or GET parameter.
*
* The '$value' argument takes a string as an array. This array consists of keys
* 'name', 'event', 'data', 'uLastmod'.
*
* @param array $value The string
* @param int $key Not used
*/
function install_lang_key(&$value, $key)
{
extract(gpsa(array('lang_code', 'updating')));
$exists = safe_field("name", 'txp_lang', "name = '" . doSlash($value['name']) . "' AND lang = '" . doSlash($lang_code) . "'");
$q = "name = '" . doSlash($value['name']) . "',\n event = '" . doSlash($value['event']) . "',\n data = '" . doSlash($value['data']) . "',\n lastmod = '" . doSlash(strftime('%Y%m%d%H%M%S', $value['uLastmod'])) . "'";
if ($exists !== false) {
$value['ok'] = safe_update('txp_lang', $q, "owner = '" . doSlash(TEXTPATTERN_LANG_OWNER_SYSTEM) . "' AND lang = '" . doSlash($lang_code) . "' AND name = '" . doSlash($value['name']) . "'");
} else {
$value['ok'] = safe_insert('txp_lang', "{$q}, lang = '" . doSlash($lang_code) . "'");
}
}
示例15: form_save
function form_save()
{
global $vars, $step, $essential_forms;
extract(doSlash(gpsa($vars)));
$name = doSlash(trim(preg_replace('/[<>&"\']/', '', gps('name'))));
if (!$name) {
$step = 'form_create';
$message = gTxt('form_name_invalid');
return form_edit(array($message, E_ERROR));
}
if (!in_array($type, array('article', 'category', 'comment', 'file', 'link', 'misc', 'section'))) {
$step = 'form_create';
$message = gTxt('form_type_missing');
return form_edit(array($message, E_ERROR));
}
if ($savenew) {
$exists = safe_field('name', 'txp_form', "name = '{$name}'");
if ($exists) {
$step = 'form_create';
$message = gTxt('form_already_exists', array('{name}' => $name));
return form_edit(array($message, E_ERROR));
}
safe_insert('txp_form', "Form = '{$Form}', type = '{$type}', name = '{$name}'");
update_lastmod();
$message = gTxt('form_created', array('{name}' => $name));
return form_edit($message);
}
safe_update('txp_form', "Form = '{$Form}', type = '{$type}', name = '{$name}'", "name = '{$oldname}'");
update_lastmod();
$message = gTxt('form_updated', array('{name}' => $name));
form_edit($message);
}