function do_delete_attachment() { $userinfo = vB_Api::instance('user')->fetchUserInfo(); if ($userinfo['userid'] < 1) { return json_error(ERR_NO_PERMISSION); } $cleaned = vB::getCleaner()->cleanArray($_REQUEST, array('attachmentid' => vB_Cleaner::TYPE_UINT)); if (empty($cleaned['attachmentid'])) { return json_error(ERR_NO_PERMISSION); } $fr_attach = vB_dB_Assertor::instance()->assertQuery('ForumRunner:getAttachmentMarkerById', array('id' => $cleaned['attachmentid'])); if (empty($fr_attach)) { return json_error(ERR_NO_PERMISSION); } $result = vB_Api::instance('content_attach')->deleteAttachment($fr_attach['attachmentid']); if (empty($result) || !empty($result['errors'])) { return json_error(ERR_NO_PERMISSION); } vB_dB_Assertor::instance()->assertQuery('ForumRunner:deleteAttachmentMarker', array('id' => $cleaned['attachmentid'])); return true; }
public static function getAssetPicker($userinfo, $registry) { //see if this user has an album we can use for background images. $albums = vB_dB_Assertor::instance()->assertQuery('CustomProfileAlbums', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'userid' => $userinfo['userid'])); $album = $albums->current(); $album_select = ''; while ($albums->valid()) { $album_select .= "<option value=\"" . $album['albumid'] . "\">" . $album['title'] . "</option>\n"; $album = $albums->next(); } require_once DIR . '/includes/class_xml.php'; $xml = new vB_XML_Builder_Ajax('text/xml'); if (empty($album_select)) { $xml->add_group('error'); $xml->add_tag('phrase', 'need_public_album_text'); } else { $xml->add_group('content'); $template = vB_Template::create('memberinfo_assetpicker'); $template->register('album_select', $album_select); $phrase = new vB_Phrase('profilefield', 'select_album_to_view'); $template->register('select_album_to_view', $phrase); $body = $template->render(); $template = vB_Template::create('memberinfo_assetpicker_footer'); $footer = $template->render(); $header = new vB_Phrase('profilefield', 'asset_picker'); //Now format this as an xml array. $xml->add_tag('body', $body); $xml->add_tag('header', $header); $xml->add_tag('footer', $footer); } $xml->close_group(); $xml->print_xml(); }
function fr_process_message_callback($matches) { if (count($matches) > 1) { $fr_attach = vB_dB_Assertor::instance()->getRow('ForumRunner:getAttachmentMarkerById', array('id' => $matches[1])); if (!empty($fr_attach)) { return '[IMG]' . fr_base_url() . 'filedata/fetch?id=' . $fr_attach['attachmentid'] . '[/IMG]'; } } return ''; }
function do_stats() { $user_counts = vB_Api::instance('wol')->fetchCounts(); if (empty($user_counts) || !empty($user_counts['errors'])) { return json_error(ERR_NO_PERMISSION); } $top = vB_Api::instance('content_channel')->fetchTopLevelChannelIds(); $forumid = $top['forum']; $contenttypeid = vB_Api::instance('contenttype')->fetchContentTypeIdFromClass('Text'); $all_texts = vB_Api::instance('node')->listNodeFullContent($forumid, 1, 10000000000, 10000, $contenttypeid, false); $total_threads = 0; $total_posts = 0; foreach ($all_texts as $node) { if ($node['starter'] == $node['nodeid']) { $total_threads++; } $total_posts++; } $total_members = vB_dB_Assertor::instance()->getRow('ForumRunner:countMembers'); $newuser = vB_dB_Assertor::instance()->getRow('ForumRunner:getNewestUser'); $total_members = $total_members['count']; $newuser = $newuser['username']; $out = array('threads' => $total_threads, 'posts' => $total_posts, 'members' => $total_members, 'newuser' => $newuser, 'record_users' => $user_counts['recordusers'], 'record_date' => $user_counts['recorddate'], 'online_members' => $user_counts['members'], 'online_guests' => $user_counts['guests']); return $out; }
/** * Returns a by-reference the assertor object * @return vB_dB_Assertor */ public static function &getDbAssertor() { if (!isset(self::$db_assertor)) { vB_dB_Assertor::init(self::getConfig()); self::$db_assertor = vB_dB_Assertor::instance(); } return self::$db_assertor; }
function get_sub_thread_updates() { $userid = vB::getUserContext()->fetchUserId(); $count = vB_dB_Assertor::instance()->getRow('ForumRunner:subscribedContentUpdateCount', array('userid' => $userid)); return intval($count['qty']); }
/** This sets the db. It will normally be call in the boot process * * @param array config array ***/ public static function init(&$config) { //currently mysqli is handled by the mysql class if ($config['Database']['dbtype'] == 'mysqli') { self::$dbtype = 'MYSQL'; } else { self::$dbtype = strtoupper($config['Database']['dbtype']); } $class = 'vB_dB_' . self::$dbtype . '_Assertor'; if (class_exists($class)) { self::$instance = new $class($config); } vB_Shutdown::instance()->add(array(self::$instance, 'executeShutdownQueries')); }
function addNode($params, $db, $check_only = false) { if ($check_only) { return !empty($params['contenttypeid']) and !empty($params['parentid']) and !empty($params['title']); } $cleaned = vB::getCleaner()->cleanArray($params, array('parentid' => vB_Cleaner::TYPE_UINT)); $params[vB_dB_Query::TYPE_KEY] = vB_dB_Query::QUERY_INSERT; //We must set the protected field. $parent = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "node WHERE nodeid =" . $cleaned['parentid']); $params['protected'] = $parent['protected']; $nodeid = vB_dB_Assertor::instance()->assertQuery('vBForum:node', $params); $config = vB::getConfig(); if ($nodeid) { $nodeid = $nodeid[0]; $sql = "INSERT INTO " . TABLE_PREFIX . "closure(parent, child, depth)\n\t\t\t\tVALUES({$nodeid}, {$nodeid}, 0) \n/**" . __FUNCTION__ . (defined('THIS_SCRIPT') ? '- ' . THIS_SCRIPT : '') . "**/"; if (isset($config['Misc']['debug_sql']) and $config['Misc']['debug_sql']) { echo "sql: {$sql} <br />\n"; } $db->query_write($sql); $sql = "INSERT INTO " . TABLE_PREFIX . "closure(parent, child, depth)\n\t\t\t\tSELECT p.parent, {$nodeid}, p.depth+1\n\t\t\t \tFROM " . TABLE_PREFIX . "closure p\n\t\t\t \tWHERE p.child=" . $cleaned['parentid'] . "\n/**" . __FUNCTION__ . (defined('THIS_SCRIPT') ? '- ' . THIS_SCRIPT : '') . "**/"; if (isset($config['Misc']['debug_sql']) and $config['Misc']['debug_sql']) { echo "sql: {$sql} <br />\n"; } $db->query_write($sql); return $nodeid; } else { return false; } }
/** This sets the db and userinfo. It will normally be call in the boot process * * @param object the db object * @param array userinfo array ***/ public static function init(&$db, &$userinfo) { self::$db = $db; self::$userinfo = $userinfo; $class = 'vB_dB_' . self::$site_db_type . '_Assertor'; if (class_exists($class)) { self::$instance = new $class(); } }
} // We have our PM list. Now lets see which ones we've already sent // and eliminate them. $sentpms = $vbulletin->db->query_read_slave("\n\t\t\tSELECT vb_pmid\n\t\t\tFROM " . TABLE_PREFIX . "forumrunner_push_data\n\t\t\tWHERE vb_userid = " . $user['vb_userid'] . " AND vb_pmid IN (" . implode(',', $pmids) . ")\n\t\t\t"); while ($sentpm = $vbulletin->db->fetch_array($sentpms)) { unset($pms[$sentpm['vb_pmid']]); } unset($sentpms); // Save that we sent PM notices foreach ($pms as $pm) { $vbulletin->db->query_write("\n\t\t\t\tINSERT INTO " . TABLE_PREFIX . "forumrunner_push_data\n\t\t\t\t(vb_userid, vb_pmid)\n\t\t\t\tVALUES\n\t\t\t\t({$user['vb_userid']}, {$pm['nodeid']})\n\t\t\t\t"); } } unset($unreadpms); $subs = array(); $sub_threads = vB_dB_Assertor::instance()->getRows('ForumRunner:getNewSubsForPushUser', array('userid' => $user['vb_userid'])); foreach ($sub_threads as $thread) { $push_threaddata = $vbulletin->db->query_first_slave("\n\t\t\tSELECT * FROM " . TABLE_PREFIX . "forumrunner_push_data\n\t\t\tWHERE vb_threadid = {$thread['nodeid']} AND vb_userid = {$user['vb_userid']}\n\t\t\t"); if ($push_threaddata) { if ($push_threaddata['vb_threadread'] < $thread['lastupdate']) { if ($push_threaddata['vb_subsent']) { continue; } $vbulletin->db->query_write("\n\t\t\t\t\tUPDATE " . TABLE_PREFIX . "forumrunner_push_data\n\t\t\t\t\tSET vb_threadread = {$thread['lastupdate']}, vb_subsent = 1\n\t\t\t\t\tWHERE id = {$push_threaddata['id']}\n\t\t\t\t\t"); $subs[] = array('threadid' => $thread['nodeid'], 'title' => $thread['title']); } } else { $subs[] = array('threadid' => $thread['nodeid'], 'title' => $thread['title']); $vbulletin->db->query_write("\n\t\t\t\tINSERT INTO " . TABLE_PREFIX . "forumrunner_push_data\n\t\t\t\t(vb_userid, vb_threadid, vb_threadread, vb_subsent)\n\t\t\t\tVALUES ({$user['vb_userid']}, {$thread['nodeid']}, {$thread['lastupdate']}, 1)\n\t\t\t\t"); } unset($push_threaddata);
function addFiledataid($posthash, $filedataid) { $result = vB_dB_Assertor::instance()->assertQuery('vBMAPI:insertPosthashFiledataid', array('posthash' => $posthash, 'filedataid' => $filedataid, 'dateline' => vB::getRequest()->getTimeNow())); return $result; }