Esempio n. 1
0
 /**
  * Generates a list of authors.
  *
  * @param  array  $atts
  * @param  string $thing
  * @return string
  */
 public static function renderAuthors($atts, $thing = null)
 {
     global $thisauthor, $txp_groups;
     extract(lAtts(array('break' => '', 'class' => '', 'form' => '', 'group' => '', 'label' => '', 'labeltag' => '', 'limit' => '', 'name' => '', 'offset' => '', 'sort' => 'name ASC', 'wraptag' => ''), $atts));
     $sql = array('1 = 1');
     $sql_limit = '';
     $sql_sort = " ORDER BY " . doSlash($sort);
     if ($name) {
         $sql[] = "name IN (" . join(', ', quote_list(do_list($name))) . ")";
     }
     if ($group !== '') {
         $privs = do_list($group);
         $groups = array_flip($txp_groups);
         foreach ($privs as &$priv) {
             if (isset($groups[$priv])) {
                 $priv = $groups[$priv];
             }
         }
         $sql[] = 'convert(privs, char) in (' . join(', ', quote_list($privs)) . ')';
     }
     if ($limit !== '' || $offset) {
         $sql_limit = " LIMIT " . intval($offset) . ", " . ($limit === '' ? PHP_INT_MAX : intval($limit));
     }
     $rs = safe_rows_start("user_id as id, name, RealName as realname, email, privs, last_access", 'txp_users', join(" AND ", $sql) . " {$sql_sort} {$sql_limit}");
     if ($rs && numRows($rs)) {
         $out = array();
         if ($thing === null && $form !== '') {
             $thing = fetch_form($form);
         }
         while ($a = nextRow($rs)) {
             $oldauthor = $thisauthor;
             $thisauthor = $a;
             $out[] = parse($thing);
             $thisauthor = $oldauthor;
         }
         unset($thisauthor);
         return doLabel($label, $labeltag) . doWrap($out, $wraptag, $break, $class);
     }
     return '';
 }
Esempio n. 2
0
function file_download($atts)
{
    global $thisfile;
    extract(lAtts(array('form' => 'files', 'id' => '', 'filename' => ''), $atts));
    $where = !empty($id) && $id != 0 ? "id='{$id}'" : (!empty($filename) ? "filename='{$filename}'" : '');
    if (empty($thisfile)) {
        $thisfile = fileDownloadFetchInfo($where);
    }
    $thing = fetch_form($form);
    return parse($thing);
}
Esempio n. 3
0
function doArticle($atts)
{
    global $pretext, $prefs;
    extract($prefs);
    extract($pretext);
    $preview = ps('preview');
    $parentid = ps('parentid');
    extract(lAtts(array('form' => 'default', 'status' => ''), $atts));
    if ($status and !is_numeric($status)) {
        $status = getStatusNum($status);
    }
    $q_status = $status ? "and Status='" . doSlash($status) . "'" : 'and Status in (4,5)';
    $rs = safe_row("*, unix_timestamp(Posted) as uPosted", "textpattern", "ID='" . intval($id) . "' {$q_status} limit 1");
    if ($rs) {
        extract($rs);
        populateArticleData($rs);
        $GLOBALS['thisarticle']['is_first'] = 1;
        $GLOBALS['thisarticle']['is_last'] = 1;
        // define the article form
        $article = fetch_form($override_form ? $override_form : $form);
        if ($preview && $parentid) {
            $article = '<txp:comments_preview bc="1" id="' . $parentid . '" />' . $article;
        }
        $article = parse($article);
        if ($use_comments and $comments_auto_append) {
            $f = fetch_form('comments_display');
            $article .= parse($f);
        }
        unset($GLOBALS['thisarticle']);
        return $article;
    }
}
Esempio n. 4
0
 function install()
 {
     //figure out what MySQL version we are using (from _update.php)
     $mysqlversion = mysql_get_server_info();
     $tabletype = intval($mysqlversion[0]) >= 5 || preg_match('#^4\\.(0\\.[2-9]|(1[89]))|(1\\.[2-9])#', $mysqlversion) ? " ENGINE=MyISAM " : " TYPE=MyISAM ";
     if (isset($txpcfg['dbcharset']) && (intval($mysqlversion[0]) >= 5 || preg_match('#^4\\.[1-9]#', $mysqlversion))) {
         $tabletype .= " CHARACTER SET = " . $txpcfg['dbcharset'] . " ";
     }
     // Create the hak_tinymce table
     $hak_tinymce_prefs_table = safe_query("CREATE TABLE `" . PFX . "txp_hak_tinymce` (\n\t\t  `pref_name` VARCHAR(255) NOT NULL, \n\t\t  `pref_value` TEXT NOT NULL,\n\t\t  PRIMARY KEY (`pref_name`)\n\t\t) {$tabletype}");
     // if the table creation succeeds populate with values
     if ($hak_tinymce_prefs_table) {
         extract(get_prefs());
         $hak_mceSettings_default = '';
         $hak_mceSettings_default .= "theme : \"advanced\",\n";
         $hak_mceSettings_default .= "language : \"en\",\n";
         $hak_mceSettings_default .= "relative_urls : false,\n";
         $hak_mceSettings_default .= "remove_script_host : false,\n";
         $hak_mceSettings_default .= "plugins : \"searchreplace,txpimage\",\n";
         $hak_mceSettings_default .= "theme_advanced_buttons1 : \"bold,italic,underline,strikethrough,forecolor,backcolor,removeformat,numlist,bullist,outdent,indent,justifyleft,justifycenter,justifyright,justifyfull\",\n";
         $hak_mceSettings_default .= "theme_advanced_buttons2 : \"link,unlink,separator,image,separator,search,replace,separator,cut,copy,paste,separator,code,separator,formatselect\",\n";
         $hak_mceSettings_default .= "theme_advanced_buttons3 : \"\",\n";
         $hak_mceSettings_default .= "theme_advanced_toolbar_location : \"top\",\n";
         $hak_mceSettings_default .= "theme_advanced_toolbar_align : \"left\",";
         $hak_mceSettings_default .= "entity_encoding : \"numeric\",";
         $hak_mceSettings_compressor = "theme : \"advanced\",\n";
         $hak_mceSettings_compressor .= "plugins : \"searchreplace,txpimage\",\n";
         $hak_mceSettings_compressor .= "disk_cache : true,\n";
         $hak_mceSettings_compressor .= "languages : \"en\",\n";
         $hak_mceSettings_compressor .= "debug : false";
         // set pref array values properly checking if it had been setup before.
         $hak_tinymce_prefs["show_toggle"] = isset($hak_tinymce_show_toggle) ? $hak_tinymce_show_toggle : "1";
         $hak_tinymce_prefs["hide_on_textile_edit"] = isset($hak_tinymce_hide_on_textile_edit) ? $hak_tinymce_hide_on_textile_edit : "1";
         $hak_tinymce_prefs["body_init"] = isset($hak_tinymce_init_form) && $hak_tinymce_init_form != "hak_tinymce_default" ? fetch_form($hak_tinymce_init_form) : $hak_mceSettings_default;
         $hak_tinymce_prefs["body_init"] .= "\nheight:420,";
         $hak_tinymce_prefs["excerpt_init"] = $hak_mceSettings_default . "\nheight:150,";
         $hak_tinymce_prefs["callbacks"] = '';
         $hak_tinymce_prefs["tinymce_path"] = 'tiny_mce/tiny_mce.js';
         $hak_tinymce_prefs["hide_textile_select"] = '0';
         $hak_tinymce_prefs["enable_body"] = '1';
         $hak_tinymce_prefs["enable_excerpt"] = '1';
         // insert them into the new table
         foreach ($hak_tinymce_prefs as $key => $value) {
             safe_insert("txp_hak_tinymce", "pref_name='" . $key . "', pref_value='" . $value . "'");
         }
         // Run any necessary upgrades
         hak_tinymce::upgrade('0.0');
         // delete old prefs
         safe_delete("txp_prefs", "name='hak_tinymce_init_form'");
         safe_delete("txp_prefs", "name='hak_tinymce_show_toggle'");
         safe_delete("txp_prefs", "name='hak_tinymce_hide_on_textile_edit'");
     }
     return true;
 }
Esempio n. 5
0
function fox_code_form($atts, $thing)
{
    global $fox_code_prefs, $thisfile;
    extract(lAtts(array('fileid' => '', 'filename' => '', 'title' => '', 'height' => '400', 'language' => 'php', 'lines' => '1', 'startline' => '1', 'width' => '500', 'overallclass' => '', 'tabs' => '2', 'css' => '0', 'keywordslinks' => '0', 'encoding' => 'UTF-8', 'form' => 'fox_code_form', 'fromline' => '', 'toline' => ''), $atts));
    if ($fileid || $filename || $thing) {
        if (empty($thisfile)) {
            if ($fileid) {
                $thisfile = fileDownloadFetchInfo('id = ' . intval($fileid));
                $local_thisfile = true;
            } else {
                if ($filename) {
                    $thisfile = fileDownloadFetchInfo("filename = '" . $filename . "'");
                    $local_thisfile = true;
                }
            }
        }
        $fox_code_prefs['fileid'] = $fileid;
        $fox_code_prefs['filename'] = $filename;
        $fox_code_prefs['title'] = $title;
        $fox_code_prefs['height'] = $height;
        $fox_code_prefs['language'] = $language;
        $fox_code_prefs['lines'] = $lines;
        $fox_code_prefs['startline'] = $startline;
        $fox_code_prefs['width'] = $width;
        $fox_code_prefs['overallclass'] = $overallclass;
        $fox_code_prefs['tabs'] = $tabs;
        $fox_code_prefs['css'] = $css;
        $fox_code_prefs['keywordslinks'] = $keywordslinks;
        $fox_code_prefs['encoding'] = $encoding;
        $fox_code_prefs['fromline'] = $fromline;
        $fox_code_prefs['toline'] = $toline;
        if (strlen($fileid) == 0 && strlen($filename) == 0) {
            $fox_code_prefs['code'] = $thing;
        }
        if (!empty($thisfile)) {
            $fox_code_prefs['filename'] = $thisfile['filename'];
            $fox_code_prefs['fileid'] = $thisfile['id'];
        }
        if (!$title) {
            $fox_code_prefs['title'] = $thisfile['filename'] != '' ? $thisfile['filename'] : $language;
        }
        $form = fetch_form($form);
        $out = parse($form);
        $thisfile = $fox_code_prefs = NULL;
        return $out;
    }
}
Esempio n. 6
0
function doArticle($atts)
{
    global $pretext, $prefs, $thisarticle;
    extract($prefs);
    extract($pretext);
    extract(gpsa(array('parentid', 'preview')));
    extract(lAtts(array('allowoverride' => '1', 'form' => 'default', 'status' => '4'), $atts, 0));
    if ($status or empty($thisarticle) or $thisarticle['thisid'] != $id) {
        $thisarticle = NULL;
        if ($status and !is_numeric($status)) {
            $status = getStatusNum($status);
        }
        $q_status = $status ? 'and Status = ' . intval($status) : 'and Status in (4,5)';
        $rs = safe_row("*, unix_timestamp(Posted) as uPosted", "textpattern", 'ID = ' . intval($id) . " {$q_status} limit 1");
        if ($rs) {
            extract($rs);
            populateArticleData($rs);
        }
    }
    if (!empty($thisarticle)) {
        extract($thisarticle);
        $thisarticle['is_first'] = 1;
        $thisarticle['is_last'] = 1;
        $form = ($allowoverride and $override_form) ? $override_form : $form;
        // define the article form
        $article = fetch_form($form);
        $article = parse($article);
        if ($use_comments and $comments_auto_append) {
            $f = fetch_form('comments_display');
            $article .= parse($f);
        }
        unset($GLOBALS['thisarticle']);
        return $article;
    }
}
function peg_parse_form_recursively($name)
{
    $f = fetch_form($name);
    if ($f) {
        // array_push($stack, $name);
        $out = parse($f);
        // array_pop($stack);
        return $out;
    }
}
/**
 * Process self-edit submission, returns success message or error
 **/
function ign_update_self($atts)
{
    global $ign_user, $ign_user_db;
    //process incoming post variables here
    $new_pass = gps('new_pass');
    $confirm_pass = gps('confirm_pass');
    $email_pass = gps('email_pass');
    $use_form = @fetch_form($form);
    if (empty($use_form) || $use_form == "<p>form <strong>{$form}</strong> does not exist</p>") {
        $use_form = ign_default_form('self_edit');
    }
    if ($new_pass != $confirm_pass) {
        return "<span class='pass_error'>The supplied passwords do not match.</span>" . $use_form;
    }
    if (empty($new_pass)) {
        return "<span class='pass_error'>Password field cannot be blank.</span>" . $use_form;
    }
    $r = safe_update('ign_users', "pass = password('{$new_pass}')", "name = '{$ign_user}'");
    if ($r) {
        if ($email_pass) {
            $themail = fetch('email', $ign_user_db, 'name', $ign_user);
            list(, , $name, ) = ign_getCookie();
            $stuff = ign_sendNewPassword($new_pass, $themail, $name);
            // return 'Password updated successfully!';
        }
        return 'Password updated successfully!';
    } else {
        return 'Error encountered. Password not updated.';
    }
}
Esempio n. 9
0
function mem_form($atts, $thing = '')
{
    global $sitename, $prefs, $file_max_upload_size, $mem_form_error, $mem_form_submit, $mem_form, $mem_form_labels, $mem_form_values, $mem_form_default, $mem_form_type, $mem_form_thanks_form, $mem_glz_custom_fields_plugin;
    extract(mem_form_lAtts(array('form' => '', 'thanks_form' => '', 'thanks' => graf(mem_form_gTxt('submitted_thanks')), 'label' => '', 'type' => '', 'redirect' => '', 'redirect_form' => '', 'class' => 'memForm', 'file_accept' => '', 'max_file_size' => $file_max_upload_size, 'form_expired_msg' => mem_form_gTxt('form_expired'), 'show_error' => 1, 'show_input' => 1), $atts));
    if (empty($type) or empty($form) && empty($thing)) {
        trigger_error('Argument not specified for mem_form tag', E_USER_WARNING);
        return '';
    }
    $out = '';
    $mem_form_type = $type;
    $mem_form_default = array();
    callback_event('mem_form.defaults');
    unset($atts['show_error'], $atts['show_input']);
    $mem_form_id = md5(serialize($atts) . preg_replace('/[\\t\\s\\r\\n]/', '', $thing));
    $mem_form_submit = ps('mem_form_id') == $mem_form_id;
    $nonce = doSlash(ps('mem_form_nonce'));
    $renonce = false;
    if ($mem_form_submit) {
        safe_delete('txp_discuss_nonce', 'issue_time < date_sub(now(), interval 10 minute)');
        if ($rs = safe_row('used', 'txp_discuss_nonce', "nonce = '{$nonce}'")) {
            if ($rs['used']) {
                unset($mem_form_error);
                $mem_form_error[] = mem_form_gTxt('form_used');
                $renonce = true;
                $_POST['mem_form_submit'] = TRUE;
                $_POST['mem_form_id'] = $mem_form_id;
                $_POST['mem_form_nonce'] = $nonce;
            }
        } else {
            $mem_form_error[] = $form_expired_msg;
            $renonce = true;
        }
    }
    if ($mem_form_submit and $nonce and !$renonce) {
        $mem_form_nonce = $nonce;
    } elseif (!$show_error or $show_input) {
        $mem_form_nonce = md5(uniqid(rand(), true));
        safe_insert('txp_discuss_nonce', "issue_time = now(), nonce = '{$mem_form_nonce}'");
    }
    $form = $form ? fetch_form($form) : $thing;
    $form = parse($form);
    if (!$mem_form_submit) {
        # don't show errors or send mail
    } elseif (mem_form_error()) {
        if ($show_error or !$show_input) {
            $out .= mem_form_display_error();
            if (!$show_input) {
                return $out;
            }
        }
    } elseif ($show_input and is_array($mem_form)) {
        if ($mem_glz_custom_fields_plugin) {
            // prep the values
            glz_custom_fields_before_save();
        }
        callback_event('mem_form.spam');
        /// load and check spam plugins/
        $evaluator =& get_mem_form_evaluator();
        $is_spam = $evaluator->is_spam();
        if ($is_spam) {
            return mem_form_gTxt('spam');
        }
        $mem_form_thanks_form = $thanks_form ? fetch_form($thanks_form) : $thanks;
        safe_update('txp_discuss_nonce', "used = '1', issue_time = now()", "nonce = '{$nonce}'");
        $result = callback_event('mem_form.submit');
        if (mem_form_error()) {
            $out .= mem_form_display_error();
            $redirect = false;
        }
        $thanks_form = $mem_form_thanks_form;
        unset($mem_form_thanks_form);
        if (!empty($result)) {
            return $result;
        }
        if (mem_form_error() and $show_input) {
            // no-op, reshow form with errors
        } else {
            if ($redirect) {
                $_POST = array();
                while (@ob_end_clean()) {
                }
                $uri = hu . ltrim($redirect, '/');
                if (empty($_SERVER['FCGI_ROLE']) and empty($_ENV['FCGI_ROLE'])) {
                    txp_status_header('303 See Other');
                    header('Location: ' . $uri);
                    header('Connection: close');
                    header('Content-Length: 0');
                } else {
                    $uri = htmlspecialchars($uri);
                    $refresh = mem_form_gTxt('refresh');
                    if (!empty($redirect_form)) {
                        $redirect_form = fetch_form($redirect_form);
                        echo str_replace('{uri}', $uri, $redirect_form);
                    }
                    if (empty($redirect_form)) {
                        echo <<<END
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
\t<title>{$sitename}</title>
\t<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\t<meta http-equiv="refresh" content="0;url={$uri}" />
</head>
<body>
<a href="{$uri}">{$refresh}</a>
</body>
</html>
END;
                    }
                }
                exit;
            } else {
                return '<div class="memThanks" id="mem' . $mem_form_id . '">' . $thanks_form . '</div>';
            }
        }
    }
    if ($show_input) {
        $file_accept = !empty($file_accept) ? ' accept="' . $file_accept . '"' : '';
        $class = htmlspecialchars($class);
        return '<form method="post"' . ((!$show_error and $mem_form_error) ? '' : ' id="mem' . $mem_form_id . '"') . ' class="' . $class . '" action="' . htmlspecialchars(serverSet('REQUEST_URI')) . '#mem' . $mem_form_id . '"' . $file_accept . '>' . ($label ? n . '<fieldset>' : n . '<div>') . ($label ? n . '<legend>' . htmlspecialchars($label) . '</legend>' : '') . $out . n . '<input type="hidden" name="mem_form_nonce" value="' . $mem_form_nonce . '" />' . n . '<input type="hidden" name="mem_form_id" value="' . $mem_form_id . '" />' . (!empty($max_file_size) ? n . '<input type="hidden" name="MAX_FILE_SIZE" value="' . $max_file_size . '" />' : '') . callback_event('mem_form.display', '', 1) . $form . callback_event('mem_form.display') . ($label ? n . '</fieldset>' : n . '</div>') . n . '</form>';
    }
    return '';
}
Esempio n. 10
0
function sed_pcf_for_each_value($atts, $thing)
{
    global $thisarticle;
    assert_article();
    $def_custom_name = 'custom1';
    extract($merged = lAtts(array('debug' => 0, 'name' => $def_custom_name, 'id' => '', 'form' => '', 'label' => '', 'labeltag' => '', 'wraptag' => 'ul', 'break' => 'li', 'class' => ''), $atts));
    if ($debug) {
        echo dmp($merged);
    }
    $field = @$thisarticle[$name];
    if (empty($field)) {
        if ($debug) {
            echo "Returning early - nothing to do in CF[{$name}].";
        }
        return '';
    }
    if (empty($class)) {
        $class = $name;
    }
    if (!empty($form)) {
        # grab the form (if any)
        $thing = fetch_form($form);
    }
    if (empty($thing)) {
        # if no form, and no enclosed thing, use built-in formula...
        $thing = '{value}';
    }
    $out = array();
    $field = do_list($field);
    foreach ($field as $value) {
        $out[] = parse(str_replace('{value}', $value, $thing));
    }
    return doLabel($label, $labeltag) . doWrap($out, $wraptag, $break, $class, '', '', '', $id);
}
Esempio n. 11
0
/**
 * Main atb_twitter txp:tag.
 */
function atb_twitter($atts, $thing)
{
    global $atb_thistweet;
    extract(lAtts(array('user' => '', 'count' => 5, 'cache' => 15, 'form' => '', 'api_base' => '', 'site_base' => 'twitter.com', 'update_lastmod' => 1), $atts));
    //Generate a hash of the attributes to use as a cache file ID.
    $hash = md5(implode($atts + array($thing)));
    //If there's cached output for this request, just return it.
    if ($outp = atb_get_tweet_cache($hash, $cache * 60)) {
        return $outp;
    }
    $template = $thing ? $thing : fetch_form($form);
    if (!$template) {
        //Nothing to do.
        return '';
    }
    if (!$site_base) {
        if ($api_base === '') {
            $api_base = 'api.twitter.com/1';
            $site_base = 'twitter.com';
        } else {
            $api_base = trim($api_base, '/ ');
            $site_base .= preg_replace('/(\\/api$)/', '', $api_base);
        }
    } elseif ('twitter.com' === $site_base) {
        $api_base = 'api.twitter.com/1';
    } elseif (!$api_base) {
        $api_base = $site_base . '/api';
    }
    $tweets = atb_get_tweets($user, $count, $api_base);
    if (!$tweets) {
        //Probable fail whale. Try using an old, outdated cache file
        //(so at least we'll have *some* content).
        $outp = atb_get_tweet_cache($hash, 0);
        return $outp ? $outp : '';
    }
    //Update Textpattern's last-modified date.
    if ($update_lastmod) {
        $currentmod = strtotime(get_pref('lastmod', false));
        $twitmod = $tweets->xpath('//status/created_at');
        $twitmod = (string) $twitmod[0];
        $twitmod = strtotime($twitmod);
        if ($currentmod && $currentmod < $twitmod) {
            set_pref('lastmod', strftime('%F %H:%M:%S', $twitmod));
        }
    }
    $tweets = $tweets->xpath('//status');
    $outp = '';
    foreach ($tweets as $twindex => $atb_thistweet) {
        $atb_thistweet->addAttribute('index', $twindex + 1);
        $atb_thistweet->addAttribute('total', count($tweets));
        $atb_thistweet->addAttribute('site_base', $site_base);
        $atb_thistweet->addAttribute('source', 'twitter.com' === $site_base ? 'twitter' : 'statusnet');
        $outp .= parse($template);
    }
    atb_put_tweet_cache($hash, $outp);
    return $outp;
}
Esempio n. 12
0
/**
 * Parses a form template.
 *
 * @param   string $name The form
 * @return  string The parsed contents
 * @package TagParser
 */
function parse_form($name)
{
    global $txp_current_form;
    static $stack = array();
    $out = '';
    $name = (string) $name;
    $f = fetch_form($name);
    if ($f) {
        if (in_array($name, $stack, true)) {
            trigger_error(gTxt('form_circular_reference', array('{name}' => $name)));
            return '';
        }
        $old_form = $txp_current_form;
        $txp_current_form = $stack[] = $name;
        trace_add("[Nesting forms: '" . join("' / '", $stack) . "']");
        $out = parse($f);
        $txp_current_form = $old_form;
        array_pop($stack);
    }
    return $out;
}
function mem_profile($atts, $body = '')
{
    global $mem_profile, $txp_user, $ign_user;
    if (isset($ign_user)) {
        $txp_user = $ign_user;
    }
    extract(lAtts(array('user' => '', 'userid' => '', 'var' => 'RealName', 'form' => ''), $atts));
    if (empty($user) && empty($userid)) {
        // use the old method
        if (!is_array($mem_profile) && $txp_user) {
            $mem_profile = safe_row('*', mem_get_user_table_name(), "name = '" . doSlash($txp_user) . "'");
        }
    } else {
        $mem_profile = is_array($mem_profile) ? $mem_profile : array();
        // look up a potentially new user
        if (!empty($user)) {
            if (!array_key_exists('name', $mem_profile) || strcmp($mem_profile['name'], $user) != 0) {
                $mem_profile = safe_row('*', mem_get_user_table_name(), "name = '" . doSlash($user) . "'");
            }
        }
        if (!empty($userid) && is_numeric($userid)) {
            if (!array_key_exists('user_id', $mem_profile) || strcmp($mem_profile['user_id'], $userid) != 0) {
                $mem_profile = safe_row('*', mem_get_user_table_name(), "user_id = " . doSlash($userid));
            }
        }
    }
    $out = '';
    if (empty($form) && empty($body)) {
        if ($mem_profile) {
            $out = array_key_exists($var, $mem_profile) ? $mem_profile[$var] : '';
        }
    } else {
        $thing = empty($body) ? fetch_form($form) : $body;
        $out = parse(EvalElse($thing, !empty($mem_profile)));
    }
    return $out;
}
Esempio n. 14
0
function search_input($atts)
{
    global $q, $permlink_mode, $doctype;
    extract(lAtts(array('form' => 'search_input', 'wraptag' => 'p', 'class' => __FUNCTION__, 'size' => '15', 'html_id' => '', 'label' => gTxt('search'), 'button' => '', 'section' => '', 'match' => 'exact'), $atts));
    if ($form and !array_diff_key($atts, array('form' => true))) {
        $rs = fetch_form($form);
        if ($rs) {
            return parse($rs);
        }
    }
    $h5 = $doctype == 'html5';
    $sub = !empty($button) ? '<input type="submit" value="' . txpspecialchars($button) . '" />' : '';
    $id = !empty($html_id) ? ' id="' . txpspecialchars($html_id) . '"' : '';
    $out = fInput($h5 ? 'search' : 'text', 'q', $q, '', '', '', $size, '', '', false, $h5);
    $out = !empty($label) ? txpspecialchars($label) . br . $out . $sub : $out . $sub;
    $out = $match === 'exact' ? $out : fInput('hidden', 'm', txpspecialchars($match)) . $out;
    $out = $wraptag ? doTag($out, $wraptag, $class) : $out;
    if (!$section) {
        return '<form method="get" action="' . hu . '"' . $id . '>' . n . $out . n . '</form>';
    }
    if ($permlink_mode != 'messy') {
        return '<form method="get" action="' . pagelinkurl(array('s' => $section)) . '"' . $id . '>' . n . $out . n . '</form>';
    }
    return '<form method="get" action="' . hu . '"' . $id . '>' . n . hInput('s', $section) . n . $out . n . '</form>';
}
Esempio n. 15
0
function parse_form($name)
{
    global $txp_current_form;
    static $stack = array();
    $f = fetch_form($name);
    if ($f) {
        if (in_array($name, $stack)) {
            trigger_error(gTxt('form_circular_reference', array('{name}' => $name)));
            return;
        }
        $old_form = $txp_current_form;
        $txp_current_form = $stack[] = $name;
        $out = parse($f);
        $txp_current_form = $old_form;
        array_pop($stack);
        return $out;
    }
}
Esempio n. 16
0
function popComments($id)
{
    global $sitename, $s, $thisarticle;
    $preview = gps('preview');
    $h3 = $preview ? hed(gTxt('message_preview'), 3) : '';
    $discuss = discuss($id);
    ob_start('parse');
    $out = fetch_form('popup_comments');
    $out = str_replace("<txp:popup_comments />", $discuss, $out);
    return $out;
}
Esempio n. 17
0
function file_download($atts)
{
    global $thisfile;
    extract(lAtts(array('filename' => '', 'form' => 'files', 'id' => ''), $atts));
    if (empty($thisfile)) {
        if ($id) {
            $thisfile = fileDownloadFetchInfo('id = ' . intval($id));
        } elseif ($filename) {
            $thisfile = fileDownloadFetchInfo("filename = '" . doSlash($filename) . "'");
        }
    }
    if ($thisfile) {
        $form = fetch_form($form);
        $out = parse($form);
        unset($thisfile);
        return $out;
    }
}
Esempio n. 18
0
function parse_form($name)
{
    static $stack = array();
    $f = fetch_form($name);
    if ($f) {
        if (in_array($name, $stack)) {
            trigger_error(gTxt('form_circular_reference', array('{name}' => $name)));
            return;
        }
        array_push($stack, $name);
        $out = parse($f);
        array_pop($stack);
        return $out;
    }
}
Esempio n. 19
0
function zem_event_available_locations()
{
    $form = @fetch_form('zem_event_locations');
    // prepare form for use
    $form = str_replace(array("\r\n", "\r"), "\n", $form);
    $list = explode("\n", $form);
    $available_locations = array();
    foreach ($list as $key => $val) {
        $location = explode('=', $val);
        // only add to the list if both a name and title were supplied
        if ($location[0] and $location[1]) {
            list($name, $title) = doArray($location, 'trim');
            $available_locations[$name] = $title;
        }
    }
    return $available_locations;
}