Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so dont bother with any of their useless mail servers here and just use oauth login instead. Thank the nice Russians for causing that. :)

Paste

Pasted as PHP by registered user atmaca ( 6 months ago )
function vbseo_is_threadedmode()
{
$tmode = vbseo_vb_userinfo("threadedmode");
if(!$tmode) $tmode = $_COOKIE[vbseo_vb_cprefix() . "threadedmode"];
$mode_nonlinear = ($tmode == 'threaded' || $tmode == '1' || $tmode == '2' || $tmode == 'hybrid');
return $mode_nonlinear;
}
function vbseo_check_highlight($type)
{
$hlpar = 'highlight';
$vbseo_hlpar = 'vbseo_highlight';
if (($type==1) && VBSEO_SEARCH_REDIRECT && isset($_COOKIE) && isset($_GET[$hlpar]))
{
setcookie($vbseo_hlpar, $_GET[$hlpar]);
return $hlpar;
}
if($type ==2)
{
if (isset($_COOKIE[$vbseo_hlpar]))
{
setcookie($vbseo_hlpar, '');
$_GET[$hlpar] = $_REQUEST[$hlpar] = $_COOKIE[$vbseo_hlpar];
}
}
}
function vbseo_clean_basehref()
{
global $headinclude;
if(defined('VBSEO_PREPROCESSED') || vbseo_is_https())
$headinclude = preg_replace('#<base href[^>]*?>(\s*?<!--\[if IE\]><\/base><!\[endif\]-->)?#is', '', $headinclude);
}
function vbseo_fb_meta(&$newtext, $meta, $content)
{
if(function_exists('is_facebookenabled') && is_facebookenabled() && $content)
{
$newtext = preg_replace('#("og\:'.$meta.'"\s*content=")[^"]*#', '$1'.htmlspecialchars($content), $newtext);
}
}
function vbseo_add_canonic_url($url)
{
global $headinclude;
vBSEO_Storage::set('canonical', $url);
$url = preg_replace('#&page=$#', '', $url);
if(VBSEO_CANONIC_LINK_TAG && $headinclude && $url)
{
$hfullurl = htmlspecialchars(vbseo_create_full_url($url));
$headinclude = '<link rel="canonical" href="'.$hfullurl.'" />' . "\n" . $headinclude;
vbseo_fb_meta($headinclude, 'url', $hfullurl);
}
}
function vbseo_vbversion()
{
global $vbulletin, $versionnumber, $vboptions;
return is_object($vbulletin) ? $vbulletin->versionnumber : 
($versionnumber ? $versionnumber : $vboptions['templateversion']);
}
function vbseo_code_template($tplname, $tplcode, $append = false)
{
if(VBSEO_VB4 && vbseo_tpl_search($tplname, 'final_rendered'))
$tplcode .= ';';
else
$tplcode = '".(('.$tplcode.') ? "":"")."';
if($append)
return vbseo_append_template($tplname, $tplcode);
else
return vbseo_prepend_template($tplname, $tplcode);
}
function vbseo_append_template($tplname, $tplcode, $show = false)
{
global $vbulletin;
if (vbseo_tpl_exists($tplname))
{
$_thistpl = & $vbulletin->templatecache[$tplname];
$_thistpl1 = $_thistpl;
$_thistpl = $_thistpl . $tplcode;
}
if($show)echo $_thistpl;
return ($_thistpl != $_thistpl1);
}
function vbseo_prepend_template($tplname, $tplcode, $show = false)
{
global $vbulletin;
if (vbseo_tpl_exists($tplname))
{
$_thistpl = & $vbulletin->templatecache[$tplname];
$_thistpl1 = $_thistpl;
$_thistpl = $tplcode . $_thistpl;
}
if($show)echo $_thistpl;
return ($_thistpl != $_thistpl1);
}
function vbseo_tpl_exists($tplname)
{
global $vbulletin;
return isset($vbulletin->templatecache[$tplname]);
}
function vbseo_tpl_search($tplname, $searchfor)
{
global $vbulletin;
return strstr($vbulletin->templatecache[$tplname], $searchfor);
}
function vbseo_tpl_match($tplname, $snr)
{
global $vbulletin;
preg_match($snr, $vbulletin->templatecache[$tplname], $pm);
return $pm;
}
function vbseo_get_postbit_tpl()
{
global $vbulletin;     
if (is_object($GLOBALS['postbit_obj']) && $GLOBALS['postbit_obj']->templatename)
$tplpostbit = $GLOBALS['postbit_obj']->templatename;
else
if (isset($vbulletin) && $vbulletin->gars)
$tplpostbit = $vbulletin->gars->process_postbit();
else
$tplpostbit = $vbulletin->options['legacypostbit'] ? 'postbit_legacy' : 'postbit';
return $tplpostbit;
}
function vbseo_vb_gpc($varname)
{
if(is_object($vbulletin) && $vbulletin->GPC)
return $vbulletin->GPC[$varname];
else
return $_REQUEST[$varname];
}
function vbseo_vb_cprefix()
{
global $vbulletin;
if (VBSEO_VB35X)
{
if (!$config && isset($vbulletin))
$config = $vbulletin->config;
$cprefix = $config['Misc']['cookieprefix'];
if (VBSEO_VB4)
$cprefix .= '_';
}
else
$cprefix = $GLOBALS['cookieprefix'];
return $cprefix;
}
function vbseo_bbarray_cookie($cookiename, $id = '')
{
global $_COOKIE;
$cookie_name = vbseo_vb_cprefix() . $cookiename;
$cookie = isset($_COOKIE["$cookie_name"]) ? $_COOKIE["$cookie_name"] : "";
if (get_magic_quotes_gpc())
$cookie = stripslashes($cookie);
if (isset($cookie) && $id)
{
if (VBSEO_VB35X)
$cookie = str_replace(array('.', '-', '_'), array('"', ':', ';'), $cookie);
else
$cookie = str_replace(array('-', '_', 'x', 'y'), array('{', '}', ':', ';'), $cookie);
if (!($uncookie = @unserialize($cookie)))
{
$cookie = substr($cookie, 32);
$uncookie = @unserialize($cookie);
}
$cookie = $uncookie[$id];
}
return $cookie;
}
function vbseo_allowed_blog($bloginfo)
{
global $vbulletin;
if (!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers']))
{
if (!$vbulletin->userinfo['userid'] OR !($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewown']))
return false;
}
if(!$bloginfo['userid'])
return false;
if($bloginfo['state'] != 'visible')
return false;
if (!$bloginfo['options_member'] & $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'])
return false;
return true;
}
function vbseo_has_cms()
{
if(VBSEO_VB_CMS)
{
if(!class_exists('vB') && function_exists('bootstrap_framework'))
bootstrap_framework();
if(class_exists('vB'))
{
require_once DIR . '/packages/vbcms/permissions.'.VBSEO_VB_EXT;
if(class_exists('vB_Types') &&
vB_Types::instance()->getContentTypeID('vBCms_Section'))
return true;
}
}
return false;
}
function vbseo_permissions_cms_str()
{
if(vbseo_has_cms())
return vBCMS_Permissions::getPermissionString();
}
function vbseo_permissions_cms()
{
global $vbulletin;
if(!vbseo_has_cms())
return;
if(!$cperm = $vbulletin->userinfo['permissions']['cms'])
{
vBCMS_Permissions::getUserPerms();
$cperm = $vbulletin->userinfo['permissions']['cms'];
}
return $cperm;
}
function vbseo_allowed_cms($cmsinfo)
{
global $vbulletin;
if(!$cperm = vbseo_permissions_cms())
return false;
if (!$cmsinfo['parentnode'] ||
(!in_array($cmsinfo['parentnode'], $cperm['canview']) &&
!in_array($cmsinfo['permissionsfrom'], $cperm['canview'])
)
)
{
return false;
}
if(!$cmsinfo['setpublish'] || !$cmsinfo['userid'] || $cmsinfo['hidden'] 
|| ($cmsinfo['publishdate'] > TIMENOW)
)
return false;
return true;
}
function vbseo_allowed_forums()
{
global $vbulletin;
$forums = $vbulletin->forumcache;
$flist  = array();
foreach ($forums AS $forumid => $null)
{
$forumperms = $vbulletin->userinfo['forumpermissions']["$forumid"];
if (
$forumperms & $vbulletin->bf_ugp_forumpermissions['canview']
AND $forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']
AND $forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']
)
{
$flist[] = $forumid;
}
}
return $flist;
}
function vbseo_forum_is_public(&$foruminfo, $foruminfo2 = '', $fullcheck = false, $canread = false, $tinfo = array())
{
global $vbulletin, $vbseo_bitfields, $forum_is_public;
$f_perms = -1;
$fullcheck_ind = $fullcheck ? 0 : 1;
$check_groups = array(1);
vbseo_cache_start();
if (!$forum_is_public)
{
$forum_is_public = array();
if (!$fullcheck)
$forum_is_public[$fullcheck_ind] = $GLOBALS['vbseo_cache']->cacheget('forum_is_public');
}
if (!$fullcheck && isset($forum_is_public[$fullcheck_ind][$foruminfo['forumid']]))
return $forum_is_public[$fullcheck_ind][$foruminfo['forumid']];
if ($fullcheck && vbseo_vb_userinfo('usergroupid'))
{
$check_groups[] = vbseo_vb_userinfo('usergroupid');
$check_groups = array_merge($check_groups,
explode(',', vbseo_vb_userinfo('membergroupids'))
);
$fperm = vbseo_vb_userinfo('forumpermissions');
$check_groups[] = - $fperm[$foruminfo['forumid']];
}
$ugp_perm = isset($vbseo_bitfields['ugp']['forumpermissions']) ?
$vbseo_bitfields['ugp']['forumpermissions'] :
$vbulletin->bf_ugp_forumpermissions;
$ispub = false;
foreach($check_groups as $gid)
{
if ($gid < 0)
$f_perms = - $gid;
else
if (@isset($foruminfo['permissions'][$gid]))
$f_perms = $foruminfo['permissions'][$gid];
else
if (@isset($foruminfo2['permissions'][$gid]))
$f_perms = $foruminfo2['permissions'][$gid];
$is_public =
($f_perms < 0) ||
(
($f_perms &(defined('CANVIEW') ? CANVIEW : 
($ugp_perm['canview'] ? $ugp_perm['canview'] : 1))) 
&& 
(
($f_perms &(defined('CANVIEWOTHERS') ? CANVIEWOTHERS : 
($ugp_perm['canviewothers'] ? $ugp_perm['canviewothers']:2))) 
||
($tinfo['postuserid'] && ($tinfo['postuserid'] == vbseo_vb_userid()))
)	
&& 
(!$canread || ($ugp_perm['canviewthreads'] ? $f_perms & $ugp_perm['canviewthreads'] : 1))
);
if ($is_public)
{
$ispub = true;
break;
}
}
if (!$fullcheck)
{
$forum_is_public[$fullcheck_ind][$foruminfo['forumid']] = $ispub;
$GLOBALS['vbseo_cache']->cacheset('forum_is_public', $forum_is_public[$fullcheck_ind]);
}
return $ispub;
}
function vbseo_vmsg_pagenum($userid, $vmid)
{
global $vboptions;
$db = vbseo_get_db();
$vmsg = $db->vbseodb_query_first("SELECT *
FROM " . vbseo_tbl_prefix('visitormessage')." AS visitormessage
WHERE visitormessage.vmid = ".intval($vmid)."
");
$getpagenum = $db->vbseodb_query_first($q="
SELECT COUNT(*) AS comments
FROM " . vbseo_tbl_prefix('visitormessage')." AS visitormessage
WHERE userid = " . intval($userid) . "
AND state in ('visible')
AND dateline >= $vmsg[dateline]
");
$perpage = intval($vboptions['vm_perpage']);
$pg = $perpage ? ceil($getpagenum['comments'] / $perpage) : 1;
return $pg;
}
function vbseo_gmsg_pagenum(&$disid, $gmid)
{
global $vboptions;
$db = vbseo_get_db();
$commno = 0;
if($GLOBALS['vbseo_gcache']['groupsdis'])
{
foreach($GLOBALS['vbseo_gcache']['groupsdis'] as $gid=>$ginfo)
{
if( ($ginfo['gmid'] == $gmid) || ($ginfo['lastpostid'] == $gmid) )
{
if(!$disid)
$disid = $ginfo['discussionid'];
if(isset($ginfo['replies']))
$commno = $ginfo['replies']+1;
break;
}
}
}
if(!$commno)
{
$gmsg = $db->vbseodb_query_first("SELECT *
FROM " . vbseo_tbl_prefix('groupmessage')."
WHERE gmid = ".intval($gmid)."
");
if(vbseo_vbversion() < '3.8')
return vbseo_grp_pagenum($gmsg['groupid'], $gmid);
if(!$disid)
$disid = $gmsg['discussionid'];
$getpagenum = $db->vbseodb_query_first($q="
SELECT COUNT(*) AS comments
FROM " . vbseo_tbl_prefix('groupmessage')."
WHERE discussionid = " . intval($disid) . "
AND state in ('visible')
AND dateline <= $gmsg[dateline]
");
$commno = $getpagenum['comments'];
}
$perpage = intval($vboptions['gm_perpage']);
$pg = $perpage ? ceil($commno / $perpage) : 1;
return $pg;
}
function vbseo_grp_pagenum($groupid, $gmid)
{
global $vboptions;
$db = vbseo_get_db();
vbseo_int_var($groupid);
vbseo_int_var($gmid);
$vmsg = $db->vbseodb_query_first($q1="SELECT *
FROM " . vbseo_tbl_prefix('groupmessage')." AS comments
WHERE gmid = '".intval($gmid)."' AND groupid = '$groupid'
");
$getpagenum = $db->vbseodb_query_first($q="
SELECT COUNT(*) AS comments
FROM " . vbseo_tbl_prefix('groupmessage') . " AS gm
WHERE groupid = '$groupid'
AND state in ('visible')
AND dateline >= $vmsg[dateline]
");
$perpage = intval($vboptions['vm_perpage']);
$pg = $perpage ? ceil($getpagenum['comments'] / $perpage) : 1;
return $pg;
}
function vbseo_pic_pagenum($picid, $commentid)
{
global $vboptions;
$db = vbseo_get_db();
vbseo_int_var($picid);
vbseo_int_var($commentid);
if(VBSEO_VB4)
{
$w = 'a.attachmentid = ' . intval($picid) ;
$j = 'LEFT JOIN '.vbseo_tbl_prefix('attachment').' a on a.filedataid = pc.filedataid';
}else
{
$w = 'pictureid = ' . intval($picid) ;
$j = '';
}
$getpagenum = $db->vbseodb_query_first($q="
SELECT COUNT(*) AS comments
FROM " . vbseo_tbl_prefix('picturecomment')." pc
$j
WHERE $w
AND pc.state in ('visible')
AND pc.commentid <= '$commentid'
");
$perpage = intval($vboptions['pc_perpage']);
$pg = $perpage ? ceil($getpagenum['comments'] / $perpage) : 1;
return $pg;
}
function vbseo_get_next_thread($threadid, $older)
{
global $vbseo_gcache;
vbseo_int_var($threadid);   
$thread = $vbseo_gcache['thread'][$threadid];
$db = vbseo_get_db();
$hasthreadprefixes = vbseo_vbversion()>='3.8';
$getnextoldest = $db->vbseodb_query_first("
SELECT t.forumid, t.threadid, " . (VBSEO_GET_THREAD_TITLES ? 't.title, ' : '') . "t.replycount, t.lastposter, t.lastpost".
((VBSEO_URL_THREAD_PREFIX && $hasthreadprefixes) ? ', t.prefixid' : '')."
FROM " . vbseo_tbl_prefix('thread') . " AS t
WHERE forumid = $thread[forumid] AND lastpost " . ($older?'<':'>') . " $thread[lastpost] AND visible = 1 AND open <> 10
ORDER BY lastpost " . ($older?'DESC':'') . "
LIMIT 1
");
vbseo_thread_seotitle($getnextoldest);
$vbseo_gcache['thread'][$getnextoldest['threadid']] = $getnextoldest;
return $getnextoldest;
}
function vbseo_get_post_info($postid)
{
global $vbseo_gcache;
if (isset($vbseo_gcache['post'][$postid]) && $vbseo_gcache['post'][$postid]['threadid']) 
return $vbseo_gcache['post'][$postid];
$db = vbseo_get_db();
$postarr = $db->vbseodb_query_first("
SELECT postid,threadid,dateline,userid,visible
FROM " . vbseo_tbl_prefix('post') . " 
WHERE postid = " . intval($postid) . " 
LIMIT 1
");
$vbseo_gcache['post'][$postid] = $postarr;
return $postarr;
}
function vbseo_get_last_post($threadid)
{
$db = vbseo_get_db();
$postarr = $db->vbseodb_query_first("
SELECT MAX(postid) AS postid
FROM " . vbseo_tbl_prefix('post') . " AS post
WHERE threadid = " . intval($threadid) . " AND visible = 1
LIMIT 1
");
return $postarr['postid'];
}
function vbseo_get_new_post($threadid)
{
global $vboptions, $vbseo_gcache;
$db = vbseo_get_db();
vbseo_int_var($threadid);
$lvisit = vbseo_vb_userinfo('lastvisit');
if ($vboptions['threadmarking'] AND vbseo_vb_userid())
{
$threadinfo = $db->vbseodb_query_first($q = "
SELECT
threadread.readtime AS threadread, forumread.readtime AS forumread
FROM " . vbseo_tbl_prefix('thread') . " AS thread
LEFT JOIN " . vbseo_tbl_prefix('threadread') . " AS threadread ON (threadread.threadid = thread.threadid AND threadread.userid = " . vbseo_vb_userid() . ")
LEFT JOIN " . vbseo_tbl_prefix('forumread') . " AS forumread ON (forumread.forumid = thread.forumid AND forumread.userid = " . vbseo_vb_userid() . ")
WHERE thread.threadid = '$threadid'
");
$lvisit = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - ($vboptions['markinglimit'] * 86400));
}
else
if (($tview = vbseo_bbarray_cookie('thread_lastview', $threadid)) > $lvisit)
$lvisit = $tview;
$postarr = $db->vbseodb_query_first($q = "
SELECT MIN(postid) AS postid
FROM " . vbseo_tbl_prefix('post') . "
WHERE threadid = $threadid
AND visible = 1
AND dateline > " . intval($lvisit) . "
LIMIT 1
");
return $postarr['postid'] ? $postarr['postid'] :
vbseo_get_last_post($threadid);
}

 

Revise this Paste

Your Name: Code Language: