par
scabbed » 12 janv. 2006, 00:48
bonjour à tous, voila j'ai un problème, en fait mon forum tourne sous vbulletin jusque là tout va bien, j'ai téléchargé un hack pour que les utilisateurs puissent créer des journaux sur le forum, ce hack marche très bien sous php4 mais l'auteur alerte les gens en disant qu'il ne fonctionne pas sous php5
malheureusement mon hebergeur est passé en php5 et depuis j'ai cette erreur :
Parse error: parse error, unexpected T_PRIVATE, expecting ']' in /home/scabbed/public_html/forum/journal.php(564) : eval()'d code on line 188
je ne sais pas comment la resoudre vu que je ne connais pas grand chose en php et vu que le gars a arreté le support je me retrouve comme un c**
voila la ligne concernée
{
$pagenumber = $countj['journals'];
}
voila le fichier journal.php si ça peut vous aider, merci d'avance
<?php
/*======================================================================*\
|| #################################################################### ||
|| # vB Journal 1.0.2 Beta 1 # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright © 2005 KirbyDE. All Rights Reserved. # ||
|| # Original vB Journal script for 3.0.x Copyright © 2004 AN-net. # ||
|| # "vBlog" additions contributed by Oblivion Knight. # ||
|| # ---------------------------------------------------------------- # ||
|| # http://www.vbulletin.org/forum/showthread.php?t=96462 # ||
|| #################################################################### ||
\*======================================================================*/
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// ##################### DEFINE IMPORTANT CONSTANTS #######################
define('CVS_REVISION', '$RCSfile: journal.php,v $ - $Revision: 1.8 $');
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
define('GET_EDIT_TEMPLATES', true);
define('THIS_SCRIPT', 'journal');
// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('posting', 'journalhack');
$globaltemplates = array(
'forumdisplay_loggedinuser',
'journal_journalbits',
'journal_latestentrybit',
'journal_latestjournalbit',
'navbar',
'JOURNAL',
'journal_entrybits',
'journal_recent_comments',
'journal_journalpage',
'journal_commentbits',
'journal_commentpage',
'journal_moods',
'journal_startpage',
'journal_submitentry',
'journal_showentrypage',
'journal_edit_journalinfo',
'journal_edit_entryinfo',
'journal_edit_commentinfo',
'journal_deletion_entry_confirmation',
'journal_deletion_journal_confirmation',
'journal_search',
'journal_searchresults',
'journal_buddy',
'journal_showbuddies',
'journal_top_viewed',
'journal_most_entries',
'journal_most_comments',
'journal_top_rated',
'journal_toppage',
'showthread_quickreply'
);
$specialtemplates= array(
'bbcodecache',
'smiliecache',
'journal_opt'
);
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
$vbulletin->input->clean_array_gpc('r', array(
'j' => TYPE_INT,
'e' => TYPE_INT,
'c' => TYPE_INT
));
// ATTN Compatibility Code
$j =& $vbulletin->GPC['j'];
$e =& $vbulletin->GPC['e'];
$c =& $vbulletin->GPC['c'];
// ATTN Compatibility Code
$vbulletin->session->db_fields['injournal'] = TYPE_INT;
function journalist_check($jid,$checkid)
{
global $db;
$check= $db->query_first("SELECT journalist_id FROM " . TABLE_PREFIX . "journals WHERE journal_id='".$jid."'");
if($check['journalist_id']!=$checkid)
{
return "false";
}
else
{
return "true";
}
}
function construct_allowed_users($allowjbuddies, $jbuddylist, $whocanview)
{
if ($allowjbuddies)
{
return trim(trim($whocanview) . ',' . trim(str_replace(' ', ',', $jbuddylist)));
}
else
{
return $whocanview;
}
}
//$setting=$db->query_first("SELECT * FROM " . TABLE_PREFIX . "journal_settings");
$vbulletin->journal_opt = unserialize($vbulletin->journal_opt);
$setting =& $vbulletin->journal_opt;
//######### Begin Building Permissions ################################
$canhave['journal'] = (($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['canhavejournal']) AND ($vbulletin->userinfo['canhavejournal']));
$canview['comments'] = ($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['canviewcomments']);
$can['comment'] = (($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['cancommentjournals']) AND $setting['allow_commenting']);
$can['rate'] = ($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['canratejournals']);
$can['report'] = (($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['canreportentries']) AND $setting['allow_reporting']);
$caneditown['journal'] = (($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['caneditownjournal']));
$caneditown['entry'] = (($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['caneditownentries']));
$caneditown['comment'] = (($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['caneditowncomments']));
$candeleteown['journal'] = ($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['candeleteownjournal']);
$candeleteown['entry'] = ($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['candeleteownentries']);
$can['search'] = (($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['cansearchjournal']) AND $setting['allow_searching']);
//######### Stop Building Permissions ################################
// *********************************************************************************
// check permissions
if (!$vbulletin->products['journalhack'])
{
eval(standard_error(fetch_error('journalmodulenotactive')));
}
if (!($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['canviewjournal']))
{
print_no_permission();
}
if (!$_REQUEST['do'])
{
$_REQUEST['do'] = 'showindex';
}
if ($_REQUEST['do'] == 'showindex')
{
$vbulletin->input->clean_array_gpc('r', array(
'page' => TYPE_INT,
'pp' => TYPE_INT,
'order' => TYPE_NOHTML,
'sort' => TYPE_NOHTML
));
// ATTN Compatibility Code
$page =& $vbulletin->GPC['page'];
$pp =& $vbulletin->GPC['pp'];
$order =& $vbulletin->GPC['order'];
$sort =& $vbulletin->GPC['sort'];
// ATTN Compatibility Code
$countj = $db->query_first("
### Journal Lisiting Pagination ####
SELECT COUNT(*) AS journals FROM " . TABLE_PREFIX . "journals
WHERE active=1
AND (journalist_id=" . $vbulletin->userinfo['userid'] . " OR private !=1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', allowedusers))
");
// Setup Pagination
// TODO: Handle pp
$perpage=$setting['journals_perpage'];
if (empty($page))
{
$page= 1;
}
$start= (($page * $perpage) - $perpage);
$pagenumber = $page++;
if ($pagenumber < 1)
{
$pagenumber = 1;
}
else if ($pagenumber > $countj['journals'])
{
$pagenumber = $countj['journals'];
}
$pgnav= construct_page_nav($pagenumber, $perpage, $countj['journals'], "journal.php?" . $vbulletin->session->vars['sessionurl'] . (!empty($vbulletin->GPC['pp']) ? "&pp=$perpage" : ""));
require_once(DIR . '/includes/functions_bigthree.php');
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$browsers = '';
$comma = '';
// Don't put the inthread value in the WHERE clause as it might not be the newest location!
$journalusers = $db->query_read("
### Users in Journal ###
SELECT user.username, user.usergroupid, user.membergroupids,
session.userid, session.inthread, session.injournal, session.location, session.lastactivity,
IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid,
IF(user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ", 1, 0) AS invisible
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)
WHERE session.lastactivity > $datecut
ORDER BY " . iif($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehidden'], 'invisible ASC, ') . "username ASC, lastactivity DESC
");
$numberguest = 0;
$numberregistered = 0;
$doneuser = array();
if ($vbulletin->userinfo['userid']) // fakes the user being in Journal
{
$vbulletin->userinfo['joingroupid'] = iif($vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['usergroupid']);
$loggedin = array(
'userid' => $vbulletin->userinfo['userid'],
'username' => $vbulletin->userinfo['username'],
'invisible' => $vbulletin->userinfo['invisible'],
'invisiblemark' => $vbulletin->userinfo['invisiblemark'],
'inthread' => $threadinfo['threadid'],
'lastactivity' => TIMENOW,
'musername' => fetch_musername($vbulletin->userinfo, 'joingroupid')
);
$numberregistered = 1;
$numbervisible = 1;
fetch_online_status($loggedin);
eval('$activeusers = "' . fetch_template('forumdisplay_loggedinuser') . '";');
$doneuser["{$vbulletin->userinfo['userid']}"] = 1;
$comma = ', ';
}
// this requires the query to have lastactivity ordered by DESC so that the latest location will be the first encountered.
while ($loggedin = $db->fetch_array($journalusers))
{
devdebug("loggedid: $loggedin[userid]");
if (empty($doneuser["$loggedin[userid]"]))
{
if ($loggedin['userid'] == 0) // Guest
{
if (strpos($loggedin['location'], 'journal.php') !== false)
{
$numberguest++;
}
}
else
{
if (strpos($loggedin['location'], 'journal.php') !== false)
{
$loggedin['musername'] = fetch_musername($loggedin);
$numberregistered++;
if (fetch_online_status($loggedin))
{
eval('$activeusers .= "' . $comma . fetch_template('forumdisplay_loggedinuser') . '";');
$comma = ', ';
}
}
}
if ($loggedin['userid'])
{
$doneuser["$loggedin[userid]"] = 1;
}
if(!empty($loggedin['injournal']))
{
$injournal['id']= $loggedin['injournal'];
$injournal[$loggedin['injournal']]++;
}
}
}
if (!$vbulletin->userinfo['userid'] AND !$numberguest)
{
$numberguest = 1;
}
global $injournal;
$totalviewing = $numberregistered + $numberguest;
if(isset($sort))
{
// TODO: Convert to switch, might be faster (no array operations)
if (!in_array($sort, array(journalist, journalname, journaldate,journaldesc, entrycount, lastentry_date, lastentry)))
{
$sort= "lastentry_date";
}
}
else
{
$sort='lastentry_date';
}
if(isset($order))
{
if(!in_array($order, array(DESC, ASC)))
{
$order= "DESC";
}
}
else
{
$order= "DESC";
}
$fjournals = $db->query_read("
### Journal Listing ###
SELECT
journals.lastentry_uids, journals.journal_id, journals.journalname, journals.journaldesc,
journals.journalist, journals.journalist_id, entrycount, commentcount, usertextfield.jbuddylist, ipaddress, journals.lastentry,
journals.lastentry_date, journals.private, journals.whocanview, journals.lastentry_id, journals.status, journals.allowbuddies, journals.journalviews,
journals.journal_totalrating AS totalrating, journals.journal_totalvotes AS totalvotes
FROM " . TABLE_PREFIX . "journals AS journals
LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON (journals.journalist_id=usertextfield.userid)
WHERE journals.active=1
AND (journals.journalist_id=" . $vbulletin->userinfo['userid'] . " OR journals.private != 1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journals.allowedusers))
ORDER BY $sort $order
LIMIT $start,$perpage
");
$check= $db->num_rows($fjournals);
if($check=="0")
{
$journalbits= $vbphrase['journalnojournals'];
}
else
{
while ($journal = $db->fetch_array($fjournals))
{
$journalid =& $journal['journal_id'];
if (empty($journal['totalrating']) OR empty($journal['totalvotes']))
{
$rating= "0";
}
else
{
$calcrating= $journal['totalrating']/$journal['totalvotes'];
$rating= round($calcrating);
}
if($injournal['id']==$journal['journal_id'])
{
$viewing[$journal['journal_id']]= $injournal[$injournal['id']];
}
else
{
$viewing[$journal['journal_id']]= 0;
}
if ($journal['private'])
{
$show['privatelock']= true;
}
else
{
$show['privatelock']= false;
}
if ($vbulletin->userinfo['lastvisitdate']=="Never")
{
$shownewentryicon[$journal['journal_id']]= true;
}
else if($vbulletin->userinfo['lastvisit']<$journal['lastentry_date'])
{
$shownewentryicon[$journal['journal_id']]= true;
}
$lastedate= vbdate($vbulletin->options['dateformat'], $journal['lastentry_date'], 1);
$lastetime= vbdate($vbulletin->options['timeformat'], $journal['lastentry_date']);
$journal['lastentry']= fetch_trimmed_title($journal['lastentry'], 30);
if ($journal['private']==1)
{
$journal_wcv = explode(',', $journal['whocanview']);
if ($vbulletin->userinfo['userid']==$journal['journalist_id'])
{
$canview['thisjournal']= true;
}
else if ($vbulletin->userinfo['usergroupid']=="6")
{
$canview['thisjournal']= true;
}
else if ((in_array($vbulletin->userinfo['userid'], $journal_wcv)) AND ($vbulletin->userinfo['userid']!=0))
{
$canview['thisjournal']= true;
}
else if ($journal['allowbuddies'])
{
if ((in_array($vbulletin->userinfo['userid'], explode(' ', $journal['jbuddylist']))) AND ($vbulletin->userinfo['userid']!=0))
{
$canview['thisjournal']= true;
}
}
else
{
$canview['thisjournal']= false;
}
}
else
{
$canview['thisjournal']= true;
}
$show['lastentry'] = (empty($journal['lastentry_uids']) OR ($journal['journalist_id'] == $vbulletin->userinfo['userid']) OR (strpos(",$journal[lastentry_uids],", ',' . $vbulletin->userinfo['userid'] . ',') !== false)) ? true : false;
if ($canview['thisjournal'])
{
eval('$journalbits .= "' . fetch_template('journal_journalbits') . '";');
}
}
$db->free_result($journal);
}
// TODO: Setting for # of latest Entries
$getlateste = $db->query_read("
### Latest Journal Entries ###
SELECT journal_entries.entrytitle,journal_entries.entrydate,journal_entries.entry_id,
journal_entries.entrytext,journal_entries.journal_id,journals.journalist,journals.journalist_id
FROM " . TABLE_PREFIX . "journal_entries AS journal_entries
LEFT JOIN " . TABLE_PREFIX . "journals AS journals ON (journal_entries.journal_id=journals.journal_id)
WHERE journal_entries.entry_active=1
AND journals.active=1
AND (
(journals.journalist_id=" . $vbulletin->userinfo['userid'] . ")
OR
(journals.private!=1 AND journal_entries.private!=1)
OR
(journals.private=1 AND journal_entries.private!=1 AND FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journals.allowedusers))
OR
(journals.private!=1 AND journal_entries.private=1 AND FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journal_entries.allowedusers))
OR
(journals.private=1 AND journal_entries.private=1 AND FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journals.allowedusers) AND FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journal_entries.allowedusers))
)
ORDER BY journal_entries.entrydate DESC
LIMIT 5
");
$countlatest= $db->num_rows($getlateste);
$latestentrybits = "";
$latestdata = array();
$counter = 0;
if ($countlatest>0)
{
while($latest= $db->fetch_array($getlateste))
{
$latestdata["$counter"]['entry'] = $latest;
$counter++;
}
$db->free_result($lastest);
}
else
{
// TODO: Hardcoded Text
$latestentrybits="There are no entries.";
}
$getlatestj = $db->query_read("
### Latest Journals ###
SELECT journalname,journalist,journalist_id,journal_id,journaldate,journaldesc FROM " . TABLE_PREFIX . "journals
WHERE active=1
AND (journalist_id=" . $vbulletin->userinfo['userid'] . " OR private != 1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', allowedusers))
ORDER BY journaldate
DESC LIMIT 5
");
$countlatestj= $db->num_rows($getlatestj);
$counter = 0;
if($countlatestj>0)
{
while($latestj= $db->fetch_array($getlatestj))
{
$latestdata["$counter"]['journal'] = $latestj;
$counter++;
}
$db->free_result($lastestj);
}
else
{
$latestjournalbits="There are no journals.";
}
$bgclass='alt1';
foreach ($latestdata AS $latestbit)
{
$latest = $latestbit['entry'];
$latestentrydate= vbdate($vbulletin->options['dateformat'], $latest['entrydate'], 1);
$latestentrytime= vbdate($vbulletin->options['timeformat'], $latest['entrydate']);
// exec_switch_bg();
// TODO: fetch_trimmed_title()
if(strlen($latest[entrytitle])>20)
{
$latest[entrytitle]= "".substr($latest[entrytitle],0,20)."...";
}
if (strlen($latest[entrytext])>150)
{
$latest[entrytext]= "".substr($latest[entrytext],0,150)."...";
}
$latest['entrytext']= htmlspecialchars_uni($latest['entrytext']);
eval('$latestbits .= "<tr>' . fetch_template('journal_latestentrybit') . '";');
$latestj = $latestbit['journal'];
if ($latestj['journaldate'])
{
$journaldate= vbdate($vbulletin->options['dateformat'], $latestj['journaldate'], 1);
$journaltime= vbdate($vbulletin->options['timeformat'], $latestj['journaldate']);
exec_switch_bg();
// TODO: fetch_trimmed_title()
if(strlen($latestj['journaldesc'])>200)
{
$latestj['journaldesc']= "".substr($latestj['journaldesc'],0,200)."...";
}
eval('$latestbits .= "' . fetch_template('journal_latestjournalbit') . '</tr>";');
}
else
{
$latestbits .= '</tr>';
}
}
$jbuddies = trim($vbulletin->userinfo['jbuddylist']);
if (!empty($jbuddies))
{
$users = $db->query_read("
### Journal Buddies ###
SELECT journalist, journalist_id, journal_id
FROM " . TABLE_PREFIX . "journals
WHERE journalist_id IN (" . str_replace(' ', ',', $vbulletin->userinfo['jbuddylist']) . ")
ORDER BY journalist ASC
");
$bcount = $db->num_rows($jbuddies);
$buddycount = 0;
$jbuddy_listbits= '';
while ($jbuddy = $db->fetch_array($users))
{
$buddycount++;
$journal_id =& $jbuddy['journal_id'];
$username =& $jbuddy['journalist'];
eval('$jbuddy_listbits .= "' . fetch_template('journal_buddy') . '";');
}
$db->free_result($jbuddies);
if (!$buddycount)
{
$jbuddy_listbits = $vbphrase['no_journal_buddies'];
}
}
else
{
$buddycount = 0;
$jbuddy_listbits = $vbphrase['no_journal_buddies'];
}
$buddycount = vb_number_format($buddycount);
unset($comma, $userinfos, $userid, $userinfo, $loggedin, $journalusers, $datecut);
$total = $db->query_first("
### Journal Statistics ###
SELECT COUNT(*) AS journals, SUM(entrycount) AS entries, SUM(commentcount) AS comments, SUM(journalviews) AS views FROM " . TABLE_PREFIX . "journals WHERE active=1
");
$total['entries']= vb_number_format($total['entries']);
$total['comments']= vb_number_format($total['comments']);
$total['views']= vb_number_format($total['views']);
$totaljournals= vb_number_format($total['journals']);
$navbits= array();
// TODO: Cache latest journalist
$getlatestj= $db->query_first("
### Latest Journalist ###
SELECT journalist,journal_id FROM " . TABLE_PREFIX . "journals WHERE active=1 AND private!=1 ORDER BY journaldate DESC
");
$journalcount = vb_number_format($countj['journals']);
$journalsstart = vb_number_format($start+1);
$journalsend = vb_number_format(min($start+$perpage, $countj['journals']));
// TODO: Hardcoded Text
$navbits["#"]= $vbphrase['journals'];
$navbits['']= $vbphrase['journal_index'];
$navbits= construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('JOURNAL') . '");');
$db->free_result($journalusers);
$db->free_result($countj);
}
if ($_REQUEST['do'] == 'showjournal')
{
$vbulletin->input->clean_array_gpc('r', array(
'page' => TYPE_INT,
'pp' => TYPE_INT,
'highlight' => TYPE_STR,
'order' => TYPE_NOHTML,
'sort' => TYPE_NOHTML
));
// ATTN Compatibility Code
$page =& $vbulletin->GPC['page'];
$pp =& $vbulletin->GPC['pp'];
$highlight =& $vbulletin->GPC['highlight'];
$order =& $vbulletin->GPC['order'];
$sort =& $vbulletin->GPC['sort'];
// ATTN Compatibility Code
$journalinfo= $db->query_first("
SELECT journals.journalname, journals.journalist_id, journals.journal_id, journals.journalviews, journals.journalist, journals.journal_totalrating AS totalrating, journals.journal_totalvotes AS totalvotes, journals.journaldate, journals.whocanview, journals.allowbuddies, journals.whovoted, journals.lastentry_date, journals.status, journals.journaldesc, commentcount, entrycount, journals.ipaddress, usertextfield.jbuddylist, journals.private
FROM " . TABLE_PREFIX . "journals AS journals
LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON (usertextfield.userid=journals.journalist_id)
WHERE journals.journal_id=$j
AND journals.active=1
");
if ($journalinfo['journal_id'])
{
$vbulletin->session->set('injournal', $journalinfo['journal_id']);
}
else
{
eval(standard_error(fetch_error('invalidid', 'Journal', $vbulletin->options['contactuslink'])));
}
/* Build Buddy List */
$jbuddies= explode(' ', $journalinfo['jbuddylist']);
if ($journalinfo['private']==1)
{
$journal_wcv = explode(',', $journalinfo['whocanview']);
if ($vbulletin->userinfo['userid']==$journalinfo['journalist_id'])
{
$canview['thisjournal']= true;
}
else if ($vbulletin->userinfo['usergroupid']=="6")
{
$canview['thisjournal']= true;
}
else if ((in_array($vbulletin->userinfo['userid'], $journal_wcv)) AND ($vbulletin->userinfo['userid']!=0))
{
$canview['thisjournal']= true;
}
else if (($journalinfo['allowbuddies']==1) AND (in_array($vbulletin->userinfo['userid'], $jbuddies)))
{
$canview['thisjournal']= true;
}
else
{
$canview['thisjournal']= false;
}
}
else
{
$canview['thisjournal']= true;
}
if ($canview['thisjournal'])
{
$db->query_write("UPDATE " . TABLE_PREFIX . "journals SET journalviews=journalviews+1 WHERE journal_id='".intval($j)."'");
$private = $db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "journal_entries WHERE entry_active=1 AND private=1 AND journal_id=".$j."");
/* Build Relations */
if ($vbulletin->userinfo['userid'])
{
if (in_array($vbulletin->userinfo['userid'], $jbuddies))
{
$show['youareabuddy']= true;
}
else
{
$show['youareabuddy']= false;
}
$viewersjbuddies= explode(' ', $vbulletin->userinfo['jbuddylist']);
if (in_array($journalinfo['journalist_id'], $viewersjbuddies))
{
$show['isabuddyofu']= true;
}
else
{
$show['isabuddyofu']= false;
}
}
/* Stop Building Relations */
/* Build Who Has Rated */
if ($vbulletin->userinfo['userid'])
{
if(isset($journalinfo['whovoted']) AND !empty($journalinfo['whovoted']))
{
$whovoted= unserialize($journalinfo['whovoted']);
if (in_array($vbulletin->userinfo['userid'], $whovoted))
{
$show['voteform']= false;
}
else
{
$show['voteform']= true;
}
}
else
{
$show['voteform']= true;
}
}
/* Stop Building Who Has Rated */
$journalinfo['lastupdated']= vbdate($vbulletin->options['dateformat'], $journalinfo['lastentry_date'], 1);
require_once(DIR . '/includes/functions_bigthree.php');
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$browsers = '';
$comma = '';
$journalviewers = $db->query_read("
SELECT user.username, user.usergroupid, user.membergroupids,
session.userid, session.inthread, session.injournal, session.location, session.lastactivity,
IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid,
IF(user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ", 1, 0) AS invisible
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)
WHERE session.lastactivity > $datecut
ORDER BY " . iif($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehidden'], 'invisible ASC, ') . "username ASC, lastactivity DESC
");
$numberguest = 0;
$numberregistered = 0;
$doneuser = array();
if ($vbulletin->userinfo['userid'])
{
$vbulletin->userinfo['joingroupid'] = iif($vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['usergroupid']);
$loggedin = array(
'userid' => $vbulletin->userinfo['userid'],
'username' => $vbulletin->userinfo['username'],
'invisible' => $vbulletin->userinfo['invisible'],
'invisiblemark' => $vbulletin->userinfo['invisiblemark'],
'inthread' => $threadinfo['threadid'],
'lastactivity' => TIMENOW,
'musername' => fetch_musername($vbulletin->userinfo, 'joingroupid')
);
$numberregistered = 1;
$numbervisible = 1;
fetch_online_status($loggedin);
eval('$activeusers = "' . fetch_template('forumdisplay_loggedinuser') . '";');
$doneuser["{$vbulletin->userinfo['userid']}"] = 1;
$comma = ', ';
}
// this requires the query to have lastactivity ordered by DESC so that the latest location will be the first encountered.
while ($loggedin = $db->fetch_array($journalviewers))
{
if (empty($doneuser["$loggedin[userid]"]))
{
if ($loggedin['userid'] == 0) // Guest
{
if($loggedin['injournal']==$j)
{
$numberguest++;
}
}
else
{
if ($loggedin['injournal']==$j)
{
$loggedin['musername'] = fetch_musername($loggedin);
$numberregistered++;
if (fetch_online_status($loggedin))
{
eval('$activeusers .= "' . $comma . fetch_template('forumdisplay_loggedinuser') . '";');
$comma = ', ';
}
}
}
if ($loggedin['userid'])
{
$doneuser["$loggedin[userid]"] = 1;
}
}
}
if (!$vbulletin->userinfo['userid'] AND !$numberguest)
{
$numberguest = 1;
}
$totalviewing = $numberregistered + $numberguest;
$journal['startdate']= vbdate($vbulletin->options['dateformat'], $journalinfo['journaldate'], 1);
if($journalinfo['totalvotes']!=0 AND $journalinfo['totalrating']!=0)
{
$journalrating= round($journalinfo['totalrating']/$journalinfo['totalvotes']);
}
else
{
$journalrating= 0;
}
require_once(DIR . '/includes/functions_user.php');
$avatar = fetch_avatar_url($journalinfo['journalist_id']);
if ($avatar == '')
{
$show['avatar'] = false;
}
else
{
$show['avatar'] = true;
// $userinfo['avatarsize'] = $avatarurl[1];
$avatarurl = $avatar[0];
}
if (empty($journalinfo))
{
eval(standard_error(fetch_error('journalnotexist')));
}
else
{
$counte= $db->query_first("SELECT COUNT(*) AS entries FROM " . TABLE_PREFIX . "journal_entries WHERE entry_active='1'
AND journal_id=$j
" . iif($journalinfo['journalist_id'] != $vbulletin->userinfo['userid'], "AND (private != 1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', allowedusers))") . "
");
$perpage= $setting['journalentries_perpage'];
if(empty($page))
{
$page= 1;
}
$start= (($page * $perpage) - $perpage);
$pagenumber = $page++;
if ($pagenumber < 1)
{
$pagenumber = 1;
}
else if ($pagenumber > $counte['entries'])
{
$pagenumber = $counte['entries'];
}
$pgnav= construct_page_nav($pagenumber, $perpage, $counte['entries'], "journal.php?" . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=$j" . (!empty($vbulletin->GPC['pp']) ? "&pp=$perpage" : ""));
if (!empty($highlight))
{
$highlight = preg_replace('#\*+#s', '*', $highlight);
if ($highlight != '*')
{
$regexfind = array('\*', '\<', '\>');
$regexreplace = array('[\w.:@*/?=]*?', '<', '>');
$highlight = preg_quote(strtolower($highlight), '#');
$highlight = explode(' ', $highlight);
$highlight = str_replace($regexfind, $regexreplace, $highlight);
foreach ($highlight AS $val)
{
if ($val = trim($val))
{
$replacewords[] = htmlspecialchars_uni($val);
}
}
}
}
$fentries = $db->query_read("
SELECT journal_entries.entry_id, journal_entries.entrytitle,
journal_entries.entrytext, journal_entries.mood, journal_entries.np, journal_entries.allowbuddies,journal_entries.entrydate,
journal_entries.entry_totalvotes, journal_moods.mood_name, journal_entries.ipaddress,journal_moods.mood_image, journal_entries.entry_totalrating,
journal_entries.private, journal_entries.whocanview,
COUNT(journal_comments.comment_text) AS comments
FROM " . TABLE_PREFIX . "journal_entries AS journal_entries
LEFT JOIN " . TABLE_PREFIX . "journal_comments AS journal_comments ON (journal_entries.entry_id=journal_comments.entry_id)
LEFT JOIN " . TABLE_PREFIX . "journal_moods AS journal_moods ON (journal_moods.mood_id=journal_entries.mood)
WHERE journal_entries.journal_id=$j
AND entry_active='1'
" . iif($journalinfo['journalist_id'] != $vbulletin->userinfo['userid'], "AND (journal_entries.private != 1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journal_entries.allowedusers))") . "
GROUP BY journal_entries.entry_id
ORDER BY entrydate DESC
LIMIT $start,$perpage
");
$check= $db->num_rows($fentries);
if (!$check)
{
$entrybits= $vbphrase['journalnoentries'];
}
else
{
$enum2 = $counte['entries']-(($pagenumber-1)*$perpage);
while ($entry= $db->fetch_array($fentries))
{
$enum = $enum2--;
$moo++;
$entry['date']= vbdate($vbulletin->options['dateformat'], $entry['entrydate'], 1);
$entry['time']= vbdate($vbulletin->options['timeformat'], $entry['entrydate']);
if (empty($entry['entry_totalrating']) OR empty($entry['entry_totalvotes']))
{
$rating= "0";
}
else
{
$calcrating= $entry['entry_totalrating']/$entry['entry_totalvotes'];
$rating= round($calcrating);
}
require_once(DIR . '/includes/functions_newpost.php');
$entry['entrytext']= convert_url_to_bbcode($entry['entrytext']);
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$entry['entrytext']= $bbcode_parser->do_parse($entry['entrytext'], 0, $setting['allow_imgcode'], $setting['allow_smilies'], $setting['allow_bbcode']);
// ATTN: Highlighting broken
/* if (is_array($replacewords))
{
$entry['entrytext'] = preg_replace('#(^|>)([^<]+)(?=<|$)#sUe', "process_highlight_postbit('\\2', \$replacewords, '\\1')", $entry['entrytext']);
$entry['entrytext'] = preg_replace('#<vb_highlight>(.*)</vb_highlight>#siU', '<span class="highlight">$1</span>', $entry['entrytext']);
} */
if (isset($entry['mood']) AND $entry['mood']>0)
{
$show['mood']= true;
}
else
{
$show['mood']= false;
}
// TODO: Get rid of those checks here, as they seem to be unnecessary anyway
$wcv_entry = explode(',', $entry['whocanview']);
if ($entry['private'])
{
if ($vbulletin->userinfo['userid']==$journalinfo['journalist_id'])
{
eval('$entrybits .= "' . fetch_template('journal_entrybits') . '";');
}
else if ($vbulletin->userinfo['usergroupid']=="6")
{
eval('$entrybits .= "' . fetch_template('journal_entrybits') . '";');
}
else if ((in_array($vbulletin->userinfo['userid'], $wcv_entry)) AND ($vbulletin->userinfo['userid']!=0))
{
eval('$entrybits .= "' . fetch_template('journal_entrybits') . '";');
}
else if ($entry['allowbuddies'])
{
if ((in_array($vbulletin->userinfo['userid'], $jbuddies)) AND ($vbulletin->userinfo['userid']!=0))
{
eval('$entrybits .= "' . fetch_template('journal_entrybits') . '";');
}
}
else
{
$entrybits.= '';
}
}
else
{
eval('$entrybits .= "' . fetch_template('journal_entrybits') . '";');
}
}
$db->free_result($entry);
}
if ($canview['comments'])
{
$recent_comments= $db->query_read("
SELECT commenter,commenter_id,comment_title,comment_text,comment_date
FROM " . TABLE_PREFIX . "journal_comments AS journal_comments
LEFT JOIN " . TABLE_PREFIX . "journal_entries AS journal_entries ON (journal_entries.entry_id=journal_comments.entry_id)
WHERE journal_comments.journal_id=$j
AND (ISNULL(journal_entries.entry_id) OR journal_entries.entry_active=1)
" . iif($journalinfo['journalist_id'] != $vbulletin->userinfo['userid'], "AND (ISNULL(journal_entries.entry_id) OR journal_entries.private != 1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journal_entries.allowedusers))") . "
ORDER BY comment_date DESC LIMIT 5
");
$check_comments= $db->num_rows($recent_comments);
if ($check_comments<1)
{
// TODO: Hardcoded Text
$reccombits="<tr><td>There are no Comments.</td></tr>\n";
}
else
{
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
while($reccom= $db->fetch_array($recent_comments))
{
$commentdate= vbdate($vbulletin->options['dateformat'], $reccom['comment_date'], 1);
$commenttime= vbdate($vbulletin->options['timeformat'], $reccom['comment_date']);
$reccom['comment_text']= $bbcode_parser->do_parse($reccom['comment_text'], 0, $setting['allow_imgcode'], $setting['allow_smilies'], $setting['allow_bbcode']);
eval('$reccombits .= "' . fetch_template('journal_recent_comments') . '";');
}
$db->free_result($reccom);
}
}
$navbits= array();
$navbits["journal.php"]= $vbphrase['journals'];
if(!empty($journalinfo['journalname']))
{
$navbits['']= $journalinfo['journalname'];
}
else
{
$navbits['']= construct_phrase($vbphrase['xs_journal'], $journalinfo['journalist']);
}
$navbits= construct_navbits($navbits);
require_once(DIR . '/includes/functions_editor.php');
$show['wysiwyg'] = ($setting['allow_bbcode'] ? is_wysiwyg_compatible() : 0);
$istyles_js = construct_editor_styles_js();
$show['qr_require_click'] = 0;
$editorid = construct_edit_toolbar('', 0, 'journal', ($setting['allow_smilies'] ? 1 : 0), 1, false, 'qr');
$messagearea = "
<script type=\"text/javascript\">
<!--
var require_click = false;
var threaded_mode = 1;
var is_last_page = false;
// -->
</script>
$messagearea
";
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_journalpage') . '");');
$db->free_result($journalinfo);
$db->free_result($avatar);
$db->free_result($loggedin);
}
}
else
{
print_no_permission();
}
}
if ($_REQUEST['do'] == 'showcomments')
{
$jpermissions= $db->query_first("SELECT journal_id,private,allowbuddies,whocanview,jbuddylist,journalist_id,status FROM " . TABLE_PREFIX . "journals AS journals
LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON (usertextfield.userid=journals.journalist_id)
WHERE journal_id=".$j."");
if (!$jpermissions['journal_id'])
{
eval(standard_error(fetch_error('invalidid', 'Journal', $vbulletin->options['contactuslink'])));
}
if ($jpermissions['private']==1)
{
$journal_wcv = explode(',', $jpermissions['whocanview']);
if (($vbulletin->userinfo['usergroupid']=="6") OR ($vbulletin->userinfo['userid']==$jpermissions['journalist_id']) OR ($vbulletin->userinfo['userid'] AND in_array($vbulletin->userinfo['userid'], $journal_wcv)))
{
$canview['thisjournal']= true;
}
else if ($jpermissions['allowbuddies']==1)
{
$jbuddies= explode(' ', $jpermissions['jbuddylist']);
if(in_array($vbulletin->userinfo['userid'], $jbuddies))
{
$canview['thisjournal']= true;
}
}
else
{
$canview['thisjournal']= false;
}
}
else
{
$canview['thisjournal']= true;
}
if (!$canview['comments'] OR !$canview['thisjournal'])
{
print_no_permission();
}
// Hmm.. I wonder
$vbulletin->input->clean_array_gpc('r', array(
'page' => TYPE_INT,
'e' => TYPE_INT,
));
$page =& $vbulletin->GPC['page'];
$e =& $vbulletin->GPC['e'];
if($e)
{
$entryinfo= $db->query_first("SELECT entry_id,entrytitle, private, allowedusers FROM " . TABLE_PREFIX . "journal_entries WHERE journal_id='".intval($j)."' AND entry_id='".intval($e)."'");
$entryget=" AND journal_entries.entry_id='".intval($e)."'";
// TODO: Check Permissions for this Entry
if (!$entryinfo['entry_id'])
{
eval(standard_error(fetch_error('invalidid', 'Journal Entry', $vbulletin->options['contactuslink'])));
}
if ($entryinfo['private'] AND $vbulletin->userinfo['usergroupid']!="6" AND $vbulletin->userinfo['userid'] != $jpermissions['journalist_id'] AND strpos(",$entry[allowedusers],", ',' . $vbulletin->userinfo['userid'] . ',') == false)
{
print_no_permission();
}
}
$countc= $db->query_first("
SELECT COUNT(*) AS comments FROM " . TABLE_PREFIX . "journal_comments AS journal_comments
LEFT JOIN " . TABLE_PREFIX . "journal_entries AS journal_entries ON (journal_entries.entry_id=journal_comments.entry_id)
WHERE journal_comments.journal_id=$j" .iif(!empty($e), $entryget) . "
AND (ISNULL(journal_entries.entry_id) OR journal_entries.entry_active=1)
" . iif($jpermissions['journalist_id'] != $vbulletin->userinfo['userid'], "AND (ISNULL(journal_entries.entry_id) OR journal_entries.private != 1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journal_entries.allowedusers))") . "
");
$perpage= $setting['journalentries_perpage'];
if (empty($page))
{
$page= 1;
}
$start= (($page * $perpage) - $perpage);
$pagenumber = $page++;
if ($pagenumber < 1)
{
$pagenumber = 1;
}
else if ($pagenumber > $countc['comments'])
{
$pagenumber = $countc['comments'];
}
$pgnav= construct_page_nav($pagenumber, $perpage, $countc['comments'], "journal.php?" . $vbulletin->session->vars['sessionurl'] . "do=showcomments&j=$j" . "&e=$e" . (!empty($vbulletin->GPC['pp']) ? "&pp=$perpage" : ""));
$fcomments= $db->query_read("
SELECT comment_id,comment_title,comment_text,comment_date,
commenter_id,commenter,journal_comments.ipaddress
FROM " . TABLE_PREFIX . "journal_comments AS journal_comments
LEFT JOIN " . TABLE_PREFIX . "journal_entries AS journal_entries ON (journal_entries.entry_id=journal_comments.entry_id)
WHERE journal_comments.journal_id='".$j."'".iif(!empty($e), $entryget)."
AND (ISNULL(journal_entries.entry_id) OR journal_entries.entry_active=1)
" . iif($jpermissions['journalist_id'] != $vbulletin->userinfo['userid'], "AND (ISNULL(journal_entries.entry_id) OR journal_entries.private != 1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journal_entries.allowedusers))") . "
ORDER BY comment_date DESC
LIMIT $start,$perpage
");
$totalcomms= $countc['comments'];
$cnum2= $countc['comments']-(($pagenumber-1)*$perpage);
while($comment= $db->fetch_array($fcomments))
{
$cnum = $cnum2--;
$baa++;
$comment['date']= vbdate($vbulletin->options['dateformat'], $comment['comment_date'], 1);
$comment['time']= vbdate($vbulletin->options['timeformat'], $comment['comment_date']);
require_once(DIR . '/includes/functions_newpost.php');
$comment['comment_text']= convert_url_to_bbcode($comment['comment_text']);
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$text= $bbcode_parser->do_parse($comment['comment_text'], 0, $setting['allow_imgcode'], $setting['allow_smilies'], $setting['allow_bbcode']);
eval('$commentbits .= "' . fetch_template('journal_commentbits') . '";');
}
$db->free_result($comment);
$journal= $db->query_first("SELECT journalname AS name,journalist FROM " . TABLE_PREFIX . "journals WHERE journal_id='".intval($j)."'");
$navbits= array();
$navbits['journal.php' . $vbulletin->session->vars['sessionurl_q']]= $vbphrase['journals'];
if (!empty($journal['name']))
{
$navbits['journal.php?' . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=$j"]= $journal['name'];
}
else
{
$navbits['journal.php?' . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=$j"]= construct_phrase($vbphrase['xs_journal'], $journal['journalist']);;
}
$navbits['']= $vbphrase['show_comments'];
$navbits= construct_navbits($navbits);
require_once(DIR . '/includes/functions_editor.php');
$show['wysiwyg'] = ($setting['allow_bbcode'] ? is_wysiwyg_compatible() : 0);
$istyles_js = construct_editor_styles_js();
$show['qr_require_click'] = 0;
$editorid = construct_edit_toolbar('', 0, 'journal', ($setting['allow_smilies'] ? 1 : 0), 1, false, 'qr');
$messagearea = "
<script type=\"text/javascript\">
<!--
var require_click = false;
var threaded_mode = 1;
var is_last_page = false;
var allow_ajax_qr = false;
// -->
</script>
$messagearea
";
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_commentpage') . '");');
$db->free_result($jpermissions);
}
if ($_REQUEST['do'] == 'insertcomment')
{
if (!$can['comment'])
{
print_no_permission();
}
$vbulletin->input->clean_array_gpc('p', array(
'title' => TYPE_NOHTML,
'wysiwyg' => TYPE_BOOL,
'message' => TYPE_STR
));
// ATTN Compatibility Code
$title =& $vbulletin->GPC['title'];
// ATTN Compatibility Code
if ($vbulletin->GPC['wysiwyg'])
{
require_once(DIR . '/includes/functions_wysiwyg.php');
$message = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], false);
}
else
{
$message =& $vbulletin->GPC['message'];
}
$floodcheck= $db->query_first("SELECT comment_date AS lastcomdate FROM " . TABLE_PREFIX . "journal_comments WHERE commenter_id=".$vbulletin->userinfo['userid']." ORDER BY comment_date DESC");
if ((TIMENOW - $floodcheck['lastcomdate'])<= $setting['floodint'])
{
eval(standard_error(fetch_error('journalfloodcheck', $setting['floodint'],' commenting')));
}
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "journal_comments
(journal_id,entry_id,comment_title,comment_text,commenter,commenter_id,comment_date,ipaddress)
VALUES ('".intval($j)."','".intval($e)."','".$db->escape_string($_POST['title'])."','".$db->escape_string($message)."',
'".$db->escape_string($vbulletin->userinfo['username'])."','".intval($vbulletin->userinfo['userid'])."','".TIMENOW."','". IPADDRESS ."')
");
$db->query_write("UPDATE " . TABLE_PREFIX . "journals SET commentcount=commentcount+1 WHERE journal_id=".intval($j)."");
$entryurl= "&e=".intval($e)."";
$vbulletin->url = "journal.php?" . $vbulletin->session->vars['sessionurl'] . "do=showcomments&j=".$j."".iif(!empty($e), $entryurl)."";
eval(print_standard_redirect('redirect_journalcommentinserted'));
}
if ($_REQUEST['do'] == 'deletecom')
{
$vbulletin->input->clean_array_gpc('r', array(
'j' => TYPE_INT,
'e' => TYPE_INT,
'com' => TYPE_INT
));
// ATTN Compatibility Code
$j =& $vbulletin->GPC['j'];
$e =& $vbulletin->GPC['e'];
$com =& $vbulletin->GPC['com'];
// ATTN Compatibility Code
if($vbulletin->userinfo['usergroupid']==6)
{
$db->query_write("DELETE FROM " . TABLE_PREFIX . "journal_comments WHERE comment_id=".$com."");
$db->query_write("UPDATE " . TABLE_PREFIX . "journals SET commentcount=commentcount-1 WHERE journal_id=".$j."");
$vbulletin->url= "journal.php?" . $vbulletin->session->vars['sessionurl'] . "do=showcomments&j=".$j."&e=".$e."";
eval(print_standard_redirect('redirect_journalcommentdeleted'));
}
else
{
print_no_permission();
}
}
if ($_REQUEST['do'] == 'startjournal')
{
if (!$canhave['journal'])
{
print_no_permission();
}
$check= $db->query_first("SELECT count(*) AS journal FROM " . TABLE_PREFIX . "journals WHERE journalist_id='".$vbulletin->userinfo['userid']."'");
if ($check['journal'])
{
eval(standard_error(fetch_error('journalalrdyexists')));
}
else
{
$getmoods= $db->query("SELECT * FROM " . TABLE_PREFIX . "journal_moods ORDER BY mood_name ASC");
while ($mood= $db->fetch_array($getmoods))
{
eval('$moodbits .= "' . fetch_template('journal_moods') . '";');
}
$db->free_result($mood);
$navbits= array();
$navbits["journal.php"]= "Journals";
require_once(DIR . '/includes/functions_editor.php');
$vbulletin->options['allowbbcode'] = $setting['allow_bbcode'];
$vbulletin->options['allowbbimagecode'] = $setting['allow_imgcode'];
$editorid = construct_edit_toolbar('', 0, 'journal', $setting['allow_smilies'], 1, 0);
$navbits['']= $vbphrase['create_journal'];
$navbits= construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_startpage') . '");');
}
}
if ($_REQUEST['do'] == 'insertjournal')
{
$vbulletin->input->clean_array_gpc('p', array(
'jname' => TYPE_NOHTML,
'jdesc' => TYPE_NOHTML,
'jpriv' => TYPE_INT,
'whocanviewj' => TYPE_NOHTML,
'etitle' => TYPE_NOHTML,
'message' => TYPE_STR,
'epriv' => TYPE_INT,
'whocanviewe' => TYPE_NOHTML,
'mood' => TYPE_INT,
'np' => TYPE_NOHTML,
'allowbuddsj' => TYPE_INT,
'allowbuddse' => TYPE_INT,
'wysiwyg' => TYPE_BOOL
));
// ATTN Compatibility Code
$jname =& $vbulletin->GPC['jname'];
$jdesc =& $vbulletin->GPC['jdesc'];
$jpriv =& $vbulletin->GPC['jpriv'];
$epriv =& $vbulletin->GPC['epriv'];
$whocanviewj =& $vbulletin->GPC['whocanviewj'];
$etitle =& $vbulletin->GPC['etitle'];
if ($vbulletin->GPC['wysiwyg'])
{
require_once(DIR . '/includes/functions_wysiwyg.php');
$emessage = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], false);
}
else
{
$emessage =& $vbulletin->GPC['message'];
}
$whocanviewe =& $vbulletin->GPC['whocanviewe'];
$mood =& $vbulletin->GPC['mood'];
$np =& $vbulletin->GPC['np'];
$allowbuddsj =& $vbulletin->GPC['allowbuddsj'];
$allowbuddse =& $vbulletin->GPC['allowbuddse'];
// ATTN Compatibility Code
if (!$canhave['journal'] OR !$vbulletin->userinfo['userid'])
{
print_no_permission();
}
$check= $db->query_first("SELECT count(*) AS journal FROM " . TABLE_PREFIX . "journals WHERE journalist_id='".$vbulletin->userinfo['userid']."'");
if ($check['journal'])
{
eval(standard_error(fetch_error('journalalrdyexists')));
}
if ($jpriv)
{
$allowedusers = construct_allowed_users($allowbuddsj, $vbulletin->userinfo['jbuddylist'], $whocanviewj);
}
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "journals
(allowedusers, journalist, journalist_id, journaldate,
journaldesc, private, allowbuddies, whocanview, lastentry,
lastentry_date,ipaddress, journalname" . ($setting['autoapprove_entries']==1 ? ',entrycount' : '')."".($setting['autoapprove_journals']==1 ? ',active' : '')."
)
VALUES
('" . $db->escape_string($allowedusers) . "', '".$db->escape_string($vbulletin->userinfo['username'])."', '".intval($vbulletin->userinfo['userid'])."',
".TIMENOW.", '".$db->escape_string($jdesc)."', ".$jpriv.", ".$allowbuddsj.", '".$db->escape_string($whocanviewj)."',
'".$db->escape_string($etitle)."', ".TIMENOW.",'". IPADDRESS ."', '" . $db->escape_string($jname) . "'" . ($setting['autoapprove_entries']==1 ? ',1' : '')."".($setting['autoapprove_journals'] ? ',1' : '')."
)
");
$preentry= $db->insert_id();
if ($epriv)
{
$allowedusers = construct_allowed_users($allowbuddse, $vbulletin->userinfo['jbuddylist'], $whocanviewe);
}
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "journal_entries
(allowedusers, journal_id, entrytitle, entrytext, entrydate,
private, allowbuddies, whocanview, ipaddress, mood, np".($setting['autoapprove_entries']==1 ? ',entry_active' : '')."
)
VALUES ('" . $db->escape_string($allowedusers) . "', '".$preentry."', '".$db->escape_string($etitle)."', '".$db->escape_string($emessage)."', ".TIMENOW.", '".$epriv."', ".$allowbuddse.",'".$db->escape_string($whocanviewe)."', '".$vbulletin->session->vars['host']."', ".$mood.", '".$db->escape_string($np)."'".($setting['autoapprove_entries']==1 ? ',1' : '')."
)
");
$entry= $db->insert_id();
$db->query_write("UPDATE " . TABLE_PREFIX . "journals SET lastentry_id='".$entry."'
WHERE lastentry='".$db->escape_string($etitle)."' AND journal_id='".$preentry."'
");
$vbulletin->url="journal.php?" . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=".$preentry."";
eval(print_standard_redirect('redirect_journalinserted'));
}
if ($_REQUEST['do'] == 'addentry')
{
if (!journalist_check($j, $vbulletin->userinfo['userid']) OR !$vbulletin->userinfo['userid'])
{
print_no_permission();
}
$getmoods= $db->query_read("SELECT * FROM " . TABLE_PREFIX . "journal_moods ORDER BY mood_name ASC");
while($mood= $db->fetch_array($getmoods))
{
eval('$moodbits .= "' . fetch_template('journal_moods') . '";');
}
$db->free_result($mood);
$navbits= array();
$navbits['journal.php' . $vbulletin->session->vars['sessionurl_q']]= $vbphrase['journals'];
$navbits['']= $vbphrase['add_entry'];
require_once(DIR . '/includes/functions_editor.php');
$vbulletin->options['allowbbcode'] = $setting['allow_bbcode'];
$vbulletin->options['allowbbimagecode'] = $setting['allow_imgcode'];
$editorid = construct_edit_toolbar('', 0, 'journal', $setting['allow_smilies'], 1, 0);
$navbits= construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_submitentry') . '");');
}
if ($_REQUEST['do'] == 'insertentry')
{
$vbulletin->input->clean_array_gpc('p', array(
'title' => TYPE_NOHTML,
'message' => TYPE_STR,
'private' => TYPE_INT,
'wcv' => TYPE_NOHTML,
'mood' => TYPE_INT,
'np' => TYPE_NOHTML,
'allowbudds' => TYPE_INT,
'wysiwyg' => TYPE_BOOL
));
// ATTN Compatibility Code
$title =& $vbulletin->GPC['title'];
if ($vbulletin->GPC['wysiwyg'])
{
require_once(DIR . '/includes/functions_wysiwyg.php');
$message = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], false);
}
else
{
$message =& $vbulletin->GPC['message'];
}
$private =& $vbulletin->GPC['private'];
$wcv =& $vbulletin->GPC['wcv'];
$mood =& $vbulletin->GPC['mood'];
$np =& $vbulletin->GPC['np'];
$allowbudds =& $vbulletin->GPC['allowbudds'];
// ATTN Compatibility Code
if (!journalist_check($j, $vbulletin->userinfo['userid']) OR !$vbulletin->userinfo['userid'])
{
print_no_permission();
}
$floodcheck= $db->query_first("SELECT entrydate AS lastentry FROM " . TABLE_PREFIX . "journal_entries WHERE journal_id=".$j." ORDER BY entrydate DESC");
if((TIMENOW - $floodcheck['lastentry'])<= $setting['floodint'])
{
eval(standard_error(fetch_error('journalfloodcheck', $setting['floodint'],'posting another entry')));
}
if ($private)
{
$allowedusers = construct_allowed_users($allowbudds, $vbulletin->userinfo['jbuddylist'], $wcv);
}
$autoentry=",'1'";
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "journal_entries
(allowedusers, journal_id, entrytitle, entrytext, entrydate, private, allowbuddies, whocanview, ipaddress, mood, np".iif($setting['autoapprove_entries']=="1", ', entry_active').")
VALUES ('" . $db->escape_string($allowedusers) . "', '".$j."','".$db->escape_string($title)."','".$db->escape_string($message)."','".TIMENOW."','".$private."', ".$allowbudds.",
'".$db->escape_string($wcv)."','". IPADDRESS ."','".$mood."','".$db->escape_string($np)."'".iif($setting['autoapprove_entries']=="1", $autoentry).")
");
$preupdate= $db->insert_id();
if ($private AND !$allowedusers)
{
$allowedusers='-';
}
$db->query_write("UPDATE " . TABLE_PREFIX . "journals SET lastentry_uids='" . $db->escape_string($allowedusers) . "', lastentry='".$db->escape_string($title)."', lastentry_date='".TIMENOW."',
lastentry_id='".$preupdate."'".($setting['autoapprove_entries']==1 ? ',entrycount=entrycount+1' : '')." WHERE journal_id='".$j."'
");
$vbulletin->url="journal.php?" . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=".$j."";
eval(print_standard_redirect('redirect_journalentryinserted'));
}
if ($_REQUEST['do'] == 'showentry')
{
$enum =& $vbulletin->input->clean_gpc('r', 'enum', TYPE_UINT);
$entry= $db->query_first("
SELECT journalist, journalname, entrytitle, entrytext, entrydate, entry_id, np, journal_entries.ipaddress, usertextfield.jbuddylist, entry_totalrating, entry_totalvotes, journals.journal_id, journalist_id, journals.private AS jpriv, journal_entries.private AS epriv, journals.whocanview AS jwcv, journal_entries.whocanview AS ewcv, journal_entries.mood, journal_moods.mood_name, journal_moods.mood_image, journals.allowbuddies AS allowbuddsj,
journal_entries.allowbuddies AS allowbuddse FROM " . TABLE_PREFIX . "journal_entries AS journal_entries
LEFT JOIN " . TABLE_PREFIX . "journals AS journals ON (journal_entries.journal_id=journals.journal_id)
LEFT JOIN " . TABLE_PREFIX . "journal_moods AS journal_moods ON (journal_entries.mood=journal_moods.mood_id)
LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON (usertextfield.userid=journals.journalist_id)
WHERE journal_entries.entry_id='".intval($e)."' AND entry_active=1
");
if(!empty($entry))
{
/* Build J Buddy List */
$jbuddies= explode(' ', $entry['jbuddylist']);
/* Stop Building J Buddy List */
/* Start Building Journal Permissions */
if($entry['jpriv']==1)
{
$jwcv = explode($entry['jwcv']);
if (($vbulletin->userinfo['usergroupid']==6) OR ($vbulletin->userinfo['userid']==$entry['journalist_id']) OR ($vbulletin->userinfo['userid'] AND in_array($vbulletin->userinfo['userid'], $jwcv)))
{
$canview['thisjournal']= true;
}
else if ($entry['allowbuddsj']==1)
{
if (in_array($vbulletin->userinfo['userid'], $jbuddies))
{
$canview['thisjournal']= true;
}
}
else
{
$canview['thisjournal']= false;
}
}
else
{
$canview['thisjournal']= true;
}
/* Stop Building Journal Permissions */
/* Start Building Journal Entry Permissions */
if ($entry['epriv']==1)
{
$ewcv = explode(',', $entry['ewcv']);
if (($vbulletin->userinfo['usergroupid']==6) OR ($vbulletin->userinfo['userid']==$entry['journalist_id']) OR ($vbulletin->userinfo['userid'] AND in_array($vbulletin->userinfo['userid'], $ewcv)))
{
$canview['thisentry']= true;
}
else if($entry['allowbuddse']==1)
{
if ($vbulletin->userinfo['userid'] AND in_array($vbulletin->userinfo['userid'], $jbuddies))
{
$canview['thisentry']= true;
}
}
else
{
$canview['thisentry']= false;
}
}
else
{
$canview['thisentry']= true;
}
if (!$canview['thisjournal'] OR !$canview['thisentry'])
{
print_no_permission();
}
$count= $db->query_first("SELECT COUNT(*) AS comments FROM " . TABLE_PREFIX . "journal_comments WHERE entry_id='".intval($e)."'");
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$text= $bbcode_parser->do_parse($entry['entrytext'], 0, $setting['allow_imgcode'], $setting['allow_smilies'], $setting['allow_bbcode']);
$entry['date']= vbdate($vbulletin->options['dateformat'], $entry['entrydate'], 1);
$entry['time']= vbdate($vbulletin->options['timeformat'], $entry['entrydate']);
$navbits= array();
$navbits['journal.php' . $vbulletin->session->vars['sessionurl_q']]= $vbphrase['journals'];
if (!empty($entry['journalname']))
{
$navbits['journal.php?' . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=$entry[journal_id]"] = $entry['journalname'];
}
else
{
$navbits['journal.php?' . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=$entry[journal_id]"]= construct_phrase($vbphrase['xs_journal'], $entry['journalist']);
}
$navbits['']= $entry['entrytitle'];
$navbits= construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_showentrypage') . '");');
}
else
{
eval(standard_error(fetch_error('journalentrynotfound')));
}
}
if ($_REQUEST['do'] == 'editjournal')
{
if ((!$vbulletin->userinfo['userid'] OR !journalist_check($j, $vbulletin->userinfo['userid']) OR !$caneditown['journal']) AND !admin)
{
print_no_permission();
}
$journalinfo= $db->query_first("SELECT journal_id, journalname, journaldesc, journalist, private, whocanview, journalist, allowbuddies FROM " . TABLE_PREFIX . "journals WHERE journal_id='".$j."'");
if ($journalinfo['journal_id'])
{
$vbulletin->session->set('injournal', $journalinfo['journal_id']);
}
else
{
eval(standard_error(fetch_error('invalidid', 'Journal', $vbulletin->options['contactuslink'])));
}
$navbits= array();
$navbits['journal.php' . $vbulletin->session->vars['sessionurl_q']]= $vbphrase['journals'];
if(!empty($journalinfo['journalname']))
{
$navbits['journal.php?' . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=$j"]= $journalinfo['journalname'];
}
else
{
$navbits['journal.php?' . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=$j"]= construct_phrase($vbphrase['xs_journal'], $journalinfo['journalist']);;
}
$navbits['']= $vbphrase['edit_journal_info'];
$navbits= construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_edit_journalinfo') . '");');
$db->free_result($journalinfo);
}
if ($_REQUEST['do'] == 'editentry')
{
if ((!$vbulletin->userinfo['userid'] OR !journalist_check($j, $vbulletin->userinfo['userid']) OR !$caneditown['entry']) AND !admin)
{
print_no_permission();
}
$entryinfo= $db->query_first("SELECT entrytitle, entrytext, private, whocanview, mood, np, allowbuddies FROM " . TABLE_PREFIX . "journal_entries WHERE entry_id='".$e."'");
// $entryinfo['entrytext']= htmlspecialchars($entryinfo['entrytext']);
$fetchmoods= $db->query("SELECT mood_id,mood_name FROM " . TABLE_PREFIX . "journal_moods");
while($mood= $db->fetch_array($fetchmoods))
{
if($entryinfo['mood']==$mood['mood_id'])
{
$selectedmood= true;
}
else
{
$selectedmood= false;
}
eval('$moodbits .= "' . fetch_template('journal_moods') . '";');
}
$db->free_result($mood);
require_once(DIR . '/includes/functions_editor.php');
$editorid = construct_edit_toolbar($entryinfo['entrytext'], 0, 'journal', (($setting['allow_smilies']) ? 1 : 0), 1, '');
$navbits= array();
$navbits['journal.php' . $vbulletin->session->vars['sessionurl_q']]= $vbphrase['journals'];
$navbits['']= $entryinfo['entrytitle'];
$navbits= construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_edit_entryinfo') . '");');
}
if ($_REQUEST['do'] == 'editcomment')
{
if((!$vbulletin->userinfo['userid'] OR !journalist_check($j, $vbulletin->userinfo['userid']) OR !$caneditown['comment']) AND !admin)
{
print_no_permission();
}
$comminfo= $db->query_first("SELECT comment_title,comment_text FROM " . TABLE_PREFIX . "journal_comments WHERE comment_id='".$c."'");
$navbits= array();
require_once(DIR . '/includes/functions_editor.php');
$vbulletin->options['allowbbcode'] = $setting['allow_bbcode'];
$vbulletin->options['allowbbimagecode'] = $setting['allow_imgcode'];
$editorid = construct_edit_toolbar($comminfo['comment_text'], 0, 'journal', $setting['allow_smilies'], 1, 0);
$navbits['journal.php' . $vbulletin->session->vars['sessionurl_q']] = $vbphrase['journals'];
$navbits['']= $vbphrase['edit_comment'];
$navbits= construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_edit_commentinfo') . '");');
}
if ($_REQUEST['do'] == 'update')
{
$vbulletin->input->clean_array_gpc('p', array(
'jname' => TYPE_NOHTML,
'jdesc' => TYPE_NOHTML,
'jpriv' => TYPE_INT,
'allowbuddsj' => TYPE_INT,
'jwcv' => TYPE_STR,
'etitle' => TYPE_NOHTML,
'message' => TYPE_TEXT,
'epriv' => TYPE_INT,
'ewcv' => TYPE_STR,
'allowbuddse' => TYPE_INT,
'mood' => TYPE_INT,
'np' => TYPE_NOHTML,
'ctitle' => TYPE_NOHTML,
'type' => TYPE_STR,
'wysiwyg' => TYPE_BOOL
));
// ATTN Compatibility Code
$jname =& $vbulletin->GPC['jname'];
$jdesc =& $vbulletin->GPC['jdesc'];
$jpriv =& $vbulletin->GPC['jpriv'];
$allowbuddsj =& $vbulletin->GPC['allowbuddsj'];
$jwcv =& $vbulletin->GPC['jwcv'];
$etitle =& $vbulletin->GPC['etitle'];
$epriv =& $vbulletin->GPC['epriv'];
$ewcv =& $vbulletin->GPC['ewcv'];
$allowbuddse =& $vbulletin->GPC['allowbuddse'];
$mood =& $vbulletin->GPC['mood'];
$np =& $vbulletin->GPC['np'];
$ctitle =& $vbulletin->GPC['ctitle'];
$type =& $vbulletin->GPC['type'];
// ATTN Compatibility Code
// die($vbulletin->GPC['allowbuddse']);
if ($vbulletin->GPC['wysiwyg'])
{
require_once(DIR . '/includes/functions_wysiwyg.php');
$message = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], false);
}
else
{
$message =& $vbulletin->GPC['message'];
}
if (!((journalist_check($j, $vbulletin->userinfo['userid'])=="true" AND $caneditown['comment'] OR $caneditown['entry'] OR $caneditown['journal']) OR $vbulletin->userinfo['usergroupid']=="6" AND $vbulletin->userinfo['userid']!=0))
{
print_no_permission();
}
$journalinfo = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "journals
bonjour à tous, voila j'ai un problème, en fait mon forum tourne sous vbulletin jusque là tout va bien, j'ai téléchargé un hack pour que les utilisateurs puissent créer des journaux sur le forum, ce hack marche très bien sous php4 mais l'auteur alerte les gens en disant qu'il ne fonctionne pas sous php5
malheureusement mon hebergeur est passé en php5 et depuis j'ai cette erreur :
[quote]Parse error: parse error, unexpected T_PRIVATE, expecting ']' in /home/scabbed/public_html/forum/journal.php(564) : eval()'d code on line 188[/quote]
je ne sais pas comment la resoudre vu que je ne connais pas grand chose en php et vu que le gars a arreté le support je me retrouve comme un c**
voila la ligne concernée
[php]{
$pagenumber = $countj['journals'];
}[/php]
voila le fichier journal.php si ça peut vous aider, merci d'avance
[php]<?php
/*======================================================================*\
|| #################################################################### ||
|| # vB Journal 1.0.2 Beta 1 # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright © 2005 KirbyDE. All Rights Reserved. # ||
|| # Original vB Journal script for 3.0.x Copyright © 2004 AN-net. # ||
|| # "vBlog" additions contributed by Oblivion Knight. # ||
|| # ---------------------------------------------------------------- # ||
|| # http://www.vbulletin.org/forum/showthread.php?t=96462 # ||
|| #################################################################### ||
\*======================================================================*/
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// ##################### DEFINE IMPORTANT CONSTANTS #######################
define('CVS_REVISION', '$RCSfile: journal.php,v $ - $Revision: 1.8 $');
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
define('GET_EDIT_TEMPLATES', true);
define('THIS_SCRIPT', 'journal');
// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('posting', 'journalhack');
$globaltemplates = array(
'forumdisplay_loggedinuser',
'journal_journalbits',
'journal_latestentrybit',
'journal_latestjournalbit',
'navbar',
'JOURNAL',
'journal_entrybits',
'journal_recent_comments',
'journal_journalpage',
'journal_commentbits',
'journal_commentpage',
'journal_moods',
'journal_startpage',
'journal_submitentry',
'journal_showentrypage',
'journal_edit_journalinfo',
'journal_edit_entryinfo',
'journal_edit_commentinfo',
'journal_deletion_entry_confirmation',
'journal_deletion_journal_confirmation',
'journal_search',
'journal_searchresults',
'journal_buddy',
'journal_showbuddies',
'journal_top_viewed',
'journal_most_entries',
'journal_most_comments',
'journal_top_rated',
'journal_toppage',
'showthread_quickreply'
);
$specialtemplates= array(
'bbcodecache',
'smiliecache',
'journal_opt'
);
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
$vbulletin->input->clean_array_gpc('r', array(
'j' => TYPE_INT,
'e' => TYPE_INT,
'c' => TYPE_INT
));
// ATTN Compatibility Code
$j =& $vbulletin->GPC['j'];
$e =& $vbulletin->GPC['e'];
$c =& $vbulletin->GPC['c'];
// ATTN Compatibility Code
$vbulletin->session->db_fields['injournal'] = TYPE_INT;
function journalist_check($jid,$checkid)
{
global $db;
$check= $db->query_first("SELECT journalist_id FROM " . TABLE_PREFIX . "journals WHERE journal_id='".$jid."'");
if($check['journalist_id']!=$checkid)
{
return "false";
}
else
{
return "true";
}
}
function construct_allowed_users($allowjbuddies, $jbuddylist, $whocanview)
{
if ($allowjbuddies)
{
return trim(trim($whocanview) . ',' . trim(str_replace(' ', ',', $jbuddylist)));
}
else
{
return $whocanview;
}
}
//$setting=$db->query_first("SELECT * FROM " . TABLE_PREFIX . "journal_settings");
$vbulletin->journal_opt = unserialize($vbulletin->journal_opt);
$setting =& $vbulletin->journal_opt;
//######### Begin Building Permissions ################################
$canhave['journal'] = (($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['canhavejournal']) AND ($vbulletin->userinfo['canhavejournal']));
$canview['comments'] = ($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['canviewcomments']);
$can['comment'] = (($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['cancommentjournals']) AND $setting['allow_commenting']);
$can['rate'] = ($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['canratejournals']);
$can['report'] = (($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['canreportentries']) AND $setting['allow_reporting']);
$caneditown['journal'] = (($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['caneditownjournal']));
$caneditown['entry'] = (($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['caneditownentries']));
$caneditown['comment'] = (($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['caneditowncomments']));
$candeleteown['journal'] = ($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['candeleteownjournal']);
$candeleteown['entry'] = ($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['candeleteownentries']);
$can['search'] = (($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['cansearchjournal']) AND $setting['allow_searching']);
//######### Stop Building Permissions ################################
// *********************************************************************************
// check permissions
if (!$vbulletin->products['journalhack'])
{
eval(standard_error(fetch_error('journalmodulenotactive')));
}
if (!($permissions['journalpermissions'] & $vbulletin->bf_ugp_journalpermissions['canviewjournal']))
{
print_no_permission();
}
if (!$_REQUEST['do'])
{
$_REQUEST['do'] = 'showindex';
}
if ($_REQUEST['do'] == 'showindex')
{
$vbulletin->input->clean_array_gpc('r', array(
'page' => TYPE_INT,
'pp' => TYPE_INT,
'order' => TYPE_NOHTML,
'sort' => TYPE_NOHTML
));
// ATTN Compatibility Code
$page =& $vbulletin->GPC['page'];
$pp =& $vbulletin->GPC['pp'];
$order =& $vbulletin->GPC['order'];
$sort =& $vbulletin->GPC['sort'];
// ATTN Compatibility Code
$countj = $db->query_first("
### Journal Lisiting Pagination ####
SELECT COUNT(*) AS journals FROM " . TABLE_PREFIX . "journals
WHERE active=1
AND (journalist_id=" . $vbulletin->userinfo['userid'] . " OR private !=1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', allowedusers))
");
// Setup Pagination
// TODO: Handle pp
$perpage=$setting['journals_perpage'];
if (empty($page))
{
$page= 1;
}
$start= (($page * $perpage) - $perpage);
$pagenumber = $page++;
if ($pagenumber < 1)
{
$pagenumber = 1;
}
else if ($pagenumber > $countj['journals'])
{
$pagenumber = $countj['journals'];
}
$pgnav= construct_page_nav($pagenumber, $perpage, $countj['journals'], "journal.php?" . $vbulletin->session->vars['sessionurl'] . (!empty($vbulletin->GPC['pp']) ? "&pp=$perpage" : ""));
require_once(DIR . '/includes/functions_bigthree.php');
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$browsers = '';
$comma = '';
// Don't put the inthread value in the WHERE clause as it might not be the newest location!
$journalusers = $db->query_read("
### Users in Journal ###
SELECT user.username, user.usergroupid, user.membergroupids,
session.userid, session.inthread, session.injournal, session.location, session.lastactivity,
IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid,
IF(user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ", 1, 0) AS invisible
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)
WHERE session.lastactivity > $datecut
ORDER BY " . iif($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehidden'], 'invisible ASC, ') . "username ASC, lastactivity DESC
");
$numberguest = 0;
$numberregistered = 0;
$doneuser = array();
if ($vbulletin->userinfo['userid']) // fakes the user being in Journal
{
$vbulletin->userinfo['joingroupid'] = iif($vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['usergroupid']);
$loggedin = array(
'userid' => $vbulletin->userinfo['userid'],
'username' => $vbulletin->userinfo['username'],
'invisible' => $vbulletin->userinfo['invisible'],
'invisiblemark' => $vbulletin->userinfo['invisiblemark'],
'inthread' => $threadinfo['threadid'],
'lastactivity' => TIMENOW,
'musername' => fetch_musername($vbulletin->userinfo, 'joingroupid')
);
$numberregistered = 1;
$numbervisible = 1;
fetch_online_status($loggedin);
eval('$activeusers = "' . fetch_template('forumdisplay_loggedinuser') . '";');
$doneuser["{$vbulletin->userinfo['userid']}"] = 1;
$comma = ', ';
}
// this requires the query to have lastactivity ordered by DESC so that the latest location will be the first encountered.
while ($loggedin = $db->fetch_array($journalusers))
{
devdebug("loggedid: $loggedin[userid]");
if (empty($doneuser["$loggedin[userid]"]))
{
if ($loggedin['userid'] == 0) // Guest
{
if (strpos($loggedin['location'], 'journal.php') !== false)
{
$numberguest++;
}
}
else
{
if (strpos($loggedin['location'], 'journal.php') !== false)
{
$loggedin['musername'] = fetch_musername($loggedin);
$numberregistered++;
if (fetch_online_status($loggedin))
{
eval('$activeusers .= "' . $comma . fetch_template('forumdisplay_loggedinuser') . '";');
$comma = ', ';
}
}
}
if ($loggedin['userid'])
{
$doneuser["$loggedin[userid]"] = 1;
}
if(!empty($loggedin['injournal']))
{
$injournal['id']= $loggedin['injournal'];
$injournal[$loggedin['injournal']]++;
}
}
}
if (!$vbulletin->userinfo['userid'] AND !$numberguest)
{
$numberguest = 1;
}
global $injournal;
$totalviewing = $numberregistered + $numberguest;
if(isset($sort))
{
// TODO: Convert to switch, might be faster (no array operations)
if (!in_array($sort, array(journalist, journalname, journaldate,journaldesc, entrycount, lastentry_date, lastentry)))
{
$sort= "lastentry_date";
}
}
else
{
$sort='lastentry_date';
}
if(isset($order))
{
if(!in_array($order, array(DESC, ASC)))
{
$order= "DESC";
}
}
else
{
$order= "DESC";
}
$fjournals = $db->query_read("
### Journal Listing ###
SELECT
journals.lastentry_uids, journals.journal_id, journals.journalname, journals.journaldesc,
journals.journalist, journals.journalist_id, entrycount, commentcount, usertextfield.jbuddylist, ipaddress, journals.lastentry,
journals.lastentry_date, journals.private, journals.whocanview, journals.lastentry_id, journals.status, journals.allowbuddies, journals.journalviews,
journals.journal_totalrating AS totalrating, journals.journal_totalvotes AS totalvotes
FROM " . TABLE_PREFIX . "journals AS journals
LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON (journals.journalist_id=usertextfield.userid)
WHERE journals.active=1
AND (journals.journalist_id=" . $vbulletin->userinfo['userid'] . " OR journals.private != 1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journals.allowedusers))
ORDER BY $sort $order
LIMIT $start,$perpage
");
$check= $db->num_rows($fjournals);
if($check=="0")
{
$journalbits= $vbphrase['journalnojournals'];
}
else
{
while ($journal = $db->fetch_array($fjournals))
{
$journalid =& $journal['journal_id'];
if (empty($journal['totalrating']) OR empty($journal['totalvotes']))
{
$rating= "0";
}
else
{
$calcrating= $journal['totalrating']/$journal['totalvotes'];
$rating= round($calcrating);
}
if($injournal['id']==$journal['journal_id'])
{
$viewing[$journal['journal_id']]= $injournal[$injournal['id']];
}
else
{
$viewing[$journal['journal_id']]= 0;
}
if ($journal['private'])
{
$show['privatelock']= true;
}
else
{
$show['privatelock']= false;
}
if ($vbulletin->userinfo['lastvisitdate']=="Never")
{
$shownewentryicon[$journal['journal_id']]= true;
}
else if($vbulletin->userinfo['lastvisit']<$journal['lastentry_date'])
{
$shownewentryicon[$journal['journal_id']]= true;
}
$lastedate= vbdate($vbulletin->options['dateformat'], $journal['lastentry_date'], 1);
$lastetime= vbdate($vbulletin->options['timeformat'], $journal['lastentry_date']);
$journal['lastentry']= fetch_trimmed_title($journal['lastentry'], 30);
if ($journal['private']==1)
{
$journal_wcv = explode(',', $journal['whocanview']);
if ($vbulletin->userinfo['userid']==$journal['journalist_id'])
{
$canview['thisjournal']= true;
}
else if ($vbulletin->userinfo['usergroupid']=="6")
{
$canview['thisjournal']= true;
}
else if ((in_array($vbulletin->userinfo['userid'], $journal_wcv)) AND ($vbulletin->userinfo['userid']!=0))
{
$canview['thisjournal']= true;
}
else if ($journal['allowbuddies'])
{
if ((in_array($vbulletin->userinfo['userid'], explode(' ', $journal['jbuddylist']))) AND ($vbulletin->userinfo['userid']!=0))
{
$canview['thisjournal']= true;
}
}
else
{
$canview['thisjournal']= false;
}
}
else
{
$canview['thisjournal']= true;
}
$show['lastentry'] = (empty($journal['lastentry_uids']) OR ($journal['journalist_id'] == $vbulletin->userinfo['userid']) OR (strpos(",$journal[lastentry_uids],", ',' . $vbulletin->userinfo['userid'] . ',') !== false)) ? true : false;
if ($canview['thisjournal'])
{
eval('$journalbits .= "' . fetch_template('journal_journalbits') . '";');
}
}
$db->free_result($journal);
}
// TODO: Setting for # of latest Entries
$getlateste = $db->query_read("
### Latest Journal Entries ###
SELECT journal_entries.entrytitle,journal_entries.entrydate,journal_entries.entry_id,
journal_entries.entrytext,journal_entries.journal_id,journals.journalist,journals.journalist_id
FROM " . TABLE_PREFIX . "journal_entries AS journal_entries
LEFT JOIN " . TABLE_PREFIX . "journals AS journals ON (journal_entries.journal_id=journals.journal_id)
WHERE journal_entries.entry_active=1
AND journals.active=1
AND (
(journals.journalist_id=" . $vbulletin->userinfo['userid'] . ")
OR
(journals.private!=1 AND journal_entries.private!=1)
OR
(journals.private=1 AND journal_entries.private!=1 AND FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journals.allowedusers))
OR
(journals.private!=1 AND journal_entries.private=1 AND FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journal_entries.allowedusers))
OR
(journals.private=1 AND journal_entries.private=1 AND FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journals.allowedusers) AND FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journal_entries.allowedusers))
)
ORDER BY journal_entries.entrydate DESC
LIMIT 5
");
$countlatest= $db->num_rows($getlateste);
$latestentrybits = "";
$latestdata = array();
$counter = 0;
if ($countlatest>0)
{
while($latest= $db->fetch_array($getlateste))
{
$latestdata["$counter"]['entry'] = $latest;
$counter++;
}
$db->free_result($lastest);
}
else
{
// TODO: Hardcoded Text
$latestentrybits="There are no entries.";
}
$getlatestj = $db->query_read("
### Latest Journals ###
SELECT journalname,journalist,journalist_id,journal_id,journaldate,journaldesc FROM " . TABLE_PREFIX . "journals
WHERE active=1
AND (journalist_id=" . $vbulletin->userinfo['userid'] . " OR private != 1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', allowedusers))
ORDER BY journaldate
DESC LIMIT 5
");
$countlatestj= $db->num_rows($getlatestj);
$counter = 0;
if($countlatestj>0)
{
while($latestj= $db->fetch_array($getlatestj))
{
$latestdata["$counter"]['journal'] = $latestj;
$counter++;
}
$db->free_result($lastestj);
}
else
{
$latestjournalbits="There are no journals.";
}
$bgclass='alt1';
foreach ($latestdata AS $latestbit)
{
$latest = $latestbit['entry'];
$latestentrydate= vbdate($vbulletin->options['dateformat'], $latest['entrydate'], 1);
$latestentrytime= vbdate($vbulletin->options['timeformat'], $latest['entrydate']);
// exec_switch_bg();
// TODO: fetch_trimmed_title()
if(strlen($latest[entrytitle])>20)
{
$latest[entrytitle]= "".substr($latest[entrytitle],0,20)."...";
}
if (strlen($latest[entrytext])>150)
{
$latest[entrytext]= "".substr($latest[entrytext],0,150)."...";
}
$latest['entrytext']= htmlspecialchars_uni($latest['entrytext']);
eval('$latestbits .= "<tr>' . fetch_template('journal_latestentrybit') . '";');
$latestj = $latestbit['journal'];
if ($latestj['journaldate'])
{
$journaldate= vbdate($vbulletin->options['dateformat'], $latestj['journaldate'], 1);
$journaltime= vbdate($vbulletin->options['timeformat'], $latestj['journaldate']);
exec_switch_bg();
// TODO: fetch_trimmed_title()
if(strlen($latestj['journaldesc'])>200)
{
$latestj['journaldesc']= "".substr($latestj['journaldesc'],0,200)."...";
}
eval('$latestbits .= "' . fetch_template('journal_latestjournalbit') . '</tr>";');
}
else
{
$latestbits .= '</tr>';
}
}
$jbuddies = trim($vbulletin->userinfo['jbuddylist']);
if (!empty($jbuddies))
{
$users = $db->query_read("
### Journal Buddies ###
SELECT journalist, journalist_id, journal_id
FROM " . TABLE_PREFIX . "journals
WHERE journalist_id IN (" . str_replace(' ', ',', $vbulletin->userinfo['jbuddylist']) . ")
ORDER BY journalist ASC
");
$bcount = $db->num_rows($jbuddies);
$buddycount = 0;
$jbuddy_listbits= '';
while ($jbuddy = $db->fetch_array($users))
{
$buddycount++;
$journal_id =& $jbuddy['journal_id'];
$username =& $jbuddy['journalist'];
eval('$jbuddy_listbits .= "' . fetch_template('journal_buddy') . '";');
}
$db->free_result($jbuddies);
if (!$buddycount)
{
$jbuddy_listbits = $vbphrase['no_journal_buddies'];
}
}
else
{
$buddycount = 0;
$jbuddy_listbits = $vbphrase['no_journal_buddies'];
}
$buddycount = vb_number_format($buddycount);
unset($comma, $userinfos, $userid, $userinfo, $loggedin, $journalusers, $datecut);
$total = $db->query_first("
### Journal Statistics ###
SELECT COUNT(*) AS journals, SUM(entrycount) AS entries, SUM(commentcount) AS comments, SUM(journalviews) AS views FROM " . TABLE_PREFIX . "journals WHERE active=1
");
$total['entries']= vb_number_format($total['entries']);
$total['comments']= vb_number_format($total['comments']);
$total['views']= vb_number_format($total['views']);
$totaljournals= vb_number_format($total['journals']);
$navbits= array();
// TODO: Cache latest journalist
$getlatestj= $db->query_first("
### Latest Journalist ###
SELECT journalist,journal_id FROM " . TABLE_PREFIX . "journals WHERE active=1 AND private!=1 ORDER BY journaldate DESC
");
$journalcount = vb_number_format($countj['journals']);
$journalsstart = vb_number_format($start+1);
$journalsend = vb_number_format(min($start+$perpage, $countj['journals']));
// TODO: Hardcoded Text
$navbits["#"]= $vbphrase['journals'];
$navbits['']= $vbphrase['journal_index'];
$navbits= construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('JOURNAL') . '");');
$db->free_result($journalusers);
$db->free_result($countj);
}
if ($_REQUEST['do'] == 'showjournal')
{
$vbulletin->input->clean_array_gpc('r', array(
'page' => TYPE_INT,
'pp' => TYPE_INT,
'highlight' => TYPE_STR,
'order' => TYPE_NOHTML,
'sort' => TYPE_NOHTML
));
// ATTN Compatibility Code
$page =& $vbulletin->GPC['page'];
$pp =& $vbulletin->GPC['pp'];
$highlight =& $vbulletin->GPC['highlight'];
$order =& $vbulletin->GPC['order'];
$sort =& $vbulletin->GPC['sort'];
// ATTN Compatibility Code
$journalinfo= $db->query_first("
SELECT journals.journalname, journals.journalist_id, journals.journal_id, journals.journalviews, journals.journalist, journals.journal_totalrating AS totalrating, journals.journal_totalvotes AS totalvotes, journals.journaldate, journals.whocanview, journals.allowbuddies, journals.whovoted, journals.lastentry_date, journals.status, journals.journaldesc, commentcount, entrycount, journals.ipaddress, usertextfield.jbuddylist, journals.private
FROM " . TABLE_PREFIX . "journals AS journals
LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON (usertextfield.userid=journals.journalist_id)
WHERE journals.journal_id=$j
AND journals.active=1
");
if ($journalinfo['journal_id'])
{
$vbulletin->session->set('injournal', $journalinfo['journal_id']);
}
else
{
eval(standard_error(fetch_error('invalidid', 'Journal', $vbulletin->options['contactuslink'])));
}
/* Build Buddy List */
$jbuddies= explode(' ', $journalinfo['jbuddylist']);
if ($journalinfo['private']==1)
{
$journal_wcv = explode(',', $journalinfo['whocanview']);
if ($vbulletin->userinfo['userid']==$journalinfo['journalist_id'])
{
$canview['thisjournal']= true;
}
else if ($vbulletin->userinfo['usergroupid']=="6")
{
$canview['thisjournal']= true;
}
else if ((in_array($vbulletin->userinfo['userid'], $journal_wcv)) AND ($vbulletin->userinfo['userid']!=0))
{
$canview['thisjournal']= true;
}
else if (($journalinfo['allowbuddies']==1) AND (in_array($vbulletin->userinfo['userid'], $jbuddies)))
{
$canview['thisjournal']= true;
}
else
{
$canview['thisjournal']= false;
}
}
else
{
$canview['thisjournal']= true;
}
if ($canview['thisjournal'])
{
$db->query_write("UPDATE " . TABLE_PREFIX . "journals SET journalviews=journalviews+1 WHERE journal_id='".intval($j)."'");
$private = $db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "journal_entries WHERE entry_active=1 AND private=1 AND journal_id=".$j."");
/* Build Relations */
if ($vbulletin->userinfo['userid'])
{
if (in_array($vbulletin->userinfo['userid'], $jbuddies))
{
$show['youareabuddy']= true;
}
else
{
$show['youareabuddy']= false;
}
$viewersjbuddies= explode(' ', $vbulletin->userinfo['jbuddylist']);
if (in_array($journalinfo['journalist_id'], $viewersjbuddies))
{
$show['isabuddyofu']= true;
}
else
{
$show['isabuddyofu']= false;
}
}
/* Stop Building Relations */
/* Build Who Has Rated */
if ($vbulletin->userinfo['userid'])
{
if(isset($journalinfo['whovoted']) AND !empty($journalinfo['whovoted']))
{
$whovoted= unserialize($journalinfo['whovoted']);
if (in_array($vbulletin->userinfo['userid'], $whovoted))
{
$show['voteform']= false;
}
else
{
$show['voteform']= true;
}
}
else
{
$show['voteform']= true;
}
}
/* Stop Building Who Has Rated */
$journalinfo['lastupdated']= vbdate($vbulletin->options['dateformat'], $journalinfo['lastentry_date'], 1);
require_once(DIR . '/includes/functions_bigthree.php');
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$browsers = '';
$comma = '';
$journalviewers = $db->query_read("
SELECT user.username, user.usergroupid, user.membergroupids,
session.userid, session.inthread, session.injournal, session.location, session.lastactivity,
IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid,
IF(user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ", 1, 0) AS invisible
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)
WHERE session.lastactivity > $datecut
ORDER BY " . iif($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehidden'], 'invisible ASC, ') . "username ASC, lastactivity DESC
");
$numberguest = 0;
$numberregistered = 0;
$doneuser = array();
if ($vbulletin->userinfo['userid'])
{
$vbulletin->userinfo['joingroupid'] = iif($vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['usergroupid']);
$loggedin = array(
'userid' => $vbulletin->userinfo['userid'],
'username' => $vbulletin->userinfo['username'],
'invisible' => $vbulletin->userinfo['invisible'],
'invisiblemark' => $vbulletin->userinfo['invisiblemark'],
'inthread' => $threadinfo['threadid'],
'lastactivity' => TIMENOW,
'musername' => fetch_musername($vbulletin->userinfo, 'joingroupid')
);
$numberregistered = 1;
$numbervisible = 1;
fetch_online_status($loggedin);
eval('$activeusers = "' . fetch_template('forumdisplay_loggedinuser') . '";');
$doneuser["{$vbulletin->userinfo['userid']}"] = 1;
$comma = ', ';
}
// this requires the query to have lastactivity ordered by DESC so that the latest location will be the first encountered.
while ($loggedin = $db->fetch_array($journalviewers))
{
if (empty($doneuser["$loggedin[userid]"]))
{
if ($loggedin['userid'] == 0) // Guest
{
if($loggedin['injournal']==$j)
{
$numberguest++;
}
}
else
{
if ($loggedin['injournal']==$j)
{
$loggedin['musername'] = fetch_musername($loggedin);
$numberregistered++;
if (fetch_online_status($loggedin))
{
eval('$activeusers .= "' . $comma . fetch_template('forumdisplay_loggedinuser') . '";');
$comma = ', ';
}
}
}
if ($loggedin['userid'])
{
$doneuser["$loggedin[userid]"] = 1;
}
}
}
if (!$vbulletin->userinfo['userid'] AND !$numberguest)
{
$numberguest = 1;
}
$totalviewing = $numberregistered + $numberguest;
$journal['startdate']= vbdate($vbulletin->options['dateformat'], $journalinfo['journaldate'], 1);
if($journalinfo['totalvotes']!=0 AND $journalinfo['totalrating']!=0)
{
$journalrating= round($journalinfo['totalrating']/$journalinfo['totalvotes']);
}
else
{
$journalrating= 0;
}
require_once(DIR . '/includes/functions_user.php');
$avatar = fetch_avatar_url($journalinfo['journalist_id']);
if ($avatar == '')
{
$show['avatar'] = false;
}
else
{
$show['avatar'] = true;
// $userinfo['avatarsize'] = $avatarurl[1];
$avatarurl = $avatar[0];
}
if (empty($journalinfo))
{
eval(standard_error(fetch_error('journalnotexist')));
}
else
{
$counte= $db->query_first("SELECT COUNT(*) AS entries FROM " . TABLE_PREFIX . "journal_entries WHERE entry_active='1'
AND journal_id=$j
" . iif($journalinfo['journalist_id'] != $vbulletin->userinfo['userid'], "AND (private != 1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', allowedusers))") . "
");
$perpage= $setting['journalentries_perpage'];
if(empty($page))
{
$page= 1;
}
$start= (($page * $perpage) - $perpage);
$pagenumber = $page++;
if ($pagenumber < 1)
{
$pagenumber = 1;
}
else if ($pagenumber > $counte['entries'])
{
$pagenumber = $counte['entries'];
}
$pgnav= construct_page_nav($pagenumber, $perpage, $counte['entries'], "journal.php?" . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=$j" . (!empty($vbulletin->GPC['pp']) ? "&pp=$perpage" : ""));
if (!empty($highlight))
{
$highlight = preg_replace('#\*+#s', '*', $highlight);
if ($highlight != '*')
{
$regexfind = array('\*', '\<', '\>');
$regexreplace = array('[\w.:@*/?=]*?', '<', '>');
$highlight = preg_quote(strtolower($highlight), '#');
$highlight = explode(' ', $highlight);
$highlight = str_replace($regexfind, $regexreplace, $highlight);
foreach ($highlight AS $val)
{
if ($val = trim($val))
{
$replacewords[] = htmlspecialchars_uni($val);
}
}
}
}
$fentries = $db->query_read("
SELECT journal_entries.entry_id, journal_entries.entrytitle,
journal_entries.entrytext, journal_entries.mood, journal_entries.np, journal_entries.allowbuddies,journal_entries.entrydate,
journal_entries.entry_totalvotes, journal_moods.mood_name, journal_entries.ipaddress,journal_moods.mood_image, journal_entries.entry_totalrating,
journal_entries.private, journal_entries.whocanview,
COUNT(journal_comments.comment_text) AS comments
FROM " . TABLE_PREFIX . "journal_entries AS journal_entries
LEFT JOIN " . TABLE_PREFIX . "journal_comments AS journal_comments ON (journal_entries.entry_id=journal_comments.entry_id)
LEFT JOIN " . TABLE_PREFIX . "journal_moods AS journal_moods ON (journal_moods.mood_id=journal_entries.mood)
WHERE journal_entries.journal_id=$j
AND entry_active='1'
" . iif($journalinfo['journalist_id'] != $vbulletin->userinfo['userid'], "AND (journal_entries.private != 1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journal_entries.allowedusers))") . "
GROUP BY journal_entries.entry_id
ORDER BY entrydate DESC
LIMIT $start,$perpage
");
$check= $db->num_rows($fentries);
if (!$check)
{
$entrybits= $vbphrase['journalnoentries'];
}
else
{
$enum2 = $counte['entries']-(($pagenumber-1)*$perpage);
while ($entry= $db->fetch_array($fentries))
{
$enum = $enum2--;
$moo++;
$entry['date']= vbdate($vbulletin->options['dateformat'], $entry['entrydate'], 1);
$entry['time']= vbdate($vbulletin->options['timeformat'], $entry['entrydate']);
if (empty($entry['entry_totalrating']) OR empty($entry['entry_totalvotes']))
{
$rating= "0";
}
else
{
$calcrating= $entry['entry_totalrating']/$entry['entry_totalvotes'];
$rating= round($calcrating);
}
require_once(DIR . '/includes/functions_newpost.php');
$entry['entrytext']= convert_url_to_bbcode($entry['entrytext']);
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$entry['entrytext']= $bbcode_parser->do_parse($entry['entrytext'], 0, $setting['allow_imgcode'], $setting['allow_smilies'], $setting['allow_bbcode']);
// ATTN: Highlighting broken
/* if (is_array($replacewords))
{
$entry['entrytext'] = preg_replace('#(^|>)([^<]+)(?=<|$)#sUe', "process_highlight_postbit('\\2', \$replacewords, '\\1')", $entry['entrytext']);
$entry['entrytext'] = preg_replace('#<vb_highlight>(.*)</vb_highlight>#siU', '<span class="highlight">$1</span>', $entry['entrytext']);
} */
if (isset($entry['mood']) AND $entry['mood']>0)
{
$show['mood']= true;
}
else
{
$show['mood']= false;
}
// TODO: Get rid of those checks here, as they seem to be unnecessary anyway
$wcv_entry = explode(',', $entry['whocanview']);
if ($entry['private'])
{
if ($vbulletin->userinfo['userid']==$journalinfo['journalist_id'])
{
eval('$entrybits .= "' . fetch_template('journal_entrybits') . '";');
}
else if ($vbulletin->userinfo['usergroupid']=="6")
{
eval('$entrybits .= "' . fetch_template('journal_entrybits') . '";');
}
else if ((in_array($vbulletin->userinfo['userid'], $wcv_entry)) AND ($vbulletin->userinfo['userid']!=0))
{
eval('$entrybits .= "' . fetch_template('journal_entrybits') . '";');
}
else if ($entry['allowbuddies'])
{
if ((in_array($vbulletin->userinfo['userid'], $jbuddies)) AND ($vbulletin->userinfo['userid']!=0))
{
eval('$entrybits .= "' . fetch_template('journal_entrybits') . '";');
}
}
else
{
$entrybits.= '';
}
}
else
{
eval('$entrybits .= "' . fetch_template('journal_entrybits') . '";');
}
}
$db->free_result($entry);
}
if ($canview['comments'])
{
$recent_comments= $db->query_read("
SELECT commenter,commenter_id,comment_title,comment_text,comment_date
FROM " . TABLE_PREFIX . "journal_comments AS journal_comments
LEFT JOIN " . TABLE_PREFIX . "journal_entries AS journal_entries ON (journal_entries.entry_id=journal_comments.entry_id)
WHERE journal_comments.journal_id=$j
AND (ISNULL(journal_entries.entry_id) OR journal_entries.entry_active=1)
" . iif($journalinfo['journalist_id'] != $vbulletin->userinfo['userid'], "AND (ISNULL(journal_entries.entry_id) OR journal_entries.private != 1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journal_entries.allowedusers))") . "
ORDER BY comment_date DESC LIMIT 5
");
$check_comments= $db->num_rows($recent_comments);
if ($check_comments<1)
{
// TODO: Hardcoded Text
$reccombits="<tr><td>There are no Comments.</td></tr>\n";
}
else
{
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
while($reccom= $db->fetch_array($recent_comments))
{
$commentdate= vbdate($vbulletin->options['dateformat'], $reccom['comment_date'], 1);
$commenttime= vbdate($vbulletin->options['timeformat'], $reccom['comment_date']);
$reccom['comment_text']= $bbcode_parser->do_parse($reccom['comment_text'], 0, $setting['allow_imgcode'], $setting['allow_smilies'], $setting['allow_bbcode']);
eval('$reccombits .= "' . fetch_template('journal_recent_comments') . '";');
}
$db->free_result($reccom);
}
}
$navbits= array();
$navbits["journal.php"]= $vbphrase['journals'];
if(!empty($journalinfo['journalname']))
{
$navbits['']= $journalinfo['journalname'];
}
else
{
$navbits['']= construct_phrase($vbphrase['xs_journal'], $journalinfo['journalist']);
}
$navbits= construct_navbits($navbits);
require_once(DIR . '/includes/functions_editor.php');
$show['wysiwyg'] = ($setting['allow_bbcode'] ? is_wysiwyg_compatible() : 0);
$istyles_js = construct_editor_styles_js();
$show['qr_require_click'] = 0;
$editorid = construct_edit_toolbar('', 0, 'journal', ($setting['allow_smilies'] ? 1 : 0), 1, false, 'qr');
$messagearea = "
<script type=\"text/javascript\">
<!--
var require_click = false;
var threaded_mode = 1;
var is_last_page = false;
// -->
</script>
$messagearea
";
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_journalpage') . '");');
$db->free_result($journalinfo);
$db->free_result($avatar);
$db->free_result($loggedin);
}
}
else
{
print_no_permission();
}
}
if ($_REQUEST['do'] == 'showcomments')
{
$jpermissions= $db->query_first("SELECT journal_id,private,allowbuddies,whocanview,jbuddylist,journalist_id,status FROM " . TABLE_PREFIX . "journals AS journals
LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON (usertextfield.userid=journals.journalist_id)
WHERE journal_id=".$j."");
if (!$jpermissions['journal_id'])
{
eval(standard_error(fetch_error('invalidid', 'Journal', $vbulletin->options['contactuslink'])));
}
if ($jpermissions['private']==1)
{
$journal_wcv = explode(',', $jpermissions['whocanview']);
if (($vbulletin->userinfo['usergroupid']=="6") OR ($vbulletin->userinfo['userid']==$jpermissions['journalist_id']) OR ($vbulletin->userinfo['userid'] AND in_array($vbulletin->userinfo['userid'], $journal_wcv)))
{
$canview['thisjournal']= true;
}
else if ($jpermissions['allowbuddies']==1)
{
$jbuddies= explode(' ', $jpermissions['jbuddylist']);
if(in_array($vbulletin->userinfo['userid'], $jbuddies))
{
$canview['thisjournal']= true;
}
}
else
{
$canview['thisjournal']= false;
}
}
else
{
$canview['thisjournal']= true;
}
if (!$canview['comments'] OR !$canview['thisjournal'])
{
print_no_permission();
}
// Hmm.. I wonder
$vbulletin->input->clean_array_gpc('r', array(
'page' => TYPE_INT,
'e' => TYPE_INT,
));
$page =& $vbulletin->GPC['page'];
$e =& $vbulletin->GPC['e'];
if($e)
{
$entryinfo= $db->query_first("SELECT entry_id,entrytitle, private, allowedusers FROM " . TABLE_PREFIX . "journal_entries WHERE journal_id='".intval($j)."' AND entry_id='".intval($e)."'");
$entryget=" AND journal_entries.entry_id='".intval($e)."'";
// TODO: Check Permissions for this Entry
if (!$entryinfo['entry_id'])
{
eval(standard_error(fetch_error('invalidid', 'Journal Entry', $vbulletin->options['contactuslink'])));
}
if ($entryinfo['private'] AND $vbulletin->userinfo['usergroupid']!="6" AND $vbulletin->userinfo['userid'] != $jpermissions['journalist_id'] AND strpos(",$entry[allowedusers],", ',' . $vbulletin->userinfo['userid'] . ',') == false)
{
print_no_permission();
}
}
$countc= $db->query_first("
SELECT COUNT(*) AS comments FROM " . TABLE_PREFIX . "journal_comments AS journal_comments
LEFT JOIN " . TABLE_PREFIX . "journal_entries AS journal_entries ON (journal_entries.entry_id=journal_comments.entry_id)
WHERE journal_comments.journal_id=$j" .iif(!empty($e), $entryget) . "
AND (ISNULL(journal_entries.entry_id) OR journal_entries.entry_active=1)
" . iif($jpermissions['journalist_id'] != $vbulletin->userinfo['userid'], "AND (ISNULL(journal_entries.entry_id) OR journal_entries.private != 1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journal_entries.allowedusers))") . "
");
$perpage= $setting['journalentries_perpage'];
if (empty($page))
{
$page= 1;
}
$start= (($page * $perpage) - $perpage);
$pagenumber = $page++;
if ($pagenumber < 1)
{
$pagenumber = 1;
}
else if ($pagenumber > $countc['comments'])
{
$pagenumber = $countc['comments'];
}
$pgnav= construct_page_nav($pagenumber, $perpage, $countc['comments'], "journal.php?" . $vbulletin->session->vars['sessionurl'] . "do=showcomments&j=$j" . "&e=$e" . (!empty($vbulletin->GPC['pp']) ? "&pp=$perpage" : ""));
$fcomments= $db->query_read("
SELECT comment_id,comment_title,comment_text,comment_date,
commenter_id,commenter,journal_comments.ipaddress
FROM " . TABLE_PREFIX . "journal_comments AS journal_comments
LEFT JOIN " . TABLE_PREFIX . "journal_entries AS journal_entries ON (journal_entries.entry_id=journal_comments.entry_id)
WHERE journal_comments.journal_id='".$j."'".iif(!empty($e), $entryget)."
AND (ISNULL(journal_entries.entry_id) OR journal_entries.entry_active=1)
" . iif($jpermissions['journalist_id'] != $vbulletin->userinfo['userid'], "AND (ISNULL(journal_entries.entry_id) OR journal_entries.private != 1 OR FIND_IN_SET('" . $vbulletin->userinfo['userid'] . "', journal_entries.allowedusers))") . "
ORDER BY comment_date DESC
LIMIT $start,$perpage
");
$totalcomms= $countc['comments'];
$cnum2= $countc['comments']-(($pagenumber-1)*$perpage);
while($comment= $db->fetch_array($fcomments))
{
$cnum = $cnum2--;
$baa++;
$comment['date']= vbdate($vbulletin->options['dateformat'], $comment['comment_date'], 1);
$comment['time']= vbdate($vbulletin->options['timeformat'], $comment['comment_date']);
require_once(DIR . '/includes/functions_newpost.php');
$comment['comment_text']= convert_url_to_bbcode($comment['comment_text']);
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$text= $bbcode_parser->do_parse($comment['comment_text'], 0, $setting['allow_imgcode'], $setting['allow_smilies'], $setting['allow_bbcode']);
eval('$commentbits .= "' . fetch_template('journal_commentbits') . '";');
}
$db->free_result($comment);
$journal= $db->query_first("SELECT journalname AS name,journalist FROM " . TABLE_PREFIX . "journals WHERE journal_id='".intval($j)."'");
$navbits= array();
$navbits['journal.php' . $vbulletin->session->vars['sessionurl_q']]= $vbphrase['journals'];
if (!empty($journal['name']))
{
$navbits['journal.php?' . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=$j"]= $journal['name'];
}
else
{
$navbits['journal.php?' . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=$j"]= construct_phrase($vbphrase['xs_journal'], $journal['journalist']);;
}
$navbits['']= $vbphrase['show_comments'];
$navbits= construct_navbits($navbits);
require_once(DIR . '/includes/functions_editor.php');
$show['wysiwyg'] = ($setting['allow_bbcode'] ? is_wysiwyg_compatible() : 0);
$istyles_js = construct_editor_styles_js();
$show['qr_require_click'] = 0;
$editorid = construct_edit_toolbar('', 0, 'journal', ($setting['allow_smilies'] ? 1 : 0), 1, false, 'qr');
$messagearea = "
<script type=\"text/javascript\">
<!--
var require_click = false;
var threaded_mode = 1;
var is_last_page = false;
var allow_ajax_qr = false;
// -->
</script>
$messagearea
";
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_commentpage') . '");');
$db->free_result($jpermissions);
}
if ($_REQUEST['do'] == 'insertcomment')
{
if (!$can['comment'])
{
print_no_permission();
}
$vbulletin->input->clean_array_gpc('p', array(
'title' => TYPE_NOHTML,
'wysiwyg' => TYPE_BOOL,
'message' => TYPE_STR
));
// ATTN Compatibility Code
$title =& $vbulletin->GPC['title'];
// ATTN Compatibility Code
if ($vbulletin->GPC['wysiwyg'])
{
require_once(DIR . '/includes/functions_wysiwyg.php');
$message = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], false);
}
else
{
$message =& $vbulletin->GPC['message'];
}
$floodcheck= $db->query_first("SELECT comment_date AS lastcomdate FROM " . TABLE_PREFIX . "journal_comments WHERE commenter_id=".$vbulletin->userinfo['userid']." ORDER BY comment_date DESC");
if ((TIMENOW - $floodcheck['lastcomdate'])<= $setting['floodint'])
{
eval(standard_error(fetch_error('journalfloodcheck', $setting['floodint'],' commenting')));
}
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "journal_comments
(journal_id,entry_id,comment_title,comment_text,commenter,commenter_id,comment_date,ipaddress)
VALUES ('".intval($j)."','".intval($e)."','".$db->escape_string($_POST['title'])."','".$db->escape_string($message)."',
'".$db->escape_string($vbulletin->userinfo['username'])."','".intval($vbulletin->userinfo['userid'])."','".TIMENOW."','". IPADDRESS ."')
");
$db->query_write("UPDATE " . TABLE_PREFIX . "journals SET commentcount=commentcount+1 WHERE journal_id=".intval($j)."");
$entryurl= "&e=".intval($e)."";
$vbulletin->url = "journal.php?" . $vbulletin->session->vars['sessionurl'] . "do=showcomments&j=".$j."".iif(!empty($e), $entryurl)."";
eval(print_standard_redirect('redirect_journalcommentinserted'));
}
if ($_REQUEST['do'] == 'deletecom')
{
$vbulletin->input->clean_array_gpc('r', array(
'j' => TYPE_INT,
'e' => TYPE_INT,
'com' => TYPE_INT
));
// ATTN Compatibility Code
$j =& $vbulletin->GPC['j'];
$e =& $vbulletin->GPC['e'];
$com =& $vbulletin->GPC['com'];
// ATTN Compatibility Code
if($vbulletin->userinfo['usergroupid']==6)
{
$db->query_write("DELETE FROM " . TABLE_PREFIX . "journal_comments WHERE comment_id=".$com."");
$db->query_write("UPDATE " . TABLE_PREFIX . "journals SET commentcount=commentcount-1 WHERE journal_id=".$j."");
$vbulletin->url= "journal.php?" . $vbulletin->session->vars['sessionurl'] . "do=showcomments&j=".$j."&e=".$e."";
eval(print_standard_redirect('redirect_journalcommentdeleted'));
}
else
{
print_no_permission();
}
}
if ($_REQUEST['do'] == 'startjournal')
{
if (!$canhave['journal'])
{
print_no_permission();
}
$check= $db->query_first("SELECT count(*) AS journal FROM " . TABLE_PREFIX . "journals WHERE journalist_id='".$vbulletin->userinfo['userid']."'");
if ($check['journal'])
{
eval(standard_error(fetch_error('journalalrdyexists')));
}
else
{
$getmoods= $db->query("SELECT * FROM " . TABLE_PREFIX . "journal_moods ORDER BY mood_name ASC");
while ($mood= $db->fetch_array($getmoods))
{
eval('$moodbits .= "' . fetch_template('journal_moods') . '";');
}
$db->free_result($mood);
$navbits= array();
$navbits["journal.php"]= "Journals";
require_once(DIR . '/includes/functions_editor.php');
$vbulletin->options['allowbbcode'] = $setting['allow_bbcode'];
$vbulletin->options['allowbbimagecode'] = $setting['allow_imgcode'];
$editorid = construct_edit_toolbar('', 0, 'journal', $setting['allow_smilies'], 1, 0);
$navbits['']= $vbphrase['create_journal'];
$navbits= construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_startpage') . '");');
}
}
if ($_REQUEST['do'] == 'insertjournal')
{
$vbulletin->input->clean_array_gpc('p', array(
'jname' => TYPE_NOHTML,
'jdesc' => TYPE_NOHTML,
'jpriv' => TYPE_INT,
'whocanviewj' => TYPE_NOHTML,
'etitle' => TYPE_NOHTML,
'message' => TYPE_STR,
'epriv' => TYPE_INT,
'whocanviewe' => TYPE_NOHTML,
'mood' => TYPE_INT,
'np' => TYPE_NOHTML,
'allowbuddsj' => TYPE_INT,
'allowbuddse' => TYPE_INT,
'wysiwyg' => TYPE_BOOL
));
// ATTN Compatibility Code
$jname =& $vbulletin->GPC['jname'];
$jdesc =& $vbulletin->GPC['jdesc'];
$jpriv =& $vbulletin->GPC['jpriv'];
$epriv =& $vbulletin->GPC['epriv'];
$whocanviewj =& $vbulletin->GPC['whocanviewj'];
$etitle =& $vbulletin->GPC['etitle'];
if ($vbulletin->GPC['wysiwyg'])
{
require_once(DIR . '/includes/functions_wysiwyg.php');
$emessage = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], false);
}
else
{
$emessage =& $vbulletin->GPC['message'];
}
$whocanviewe =& $vbulletin->GPC['whocanviewe'];
$mood =& $vbulletin->GPC['mood'];
$np =& $vbulletin->GPC['np'];
$allowbuddsj =& $vbulletin->GPC['allowbuddsj'];
$allowbuddse =& $vbulletin->GPC['allowbuddse'];
// ATTN Compatibility Code
if (!$canhave['journal'] OR !$vbulletin->userinfo['userid'])
{
print_no_permission();
}
$check= $db->query_first("SELECT count(*) AS journal FROM " . TABLE_PREFIX . "journals WHERE journalist_id='".$vbulletin->userinfo['userid']."'");
if ($check['journal'])
{
eval(standard_error(fetch_error('journalalrdyexists')));
}
if ($jpriv)
{
$allowedusers = construct_allowed_users($allowbuddsj, $vbulletin->userinfo['jbuddylist'], $whocanviewj);
}
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "journals
(allowedusers, journalist, journalist_id, journaldate,
journaldesc, private, allowbuddies, whocanview, lastentry,
lastentry_date,ipaddress, journalname" . ($setting['autoapprove_entries']==1 ? ',entrycount' : '')."".($setting['autoapprove_journals']==1 ? ',active' : '')."
)
VALUES
('" . $db->escape_string($allowedusers) . "', '".$db->escape_string($vbulletin->userinfo['username'])."', '".intval($vbulletin->userinfo['userid'])."',
".TIMENOW.", '".$db->escape_string($jdesc)."', ".$jpriv.", ".$allowbuddsj.", '".$db->escape_string($whocanviewj)."',
'".$db->escape_string($etitle)."', ".TIMENOW.",'". IPADDRESS ."', '" . $db->escape_string($jname) . "'" . ($setting['autoapprove_entries']==1 ? ',1' : '')."".($setting['autoapprove_journals'] ? ',1' : '')."
)
");
$preentry= $db->insert_id();
if ($epriv)
{
$allowedusers = construct_allowed_users($allowbuddse, $vbulletin->userinfo['jbuddylist'], $whocanviewe);
}
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "journal_entries
(allowedusers, journal_id, entrytitle, entrytext, entrydate,
private, allowbuddies, whocanview, ipaddress, mood, np".($setting['autoapprove_entries']==1 ? ',entry_active' : '')."
)
VALUES ('" . $db->escape_string($allowedusers) . "', '".$preentry."', '".$db->escape_string($etitle)."', '".$db->escape_string($emessage)."', ".TIMENOW.", '".$epriv."', ".$allowbuddse.",'".$db->escape_string($whocanviewe)."', '".$vbulletin->session->vars['host']."', ".$mood.", '".$db->escape_string($np)."'".($setting['autoapprove_entries']==1 ? ',1' : '')."
)
");
$entry= $db->insert_id();
$db->query_write("UPDATE " . TABLE_PREFIX . "journals SET lastentry_id='".$entry."'
WHERE lastentry='".$db->escape_string($etitle)."' AND journal_id='".$preentry."'
");
$vbulletin->url="journal.php?" . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=".$preentry."";
eval(print_standard_redirect('redirect_journalinserted'));
}
if ($_REQUEST['do'] == 'addentry')
{
if (!journalist_check($j, $vbulletin->userinfo['userid']) OR !$vbulletin->userinfo['userid'])
{
print_no_permission();
}
$getmoods= $db->query_read("SELECT * FROM " . TABLE_PREFIX . "journal_moods ORDER BY mood_name ASC");
while($mood= $db->fetch_array($getmoods))
{
eval('$moodbits .= "' . fetch_template('journal_moods') . '";');
}
$db->free_result($mood);
$navbits= array();
$navbits['journal.php' . $vbulletin->session->vars['sessionurl_q']]= $vbphrase['journals'];
$navbits['']= $vbphrase['add_entry'];
require_once(DIR . '/includes/functions_editor.php');
$vbulletin->options['allowbbcode'] = $setting['allow_bbcode'];
$vbulletin->options['allowbbimagecode'] = $setting['allow_imgcode'];
$editorid = construct_edit_toolbar('', 0, 'journal', $setting['allow_smilies'], 1, 0);
$navbits= construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_submitentry') . '");');
}
if ($_REQUEST['do'] == 'insertentry')
{
$vbulletin->input->clean_array_gpc('p', array(
'title' => TYPE_NOHTML,
'message' => TYPE_STR,
'private' => TYPE_INT,
'wcv' => TYPE_NOHTML,
'mood' => TYPE_INT,
'np' => TYPE_NOHTML,
'allowbudds' => TYPE_INT,
'wysiwyg' => TYPE_BOOL
));
// ATTN Compatibility Code
$title =& $vbulletin->GPC['title'];
if ($vbulletin->GPC['wysiwyg'])
{
require_once(DIR . '/includes/functions_wysiwyg.php');
$message = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], false);
}
else
{
$message =& $vbulletin->GPC['message'];
}
$private =& $vbulletin->GPC['private'];
$wcv =& $vbulletin->GPC['wcv'];
$mood =& $vbulletin->GPC['mood'];
$np =& $vbulletin->GPC['np'];
$allowbudds =& $vbulletin->GPC['allowbudds'];
// ATTN Compatibility Code
if (!journalist_check($j, $vbulletin->userinfo['userid']) OR !$vbulletin->userinfo['userid'])
{
print_no_permission();
}
$floodcheck= $db->query_first("SELECT entrydate AS lastentry FROM " . TABLE_PREFIX . "journal_entries WHERE journal_id=".$j." ORDER BY entrydate DESC");
if((TIMENOW - $floodcheck['lastentry'])<= $setting['floodint'])
{
eval(standard_error(fetch_error('journalfloodcheck', $setting['floodint'],'posting another entry')));
}
if ($private)
{
$allowedusers = construct_allowed_users($allowbudds, $vbulletin->userinfo['jbuddylist'], $wcv);
}
$autoentry=",'1'";
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "journal_entries
(allowedusers, journal_id, entrytitle, entrytext, entrydate, private, allowbuddies, whocanview, ipaddress, mood, np".iif($setting['autoapprove_entries']=="1", ', entry_active').")
VALUES ('" . $db->escape_string($allowedusers) . "', '".$j."','".$db->escape_string($title)."','".$db->escape_string($message)."','".TIMENOW."','".$private."', ".$allowbudds.",
'".$db->escape_string($wcv)."','". IPADDRESS ."','".$mood."','".$db->escape_string($np)."'".iif($setting['autoapprove_entries']=="1", $autoentry).")
");
$preupdate= $db->insert_id();
if ($private AND !$allowedusers)
{
$allowedusers='-';
}
$db->query_write("UPDATE " . TABLE_PREFIX . "journals SET lastentry_uids='" . $db->escape_string($allowedusers) . "', lastentry='".$db->escape_string($title)."', lastentry_date='".TIMENOW."',
lastentry_id='".$preupdate."'".($setting['autoapprove_entries']==1 ? ',entrycount=entrycount+1' : '')." WHERE journal_id='".$j."'
");
$vbulletin->url="journal.php?" . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=".$j."";
eval(print_standard_redirect('redirect_journalentryinserted'));
}
if ($_REQUEST['do'] == 'showentry')
{
$enum =& $vbulletin->input->clean_gpc('r', 'enum', TYPE_UINT);
$entry= $db->query_first("
SELECT journalist, journalname, entrytitle, entrytext, entrydate, entry_id, np, journal_entries.ipaddress, usertextfield.jbuddylist, entry_totalrating, entry_totalvotes, journals.journal_id, journalist_id, journals.private AS jpriv, journal_entries.private AS epriv, journals.whocanview AS jwcv, journal_entries.whocanview AS ewcv, journal_entries.mood, journal_moods.mood_name, journal_moods.mood_image, journals.allowbuddies AS allowbuddsj,
journal_entries.allowbuddies AS allowbuddse FROM " . TABLE_PREFIX . "journal_entries AS journal_entries
LEFT JOIN " . TABLE_PREFIX . "journals AS journals ON (journal_entries.journal_id=journals.journal_id)
LEFT JOIN " . TABLE_PREFIX . "journal_moods AS journal_moods ON (journal_entries.mood=journal_moods.mood_id)
LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON (usertextfield.userid=journals.journalist_id)
WHERE journal_entries.entry_id='".intval($e)."' AND entry_active=1
");
if(!empty($entry))
{
/* Build J Buddy List */
$jbuddies= explode(' ', $entry['jbuddylist']);
/* Stop Building J Buddy List */
/* Start Building Journal Permissions */
if($entry['jpriv']==1)
{
$jwcv = explode($entry['jwcv']);
if (($vbulletin->userinfo['usergroupid']==6) OR ($vbulletin->userinfo['userid']==$entry['journalist_id']) OR ($vbulletin->userinfo['userid'] AND in_array($vbulletin->userinfo['userid'], $jwcv)))
{
$canview['thisjournal']= true;
}
else if ($entry['allowbuddsj']==1)
{
if (in_array($vbulletin->userinfo['userid'], $jbuddies))
{
$canview['thisjournal']= true;
}
}
else
{
$canview['thisjournal']= false;
}
}
else
{
$canview['thisjournal']= true;
}
/* Stop Building Journal Permissions */
/* Start Building Journal Entry Permissions */
if ($entry['epriv']==1)
{
$ewcv = explode(',', $entry['ewcv']);
if (($vbulletin->userinfo['usergroupid']==6) OR ($vbulletin->userinfo['userid']==$entry['journalist_id']) OR ($vbulletin->userinfo['userid'] AND in_array($vbulletin->userinfo['userid'], $ewcv)))
{
$canview['thisentry']= true;
}
else if($entry['allowbuddse']==1)
{
if ($vbulletin->userinfo['userid'] AND in_array($vbulletin->userinfo['userid'], $jbuddies))
{
$canview['thisentry']= true;
}
}
else
{
$canview['thisentry']= false;
}
}
else
{
$canview['thisentry']= true;
}
if (!$canview['thisjournal'] OR !$canview['thisentry'])
{
print_no_permission();
}
$count= $db->query_first("SELECT COUNT(*) AS comments FROM " . TABLE_PREFIX . "journal_comments WHERE entry_id='".intval($e)."'");
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$text= $bbcode_parser->do_parse($entry['entrytext'], 0, $setting['allow_imgcode'], $setting['allow_smilies'], $setting['allow_bbcode']);
$entry['date']= vbdate($vbulletin->options['dateformat'], $entry['entrydate'], 1);
$entry['time']= vbdate($vbulletin->options['timeformat'], $entry['entrydate']);
$navbits= array();
$navbits['journal.php' . $vbulletin->session->vars['sessionurl_q']]= $vbphrase['journals'];
if (!empty($entry['journalname']))
{
$navbits['journal.php?' . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=$entry[journal_id]"] = $entry['journalname'];
}
else
{
$navbits['journal.php?' . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=$entry[journal_id]"]= construct_phrase($vbphrase['xs_journal'], $entry['journalist']);
}
$navbits['']= $entry['entrytitle'];
$navbits= construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_showentrypage') . '");');
}
else
{
eval(standard_error(fetch_error('journalentrynotfound')));
}
}
if ($_REQUEST['do'] == 'editjournal')
{
if ((!$vbulletin->userinfo['userid'] OR !journalist_check($j, $vbulletin->userinfo['userid']) OR !$caneditown['journal']) AND !admin)
{
print_no_permission();
}
$journalinfo= $db->query_first("SELECT journal_id, journalname, journaldesc, journalist, private, whocanview, journalist, allowbuddies FROM " . TABLE_PREFIX . "journals WHERE journal_id='".$j."'");
if ($journalinfo['journal_id'])
{
$vbulletin->session->set('injournal', $journalinfo['journal_id']);
}
else
{
eval(standard_error(fetch_error('invalidid', 'Journal', $vbulletin->options['contactuslink'])));
}
$navbits= array();
$navbits['journal.php' . $vbulletin->session->vars['sessionurl_q']]= $vbphrase['journals'];
if(!empty($journalinfo['journalname']))
{
$navbits['journal.php?' . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=$j"]= $journalinfo['journalname'];
}
else
{
$navbits['journal.php?' . $vbulletin->session->vars['sessionurl'] . "do=showjournal&j=$j"]= construct_phrase($vbphrase['xs_journal'], $journalinfo['journalist']);;
}
$navbits['']= $vbphrase['edit_journal_info'];
$navbits= construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_edit_journalinfo') . '");');
$db->free_result($journalinfo);
}
if ($_REQUEST['do'] == 'editentry')
{
if ((!$vbulletin->userinfo['userid'] OR !journalist_check($j, $vbulletin->userinfo['userid']) OR !$caneditown['entry']) AND !admin)
{
print_no_permission();
}
$entryinfo= $db->query_first("SELECT entrytitle, entrytext, private, whocanview, mood, np, allowbuddies FROM " . TABLE_PREFIX . "journal_entries WHERE entry_id='".$e."'");
// $entryinfo['entrytext']= htmlspecialchars($entryinfo['entrytext']);
$fetchmoods= $db->query("SELECT mood_id,mood_name FROM " . TABLE_PREFIX . "journal_moods");
while($mood= $db->fetch_array($fetchmoods))
{
if($entryinfo['mood']==$mood['mood_id'])
{
$selectedmood= true;
}
else
{
$selectedmood= false;
}
eval('$moodbits .= "' . fetch_template('journal_moods') . '";');
}
$db->free_result($mood);
require_once(DIR . '/includes/functions_editor.php');
$editorid = construct_edit_toolbar($entryinfo['entrytext'], 0, 'journal', (($setting['allow_smilies']) ? 1 : 0), 1, '');
$navbits= array();
$navbits['journal.php' . $vbulletin->session->vars['sessionurl_q']]= $vbphrase['journals'];
$navbits['']= $entryinfo['entrytitle'];
$navbits= construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_edit_entryinfo') . '");');
}
if ($_REQUEST['do'] == 'editcomment')
{
if((!$vbulletin->userinfo['userid'] OR !journalist_check($j, $vbulletin->userinfo['userid']) OR !$caneditown['comment']) AND !admin)
{
print_no_permission();
}
$comminfo= $db->query_first("SELECT comment_title,comment_text FROM " . TABLE_PREFIX . "journal_comments WHERE comment_id='".$c."'");
$navbits= array();
require_once(DIR . '/includes/functions_editor.php');
$vbulletin->options['allowbbcode'] = $setting['allow_bbcode'];
$vbulletin->options['allowbbimagecode'] = $setting['allow_imgcode'];
$editorid = construct_edit_toolbar($comminfo['comment_text'], 0, 'journal', $setting['allow_smilies'], 1, 0);
$navbits['journal.php' . $vbulletin->session->vars['sessionurl_q']] = $vbphrase['journals'];
$navbits['']= $vbphrase['edit_comment'];
$navbits= construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('journal_edit_commentinfo') . '");');
}
if ($_REQUEST['do'] == 'update')
{
$vbulletin->input->clean_array_gpc('p', array(
'jname' => TYPE_NOHTML,
'jdesc' => TYPE_NOHTML,
'jpriv' => TYPE_INT,
'allowbuddsj' => TYPE_INT,
'jwcv' => TYPE_STR,
'etitle' => TYPE_NOHTML,
'message' => TYPE_TEXT,
'epriv' => TYPE_INT,
'ewcv' => TYPE_STR,
'allowbuddse' => TYPE_INT,
'mood' => TYPE_INT,
'np' => TYPE_NOHTML,
'ctitle' => TYPE_NOHTML,
'type' => TYPE_STR,
'wysiwyg' => TYPE_BOOL
));
// ATTN Compatibility Code
$jname =& $vbulletin->GPC['jname'];
$jdesc =& $vbulletin->GPC['jdesc'];
$jpriv =& $vbulletin->GPC['jpriv'];
$allowbuddsj =& $vbulletin->GPC['allowbuddsj'];
$jwcv =& $vbulletin->GPC['jwcv'];
$etitle =& $vbulletin->GPC['etitle'];
$epriv =& $vbulletin->GPC['epriv'];
$ewcv =& $vbulletin->GPC['ewcv'];
$allowbuddse =& $vbulletin->GPC['allowbuddse'];
$mood =& $vbulletin->GPC['mood'];
$np =& $vbulletin->GPC['np'];
$ctitle =& $vbulletin->GPC['ctitle'];
$type =& $vbulletin->GPC['type'];
// ATTN Compatibility Code
// die($vbulletin->GPC['allowbuddse']);
if ($vbulletin->GPC['wysiwyg'])
{
require_once(DIR . '/includes/functions_wysiwyg.php');
$message = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], false);
}
else
{
$message =& $vbulletin->GPC['message'];
}
if (!((journalist_check($j, $vbulletin->userinfo['userid'])=="true" AND $caneditown['comment'] OR $caneditown['entry'] OR $caneditown['journal']) OR $vbulletin->userinfo['usergroupid']=="6" AND $vbulletin->userinfo['userid']!=0))
{
print_no_permission();
}
$journalinfo = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "journals