/** * Adds a new node. * * @param mixed $data Array of field => value pairs which define the record. * @param array Array of options for the content being created. * Understands skipTransaction, skipFloodCheck, floodchecktime, skipDupCheck, skipNotification, nl2br, autoparselinks. * - nl2br: if TRUE, all \n will be converted to <br /> so that it's not removed by the html parser (e.g. comments). * - wysiwyg: if true convert html to bbcode. Defaults to true if not given. * * @throws vB_Exception_Api * * @return integer the new nodeid */ public function add($data, $options = array()) { $vboptions = vB::getDatastore()->getValue('options'); if (!empty($data['pagetext'])) { $strlen = vB_String::vbStrlen($this->library->parseAndStrip($data['pagetext']), true); if ($strlen < $vboptions['postminchars']) { throw new vB_Exception_Api('please_enter_message_x_chars', $vboptions['postminchars']); } if ($vboptions['postmaxchars'] != 0 and $strlen > $vboptions['postmaxchars']) { throw new vB_Exception_Api('maxchars_exceeded_x_y', array($vboptions['postmaxchars'], $strlen)); } } else { if (!empty($data['rawtext'])) { $strlen = vB_String::vbStrlen($this->library->parseAndStrip($data['rawtext']), true); if ($strlen < $vboptions['postminchars']) { throw new vB_Exception_Api('please_enter_message_x_chars', $vboptions['postminchars']); } if ($vboptions['postmaxchars'] != 0 and $strlen > $vboptions['postmaxchars']) { throw new vB_Exception_Api('maxchars_exceeded_x_y', array($vboptions['postmaxchars'], $strlen)); } } else { throw new vB_Exception_Api('invalid_data'); } } $this->cleanInput($data); $this->cleanOptions($options); $wysiwyg = true; if (isset($options['wysiwyg'])) { $wysiwyg = (bool) $options['wysiwyg']; } $result = $this->library->add($data, $options, $wysiwyg); return $result['nodeid']; }
protected function buildOutputFromItems($items, $options) { parent::buildOutputFromItems($items, $options); $xml = new vB_Xml_Builder(); $xml->add_group('rss', array('version' => '0.91')); $xml->add_group('channel'); $xml->add_tag('title', $this->rssinfo['title']); $xml->add_tag('link', $this->rssinfo['link'] . '/', array(), false, true); $xml->add_tag('description', $this->rssinfo['description']); $xml->add_tag('language', $this->defaultLang['languagecode']); $xml->add_group('image'); $xml->add_tag('url', $this->rssinfo['icon']); $xml->add_tag('title', $this->rssinfo['title']); $xml->add_tag('link', $this->rssinfo['link'] . '/', array(), false, true); $xml->close_group('image'); $dateformat = vB::getDatastore()->getOption('dateformat'); $timeformat = vB::getDatastore()->getOption('timeformat'); // gather channel info $channelsInfo = $this->getItemsChannelInfo($items); $items = $this->formatItems($items, $options); foreach ($items as $id => $item) { $item = $item['content']; $xml->add_group('item'); $xml->add_tag('title', $item['external_prefix_plain'] . vB_String::htmlSpecialCharsUni($item['external_title'])); $xml->add_tag('link', vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['external_nodeid']), array(), false, true); $xml->add_tag('description', vB_Phrase::fetchSinglePhrase('rss_91_forum_w_posted_by_x_post_time_y_at_z', array($channelsInfo[$item['channelid']]['htmltitle'], $item['authorname'], $this->callvBDate($dateformat, $item['publishdate']), $this->callvBDate($timeformat, $item['publishdate'])))); $xml->close_group('item'); } $xml->close_group('channel'); $xml->close_group('rss'); $output .= '<!DOCTYPE rss PUBLIC "-//RSS Advisory Board//DTD RSS 0.91//EN" "http://www.rssboard.org/rss-0.91.dtd">' . "\r\n"; $output .= $xml->output(); return $xml->fetch_xml_tag() . $output; }
public function call($forumid, $perpage = 20, $pagenumber = 1) { $contenttype = vB_Api::instance('contenttype')->fetchContentTypeIdFromClass('Channel'); $forum = vB_Api::instance('node')->getNodeFullContent($forumid); if (empty($forum) or isset($forum['errors'])) { return array("response" => array("errormessage" => array("invalidid"))); } $forum = $forum[$forumid]; $modPerms = vB::getUserContext()->getModeratorPerms($forum); $foruminfo = array('forumid' => $forum['nodeid'], 'title' => vB_String::unHtmlSpecialChars($forum['title']), 'description' => $forum['description'], 'title_clean' => $forum['htmltitle'], 'description_clean' => strip_tags($forum['description']), 'prefixrequired' => 0); $nodes = vB_Api::instance('node')->fetchChannelNodeTree($forumid, 3); $channels = array(); if (!empty($nodes) and empty($nodes['errors']) and isset($nodes['channels']) and !empty($nodes['channels'])) { foreach ($nodes['channels'] as $node) { $channels[] = vB_Library::instance('vb4_functions')->parseForum($node); } } $forumbits = $channels; $topics = array(); $topics_sticky = array(); $page_nav = vB_Library::instance('vb4_functions')->pageNav(1, $perpage, 1); $search = array("channel" => $forumid); $search['view'] = vB_Api_Search::FILTER_VIEW_TOPIC; $search['depth'] = 1; $search['include_sticky'] = true; $search['sort']['lastcontent'] = 'desc'; $search['nolimit'] = 1; $topic_search = vB_Api::instanceInternal('search')->getInitialResults($search, $perpage, $pagenumber, true); if (!isset($topic_search['errors']) and !empty($topic_search['results'])) { $topic_search['results'] = vB_Api::instance('node')->mergeNodeviewsForTopics($topic_search['results']); foreach ($topic_search['results'] as $key => $node) { if ($node['content']['contenttypeclass'] == 'Channel' or $node['content']['starter'] != $node['content']['nodeid']) { unset($topic_search['results'][$key]); } else { $topic = vB_Library::instance('vb4_functions')->parseThread($node); if ($topic['thread']['sticky']) { $topics_sticky[] = $topic; } else { $topics[] = $topic; } } } $page_nav = vB_Library::instance('vb4_functions')->pageNav($topic_search['pagenumber'], $perpage, $topic_search['totalRecords']); } $inlinemod = $forum['canmoderate'] ? 1 : 0; $subscribed = vB_Api::instance('follow')->isFollowingContent($forum['nodeid']); $subscribed = $subscribed ? 1 : 0; $forumsearch = vB::getUserContext()->hasPermission('forumpermissions', 'cansearch'); $response = array(); $response['response']['forumbits'] = $forumbits; $response['response']['foruminfo'] = $foruminfo; $response['response']['threadbits'] = $topics; $response['response']['threadbits_sticky'] = $topics_sticky; $response['response']['pagenav'] = $page_nav; $response['response']['pagenumber'] = intval($pagenumber); $response['show'] = array('subscribed_to_forum' => $subscribed, 'inlinemod' => $inlinemod, 'spamctrls' => $modPerms['candeleteposts'] > 0 ? 1 : 0, 'openthread' => $modPerms['canopenclose'] > 0 ? 1 : 0, 'approvethread' => $modPerms['canmoderateposts'] > 0 ? 1 : 0, 'movethread' => $modPerms['canmassmove'] > 0 ? 1 : 0, 'forumsearch' => $forumsearch, 'stickies' => count($topics_sticky) > 0 ? 1 : 0); return $response; }
public function getUrl() { // the regex contains the url $url = '/' . $this->prefix . '/' . $this->arguments['tab']; if (strtolower(vB_String::getCharset()) != 'utf-8') { $url = vB_String::encodeUtf8Url($url); } return $url; }
public function getUrl() { $bburl = vB::getDatastore()->getOption('bburl'); $url = $bburl . '/' . $this->prefix . '/' . $this->arguments['file'] . '.php'; if (strtolower(vB_String::getCharset()) != 'utf-8') { $url = vB_String::encodeUtf8Url($url); } return $url; }
protected function buildOutputFromItems($items, $options) { parent::buildOutputFromItems($items, $options); if ($this->rssinfo['ttl'] <= 60) { $updateperiod = 'hourly'; $updatefrequency = round(60 / $this->rssinfo['ttl']); } else { $updateperiod = 'daily'; $updatefrequency = round(1440 / $this->rssinfo['ttl']); } $xml = new vB_Xml_Builder(); $xml->add_group('rdf:RDF', array('xmlns:rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:syn' => 'http://purl.org/rss/1.0/modules/syndication/', 'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/', 'xmlns' => 'http://purl.org/rss/1.0/')); $xml->add_group('channel', array('rdf:about' => $this->rssinfo['link'])); $xml->add_tag('title', $this->rssinfo['title']); $xml->add_tag('link', $this->rssinfo['link'] . '/', array(), false, true); $xml->add_tag('description', $this->rssinfo['description']); $xml->add_tag('syn:updatePeriod', $updateperiod); $xml->add_tag('syn:updateFrequency', $updatefrequency); $xml->add_tag('syn:updateBase', '1970-01-01T00:00Z'); $xml->add_tag('dc:language', $this->defaultLang['languagecode']); $xml->add_tag('dc:creator', 'vBulletin'); $xml->add_tag('dc:date', gmdate('Y-m-d\\TH:i:s') . 'Z'); $xml->add_group('items'); $xml->add_group('rdf:Seq'); $xml->add_tag('rdf:li', '', array('rdf:resource' => $this->rssinfo['link'] . '/')); $xml->close_group('rdf:Seq'); $xml->close_group('items'); $xml->add_group('image'); $xml->add_tag('url', $this->rssinfo['icon']); $xml->add_tag('title', $this->rssinfo['title']); $xml->add_tag('link', $this->rssinfo['link'] . '/', array(), false, true); $xml->close_group('image'); $xml->close_group('channel'); // gather channel info $channelsInfo = $this->getItemsChannelInfo($items); $items = $this->formatItems($items, $options); foreach ($items as $id => $item) { $item = $item['content']; $xml->add_group('item', array('rdf:about' => vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['external_nodeid']))); $xml->add_tag('title', $item['external_prefix_plain'] . vB_String::htmlSpecialCharsUni($item['external_title'])); $xml->add_tag('link', vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['external_nodeid']), array(), false, true); $xml->add_tag('description', $this->getItemDescription($item['rawtext'], $options)); if (empty($options['nohtml'])) { $xml->add_tag('content:encoded', vB_Library::instance('bbcode')->doParse($item['rawtext'])); } $xml->add_tag('dc:date', gmdate('Y-m-d\\TH:i:s', $item['publishdate']) . 'Z'); $xml->add_tag('dc:creator', vB_String::unHtmlSpecialChars($item['authorname'])); $xml->add_tag('dc:subject', $channelsInfo[$item['channelid']]['htmltitle']); $xml->close_group('item'); } $xml->close_group('rdf:RDF'); return $xml->fetch_xml(); }
public function getUrl() { //bburl isn't correct as it will create a link to core rather than admincp. This happens to work //for admincp for the time being, but is the wrong url. // $bburl = vB::getDatastore()->getOption('bburl'); // return $bburl . '/' . $this->prefix . '/' . $this->arguments['file'] . '.php'; //user the header hack instead. $url = vB::getDatastore()->getOption('frontendurl') . '/' . $this->prefix . '/' . $this->arguments['file'] . '.php'; if (strtolower(vB_String::getCharset()) != 'utf-8') { $url = vB_String::encodeUtf8Url($url); } return $url; }
protected function buildOutputFromItems($items, $options) { $output = $this->threadObj; $output .= "var threads = new Array(" . sizeof($items) . ");\r\n"; $itemnum = 0; $items = $this->formatItems($items, $options); foreach ($items as $item) { $item = $item['content']; $item['title'] = vB_Library_Functions::addSlashesJs(vB_String::htmlSpecialCharsUni($item['external_prefix_plain']) . $item['external_title']); $item['authorname'] = vB_Library_Functions::addSlashesJs($item['authorname']); $output .= "\tthreads[{$itemnum}] = new thread({$item['external_nodeid']}, '{$item['title']}', '{$item['authorname']}', '" . vB_Library_Functions::addSlashesJs($this->callvBDate(vB::getDatastore()->getOption('dateformat'), $item['publishdate'])) . "', '" . vB_Library_Functions::addSlashesJs($this->callvBDate(vB::getDatastore()->getOption('timeformat'), $item['publishdate'])) . "');\r\n"; $itemnum++; } return $output; }
public function getUrl() { if (empty($this->arguments['username'])) { $userInfo = vB_Api::instanceInternal('user')->fetchProfileInfo($this->arguments['userid']); $this->arguments['username'] = $userInfo['username']; } // the regex contains the url $url = '/' . $this->prefix . '/' . $this->arguments['userid'] . '-' . vB_String::getUrlIdent($this->arguments['username']) . '/' . $this->arguments['tab']; if (isset($this->arguments['pagenum']) and is_numeric($this->arguments['pagenum']) and $this->arguments['pagenum'] > 1) { $url .= '/page' . intval($this->arguments['pagenum']); } if (strtolower(vB_String::getCharset()) != 'utf-8') { $url = vB_String::encodeUtf8Url($url); } return $url; }
protected function buildOutputFromItems($items, $options) { $xml = new vB_XML_Builder(); $xml->add_group('source'); $xml->add_tag('url', vB::getDatastore()->getOption('frontendurl') . '/'); $items = $this->formatItems($items, $options); foreach ($items as $id => $item) { $item = $item['content']; $xml->add_group('thread', array('id' => $item['external_nodeid'])); $xml->add_tag('title', $item['external_prefix_plain'] . vB_String::unHtmlSpecialChars($item['external_title'])); $xml->add_tag('author', vB_String::unHtmlSpecialChars($item['authorname'])); $xml->add_tag('date', $this->callvBDate(vB::getDatastore()->getOption('dateformat'), $item['publishdate'])); $xml->add_tag('time', $this->callvBDate(vB::getDatastore()->getOption('timeformat'), $item['publishdate'])); $xml->close_group('thread'); } $xml->close_group('source'); return $xml->fetch_xml(); }
public function getUrl() { $cache = vB_Cache::instance(vB_Cache::CACHE_FAST); $hashKey = 'vbRouteURLIndent_' . $this->arguments['nodeid']; $urlident = $cache->read($hashKey); if (empty($urlident)) { $node = vB_Library::instance('node')->getNodeBare($this->arguments['nodeid']); $urlident = $node['urlident']; $cache->write($hashKey, $urlident); } elseif (is_array($urlident) and !empty($urlident['urlident'])) { $urlident = $urlident['urlident']; } $url = '/album/' . $this->arguments['nodeid'] . '-' . $urlident; if (strtolower(vB_String::getCharset()) != 'utf-8') { $url = vB_String::encodeUtf8Url($url); } return $url; }
function construct_nav_option($title, $url) { // creates an <option> or <a href for the left-panel of index.php // (depending on value of $cpnavjs) // NOTE: '&' . vB::getCurrentSession()->get('sessionurl') will be AUTOMATICALLY added to the URL - do not add to your link! global $options; static $sessionlink = ''; $url_query = vB_String::parseUrl($url, PHP_URL_QUERY); if (!isset($options)) { $options = array(); if (vB::getCurrentSession()->get('sessionurl') == '') { $sessionlink = ''; } else { $sessionlink = "s=" . vB::getCurrentSession()->get('sessionhash'); } } $url .= empty($url_query) ? '?' : '&'; $options[] = "\t\t<a class=\"navlink\" href=\"{$url}{$sessionlink}\">{$title}</a>\n"; }
/** * Returns a hierarchical array of smilie data for displaying the smilies panel. * * @return array The smilies */ public function fetchAllSmilies() { $smilies = vB::get_db_assertor()->getRows('vBForum:fetchImagesSortedLimited', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_METHOD, 'table' => 'smilie')); $options = vB::getDatastore()->get_value('options'); $smilieInfo = array(); $previewSmilies = array(); $previewCount = 0; $smilieCount = 0; foreach ($smilies as $smilie) { if (!isset($smilieInfo[$smilie['category']])) { $smilieInfo[$smilie['category']] = array(); } $smilieInfo[$smilie['category']][$smilie['smilieid']] = array('image' => $smilie['smiliepath'], 'description' => vB_String::htmlSpecialCharsUni($smilie['title'] . ' ' . $smilie['smilietext'])); ++$smilieCount; if ($previewCount < $options['wysiwyg_smtotal']) { $previewSmilies[$smilie['smilieid']] = $smilieInfo[$smilie['category']][$smilie['smilieid']]; } ++$previewCount; } return array('categories' => $smilieInfo, 'previewSmilies' => $previewSmilies, 'categoryCount' => count($smilieInfo), 'smilieCount' => $smilieCount, 'previewCount' => count($previewSmilies), 'moreSmilies' => $smilieCount > count($previewSmilies)); }
protected function buildOutputFromItems($items, $options) { parent::buildOutputFromItems($items, $options); $xml = new vB_Xml_Builder(); $xml->add_group('rss', array('version' => '2.0', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/')); $xml->add_group('channel'); $xml->add_tag('title', $this->rssinfo['title']); $xml->add_tag('link', $this->rssinfo['link'] . '/', array(), false, true); $xml->add_tag('description', $this->rssinfo['description']); $xml->add_tag('language', $this->defaultLang['languagecode']); $xml->add_tag('lastBuildDate', gmdate('D, d M Y H:i:s') . ' GMT'); $xml->add_tag('generator', 'vBulletin'); $xml->add_tag('ttl', $this->rssinfo['ttl']); $xml->add_group('image'); $xml->add_tag('url', $this->rssinfo['icon']); $xml->add_tag('title', $this->rssinfo['title']); $xml->add_tag('link', $this->rssinfo['link'] . '/', array(), false, true); $xml->close_group('image'); // gather channel info $channelsInfo = $this->getItemsChannelInfo($items); $items = $this->formatItems($items, $options); foreach ($items as $id => $item) { $item = $item['content']; $xml->add_group('item'); $xml->add_tag('title', $item['external_prefix_plain'] . vB_String::htmlSpecialCharsUni($item['external_title'])); $xml->add_tag('link', vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['external_nodeid']), array(), false, true); $xml->add_tag('pubDate', gmdate('D, d M Y H:i:s', $item['publishdate']) . ' GMT'); $xml->add_tag('description', $this->getItemDescription($item['rawtext'], $options)); if (empty($options['nohtml'])) { $xml->add_tag('content:encoded', vB_Library::instance('bbcode')->doParse($item['rawtext'])); } $xml->add_tag('category', $channelsInfo[$item['channelid']]['htmltitle'], array('domain' => vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['channelid']))); $xml->add_tag('dc:creator', vB_String::unHtmlSpecialChars($item['authorname'])); $xml->add_tag('guid', vB_Api::instanceInternal('route')->getAbsoluteNodeUrl($item['external_nodeid']), array('isPermaLink' => 'true')); $xml->close_group('item'); } $xml->close_group('channel'); $xml->close_group('rss'); return $xml->fetch_xml(); }
function admin_login_error($error, array $args = array()) { global $vbulletin; if ($vbulletin->GPC['logintype'] === 'cplogin' or $vbulletin->GPC['logintype'] === 'modcplogin') { require_once DIR . '/includes/adminfunctions.php'; $url = unhtmlspecialchars($vbulletin->url); $urlarr = vB_String::parseUrl($url); $urlquery = $urlarr['query']; $oldargs = array(); if ($urlquery) { parse_str($urlquery, $oldargs); } $args = array_merge($oldargs, $args); unset($args['loginerror']); $argstr = http_build_query($args); $url = "/{$urlarr['path']}?loginerror=" . $error; if ($argstr) { $url .= '&' . $argstr; } print_cp_redirect($url); } }
public function getUrl() { $url = "/{$this->prefix}/" . $this->actionInternal . $this->actionClass->getUrlParameters(); if (strtolower(vB_String::getCharset()) != 'utf-8') { $url = vB_String::encodeUtf8Url($url); } return $url; }
/** * Fetches the path for the current request relative to the basepath. * This is useful for local anchors (<a href="{vb:raw relpath}#post">). * * Substracts any overlap between basepath and path with the following results: * * base: http://www.example.com/forums/ * path: /forums/content.php * result: content.php * * base: http://www.example.com/forums/admincp * path: /forums/content/1-Article * result: ../content/1-Article * * @return string */ function fetch_relpath($path = false) { if (!$path and (isset($this->registry->relpath) and $this->registry->relpath != '')) { return $this->registry->relpath; } // if no path specified, use the request path if (!$path) { if ($_SERVER['REQUEST_METHOD'] == 'POST' and isset($_SERVER['HTTP_X_REQUESTED_WITH']) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' and !empty($_POST['relpath'])) { $relpath = $_POST['relpath']; $query = ''; } else { $relpath = VB_URL_PATH; $query = VB_URL_QUERY; $fragment = ""; } } else { // if the path is already absolute there's nothing to do if (strpos($path, '://')) { return $path; } if (!$path) { return $path; } $relpath = vB_String::parseUrl($path, PHP_URL_PATH); $query = vB_String::parseUrl($path, PHP_URL_QUERY); $fragment = vB_String::parseUrl($path, PHP_URL_FRAGMENT); } $relpath = ltrim($relpath, '/'); $basepath = @vB_String::parseUrl($this->fetch_basepath(), PHP_URL_PATH); $basepath = trim($basepath, '/'); // get path segments for comparison $relpath = explode('/', $relpath); $basepath = explode('/', $basepath); // remove segments that basepath and relpath share foreach ($basepath as $segment) { if ($segment == current($relpath)) { array_shift($basepath); array_shift($relpath); } else { break; } } // rebuild the relpath $relpath = implode('/', $relpath); // add the query string if the current path is being used if ($query) { $relpath = $this->add_query($relpath, $query); } // add the fragment back if ($fragment) { $relpath = $this->add_fragment($relpath, $fragment); } return $relpath; }
$userinfo = $getuserid; if (!$userinfo) { print_stop_message2('invalid_user_specified'); } } else { if ($vbulletin->GPC['userid']) { $userid = $vbulletin->GPC['userid']; try { $userinfo = vB_Api::instanceInternal('user')->fetchUserInfo($vbulletin->GPC['userid']); } catch (vB_Exception_Api $ex) { $userinfo = false; } if (!$userinfo) { print_stop_message2('invalid_user_specified'); } $vbulletin->GPC['username'] = vB_String::unHtmlSpecialChars($userinfo['username']); } else { $userid = 0; } } if ($vbulletin->GPC['ipaddress'] or $userid) { if ($vbulletin->GPC['ipaddress']) { print_form_header('', ''); print_table_header(construct_phrase($vbphrase['ip_address_search_for_ip_address_x'], $vbulletin->GPC['ipaddress'])); $hostname = @gethostbyaddr($vbulletin->GPC['ipaddress']); if (!$hostname or $hostname == $vbulletin->GPC['ipaddress']) { $hostname = $vbphrase['could_not_resolve_hostname']; } print_description_row("<div style=\"margin-" . vB_Template_Runtime::fetchStyleVar('left') . ":20px\"><a href=\"usertools.php?" . vB::getCurrentSession()->get('sessionurl') . "do=gethost&ip=" . $vbulletin->GPC['ipaddress'] . "\">" . $vbulletin->GPC['ipaddress'] . "</a> : <b>{$hostname}</b></div>"); $results = construct_ip_usage_table($vbulletin->GPC['ipaddress'], 0, $vbulletin->GPC['depth']); print_description_row($vbphrase['post_ip_addresses'], false, 2, 'thead');
/** * Updates the user status * * @param int UserID * @param String Status to set * * @return String Updated status from user. */ public function updateStatus($userid = false, $status) { $userContext = vB::getUserContext(); $currentUserId = $userContext->fetchUserId(); $userid = intval($userid); $vboptions = vB::getDatastore()->getValue('options'); if (vB_String::vbStrlen($status) > $vboptions['statusMaxChars']) { throw new vB_Exception_Api('please_enter_user_status_with_at_most_x_characters', array($vboptions['statusMaxChars'])); } if ($userid <= 0 and $currentUserId) { $userid = $currentUserId; } // check user is logged if (!$userid or !$currentUserId) { throw new vB_Exception_Api('invalid_userid'); } // Check if current user canadminusers try { $this->checkHasAdminPermission('canadminusers'); } catch (Exception $e) { // No. Then we need to do something here. if ($currentUserId != $userid) { // If current user isn't the same as passed $userid throw new vB_Exception_Api('no_permission'); } } $userInfo = vB_User::fetchUserInfo($userid); $userdata = new vB_Datamanager_User(); $userdata->set_existing($userInfo); $userdata->set('status', $status); $result = $userdata->save(); if (!is_array($result)) { $userInfo = vB_User::fetchUserInfo(0, array(), 0, true); return $userInfo['status']; } else { return false; } }
/** * Starts the process of sending an email - preps it so it's fully ready to send. * Call send() to actually send it. * * @param string $toemail Destination email address * @param string $subject Email message subject * @param string $message Email message body * @param string $from Optional name/email to use in 'From' header * @param string $uheaders Additional headers * @param string $username Username of person sending the email * * @return boolean True on success, false on failure */ public function start($toemail, $subject, $message, $from = '', $uheaders = '', $username = '') { $toemail = $this->fetchFirstLine($toemail); if (empty($toemail)) { return false; } $delimiter =& $this->delimiter; $vboptions = vB::getDatastore()->getValue('options'); $toemail = vB_String::unHtmlSpecialChars($toemail); $subject = $this->fetchFirstLine($subject); $message = preg_replace("#(\r\n|\r|\n)#s", $delimiter, trim($message)); if ((strtolower(vB_Template_Runtime::fetchStyleVar('charset')) == 'iso-8859-1' or vB_Template_Runtime::fetchStyleVar('charset') == '') and preg_match('/&[a-z0-9#]+;/i', $message)) { $message = utf8_encode($message); $subject = utf8_encode($subject); $username = utf8_encode($username); $encoding = 'UTF-8'; $unicode_decode = true; } else { if ($vboptions['utf8encode']) { $message = to_utf8($message, vB_Template_Runtime::fetchStyleVar('charset')); $subject = to_utf8($subject, vB_Template_Runtime::fetchStyleVar('charset')); $username = to_utf8($username, vB_Template_Runtime::fetchStyleVar('charset')); $encoding = 'UTF-8'; $unicode_decode = true; } else { // we know nothing about the message's encoding in relation to UTF-8, // so we can't modify the message at all; just set the encoding $encoding = vB_Template_Runtime::fetchStyleVar('charset'); $unicode_decode = false; } } // theses lines may need to call convert_int_to_utf8 directly $message = vB_String::unHtmlSpecialChars($message, $unicode_decode); $subject = $this->encodeEmailHeader(vB_String::unHtmlSpecialChars($subject, $unicode_decode), $encoding, false, false); $from = $this->fetchFirstLine($from); if (empty($from)) { $vbphrase = vB_Api::instanceInternal('phrase')->fetch(array('x_mailer')); if (isset($vbphrase['x_mailer'])) { $mailfromname = sprintf($this->fetchFirstLine($vbphrase['x_mailer']), $vboptions['bbtitle']); } else { $mailfromname = $vboptions['bbtitle']; } if ($unicode_decode == true) { $mailfromname = utf8_encode($mailfromname); } $mailfromname = $this->encodeEmailHeader(vB_String::unHtmlSpecialChars($mailfromname, $unicode_decode), $encoding); $headers = "From: {$mailfromname} <" . $vboptions['webmasteremail'] . '>' . $delimiter; $headers .= 'Auto-Submitted: auto-generated' . $delimiter; // Exchange (Oh Microsoft) doesn't respect auto-generated: http://www.vbulletin.com/forum/project.php?issueid=27687 if ($vboptions['usebulkheader']) { $headers .= 'Precedence: bulk' . $delimiter; } } else { if ($username) { $mailfromname = "{$username} @ " . $vboptions['bbtitle']; } else { $mailfromname = $from; } if ($unicode_decode == true) { $mailfromname = utf8_encode($mailfromname); } $mailfromname = $this->encodeEmailHeader(vB_String::unHtmlSpecialChars($mailfromname, $unicode_decode), $encoding); $headers = "From: {$mailfromname} <{$from}>" . $delimiter; $headers .= "Sender: " . $vboptions['webmasteremail'] . $delimiter; } $fromemail = empty($vboptions['bounceemail']) ? $vboptions['webmasteremail'] : $vboptions['bounceemail']; $headers .= 'Return-Path: ' . $fromemail . $delimiter; $http_host = vB::getRequest()->getVbHttpHost(); if (!$http_host) { $http_host = substr(md5($message), 12, 18) . '.vb_unknown.unknown'; } $msgid = '<' . gmdate('YmdHis') . '.' . substr(md5($message . microtime()), 0, 12) . '@' . $http_host . '>'; $headers .= 'Message-ID: ' . $msgid . $delimiter; $headers .= preg_replace("#(\r\n|\r|\n)#s", $delimiter, $uheaders); unset($uheaders); $headers .= 'MIME-Version: 1.0' . $delimiter; $headers .= 'Content-Type: text/plain' . iif($encoding, "; charset=\"{$encoding}\"") . $delimiter; $headers .= 'Content-Transfer-Encoding: 8bit' . $delimiter; $headers .= 'X-Priority: 3' . $delimiter; $headers .= 'X-Mailer: vBulletin Mail via PHP' . $delimiter; if (!empty($vboptions['extra_smtp_headers'])) { $headers .= preg_replace("#\r[^\n]|[^r]\n#", $delimiter, $vboptions['extra_smtp_headers']) . $delimiter; } $this->toemail = $toemail; $this->subject = $subject; $this->message = $message; $this->headers = $headers; $this->fromemail = $fromemail; return true; }
} if ($vb5_config['Misc']['debug'] and vB::getUserContext()->hasAdminPermission('canadmintemplates')) { echo construct_link_code($vbphrase['rebuild_all_styles'], "template.php?" . vB::getCurrentSession()->get('sessionurl') . "do=rebuild&goto=template.php?" . vB::getCurrentSession()->get('sessionurl')); } echo "</p>\n"; } // ############################################################################# // rebuilds all parent lists and id cache lists if ($_REQUEST['do'] == 'rebuild') { if (!vB::getUserContext()->hasAdminPermission('canadmintemplates')) { print_cp_no_permission(); } $vbulletin->input->clean_array_gpc('r', array('renumber' => vB_Cleaner::TYPE_INT, 'install' => vB_Cleaner::TYPE_INT, 'goto' => vB_Cleaner::TYPE_STR)); echo "<p> </p>"; vB_Library::instance('style')->buildAllStyles($vbulletin->GPC['renumber'], $vbulletin->GPC['install']); $execurl = vB_String::parseUrl($vbulletin->GPC['goto']); $pathinfo = pathinfo($execurl['path']); $file = $pathinfo['basename']; parse_str($execurl['query'], $args); print_cp_redirect2($file, $args); } // ############################################################################# // hex convertor if ($_REQUEST['do'] == 'colorconverter') { $vbulletin->input->clean_array_gpc('r', array('hex' => vB_Cleaner::TYPE_NOHTML, 'rgb' => vB_Cleaner::TYPE_NOHTML, 'hexdec' => vB_Cleaner::TYPE_STR, 'dechex' => vB_Cleaner::TYPE_STR)); if ($vbulletin->GPC['dechex']) { $vbulletin->GPC['rgb'] = preg_split('#\\s*,\\s*#si', $vbulletin->GPC['rgb'], -1, PREG_SPLIT_NO_EMPTY); $vbulletin->GPC['hex'] = '#'; foreach ($vbulletin->GPC['rgb'] as $i => $value) { $vbulletin->GPC['hex'] .= strtoupper(str_pad(dechex($value), 2, '0', STR_PAD_LEFT)); }
if ($vbulletin->GPC['address']) { // chosen to address the issue -- redirect to the appropriate page $adminmessageid = intval($vbulletin->GPC['address'][0]); $adminmessage = vB::getDbAssertor()->getRow('adminmessage', array('adminmessageid' => $adminmessageid)); if (!empty($adminmessage)) { // set the issue as addressed vB::getDbAssertor()->update('adminmessage', array('status' => 'done', 'statususerid' => $vbulletin->userinfo['userid']), array('adminmessageid' => $adminmessageid)); } if (!empty($adminmessage) and !empty($adminmessage['execurl'])) { if ($adminmessage['method'] == 'get') { // get redirect -- can use the url basically as is if (!strpos($adminmessage['execurl'], '?')) { $adminmessage['execurl'] .= '?'; } $args = array(); $execurl = vB_String::parseUrl($adminmessage['execurl'] . vB::getCurrentSession()->get('sessionurl_js')); $pathinfo = pathinfo($execurl['path']); $file = $pathinfo['basename']; parse_str($execurl['query'], $args); print_cp_redirect2($file, $args); } else { // post redirect -- need to seperate into <file>?<querystring> first if (preg_match('#^(.+)\\?(.*)$#siU', $adminmessage['execurl'], $match)) { $script = $match[1]; $arguments = explode('&', $match[2]); } else { $script = $adminmessage['execurl']; $arguments = array(); } echo ' <form action="' . htmlspecialchars($script) . '" method="post" id="postform">
/** * Determines whether a string contains an [img] tag. * * @param string Text to search * * @return bool Whether the text contains an [img] tag */ protected function containsBbcodeImgTags($text) { // use a bitfield system to look for img, attach, and sigpic tags $hasimage = 0; if (vB_String::stripos($text, '[/img]') !== false) { $hasimage += self::BBCODE_HAS_IMG; } if (vB_String::stripos($text, '[/attach]') !== false) { $hasimage += self::BBCODE_HAS_ATTACH; } if (vB_String::stripos($text, '[/sigpic]') !== false) { // permissions are checked on API method if (!empty($this->parseUserinfo['userid']) and !empty($this->parseUserinfo['sigpic'])) { $hasimage += self::BBCODE_HAS_SIGPIC; } } if (vB_String::stripos($text, '[/relpath]') !== false) { $hasimage += self::BBCODE_HAS_RELPATH; } return $hasimage; }
} } // ###################### Start view client ####################### if ($_REQUEST['do'] == 'viewclient') { $vbulletin->input->clean_array_gpc('r', array('apiclientid' => vB_Cleaner::TYPE_UINT)); if (!$vbulletin->GPC['apiclientid'] or !($client = vB::getDbAssertor()->getRow('api_fetchclientbyid', array('apiclientid' => $vbulletin->GPC['apiclientid'])))) { print_stop_message2(array('invalidid', 'apiclientid')); } print_form_header('api', 'viewclient'); print_table_header($vbphrase['apiclient']); print_label_row($vbphrase['apiclientid'], $client['apiclientid']); print_label_row($vbphrase['apiclientname'], vB_String::htmlSpecialCharsUni($client['clientname'])); print_label_row($vbphrase['apiclientversion'], vB_String::htmlSpecialCharsUni($client['clientversion'])); print_label_row($vbphrase['apiclient_platformname'], vB_String::htmlSpecialCharsUni($client['platformname'])); print_label_row($vbphrase['apiclient_platformversion'], vB_String::htmlSpecialCharsUni($client['platformversion'])); print_label_row($vbphrase['apiclient_uniqueid'], vB_String::htmlSpecialCharsUni($client['uniqueid'])); print_label_row($vbphrase['apiclient_initialipaddress'], iif(!empty($client['initialipaddress']), "<a href=\"usertools.php?" . vB::getCurrentSession()->get('sessionurl') . "do=doips&depth=2&ipaddress={$client['initialipaddress']}&hash=" . CP_SESSIONHASH . "\">{$client['initialipaddress']}</a>", " ")); print_label_row($vbphrase['apiclient_initialtime'], vbdate($vbulletin->options['dateformat'] . ' ' . $vbulletin->options['timeformat'], $client['dateline'])); print_label_row($vbphrase['apiclient_lastactivity'], vbdate($vbulletin->options['dateformat'] . ' ' . $vbulletin->options['timeformat'], $client['lastactivity'])); print_label_row($vbphrase['apiclient_clienthash'], $client['clienthash']); print_label_row($vbphrase['apiclient_secret'], $client['secret']); print_label_row($vbphrase['apiclient_apiaccesstoken'], $client['apiaccesstoken']); print_label_row($vbphrase['apiclient_remembereduser'], iif(!empty($client['username']), "<a href=\"user.php?" . vB::getCurrentSession()->get('sessionurl') . "do=edit&u={$client['userid']}\"><b>{$client['username']}</b></a>", $vbphrase['guest'])); print_table_footer(); } echo '<p class="smallfont" align="center"><a href="#" onclick="js_open_help(\'adminlog\', \'restrict\', \'\');">' . $vbphrase['want_to_access_grant_access_to_this_script'] . '</a></p>'; print_cp_footer(); /*=========================================================================*\ || ####################################################################### || # Downloaded: 15:45, Tue Sep 8th 2015 || # CVS: $RCSfile$ - $Revision: 83435 $
/** * Reverse an infraction * * @param int The infraction nodeid * @param string Reason for the reversal * * @return int The number of rows that were affected */ public function reverseInfraction($nodeid, $reason) { if (!$this->canReverseInfraction()) { throw new vB_Exception_Api('no_permission'); } $nodeid = (int) $nodeid; $reason = vB_String::htmlSpecialCharsUni($reason); if ($nodeid < 1) { throw new vB_Exception_Api('invalid_node'); } return $this->library->reverseInfraction($nodeid, $reason); }
/** * Performs fetching of the file if possible * * @return integer Returns one of two constants, VURL_NEXT or VURL_HANDLED */ public function exec() { $urlinfo = @vB_String::parseUrl($this->vurl->options[VURL_URL]); if (!$this->validateUrl($urlinfo)) { return VURL_NEXT; } if (!function_exists('curl_init') or ($this->ch = curl_init()) === false) { return VURL_NEXT; } curl_setopt($this->ch, CURLOPT_TIMEOUT, $this->vurl->options[VURL_TIMEOUT]); if (!empty($this->vurl->options[VURL_CUSTOMREQUEST])) { curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, $this->vurl->options[VURL_CUSTOMREQUEST]); } else { if ($this->vurl->bitoptions & VURL_POST) { curl_setopt($this->ch, CURLOPT_POST, 1); curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->vurl->options[VURL_POSTFIELDS]); } else { curl_setopt($this->ch, CURLOPT_POST, 0); } } curl_setopt($this->ch, CURLOPT_HEADER, $this->vurl->bitoptions & VURL_HEADER ? 1 : 0); curl_setopt($this->ch, CURLOPT_HTTPHEADER, $this->vurl->options[VURL_HTTPHEADER]); curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, $this->vurl->bitoptions & VURL_RETURNTRANSFER ? 1 : 0); if ($this->vurl->bitoptions & VURL_NOBODY) { curl_setopt($this->ch, CURLOPT_NOBODY, 1); } //if we aren't following the location or we're using the built in curl method of following //redirects we only want to try to load the url once. Otherwise we'll want to loop internally //to handle redirects up to the limit. $redirect_tries = 1; if ($this->vurl->bitoptions & VURL_FOLLOWLOCATION) { // disabled in safe_mode/open_basedir in PHP 5.1.6/4.4.4 // Added method to force "safe mode" behavior without setting it primarily for unit testing if ($this->vurl->bitoptions & VURL_NOCURLFOLLOW or @curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1) === false) { $redirect_tries = $this->vurl->options[VURL_MAXREDIRS]; } else { curl_setopt($this->ch, CURLOPT_MAXREDIRS, $this->vurl->options[VURL_MAXREDIRS]); } } else { curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 0); } if ($this->vurl->options[VURL_ENCODING]) { // this will work on versions of cURL after 7.10, though was broken on PHP 4.3.6/Win32 @curl_setopt($this->ch, CURLOPT_ENCODING, $this->vurl->options[VURL_ENCODING]); } curl_setopt($this->ch, CURLOPT_WRITEFUNCTION, array(&$this, 'curl_callback_response')); curl_setopt($this->ch, CURLOPT_HEADERFUNCTION, array(&$this, 'curl_callback_header')); if (!($this->vurl->bitoptions & VURL_VALIDSSLONLY)) { curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0); } $url = $this->vurl->options[VURL_URL]; $redirectCodes = array(301, 302); for ($i = $redirect_tries; $i > 0; $i--) { $isHttps = $urlinfo['scheme'] == 'https'; if ($isHttps) { // curl_version crashes if no zlib support in cURL (php <= 5.2.5) $curlinfo = curl_version(); if (empty($curlinfo['ssl_version'])) { curl_close($this->ch); return VURL_NEXT; } } $result = $this->execCurl($url, $isHttps); //if we don't have another iteration of the loop to go, skip the effort here. if ($i > 1 and in_array(curl_getinfo($this->ch, CURLINFO_HTTP_CODE), $redirectCodes)) { $url = curl_getinfo($this->ch, CURLINFO_REDIRECT_URL); $urlinfo = @vB_String::parseUrl($url); if (!$this->validateUrl($urlinfo)) { $this->closeTempFile(); return VURL_NEXT; } } } //if we are following redirects and still have a redirect code, its because we hit our limit without finding a real page //we want the fallback code to mimic the behavior of curl in this case if ($this->vurl->bitoptions & VURL_FOLLOWLOCATION && in_array(curl_getinfo($this->ch, CURLINFO_HTTP_CODE), $redirectCodes)) { $this->closeTempFile(); return VURL_NEXT; } //close the connection and clean up the file. curl_close($this->ch); $this->closeTempFile(); if ($result !== false or !$this->vurl->options[VURL_DIEONMAXSIZE] and $this->max_limit_reached) { return VURL_HANDLED; } return VURL_NEXT; }
protected function saveNavbarPhrase(&$element, &$phrases) { if (!isset($element['phrase']) or empty($element['phrase']) or strpos($element['phrase'], 'navbar_') !== 0 or isset($phrases[$element['phrase']]) and $phrases[$element['phrase']] != $element['title']) { $words = explode(' ', $element['title']); array_walk($words, 'trim'); $phrase = strtolower(implode('_', $words)); //translating some special characters to their latin form $phrase = vB_String::latinise($phrase); // remove any invalid chars $phrase = preg_replace('#[^' . vB_Library_Phrase::VALID_CLASS . ']+#', '', $phrase); $phrase = 'navbar_' . $phrase; $suffix = 0; $tmpPhrase = $phrase; while (isset($phrases[$tmpPhrase]) and $phrases[$tmpPhrase] != $element['title']) { $tmpPhrase = $phrase . ++$suffix; } $element['phrase'] = $tmpPhrase; } // Store the phrase-value so that we can check $phrases[$element['phrase']] = $element['title']; $existingPhrases = vB::getDbAssertor()->getRows('phrase', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'varname' => $element['phrase'])); // don't destroy translations $text = array(); foreach ($existingPhrases as $existingPhrase) { $text[$existingPhrase['languageid']] = $existingPhrase['text']; } // the edited phrase $text[0] = $element['title']; vB_Api::instance('phrase')->save('navbarlinks', $element['phrase'], array('text' => $text, 'oldvarname' => $element['phrase'], 'oldfieldname' => 'navbarlinks', 't' => 0, 'ismaster' => 0, 'product' => 'vbulletin')); // store phrase name instead of title $element['title'] = $element['phrase']; unset($element['phrase']); // do the same for subnavigation if (isset($element['subnav']) and !empty($element['subnav'])) { foreach ($element['subnav'] as &$subnav) { $this->saveNavbarPhrase($subnav, $phrases); } } }
public function actionLoadPreview() { $input = array('parentid' => isset($_POST['parentid']) ? intval($_POST['parentid']) : 0, 'channelid' => isset($_POST['channelid']) ? intval($_POST['channelid']) : 0, 'pagedata' => isset($_POST['pagedata']) ? (array) $_POST['pagedata'] : array(), 'conversationtype' => isset($_POST['conversationtype']) ? trim(strval($_POST['conversationtype'])) : '', 'posttags' => isset($_POST['posttags']) ? trim(strval($_POST['posttags'])) : '', 'rawtext' => isset($_POST['rawtext']) ? trim(strval($_POST['rawtext'])) : '', 'filedataid' => isset($_POST['filedataid']) ? (array) $_POST['filedataid'] : array(), 'link' => isset($_POST['link']) ? (array) $_POST['link'] : array(), 'poll' => isset($_POST['poll']) ? (array) $_POST['poll'] : array(), 'video' => isset($_POST['video']) ? (array) $_POST['video'] : array(), 'htmlstate' => isset($_POST['htmlstate']) ? trim(strval($_POST['htmlstate'])) : '', 'disable_bbcode' => isset($_POST['disable_bbcode']) ? intval($_POST['disable_bbcode']) : 0); $results = array(); if ($input['parentid'] < 1) { $results['error'] = 'invalid_parentid'; $this->sendAsJson($results); return; } if (!in_array($input['htmlstate'], array('off', 'on_nl2br', 'on'), true)) { $input['htmlstate'] = 'off'; } // when creating a new content item, channelid == parentid $input['channelid'] = $input['channelid'] == 0 ? $input['parentid'] : $input['channelid']; $templateName = 'display_contenttype_conversationreply_'; $templateName .= ucfirst($input['conversationtype']); $api = Api_InterfaceAbstract::instance(); $channelBbcodes = $api->callApi('content_channel', 'getBbcodeOptions', array($input['channelid'])); // The $node['starter'] and $node['nodeid'] values are just there to differentiate starters and replies $node = array('rawtext' => '', 'userid' => vB5_User::get('userid'), 'authorname' => vB5_User::get('username'), 'tags' => $input['posttags'], 'taglist' => $input['posttags'], 'approved' => true, 'created' => time(), 'avatar' => $api->callApi('user', 'fetchAvatar', array('userid' => vB5_User::get('userid'))), 'parentid' => $input['parentid'], 'starter' => $input['channelid'] == $input['parentid'] ? 0 : $input['parentid'], 'nodeid' => $input['channelid'] == $input['parentid'] ? 0 : 1); if ($input['conversationtype'] == 'gallery') { $node['photopreview'] = array(); foreach ($input['filedataid'] as $filedataid) { $node['photopreview'][] = array('nodeid' => $filedataid, 'htmltitle' => isset($_POST['title_' . $filedataid]) ? vB_String::htmlSpecialCharsUni($_POST['title_' . $filedataid]) : ''); //photo preview is up to 3 photos only if (count($node['photopreview']) == 3) { break; } } $node['photocount'] = count($input['filedataid']); } if ($input['conversationtype'] == 'link') { $node['url_title'] = !empty($input['link']['title']) ? $input['link']['title'] : ''; $node['url'] = !empty($input['link']['url']) ? $input['link']['url'] : ''; $node['meta'] = !empty($input['link']['meta']) ? $input['link']['meta'] : ''; $node['previewImage'] = !empty($input['link']['url_image']) ? $input['link']['url_image'] : ''; } if ($input['conversationtype'] == 'poll') { $node['multiple'] = !empty($input['poll']['mutliple']); $node['options'] = array(); if (!empty($input['poll']['options']) and is_array($input['poll']['options'])) { $optionIndex = 1; foreach ($input['poll']['options'] as $option) { $node['options'][] = array('polloptionid' => $optionIndex, 'title' => $option); $optionIndex++; } } $node['permissions']['canviewthreads'] = 1; //TODO: Fix this!! } if ($input['conversationtype'] == 'video') { $node['url_title'] = !empty($input['video']['title']) ? $input['video']['title'] : ''; $node['url'] = !empty($input['video']['url']) ? $input['video']['url'] : ''; $node['meta'] = !empty($input['video']['meta']) ? $input['video']['meta'] : ''; $node['items'] = !empty($input['video']['items']) ? $input['video']['items'] : ''; } try { $results = vB5_Template::staticRenderAjax($templateName, array('nodeid' => $node['nodeid'], 'conversation' => $node, 'currentConversation' => $node, 'bbcodeOptions' => $channelBbcodes, 'pagingInfo' => array(), 'postIndex' => 0, 'reportActivity' => false, 'showChannelInfo' => false, 'showInlineMod' => false, 'commentsPerPage' => 1, 'view' => 'stream', 'previewMode' => true)); } catch (Exception $e) { if (vB5_Config::instance()->debug) { $results['error'] = 'error_rendering_preview_template ' . (string) $e; } else { $results['error'] = 'error_rendering_preview_template'; } $this->sendAsJson($results); return; } $bbcodeoptions = array('allowhtml' => in_array($input['htmlstate'], array('on', 'on_nl2br'), true), 'allowbbcode' => !$input['disable_bbcode'], 'htmlstate' => $input['htmlstate']); $results = array_merge($results, $this->parseBbCodeForPreview(fetch_censored_text($input['rawtext']), $bbcodeoptions)); $this->sendAsJson($results); }
/** * Verifies that the provided username is valid, and attempts to correct it if it is not valid * * @param string Username * * @return boolean Returns true if the username is valid, or has been corrected to be valid */ function verify_username(&$username) { // this is duplicated from the user manager // fix extra whitespace and invisible ascii stuff $username = trim(preg_replace('#[ \\r\\n\\t]+#si', ' ', strip_blank_ascii($username, ' '))); $username_raw = $username; $username = vB_String::cleanUserName($username); $username = str_replace(chr(0), '', $username); $username = trim($username); $length = vB_String::vbStrlen($username); if ($length < $this->registry->options['minuserlength']) { // name too short $this->error('usernametooshort', $this->registry->options['minuserlength']); return false; } else { if ($length > $this->registry->options['maxuserlength']) { // name too long $this->error('usernametoolong', $this->registry->options['maxuserlength']); return false; } else { if (preg_match('/(?<!&#[0-9]{3}|&#[0-9]{4}|&#[0-9]{5});/', $username)) { // name contains semicolons $this->error('username_contains_semi_colons'); return false; } else { if ($username != fetch_censored_text($username)) { // name contains censored words $this->error('censorfield'); return false; } else { $result = $this->assertor->assertQuery('verifyUsername', array('userid' => intval($this->existing['userid']), 'username' => vB_String::htmlSpecialCharsUni($username), 'username_raw' => vB_String::htmlSpecialCharsUni($username_raw))); if ($result->valid() and $result->current()) { // name is already in use $this->error('usernametaken', vB_String::htmlSpecialCharsUni($username), vB::getCurrentSession()->get('sessionurl')); return false; } else { if (!empty($this->registry->options['illegalusernames'])) { // check for illegal username $usernames = preg_split('/[ \\r\\n\\t]+/', $this->registry->options['illegalusernames'], -1, PREG_SPLIT_NO_EMPTY); foreach ($usernames as $val) { if (strpos(strtolower($username), strtolower($val)) !== false) { // wierd error to show, but hey... $this->error('usernametaken', vB_String::htmlSpecialCharsUni($username), vB::getCurrentSession()->get('sessionurl')); return false; } } } } } } } } // if we got here, everything is okay $username = vB_String::htmlSpecialCharsUni($username); return true; }
function parseThreadInfo($node) { $info = array('title' => vB_String::unHtmlSpecialChars($node['title']), 'threadid' => $node['nodeid']); return $info; }