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 )
<?php
/* functions_vbseo_ui.php dosyası. Parça 1/2 */
/************************************************************************************
* vBSEO 3.6.0 for vBulletin v3.x & v4.x by Crawlability, Inc. *
* *
* Copyright © 2011, Crawlability, Inc. All rights reserved. *
* You may not redistribute this file or its derivatives without written permission. *
* *
* Sales Email: sales@crawlability.com *
* *
*----------------------------vBSEO IS NOT FREE SOFTWARE-----------------------------*
* http://www.crawlability.com/vbseo/license/ *
************************************************************************************/
define(VBSEO_UI_THREAD, 1);
define(VBSEO_UI_BLOG, 2);
define(VBSEO_UI_CMS, 3);
define(VBSEO_UI_CID_TOP,-1);
class vBSEO_UI
{
private static $ginfo = array();
private static $page_ids = array();
private static $shortlist= 3;
private static $toplist= 10;
private static $longlist = 100;
private static $default_top_tree = true;
public static function head_hook()
{
$container_class = "'postbody','blogbit','content','postcontainer','vbseo_like_postbit'";
$vbseoui_options = '"'.addslashes(VBSEO_VB_EXT).'",'.(VBSEO_LIKE_LINK_VISIBLE ? 1 : 0);
eval(vbseo_eval_template('vbseo_ui_headinc', '$ls_js'));
if(THIS_SCRIPT=='vbcms' || !VBSEO_VB4)
vbseo_insert_code($ls_js, 'head_end');
else
{
global $headinclude_bottom;
$headinclude_bottom.=$ls_js;
}
}
public static function parse_tpl_hook()
{
global $template_hook;
if(THIS_SCRIPT == 'member')
{
$menuitem = vbseo_fetch_tpl('vbseo_profile_menu');
if(VBSEO_VB4)
vbseo_modify_template('MEMBERINFO',
'#(\<ul[^>]*"usermenu".*?)(</ul>)#s', '$1'.$menuitem.'$2');
else
vbseo_modify_template('memberinfo_block_ministats',
'#(\[posts\]</dd>)#is', '$1'.$menuitem);
}
$template_hook['custom_css_list'] .= ($template_hook['custom_css_list'] ? "," : "").
"vbseo_buttons.css" . ((THIS_SCRIPT == 'showthread') ? ",vbseo_buttons_fix.css" : "");
$tplpostbit = vbseo_get_postbit_tpl();
vbseo_modify_template($tplpostbit, $sf ='|| $post[\'signature\']', $sf . ' || 1');
if(!VBSEO_VB4)
vbseo_modify_template($tplpostbit, $sf='class=\"tborder', $sf . ' vbseo_like_postbit');
}
public static function postbit_hook(&$post, &$template_hook)
{
global $show, $thread, $vboptions, $vbseo_gcache;
$is_public = vbseo_forum_is_public($GLOBALS['forum'], $GLOBALS['foruminfo'], false, true);
if (THIS_SCRIPT != 'showthread')
return false;
if($fi = $GLOBALS['forum'])
if(!$fi['vbseo_enable_likes'])
return;
if ($is_public && VBSEO_BOOKMARK_POST && ($bmlist = vbseo_get_bookmarks()))
{
$book_t = urlencode($thread['title']);
$vbseo_url_t = urlencode($vboptions['bburl2'] . '/' .
vbseo_thread_url($thread['threadid'], $_GET['page']) . '#post') . $post['postid'];
$bookmarks = array();
foreach($bmlist as $bm)
{
$url = str_replace('%url%', $vbseo_url_t, str_replace('%title%', $book_t, str_replace('&', '&', $bm[0])));
$bookmarks[] = array(
'url' => $url,
'image' => $bm[1],
'text' => $bm[3]
);
}
}else $bookmarks = '';
$vbseo_likeshare = self::likeshare_bit(VBSEO_UI_THREAD,
$post['threadid'], $post['postid'], $post['userid'], $bookmarks);
if($vbseo_likeshare)
{
vbseo_modify_template34('SHOWTHREAD', '#('.$sfor.')#s', '$1'.$liketree,
0, '<!--VBSEO_LIKE_TREE-->');
$template_hook['postbit_signature_start'] .= $vbseo_likeshare;
}
}
public static function thread_hook()
{
global $thread, $vbseo_gcache;
if($fi = $GLOBALS['forum'])
if(!$fi['vbseo_enable_likes'])
return;
$tpage = count(self::$ginfo[VBSEO_UI_THREAD][$thread['threadid']]);
if(self::$default_top_tree && (vbseo_page_size(true) <= $thread['replycount']))
{
self::$ginfo = array();
}
$liketree = self::liketree_bit(VBSEO_UI_THREAD,
$thread['threadid'],
$thread['vbseo_likes'],
$tpage
);
if($liketree)
{
$sfor = VBSEO_VB4 ?
'<div id="pagetitle".*?>' :
'id=\\\\"poststop\\\\".*?</a>';
vbseo_modify_template34('SHOWTHREAD', '#('.$sfor.')#s', '$1'.$liketree,
0, '<!--VBSEO_LIKE_TREE-->');
}
}
public static function liketree_bit($ctype, $cgroup, $like_total, $like_page = 0)
{
global $vbseo_gcache, $vbphrase;
$alikes = array();
$agr = self::lcache_get($ctype, $cgroup);
if(is_array($agr))
foreach($agr as $cid=>$gc)
{
$al = array();
if($ctype == VBSEO_UI_THREAD)
{
$al = $vbseo_gcache['post'][$cid];
if(!$al)
$al = $vbseo_gcache['post'][$cid] = array(
'postid' => $cid,
'threadid' => $cgroup
);
}
$al = array_merge($gc, $al);
$al['postno'] = $gc['preposts'];
$alikes[] = $al;
}
if($like_total)
{
self::prerender_likes($alikes);
$ret = vbseo_vbtemplate_render_any('vbseo_like_tree', array(
'page_ids' => implode(',',self::$page_ids),
'alikes' => $alikes,
'ctype' => $ctype,
'cgroup' => $cgroup,
'like_total' => $like_total,
'like_page' => $like_page)
);
}
return $ret.' ';
}
public static function blog_comment_hook($bresponse)
{
if(!is_object($bresponse) || !$bresponse->response )
return;
$vbseo_likeshare = self::likeshare_bit(VBSEO_UI_BLOG,
$bresponse->response['blogid'],
$bresponse->response['blogtextid'],
$bresponse->response['userid']
);
if($vbseo_likeshare)
vbseo_modify_template('blog_comment', '#(<div class="vbseo_buttons.*</div>\s*)?(<div class="commentfoot)#is', $vbseo_likeshare.'$2');
}
public static function blog_entry_hook(&$blog)
{
global $show, $vboptions;
if (!in_array(THIS_SCRIPT, array('entry','blog')))
return false;
self::extract_likes_page(VBSEO_UI_BLOG, $blog['blogid'], -1);
if (VBSEO_BOOKMARK_BLOG)
{
$vbseo_url_b = vbseo_http_s_url('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['VBSEO_URI']);
$book_t = urlencode($blog['title']);
$bmlist = vbseo_get_bookmarks();
$bookmarks = array();
foreach($bmlist as $bm)
{
$url = str_replace('%url%', urlencode($vbseo_url_b), str_replace('%title%', $book_t, $bm[0]));
$bookmarks[] = array(
'url' => $url,
'image' => $bm[1],
'text' => $bm[4]
);
}
}
$vbseo_likeshare = self::likeshare_bit(VBSEO_UI_BLOG,
$blog['blogid'], $blog['firstblogtextid'], $blog['userid'],
$bookmarks);
if($vbseo_likeshare)
{
vbseo_modify_template34('blog_show_entry', '#(<div id=\\\\?"(?:entry_text|blog_message).*?</div>)#is',
'$1'.$vbseo_likeshare, 0, '<!--VBSEO_LIKE_SHARE-->');
if(!VBSEO_VB4)
vbseo_modify_template34('blog_show_entry', '#(<div class=\\\\")([^>]*?id=\\\\?"entry)#is',
'$01vbseo_like_postbit $2');
}
}
public static function cms_hook(&$view)
{
global $show, $vboptions;
if(!is_object($view))return;
$cid = $view->node;
self::extract_likes_page(VBSEO_UI_CMS, $cid, VBSEO_UI_CID_TOP);
if (VBSEO_BOOKMARK_CMS)
{
$vbseo_url_b = vbseo_http_s_url('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['VBSEO_URI']);
$book_t = urlencode($view->title);
$bmlist = vbseo_get_bookmarks();
$bookmarks = array();
foreach($bmlist as $bm)
{
$url = str_replace('%url%', urlencode($vbseo_url_b), str_replace('%title%', $book_t, $bm[0]));
$bookmarks[] = array(
'url' => $url,
'image' => $bm[1],
'text' => $bm[4]
);
}
}
$vbseo_likeshare = self::likeshare_bit(VBSEO_UI_CMS, $cid, VBSEO_UI_CID_TOP, $view->userid, $bookmarks);
if($vbseo_likeshare)
$view->pagetext .= $vbseo_likeshare;
}
public static function likeshare_bit($contenttype, $contentgroup, $contentid, $duserid, $bookmarks = array())
{
global $show, $vboptions, $vbphrase;
if(!$contenttype || !$contentgroup || !$contentid)
return '';
self::$page_ids[] = $contentid;
$vbseo_liked = self::get_liked_info($contenttype, $contentgroup, $contentid);
$own_liked = self::lcache_get($contenttype, $contentgroup, $contentid, 'ownlike');
$own_content = ($duserid == vbseo_vb_userid());
$like_link_visible = VBSEO_LIKE_LINK_VISIBLE;
eval(vbseo_eval_template('vbseo_likeshare', '$vbseo_likeshare'));
return $vbseo_likeshare;
}
public static function ajax_hook()
{
global $vbulletin, $vbseo_gcache;
$response = array();
$cid = intval($_POST['contentid']);
$ctype = intval($_POST['contenttype']);
$cgroup = intval($_POST['contentgroup']);
$cduser = intval($_POST['duserid']);
if($ctype == VBSEO_UI_THREAD)
{
$pinfo = vbseo_get_post_info($cid);
if($pinfo)
{
$cgroup = $pinfo['threadid'];
$cduser = $pinfo['userid'];
}
$tinfos= vbseo_get_thread_info($cgroup);
$flist = vbseo_allowed_forums();
if(!in_array($tinfos[$cgroup]['forumid'], $flist))
{
$err = 'Access denied';
}
}else
if($ctype == VBSEO_UI_BLOG)
{
$pinfo = vbseo_get_blog_info($cid, true, true);
if($pinfo)
{
$cgroup = $pinfo['blogid'];
$cduser = $pinfo['userid'];
if(!vbseo_allowed_blog($pinfo))
{
$err = 'Access denied';
}
}else
$err = 'Content not found';
}else
if($ctype == VBSEO_UI_CMS)
{
vbseo_get_object_info('cmscont', array($cgroup));
$pinfo = $vbseo_gcache['cmscont'][$cgroup];
if($pinfo['tyid'])$pinfo['nodeid'] = $pinfo['tyid'];
if($pinfo)
{
$cduser = $pinfo['userid'];
$cid = VBSEO_UI_CID_TOP;
if(!vbseo_allowed_cms($pinfo))
{
$err = 'Access denied';
}
}else
$err = 'Content not found';
}else
{
$err = 'Unrecognized content type';
}
if(!$err)
switch($act = $_POST['action'])
{
case 'like':
case 'others':
if(!vbseo_vb_userid())
$err = 'Not logged in';
if(!$pinfo)
$err = 'Content not found';
if(!$err)
{
$li = self::get_like($cid, $cgroup, $ctype);
if($act == 'like')
{
if($cduser == vbseo_vb_userid())
$err = 'Access denied';
else
{
if($li)
$res = self::remove_like($cid, $ctype, $cgroup, 0, $cduser);
else
$res = self::add_like($cid, $ctype, $cgroup, 0, $cduser);
if(!$res)
$err = 'Error processing request';
$li = !$li;
}
}else
if($act == 'others')
{
self::$shortlist = 200;
}
global $vbphrase;
$response['contentid'] = $cid;
$response['contenttype'] = $ctype;
$response['contentgroup'] = $cgroup;
$response['self'] = $vbphrase[$li ? 'vbseo_unlike' : 'vbseo_like'];
self::extract_likes_page($ctype, $cgroup, $cid);
$ll = self::get_liked_info($ctype, $cgroup, $cid);
$response['likelist'] = $ll ? $ll : '.';
}
break;
case 'treetab':
$atabs = array('top', 'all', 'page');
$tt = $atabs[$_POST['tab']];
if($tt)
{
self::$page_ids = explode(',', $_POST['cids']) ;
vbseo_int_var(self::$page_ids);
$cids = ($tt == 'page') ? self::$page_ids : array();
self::extract_likes_bygroup($ctype, $cgroup, 0, $cids, $tt);
$liketree = self::liketree_bit($ctype, $cgroup, $tinfos[$cgroup]['vbseo_likes']);
$liketree = preg_replace('#^.*class="vbseo-likes-list.*?>(.*?)</ul>.*$#is', '$1', $liketree);
$response['ltree'] = $liketree;
}
break;
}
if($err)
$response['error'] = $err;
$xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml');
$xml->add_group('vbseo');
foreach($response as $k=>$v)
{
$xml->add_tag($k, $v);
}
$xml->close_group();
$xml->print_xml();
exit;
}
private static function get_like($cid, $cgroup, $ctype, $userid = 0)
{
if(!$userid && (!$userid = vbseo_vb_userid()))
return false;
$db = vbseo_get_db();
$larr = $db->vbseodb_query_first("
SELECT *
FROM " . vbseo_tbl_prefix('vbseo_likes') . "
WHERE l_contentid = " . intval($cid) . " AND l_cgroup = ".intval($cgroup)." AND l_ctype = " . intval($ctype) . "
AND l_from_userid = ".intval($userid)."
LIMIT 1
");
return $larr;
}
public static function delete_likes($cid, $cgroup, $ctype)
{
if(!$cgroup && !$cid)return 0;
$whr = $cid ? "l_contentid=".intval($cid) : "l_cgroup=".intval($cgroup);
$whr.= " AND l_ctype=".intval($ctype);
$db = vbseo_get_db();
$gq = $db->vbseodb_query("SELECT * FROM " . vbseo_tbl_prefix('vbseo_likes') . " WHERE $whr");
$lrems = array();
while($li = $db->vbseodb_fetch_assoc($gq))
{
$lrems[$li['l_cgroup']]++;
self::like_counter_user($li['l_from_userid'], $li['l_dest_userid'], -1);
}
$db->vbseodb_query("DELETE FROM " . vbseo_tbl_prefix('vbseo_likes') . " WHERE $whr");
foreach($lrems as $gid=>$lrem)
self::like_counter_type($ctype, $gid, -$lrem);
return true;
}
public static function move_likes($cgroup, $destgroup, $ctype)
{
Revise this Paste