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); } }
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}'"); }
/** * 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; }
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(); } }
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}'"); } }
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')); } }
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')); } }
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')); } }
/** * 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); }
/** * 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; }
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); } }
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()); }
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')); } }
/** * 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) . "'"); } }
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); }
function plugin_install() { $plugin = ps('plugin64'); if (strpos($plugin, '$plugin=\'') !== false) { @ini_set('pcre.backtrack_limit', '1000000'); $plugin = preg_replace('@.*\\$plugin=\'([\\w=+/]+)\'.*@s', '$1', $plugin); } $plugin = preg_replace('/^#.*$/m', '', $plugin); if (trim($plugin)) { $plugin = base64_decode($plugin); if (strncmp($plugin, "‹", 2) === 0) { $plugin = gzinflate(substr($plugin, 10)); } if ($plugin = unserialize($plugin)) { if (is_array($plugin)) { extract($plugin); $type = empty($type) ? 0 : min(max(intval($type), 0), 3); $order = empty($order) ? 5 : min(max(intval($order), 1), 9); $flags = empty($flags) ? 0 : intval($flags); $exists = fetch('name', 'txp_plugin', 'name', $name); if (isset($help_raw) && empty($plugin['allow_html_help'])) { // default: help is in Textile format include_once txpath . '/lib/classTextile.php'; $textile = new Textile(); $help = $textile->TextileRestricted($help_raw, 0, 0); } if ($exists) { $rs = safe_update("txp_plugin", "status = 0,\n\t\t\t\t\t\t\ttype = {$type},\n\t\t\t\t\t\t\tauthor = '" . doSlash($author) . "',\n\t\t\t\t\t\t\tauthor_uri = '" . doSlash($author_uri) . "',\n\t\t\t\t\t\t\tversion = '" . doSlash($version) . "',\n\t\t\t\t\t\t\tdescription = '" . doSlash($description) . "',\n\t\t\t\t\t\t\thelp = '" . doSlash($help) . "',\n\t\t\t\t\t\t\tcode = '" . doSlash($code) . "',\n\t\t\t\t\t\t\tcode_restore = '" . doSlash($code) . "',\n\t\t\t\t\t\t\tcode_md5 = '" . doSlash($md5) . "',\n\t\t\t\t\t\t\tflags \t = {$flags}", "name = '" . doSlash($name) . "'"); } else { $rs = safe_insert("txp_plugin", "name = '" . doSlash($name) . "',\n\t\t\t\t\t\t\tstatus = 0,\n\t\t\t\t\t\t\ttype = {$type},\n\t\t\t\t\t\t\tauthor = '" . doSlash($author) . "',\n\t\t\t\t\t\t\tauthor_uri = '" . doSlash($author_uri) . "',\n\t\t\t\t\t\t\tversion = '" . doSlash($version) . "',\n\t\t\t\t\t\t\tdescription = '" . doSlash($description) . "',\n\t\t\t\t\t\t\thelp = '" . doSlash($help) . "',\n\t\t\t\t\t\t\tcode = '" . doSlash($code) . "',\n\t\t\t\t\t\t\tcode_restore = '" . doSlash($code) . "',\n\t\t\t\t\t\t\tcode_md5 = '" . doSlash($md5) . "',\n\t\t\t\t\t\t\tload_order = '" . $order . "',\n\t\t\t\t\t\t\tflags \t = {$flags}"); } if ($rs and $code) { if (!empty($textpack)) { install_textpack($textpack, false); // TODO: How do we get rid of stale Textpacks once a plugin is uninstalled? } if ($flags & PLUGIN_LIFECYCLE_NOTIFY) { load_plugin($name, true); $message = callback_event("plugin_lifecycle.{$name}", 'installed'); } if (empty($message)) { $message = gTxt('plugin_installed', array('{name}' => $name)); } plugin_list($message); return; } else { $message = array(gTxt('plugin_install_failed', array('{name}' => $name)), E_ERROR); plugin_list($message); return; } } } } plugin_list(array(gTxt('bad_plugin_code'), E_ERROR)); }
if (!safe_field('name', 'txp_prefs', "name = 'default_event'")) { safe_insert('txp_prefs', "prefs_id = 1, name = 'default_event', val = 'article', type = '1', event = 'admin', html = 'default_event', position = '150'"); } // Add columns for thumbnail dimensions. $cols = getThings('describe `' . PFX . 'txp_image`'); if (!in_array('thumb_w', $cols)) { safe_alter('txp_image', "ADD `thumb_w` int(8) NOT NULL default 0, ADD `thumb_h` int(8) NOT NULL default 0"); } // Plugin flags. $cols = getThings('describe `' . PFX . 'txp_plugin`'); if (!in_array('flags', $cols)) { safe_alter('txp_plugin', "ADD flags SMALLINT UNSIGNED NOT NULL DEFAULT 0"); } // Default theme. if (!safe_field('name', 'txp_prefs', "name = 'theme_name'")) { safe_insert('txp_prefs', "prefs_id = 1, name = 'theme_name', val = 'classic', type = '1', event = 'admin', html = 'themename', position = '160'"); } safe_alter('txp_plugin', 'CHANGE code code MEDIUMTEXT NOT NULL, CHANGE code_restore code_restore MEDIUMTEXT NOT NULL'); safe_alter('txp_prefs', 'CHANGE val val TEXT NOT NULL'); // Add author column to files and links, // Boldy assuming that the publisher in charge of updating this site is the author of any existing content items. foreach (array('txp_file', 'txp_link') as $table) { $cols = getThings('describe `' . PFX . $table . '`'); if (!in_array('author', $cols)) { safe_alter($table, "ADD author varchar(255) NOT NULL default '', ADD INDEX author_idx (author)"); safe_update($table, "author='" . doSlash($txp_user) . "'", '1=1'); } } // Add indices on author columns. foreach (array('textpattern' => 'AuthorID', 'txp_image' => 'author') as $table => $col) { $has_idx = 0;
safe_query("alter ignore table " . safe_pfx('txp_category') . " modify parent INT not null"); $types = safe_column('distinct type', 'txp_category', '1=1'); foreach ($types as $type) { $root = safe_field('id', 'txp_category', "type='" . doSlash($type) . "' and name='root' and parent=0"); if (!$root) { $root = safe_insert('txp_category', "name='root', type='" . doSlash($type) . "', parent=0"); } safe_update('txp_category', "parent='" . $root . "'", "type='" . doSlash($type) . "' and parent=0 and id != '" . $root . "'"); tree_rebuild_full('txp_category', "type='" . doSlash($type) . "'"); } // index on form type safe_upgrade_index('txp_form', 'type_idx', '', 'type'); // dropdown ui for certain prefs safe_upgrade_table('txp_prefs', array('choices' => 'varchar(64)')); safe_update('txp_prefs', "html='checkbox'", "html='yesnoradio'"); safe_update('txp_prefs', "html='text'", "html='text_input'"); safe_update('txp_prefs', "choices='commentmode', html='select'", "html='commentmode'"); safe_update('txp_prefs', "choices='logging', html='select'", "html='logging'"); safe_update('txp_prefs', "choices='production_stati', html='radio'", "html='prod_levels'"); safe_update('txp_prefs', "choices='gmtoffsets', html='select'", "html='gmtoffset_select'"); safe_update('txp_prefs', "choices='weeks', html='select'", "html='weeks'"); safe_update('txp_prefs', "choices='languages', html='select'", "html='languages'"); safe_update('txp_prefs', "choices='permlinkmodes', html='radio'", "html='permlinkmodes'"); safe_update('txp_prefs', "choices='dateformats', html='select'", "html='dateformats'"); // change previous Textile prefs into matching markup class names from classMarkup.php $use_textile = safe_field('val', 'txp_prefs', "name='use_textile'"); $markups = array('txprawxhtml', 'txptextile', 'txpnl2br'); if (!empty($markups[$use_textile])) { safe_insert('txp_prefs', "prefs_id = 1, event='publish', name = 'markup_default', val = '{$markups[$use_textile]}', type = '0', html='select', choices='markups'"); safe_delete('txp_prefs', "name='use_textile'"); }
private function setEntry($update = NULL) { $html = file_get_contents($this->uri); $eventsStart = strpos($html, '<h2>Events</h2>'); $firstPos = strpos($html, '<li>', $eventsStart); $lastPos = strpos($html, '</ul>', $firstPos); $events = substr($html, $firstPos, $lastPos - $firstPos); // Fix relative links $events = str_replace("/wiki/", $this->rootUri, $events); if ($update === NULL) { safe_insert("jmd_wiki_events", "title='{$this->day}', last_mod='{$this->currentDate}', contents='" . doSlash($events) . "'"); } else { safe_update("jmd_wiki_events", "last_mod='{$this->currentDate}', contents='" . doSlash($events) . "'", "title='{$this->day}'"); } return $events; }
function author_save_new() { require_privs('admin.edit'); extract(doSlash(psa(array('privs', 'name', 'email', 'RealName')))); $privs = assert_int($privs); if ($name && is_valid_email($email)) { $password = doSlash(generate_password(6)); $nonce = doSlash(md5(uniqid(mt_rand(), TRUE))); $rs = safe_insert('txp_users', "\n\t\t\t\tprivs = {$privs},\n\t\t\t\tname = '{$name}',\n\t\t\t\temail = '{$email}',\n\t\t\t\tRealName = '{$RealName}',\n\t\t\t\tnonce = '{$nonce}',\n\t\t\t\tpass = password(lower('{$password}'))\n\t\t\t"); if ($rs) { send_password($RealName, $name, $email, $password); admin(gTxt('password_sent_to') . sp . $email); return; } } admin(gTxt('error_adding_new_author')); }
} safe_update('textpattern', "Keywords=TRIM(BOTH ',' FROM REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(Keywords,'\n',','),'\r',','),'\t',','),' ',' '),' ',' '),' ',' '),' ,',','),', ',','),',,,,',','),',,',','),',,',','))", "Keywords != ''"); // shift preferences to more intuitive spots // give positions, leave enough room for later additions safe_update('txp_prefs', "position = 20", "name in(\n\t\t'sitename',\n\t\t'comments_on_default',\n\t\t'img_dir',\n\t\t'comments_require_name',\n\t\t'syndicate_body_or_excerpt',\n\t\t'title_no_widow'\n\t)"); safe_update('txp_prefs', "position = 40", "name in(\n\t\t'siteurl',\n\t\t'comments_default_invite',\n\t\t'file_base_path',\n\t\t'comments_require_email',\n\t\t'rss_how_many',\n\t\t'articles_use_excerpts'\n\t)"); safe_update('txp_prefs', "position = 60", "name in('\n\t\tsite_slogan',\n\t\t'comments_moderate',\n\t\t'never_display_email',\n\t\t'file_max_upload_size',\n\t\t'show_comment_count_in_feed',\n\t\t'allow_form_override'\n\t)"); safe_update('txp_prefs', "position = 80", "name in(\n\t\t'production_status',\n\t\t'comments_disabled_after',\n\t\t'tempdir',\n\t\t'comment_nofollow',\n\t\t'include_email_atom',\n\t\t'attach_titles_to_permalinks'\n\t)"); safe_update('txp_prefs', "position = 100", "name in(\n\t\t'gmtoffset',\n\t\t'comments_auto_append',\n\t\t'plugin_cache_dir',\n\t\t'permalink_title_format',\n\t\t'use_mail_on_feeds_id'\n\t)"); safe_update('txp_prefs', "position = 120", "name in(\n\t\t'is_dst',\n\t\t'comments_mode',\n\t\t'override_emailcharset'\n\t)"); safe_update('txp_prefs', "position = 120, event = 'publish'", "name = 'send_lastmod'"); safe_update('txp_prefs', "position = 140", "name in(\n\t\t'dateformat',\n\t\t'comments_dateformat',\n\t\t'spam_blacklists',\n\t\t'lastmod_keepalive'\n\t)"); safe_update('txp_prefs', "position = 160", "name in(\n\t\t'archive_dateformat',\n\t\t'comments_are_ol',\n\t\t'comment_means_site_updated',\n\t\t'ping_weblogsdotcom'\n\t)"); safe_update('txp_prefs', "position = 180", "name in('permlink_mode','comments_sendmail','ping_textpattern_com')"); safe_update('txp_prefs', "position = 200", "name in('use_textile','expire_logs_after')"); safe_update('txp_prefs', "position = 220", "name in('logging','use_dns')"); safe_update('txp_prefs', "position = 240", "name in('use_comments','max_url_len')"); safe_update('txp_prefs', "position = 260", "name = 'use_plugins'"); safe_update('txp_prefs', "position = 280", "name = 'admin_side_plugins'"); safe_update('txp_prefs', "position = 300", "name = 'allow_page_php_scripting'"); safe_update('txp_prefs', "position = 320", "name = 'allow_article_php_scripting'"); safe_update('txp_prefs', "position = 340", "name = 'allow_raw_php_scripting'"); safe_update('txp_prefs', "position = 120, type = 1", "name = 'comments_disallow_images'"); safe_update('txp_prefs', "event = 'comments'", "name in(\n\t\t'never_display_email',\n\t\t'comment_nofollow',\n\t\t'spam_blacklists',\n\t\t'comment_means_site_updated'\n\t)"); safe_update('txp_prefs', "event = 'feeds'", "name in(\n\t\t'syndicate_body_or_excerpt',\n\t\t'rss_how_many',\n\t\t'show_comment_count_in_feed',\n\t\t'include_email_atom',\n\t\t'use_mail_on_feeds_id'\n\t)"); # 'Textile links' feature removed due to unclear specs. safe_delete('txp_prefs', "event='link' and name='textile_links'"); # Use TextileRestricted lite/fat in comments? if (!safe_field('name', 'txp_prefs', "name = 'comments_use_fat_textile'")) { safe_insert('txp_prefs', "prefs_id = 1, name = 'comments_use_fat_textile', val = '0', type = '1', event='comments', html='yesnoradio', position='130'"); }
if ((include txpath . DS . 'update' . DS . '_to_4.3.0.php') !== false) { $dbversion = '4.3.0'; } } if (version_compare($dbversion, '4.4.0', '<')) { if ((include txpath . DS . 'update' . DS . '_to_4.4.0.php') !== false) { $dbversion = '4.4.0'; } } if (version_compare($dbversion, '4.4.1', '<')) { if ((include txpath . DS . 'update' . DS . '_to_4.4.1.php') !== false) { $dbversion = '4.4.1'; } } if (version_compare($dbversion, '4.4.2', '<')) { if ((include txpath . DS . 'update' . DS . '_to_4.4.2.php') !== false) { $dbversion = '4.4.2'; } } // keep track of updates for svn users safe_delete('txp_prefs', "name = 'dbupdatetime'"); safe_insert('txp_prefs', "prefs_id=1, name='dbupdatetime',val='" . max(newest_file(), time()) . "', type='2'"); // update version safe_delete('txp_prefs', "name = 'version'"); safe_insert('txp_prefs', "prefs_id=1, name='version',val='{$dbversion}', type='2'"); // updated, baby. So let's get the fresh prefs and send them to languages define('TXP_UPDATE_DONE', 1); $event = 'prefs'; $step = 'list_languages'; $prefs = get_prefs(); extract($prefs);
function install_textpack($textpack, $add_new_langs = false) { global $prefs; $textpack = explode(n, $textpack); if (empty($textpack)) { return 0; } // presume site language equals textpack language $language = get_pref('language', 'en-gb'); $installed_langs = safe_column('lang', 'txp_lang', "1 = 1 group by lang"); $doit = true; $done = 0; foreach ($textpack as $line) { $line = trim($line); // A line starting with #, not followed by @ is a simple comment if (preg_match('/^#[^@]/', $line, $m)) { continue; } // A line matching "#@language xx-xx" establishes the designated language for all subsequent lines if (preg_match('/^#@language\\s+(.+)$/', $line, $m)) { $language = doSlash($m[1]); // May this Textpack introduce texts for this language? $doit = $add_new_langs || in_array($language, $installed_langs); continue; } // A line matching "#@event_name" establishes the event value for all subsequent lines if (preg_match('/^#@([a-zA-Z0-9_-]+)$/', $line, $m)) { $event = doSlash($m[1]); continue; } // Data lines match a "name => value" pattern. Some white space allowed. if ($doit && preg_match('/^(\\w+)\\s*=>\\s*(.+)$/', $line, $m)) { if (!empty($m[1]) && !empty($m[2])) { $name = doSlash($m[1]); $value = doSlash($m[2]); $where = "lang='{$language}' AND name='{$name}'"; // Store text; do *not* tamper with last modification date from RPC but use a well-known date in the past if (safe_count('txp_lang', $where)) { safe_update('txp_lang', "lastmod='2005-08-14', data='{$value}', event='{$event}'", $where); } else { safe_insert('txp_lang', "lastmod='2005-08-14', data='{$value}', event='{$event}', lang='{$language}', name='{$name}'"); } ++$done; } } } return $done; }
// publisher's email address if (!safe_field('name', 'txp_prefs', "name = 'publisher_email'")) { safe_insert('txp_prefs', "prefs_id = 1, name = 'publisher_email', val = '', type = 1, event = 'admin', position = 115"); } // goodbye raw ?php support if (safe_field('name', 'txp_prefs', "name = 'allow_raw_php_scripting'")) { safe_delete('txp_prefs', "name = 'allow_raw_php_scripting'"); } safe_alter('txp_users', "MODIFY RealName VARCHAR(255) NOT NULL default '', MODIFY email VARCHAR(254) NOT NULL default ''"); // Remove any setup strings from lang table safe_delete('txp_lang', "event='setup'"); $has_idx = 0; $rs = getRows('show index from `' . PFX . 'textpattern`'); foreach ($rs as $row) { if ($row['Key_name'] == 'url_title_idx') { $has_idx = 1; } } if (!$has_idx) { safe_query('alter ignore table `' . PFX . 'textpattern` add index url_title_idx(`url_title`)'); } // Remove is_default from txp_section table and make it a preference if (!safe_field('name', 'txp_prefs', "name = 'default_section'")) { $current_default_section = safe_field('name', 'txp_section', 'is_default=1'); safe_insert('txp_prefs', "prefs_id = 1, name = 'default_section', val = '" . doSlash($current_default_section) . "', type = '2', event = 'section', html = 'text_input', position = '0'"); } $cols = getThings('describe `' . PFX . 'txp_section`'); if (in_array('is_default', $cols)) { safe_alter('txp_section', "DROP `is_default`"); } safe_alter('txp_css', 'MODIFY css MEDIUMTEXT NOT NULL');
function css_save() { extract(gpsa(array('name', 'css', 'savenew', 'newname', 'copy'))); $css = doSlash(base64_encode($css)); if ($savenew or $copy) { $newname = doSlash(trim(preg_replace('/[<>&"\']/', '', gps('newname')))); if ($newname and safe_field('name', 'txp_css', "name = '{$newname}'")) { $message = gTxt('css_already_exists', array('{name}' => $newname)); } elseif ($newname) { safe_insert('txp_css', "name = '" . $newname . "', css = '{$css}'"); // update site last mod time update_lastmod(); $message = gTxt('css_created', array('{name}' => $newname)); } else { $message = gTxt('css_name_required'); } css_edit($message); } else { safe_update('txp_css', "css = '{$css}'", "name = '" . doSlash($name) . "'"); // update site last mod time update_lastmod(); $message = gTxt('css_updated', array('{name}' => $name)); css_edit($message); } }
function article_post() { global $txp_user, $vars, $txpcfg; extract(get_prefs()); $incoming = psa($vars); $message = ''; include_once $txpcfg['txpath'] . '/lib/classTextile.php'; $textile = new Textile(); if ($use_textile == 0 or !$incoming['textile_body']) { $incoming['Body_html'] = trim($incoming['Body']); } else { if ($use_textile == 1) { $incoming['Body_html'] = nl2br(trim($incoming['Body'])); } else { if ($use_textile == 2 && $incoming['textile_body']) { $incoming['Body_html'] = $textile->TextileThis($incoming['Body']); } } } $incoming['Title_plain'] = $incoming['Title']; $incoming['Title'] = $textile->TextileThis($incoming['Title'], '', 1); if ($incoming['textile_excerpt']) { $incoming['Excerpt_html'] = $textile->TextileThis($incoming['Excerpt']); } else { $incoming['Excerpt_html'] = $textile->TextileThis($incoming['Excerpt'], 1); } extract(doSlash($incoming)); if ($publish_now == 1) { $when = 'now()'; } else { $when = strtotime($year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $minute . ":00") - tz_offset(); $when = "from_unixtime({$when})"; } if ($Title or $Body or $Excerpt) { $textile_body = !$textile_body ? 0 : 1; $textile_excerpt = !$textile_excerpt ? 0 : 1; 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\t\tBody = '{$Body}',\n\t\t\t\t\tBody_html = '{$Body_html}',\n\t\t\t\t\tExcerpt = '{$Excerpt}',\n\t\t\t\t\tExcerpt_html = '{$Excerpt_html}',\n\t\t\t\t\tImage = '{$Image}',\n\t\t\t\t\tKeywords = '{$Keywords}',\n\t\t\t\t\tStatus = '{$Status}',\n\t\t\t\t\tPosted = {$when},\n\t\t\t\t\tLastMod = now(),\n\t\t\t\t\tAuthorID = '{$txp_user}',\n\t\t\t\t\tSection = '{$Section}',\n\t\t\t\t\tCategory1 = '{$Category1}',\n\t\t\t\t\tCategory2 = '{$Category2}',\n\t\t\t\t\ttextile_body = {$textile_body},\n\t\t\t\t\ttextile_excerpt = {$textile_excerpt},\n\t\t\t\t\tAnnotate = '{$Annotate}',\n\t\t\t\t\toverride_form = '{$override_form}',\n\t\t\t\t\turl_title = '{$url_title}',\n\t\t\t\t\tAnnotateInvite = '{$AnnotateInvite}',\n\t\t\t\t\tcustom_1 = '{$custom_1}',\n\t\t\t\t\tcustom_2 = '{$custom_2}',\n\t\t\t\t\tcustom_3 = '{$custom_3}',\n\t\t\t\t\tcustom_4 = '{$custom_4}',\n\t\t\t\t\tcustom_5 = '{$custom_5}',\n\t\t\t\t\tcustom_6 = '{$custom_6}',\n\t\t\t\t\tcustom_7 = '{$custom_7}',\n\t\t\t\t\tcustom_8 = '{$custom_8}',\n\t\t\t\t\tcustom_9 = '{$custom_9}',\n\t\t\t\t\tcustom_10 = '{$custom_10}',\n\t\t\t\t\tuid\t\t\t\t= '" . md5(uniqid(rand(), true)) . "',\n\t\t\t\t\tfeed_time\t\t= curdate()"); $GLOBALS['ID'] = mysql_insert_id(); if ($Status >= 4) { safe_update("txp_prefs", "val = now()", "`name` = 'lastmod'"); $message = gTxt('article_posted'); include_once $txpcfg['txpath'] . '/lib/IXRClass.php'; if ($ping_textpattern_com) { $tx_client = new IXR_Client('http://textpattern.com/xmlrpc/'); $tx_client->query('ping.Textpattern', $sitename, hu); } if ($ping_weblogsdotcom == 1) { $wl_client = new IXR_Client('http://rpc.pingomatic.com/'); $wl_client->query('weblogUpdates.ping', $sitename, hu); } } else { if ($Status == 3) { $message = gTxt("article_saved_pending"); } else { if ($Status == 2) { $message = gTxt("article_saved_hidden"); } else { if ($Status == 1) { $message = gTxt("article_saved_draft"); } } } } $message .= check_url_title($url_title); article_edit($message); } else { article_edit(); } }
{ padding: 0.3em 0; } #jmd_form_toggle .checkbox { text-align: right; } #jmd_form_toggle tr {} #jmd_form_toggle .current { background: #ffffcc; } EOD; $css = base64_encode($css); safe_insert("txp_css", "name='jmd_form_toggle', css='{$css}'"); } } /** * Adds headers for each form type. * * @param string $buffer */ function jmd_form_toggle($buffer) { global $DB, $essential_forms, $step; if (empty($DB)) { $DB = new DB(); } $curForm = gps('name') ? gps('name') : 'default'; $out = sLink('form', 'form_create', gTxt('create_new_form'), 'action');
function ign_userSaveNew() { global $ign_user_db; extract(doSlash(psa(array('privs', 'name', 'email', 'RealName')))); $pw = ign_generatePassword(8); $nonce = md5(uniqid(rand(), true)); if ($name) { $rs = safe_insert($ign_user_db, "privs\t\t\t = '{$privs}',\n\t\t\t\t name\t\t\t\t = '{$name}',\n\t\t\t\t email\t\t\t = '{$email}',\n\t\t\t\t RealName = '{$RealName}',\n\t\t\t\t pass\t\t\t\t =\t password(lower('{$pw}')),\n\t\t\t\t nonce\t\t\t = '{$nonce}'"); } if ($name && $rs) { ign_send_password($pw, $email); ign_admin(gTxt('password_sent_to') . sp . $email); } else { ign_admin(ign_gTxt('error_adding_new_user')); } }
function customer_save($event, $step) { global $txp_user, $vars, $txpcfg, $prefs; extract($prefs); extract(doSlash($_REQUEST)); $RealName = $billing_firstname . " " . $billing_lastname; if (!isset($shipping_same_as_billing)) { $shipping_same_as_billing = 0; } else { $shipping_same_as_billing = 1; } if (!function_exists("generate_password")) { require_once txpath . '/include/txp_admin.php'; } if (!function_exists("is_valid_email")) { require_once txpath . '/lib/txplib_misc.php'; } if ($name && is_valid_email($email)) { $password = doSlash(generate_password(6)); $nonce = doSlash(md5(uniqid(rand(), true))); $rs = safe_insert('txp_users', "\r\n\t\t\t\tprivs\t\t = 0,\r\n\t\t\t\tname\t\t = '{$name}',\r\n\t\t\t\temail\t\t = '{$email}',\r\n\t\t\t\tRealName = '{$RealName}',\r\n\t\t\t\tpass\t\t =\tpassword(lower('{$password}')),\r\n\t\t\t\tnonce\t\t = '{$nonce}',\r\n\t\t\t\tbilling_company = '{$billing_company}',\r\n\t\t\t\tbilling_address1 = '{$billing_address1}',\r\n\t\t\t\tbilling_address2 = '{$billing_address2}',\r\n\t\t\t\tbilling_city = '{$billing_city}',\r\n\t\t\t\tbilling_state = '{$billing_state}',\r\n\t\t\t\tbilling_zip = '{$billing_zip}',\r\n\t\t\t\tbilling_country = '{$billing_country}',\r\n\t\t\t\tbilling_fax = '{$billing_fax}',\r\n\t\t\t\tbilling_phone = '{$billing_phone}',\r\n\t\t\t\tshipping_same_as_billing = {$shipping_same_as_billing},\r\n\t\t\t\tshipping_company = '{$shipping_company}',\r\n\t\t\t\tshipping_address1 = '{$shipping_address1}',\r\n\t\t\t\tshipping_address2 = '{$shipping_address2}',\r\n\t\t\t\tshipping_city = '{$shipping_city}',\r\n\t\t\t\tshipping_state = '{$shipping_state}',\r\n\t\t\t\tshipping_zip = '{$shipping_zip}',\r\n\t\t\t\tshipping_country = '{$shipping_country}',\r\n\t\t\t\tshipping_fax = '{$shipping_fax}',\r\n\t\t\t\tshipping_phone = '{$shipping_phone}',\r\n\t\t\t\tshipping_firstname = '{$shipping_firstname}',\r\n\t\t\t\tshipping_lastname = '{$shipping_lastname}',\r\n\t\t\t\tbilling_firstname = '{$billing_firstname}',\r\n\t\t\t\tbilling_lastname = '{$billing_lastname}'"); if ($rs) { send_customer_password($RealName, $name, $email, $password); /*admin( gTxt('password_sent_to').sp.$email );*/ customers_list('', '', gTxt('password_sent_to') . sp . $email); } else { echo mysql_error(); } } //admin("There was an error trying to add this customer"); }
function doImportMTDB($mt_dblogin, $mt_db, $mt_dbpass, $mt_dbhost, $blog_id, $insert_into_section, $insert_with_status, $default_comment_invite) { global $txpcfg; //Keep some response on some part $results = array(); //Avoid left joins $authors_map = array(); $categories_map = array(); // let's go - Dean says ;-). $mtlink = mysql_connect($mt_dbhost, $mt_dblogin, $mt_dbpass, true); if (!$mtlink) { return 'mt database values don’t work. Please replace them and try again'; } mysql_select_db($mt_db, $mtlink); $results[] = 'connected to mt database. Importing Data'; sleep(2); $a = mysql_query("\n\t\t\tselect\n\t\t\tauthor_id as user_id,\n\t\t\tauthor_nickname as name,\n\t\t\tauthor_name as RealName,\n\t\t\tauthor_email as email,\n\t\t\tauthor_password as pass\n\t\t\tfrom mt_author\n\t\t", $mtlink); while ($b = mysql_fetch_assoc($a)) { $authors[] = $b; } $a = mysql_query("\n\t\t\tselect\n\t\t\tmt_entry.entry_id as ID,\n\t\t\tmt_entry.entry_text as Body,\n\t\t\tmt_entry.entry_text_more as Body2,\n\t\t\tmt_entry.entry_title as Title,\n\t\t\tmt_entry.entry_excerpt as Excerpt,\n\t\t\tmt_entry.entry_keywords as Keywords,\n\t\t\tmt_entry.entry_created_on as Posted,\n\t\t\tmt_entry.entry_modified_on as LastMod,\n\t\t\tmt_entry.entry_author_id as AuthorID\n\t\t\tfrom mt_entry\n\t\t\twhere entry_blog_id = '{$blog_id}'\n\t\t", $mtlink); $results[] = mysql_error(); while ($b = mysql_fetch_assoc($a)) { $cat = mysql_query("select placement_category_id as category_id from mt_placement where placement_entry_id='{$b['ID']}'"); while ($cat_id = mysql_fetch_row($cat)) { $categories[] = $cat_id[0]; } if (!empty($categories[0])) { $b['Category1'] = $categories[0]; } if (!empty($categories[1])) { $b['Category2'] = $categories[1]; } unset($categories); //Trap comments for each article $comments = array(); $q = "\n\t\t\t\tselect\n\t\t\t\tmt_comment.comment_id as discussid,\n\t\t\t\tmt_comment.comment_ip as ip,\n\t\t\t\tmt_comment.comment_author as name,\n\t\t\t\tmt_comment.comment_email as email,\n\t\t\t\tmt_comment.comment_url as web,\n\t\t\t\tmt_comment.comment_text as message,\n\t\t\t\tmt_comment.comment_created_on as posted\n\t\t\t\tfrom mt_comment where comment_blog_id = '{$blog_id}' AND comment_entry_id='{$b['ID']}'\n\t\t\t"; $c = mysql_query($q, $mtlink); while ($d = mysql_fetch_assoc($c)) { $comments[] = $d; } //Attach comments to article $b['comments'] = $comments; unset($comments); //Article finished $articles[] = $b; } $a = mysql_query("\n\t\t\tselect category_id,category_label from mt_category where category_blog_id='{$blog_id}'\n\t\t", $mtlink); while ($b = mysql_fetch_assoc($a)) { $categories_map[$b['category_id']] = $b['category_label']; } mysql_close($mtlink); //Yes, we have to make a new connection //otherwise doArray complains $DB = new DB(); include txpath . '/lib/classTextile.php'; $textile = new Textile(); if (!empty($authors)) { foreach ($authors as $author) { extract($author); $name = empty($name) ? $RealName : $name; $authors_map[$user_id] = $name; $authorid = safe_field('user_id', 'txp_users', "name = '" . doSlash($name) . "'"); if (!$authorid) { //Add new authors $q = safe_insert("txp_users", "\n\t\t\t\t\t\tname = '" . doSlash($RealName) . "',\n\t\t\t\t\t\temail = '" . doSlash($email) . "',\n\t\t\t\t\t\tpass = '******',\n\t\t\t\t\t\tRealName = '" . doSlash($RealName) . "',\n\t\t\t\t\t\tprivs='1'"); if ($q) { $results[] = 'inserted ' . $RealName . ' into txp_users'; } else { $results[] = mysql_error(); } } } } if (!empty($categories_map)) { foreach ($categories_map as $category) { $category = doSlash($category); $rs = safe_row('id', 'txp_category', "name='{$category}' and type='article'"); if (!$rs) { $q = safe_insert("txp_category", "name='{$category}',type='article',parent='root'"); if ($q) { $results[] = 'inserted ' . stripslashes($category) . ' into txp_category'; } else { $results[] = mysql_error(); } } } } if (!empty($articles)) { foreach ($articles as $article) { extract($article); $Body .= trim($Body2) ? "\n\n" . $Body2 : ''; $Body_html = $textile->textileThis($Body); $Excerpt_html = $textile->textileThis($Excerpt); $Title = $textile->textileThis($Title, 1); $Category1 = !empty($Category1) ? doSlash($Category1) : ''; $AuthorID = !empty($authors_map[$AuthorID]) ? doSlash($authors_map[$AuthorID]) : ''; $insertID = safe_insert("textpattern", "\n\t\t\t\t\tID \t = '{$ID}',\n\t\t\t\t\tPosted = '{$Posted}',\n\t\t\t\t\tLastMod = '{$LastMod}',\n\t\t\t\t\tTitle = '" . doSlash($Title) . "',\n\t\t\t\t\tBody = '" . doSlash($Body) . "',\n\t\t\t\t\tExcerpt\t\t = '" . doSlash($Excerpt) . "',\n\t\t\t\t\tExcerpt_html = '" . doSlash($Excerpt_html) . "',\n\t\t\t\t\tKeywords\t = '" . doSlash($Keywords) . "',\n\t\t\t\t\tBody_html = '" . doSlash($Body_html) . "',\n\t\t\t\t\tAuthorID = '{$AuthorID}',\n\t\t\t\t\tCategory1 = '{$Category1}',\n\t\t\t\t\tAnnotateInvite = '" . doSlash($default_comment_invite) . "',\n\t\t\t\t\tSection = '" . doSlash($insert_into_section) . "',\n\t\t\t\t\tuid = '" . md5(uniqid(rand(), true)) . "',\n\t\t\t\t\tfeed_time = '" . substr($Posted, 0, 10) . "',\n\t\t\t\t\tStatus = '{$insert_with_status}'\n\t\t\t\t"); if ($insertID) { $results[] = 'inserted MT entry ' . strong($Title) . ' into Textpattern as article ' . strong($insertID) . ''; //Do coment for article if (!empty($comments) && is_array($comments)) { foreach ($comments as $comment) { extract($comment); $message = nl2br($message); $commentID = safe_insert("txp_discuss", "\n\t\t\t\t\t\t\t\tdiscussid = {$discussid},\n\t\t\t\t\t\t\t\tparentid = {$insertID},\n\t\t\t\t\t\t\t\tname = '" . doSlash($name) . "',\n\t\t\t\t\t\t\t\temail = '" . doSlash($email) . "',\n\t\t\t\t\t\t\t\tweb = '" . doSlash($web) . "',\n\t\t\t\t\t\t\t\tmessage = '" . doSlash($message) . "',\n\t\t\t\t\t\t\t\tip = '{$ip}',\n\t\t\t\t\t\t\t\tposted = '{$posted}',\n\t\t\t\t\t\t\t\tvisible = 1"); if ($commentID) { $results[] = 'inserted MT comment ' . $commentID . ' for article ' . $insertID . ' into txp_discuss'; } else { $results[] = mysql_error(); } } } } else { $results[] = mysql_error(); } } } return join('<br />', $results); }