' . LB;
+ }
+ $cal_templates->set_var('year_options', $yroptions);
+
+ for ($i = 1; $i <= 6; $i++) {
+ $wday = '';
+ for ($j = 1; $j <= 7; $j++) {
+ $curday = $cal->getDayData($i, $j);
+ if (!empty($curday)) {
+ // Cache first actual day of the week to build week view link
+ if (empty($wday)) {
+ $wday = $curday->daynumber;
+ }
+ if (($currentyear > $year) OR
+ ($currentmonth > $month && $currentyear == $year) OR
+ ($currentmonth == $month && $currentday > $curday->daynumber && $currentyear == $year)
+ ) {
+ $cal_templates->set_var('cal_day_style', 'cal-oldday');
+ } else {
+ if ($currentyear == $year && $currentmonth == $month && $currentday == $curday->daynumber) {
+ $cal_templates->set_var('cal_day_style', 'cal-today');
+ } else {
+ $cal_templates->set_var('cal_day_style', 'cal-futureday');
+ }
+ }
- if ($mode == 'personal') {
- $calsql_tbl = $_TABLES['personal_events'];
- $calsql_filt = "AND (uid = {$_USER['uid']})";
- } else {
- $calsql_tbl = $_TABLES['events'];
- $calsql_filt = COM_getPermSql ('AND');
- }
+ if (strlen($curday->daynumber) == 1) {
+ $curday->daynumber = '0' . $curday->daynumber;
+ }
+
+ $cal_templates->set_var('cal_day_anchortags',
+ COM_createLink($curday->daynumber, $_CONF['site_url']
+ . '/calendar/index.php?view=day&' . addMode($mode)
+ . 'day=' . $curday->daynumber . "&month=$month&year=$year",
+ array('class' => 'cal-date'))
+ . ' '
+ );
- $calsql = "SELECT eid,title,datestart,dateend,timestart,timeend,allday,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM $calsql_tbl WHERE "
- . "((datestart >= '$year-$month-$curday->daynumber 00:00:00' "
- . "AND datestart <= '$year-$month-$curday->daynumber 23:59:59') "
- . "OR (dateend >= '$year-$month-$curday->daynumber 00:00:00' "
- . "AND dateend <= '$year-$month-$curday->daynumber 23:59:59') "
- . "OR ('$year-$month-$curday->daynumber' BETWEEN datestart AND dateend))"
- . $calsql_filt . " ORDER BY datestart,timestart";
-
- $query2 = DB_query($calsql);
- $q2_numrows = DB_numRows($query2);
-
- if ($q2_numrows > 0) {
- $entries = '';
- for ($z = 1; $z <= $q2_numrows; $z++) {
- $results = DB_fetchArray ($query2);
- if ($results['title']) {
- $cal_templates->set_var ('cal_day_entries', '');
- $entries .=
- COM_createLink(
- stripslashes ($results['title']),
- $_CONF['site_url'] . '/calendar/event.php?' . addMode ($mode)
- . 'eid=' . $results['eid'],
- array('class'=>'cal-event'))
- . ' ';
+ if (strlen($month) == 1) {
+ $month = '0' . $month;
}
- }
- for ($z = $z; $z <= 4; $z++) {
- $entries .= ' ';
- }
- $cal_templates->set_var('event_anchortags', $entries);
+ if ($mode == 'personal') {
+ $calsql_tbl = $_TABLES['personal_events'];
+ $calsql_filt = "AND (uid = {$_USER['uid']})";
+ } else {
+ $calsql_tbl = $_TABLES['events'];
+ $calsql_filt = COM_getPermSql('AND');
+ }
- } else {
- if ($q2_numrows < 4) {
- for ($t=0; $t < (4 - $q2_numrows); $t++) {
- $cal_templates->set_var('cal_day_entries',' ');
+ $calsql = "SELECT eid,title,datestart,dateend,timestart,timeend,allday,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM $calsql_tbl WHERE "
+ . "((datestart >= '$year-$month-$curday->daynumber 00:00:00' "
+ . "AND datestart <= '$year-$month-$curday->daynumber 23:59:59') "
+ . "OR (dateend >= '$year-$month-$curday->daynumber 00:00:00' "
+ . "AND dateend <= '$year-$month-$curday->daynumber 23:59:59') "
+ . "OR ('$year-$month-$curday->daynumber' BETWEEN datestart AND dateend))"
+ . $calsql_filt . " ORDER BY datestart,timestart";
+
+ $query2 = DB_query($calsql);
+ $q2_numrows = DB_numRows($query2);
+
+ if ($q2_numrows > 0) {
+ $entries = '';
+ for ($z = 1; $z <= $q2_numrows; $z++) {
+ $results = DB_fetchArray($query2);
+ if ($results['title']) {
+ $cal_templates->set_var('cal_day_entries', '');
+ $entries .=
+ COM_createLink(
+ stripslashes($results['title']),
+ $_CONF['site_url'] . '/calendar/event.php?' . addMode($mode)
+ . 'eid=' . $results['eid'],
+ array('class' => 'cal-event'))
+ . ' ';
+ }
+ }
+ for ($z = $z; $z <= 4; $z++) {
+ $entries .= ' ';
+ }
+
+ $cal_templates->set_var('event_anchortags', $entries);
+
+ } else {
+ if ($q2_numrows < 4) {
+ for ($t = 0; $t < (4 - $q2_numrows); $t++) {
+ $cal_templates->set_var('cal_day_entries', ' ');
+ }
+ }
+ }
+
+ $cal_templates->parse('cal_day_entries', 'event', true);
+ $cal_templates->set_var('event_anchortags', '');
+ } else {
+ if ($i > 1) {
+ // Close out calendar if needed
+ for ($k = $j; $k <= 7; $k++) {
+ $cal_templates->set_var('cal_day_style', 'cal-nullday');
+ $cal_templates->set_var('cal_day_anchortags', '');
+ $cal_templates->set_var('cal_day_entries', ' ');
+ if ($k < 7) $cal_templates->parse('cal_days', 'day', true);
+ }
+ // for looping to stop...we are done now
+ $i = 7;
+ $j = 8;
+ } else {
+ // Print empty box for any days in the first week that occur
+ // before the first day
+ $cal_templates->set_var('cal_day_style', 'cal-nullday');
+ $cal_templates->set_var('cal_day_anchortags', '');
+ $cal_templates->set_var('cal_day_entries', ' ');
}
}
+ $cal_templates->parse('cal_days', 'day', true);
}
+ list($wmonth, $wday, $wyear) = getPriorSunday($month, $wday, $year);
+ $cal_templates->set_var('wmonth', $wmonth);
+ $cal_templates->set_var('wday', $wday);
+ $cal_templates->set_var('wyear', $wyear);
+ $cal_templates->parse('cal_week', 'week', true);
+ $cal_templates->set_var('cal_days', '');
+
+ // check if we need to render the following week at all
+ if ($i < 6) {
+ $data = $cal->getDayData($i + 1, 1);
+ if (empty ($data)) {
+ break;
+ }
+ }
+ }
- $cal_templates->parse('cal_day_entries', 'event', true);
- $cal_templates->set_var('event_anchortags','');
+ if ($mode == 'personal') {
+ $cal_templates->set_var('lang_mastercal', $LANG_CAL_2[25] . $LANG_CAL_2[11]);
+ $cal_templates->parse('master_calendar_option', 'mastercal', true);
} else {
- if ($i > 1) {
- // Close out calendar if needed
- for ($k = $j; $k <= 7; $k++) {
- $cal_templates->set_var('cal_day_style','cal-nullday');
- $cal_templates->set_var('cal_day_anchortags', '');
- $cal_templates->set_var('cal_day_entries',' ');
- if ($k < 7) $cal_templates->parse('cal_days', 'day', true);
- }
- // for looping to stop...we are done now
- $i = 7;
- $j = 8;
+ if (!COM_isAnonUser() && ($_CA_CONF['personalcalendars'] == 1)) {
+ $cal_templates->set_var('lang_mycalendar', $LANG_CAL_2[12]);
+ $cal_templates->parse('personal_calendar_option', 'personalcal', true);
} else {
- // Print empty box for any days in the first week that occur
- // before the first day
- $cal_templates->set_var('cal_day_style','cal-nullday');
- $cal_templates->set_var('cal_day_anchortags', '');
- $cal_templates->set_var('cal_day_entries',' ');
+ $cal_templates->set_var('personal_calendar_option', ' ');
}
}
- $cal_templates->parse('cal_days','day',true);
- }
- list($wmonth, $wday, $wyear) = getPriorSunday($month, $wday, $year);
- $cal_templates->set_var('wmonth', $wmonth);
- $cal_templates->set_var('wday', $wday);
- $cal_templates->set_var('wyear', $wyear);
- $cal_templates->parse('cal_week', 'week',true);
- $cal_templates->set_var('cal_days','');
-
- // check if we need to render the following week at all
- if ($i < 6) {
- $data = $cal->getDayData ($i + 1, 1);
- if (empty ($data)) {
- break;
- }
- }
-}
-
-if ($mode == 'personal') {
- $cal_templates->set_var('lang_mastercal', $LANG_CAL_2[25] . $LANG_CAL_2[11]);
- $cal_templates->parse('master_calendar_option','mastercal',true);
-} else {
- if (!COM_isAnonUser() && ($_CA_CONF['personalcalendars'] == 1)) {
- $cal_templates->set_var('lang_mycalendar', $LANG_CAL_2[12]);
- $cal_templates->parse('personal_calendar_option','personalcal',true);
- } else {
- $cal_templates->set_var('personal_calendar_option',' ');
- }
-}
-$cal_templates->set_var('lang_cal_curmo', $LANG_MONTH[$currentmonth + 0]);
-$cal_templates->set_var('cal_curmo_num', $currentmonth);
-$cal_templates->set_var('cal_curyr_num', $currentyear);
-$cal_templates->set_var('lang_cal_displaymo', $LANG_MONTH[$month + 0]);
-$cal_templates->set_var('cal_displaymo_num', $month);
-$cal_templates->set_var('cal_displayyr_num', $year);
-if ($mode == 'personal') {
- $cal_templates->set_var('lang_addevent', $LANG_CAL_2[8]);
- $cal_templates->set_var('addevent_formurl', '/calendar/index.php');
-} else {
- $cal_templates->set_var('lang_addevent', $LANG_CAL_2[42]);
- $cal_templates->set_var('addevent_formurl', '/submit.php?type=calendar');
-}
-$cal_templates->parse('add_event_option','addevent',true);
-$cal_templates->parse('output','calendar');
-$display .= $cal_templates->finish($cal_templates->get_var('output'));
+ $cal_templates->set_var('lang_cal_curmo', $LANG_MONTH[$currentmonth + 0]);
+ $cal_templates->set_var('cal_curmo_num', $currentmonth);
+ $cal_templates->set_var('cal_curyr_num', $currentyear);
+ $cal_templates->set_var('lang_cal_displaymo', $LANG_MONTH[$month + 0]);
+ $cal_templates->set_var('cal_displaymo_num', $month);
+ $cal_templates->set_var('cal_displayyr_num', $year);
+ if ($mode == 'personal') {
+ $cal_templates->set_var('lang_addevent', $LANG_CAL_2[8]);
+ $cal_templates->set_var('addevent_formurl', '/calendar/index.php');
+ } else {
+ $cal_templates->set_var('lang_addevent', $LANG_CAL_2[42]);
+ $cal_templates->set_var('addevent_formurl', '/submit.php?type=calendar');
+ }
+ $cal_templates->parse('add_event_option', 'addevent', true);
+ $cal_templates->parse('output', 'calendar');
+ $display .= $cal_templates->finish($cal_templates->get_var('output'));
-$display = COM_createHTMLDocument($display, array('pagetitle' => $pagetitle));
-break;
+ $display = COM_createHTMLDocument($display, array('pagetitle' => $pagetitle));
+ break;
} // end switch
COM_output($display);
-
-?>
diff --git a/public_html/comment.php b/public_html/comment.php
index d605f5477..8d5256938 100644
--- a/public_html/comment.php
+++ b/public_html/comment.php
@@ -45,14 +45,12 @@
*
*/
-/**
-* Geeklog common function library
-*/
+global $_CONF;
+
+// Geeklog common function library
require_once 'lib-common.php';
-/**
- * Geeklog comment function library
- */
+// Geeklog comment function library
require_once $_CONF['path_system'] . 'lib-comment.php';
// Uncomment the line below if you need to debug the HTTP variables being passed
@@ -75,5 +73,4 @@
}
$display .= CMT_handleComment($mode);
-
COM_output($display);
diff --git a/public_html/lib-common.php b/public_html/lib-common.php
index b1b9ca99a..be668a9ac 100755
--- a/public_html/lib-common.php
+++ b/public_html/lib-common.php
@@ -3780,7 +3780,7 @@ function COM_undoSpecialChars($string)
*
* @return string $sid Story ID
*/
-function COM_makesid()
+function COM_makeSid()
{
$sid = date('YmdHis');
$sid .= rand(0, 999);
diff --git a/public_html/links/index.php b/public_html/links/index.php
index 5b4682c2e..ff0434850 100644
--- a/public_html/links/index.php
+++ b/public_html/links/index.php
@@ -37,25 +37,26 @@
/**
* This is the links page
*
- * @package Links
+ * @package Links
* @subpackage public_html
* @filesource
- * @version 2.1
- * @since GL 1.4.0
- * @copyright Copyright © 2005-2010
- * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
- * @author Tony Bibbs, tony AT tonybibbs DOT com
- * @author Mark Limburg, mlimburg AT users DOT sourceforge DOT net
- * @author Jason Whittenburg, jwhitten AT securitygeeks DOT com
- * @author Tom Willett, tomw AT pigstye DOT net
- * @author Trinity Bays, trinity93 AT gmail DOT com
- * @author Dirk Haun, dirk AT haun-online DOT de
- *
+ * @version 2.1
+ * @since GL 1.4.0
+ * @copyright Copyright © 2005-2010
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+ * @author Tony Bibbs, tony AT tonybibbs DOT com
+ * @author Mark Limburg, mlimburg AT users DOT sourceforge DOT net
+ * @author Jason Whittenburg, jwhitten AT securitygeeks DOT com
+ * @author Tom Willett, tomw AT pigstye DOT net
+ * @author Trinity Bays, trinity93 AT gmail DOT com
+ * @author Dirk Haun, dirk AT haun-online DOT de
*/
+global $_CONF, $_PLUGINS, $_LI_CONF;
+
/**
-* Geeklog common function library
-*/
+ * Geeklog common function library
+ */
require_once '../lib-common.php';
if (!in_array('links', $_PLUGINS)) {
@@ -64,12 +65,11 @@
}
/**
-* Create the links list depending on the category given
-*
-* @param array $message message(s) to display
-* @return string the links page
-*
-*/
+ * Create the links list depending on the category given
+ *
+ * @param array $message message(s) to display
+ * @return string the links page
+ */
function links_list($message)
{
global $_CONF, $_TABLES, $_LI_CONF, $LANG_LINKS_ADMIN, $LANG_LINKS,
@@ -85,7 +85,7 @@ function links_list($message)
$cat = DB_escapeString($cid);
$page = 0;
if (isset ($_GET['page'])) {
- $page = COM_applyFilter ($_GET['page'], true);
+ $page = COM_applyFilter($_GET['page'], true);
}
if ($page == 0) {
$page = 1;
@@ -93,7 +93,7 @@ function links_list($message)
if (empty($cid)) {
if ($page > 1) {
- $page_title = sprintf ($LANG_LINKS[114] . ' (%d)', $page);
+ $page_title = sprintf($LANG_LINKS[114] . ' (%d)', $page);
} else {
$page_title = $LANG_LINKS[114];
}
@@ -102,13 +102,13 @@ function links_list($message)
$category = $LANG_LINKS['root'];
} else {
$category = DB_getItem($_TABLES['linkcategories'], 'category',
- "cid = '{$cat}'");
+ "cid = '{$cat}'");
}
if ($page > 1) {
- $page_title = sprintf ($LANG_LINKS[114] . ': %s (%d)', $category,
- $page);
+ $page_title = sprintf($LANG_LINKS[114] . ': %s (%d)', $category,
+ $page);
} else {
- $page_title = sprintf ($LANG_LINKS[114] . ': %s', $category);
+ $page_title = sprintf($LANG_LINKS[114] . ': %s', $category);
}
}
@@ -116,16 +116,16 @@ function links_list($message)
if ($cid != $_LI_CONF['root']) {
$result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['linkcategories']} WHERE cid='{$cat}'");
$A = DB_fetchArray($result);
- if (SEC_hasAccess ($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) < 2) {
- $display .= COM_showMessage (5, 'links');
+ if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) < 2) {
+ $display .= COM_showMessage(5, 'links');
$display = COM_createHTMLDocument($display, array('pagetitle' => $page_title));
COM_output($display);
exit;
}
// check existent
- if ( !isset($A['owner_id']) ) {
- $display .= COM_showMessage (16, 'links');
+ if (!isset($A['owner_id'])) {
+ $display .= COM_showMessage(16, 'links');
$display = COM_createHTMLDocument($display, array('pagetitle' => $page_title));
COM_output($display);
exit;
@@ -141,35 +141,37 @@ function links_list($message)
}
}
- $linklist = COM_newTemplate(CTL_plugin_templatePath('links'));
- $linklist->set_file (array ('linklist' => 'links.thtml',
- 'catlinks' => 'categorylinks.thtml',
- 'link' => 'linkdetails.thtml',
- 'catnav' => 'categorynavigation.thtml',
- 'catrow' => 'categoryrow.thtml',
- 'catcol' => 'categorycol.thtml',
- 'actcol' => 'categoryactivecol.thtml',
- 'pagenav' => 'pagenavigation.thtml',
- 'catdrop' => 'categorydropdown.thtml'));
- $linklist->set_var('blockheader', COM_startBlock($LANG_LINKS[114]));
+ $linkList = COM_newTemplate(CTL_plugin_templatePath('links'));
+ $linkList->set_file(array(
+ 'linklist' => 'links.thtml',
+ 'catlinks' => 'categorylinks.thtml',
+ 'link' => 'linkdetails.thtml',
+ 'catnav' => 'categorynavigation.thtml',
+ 'catrow' => 'categoryrow.thtml',
+ 'catcol' => 'categorycol.thtml',
+ 'actcol' => 'categoryactivecol.thtml',
+ 'pagenav' => 'pagenavigation.thtml',
+ 'catdrop' => 'categorydropdown.thtml',
+ ));
+ $linkList->set_var('blockheader', COM_startBlock($LANG_LINKS[114]));
if ($_LI_CONF['linkcols'] > 0) {
// Create breadcrumb trail
- $linklist->set_var('breadcrumbs',
- links_breadcrumbs($_LI_CONF['root'], $cid));
+ $linkList->set_var('breadcrumbs',
+ links_breadcrumbs($_LI_CONF['root'], $cid));
// Set dropdown for category jump
- $linklist->set_var('lang_go', $LANG_LINKS[124]);
- $linklist->set_var('link_dropdown', links_select_box(2, $cid));
+ $linkList->set_var('lang_go', $LANG_LINKS[124]);
+ $linkList->set_var('link_dropdown', links_select_box(2, $cid));
// Show categories
$sql = "SELECT cid,pid,category,description FROM {$_TABLES['linkcategories']} WHERE pid='{$cat}'";
$sql .= COM_getLangSQL('cid', 'AND');
$sql .= COM_getPermSQL('AND') . " ORDER BY category";
$result = DB_query($sql);
- $nrows = DB_numRows ($result);
+ $nrows = DB_numRows($result);
if ($nrows > 0) {
- $linklist->set_var ('lang_categories', $LANG_LINKS_ADMIN[14]);
+ $linkList->set_var('lang_categories', $LANG_LINKS_ADMIN[14]);
for ($i = 1; $i <= $nrows; $i++) {
$C = DB_fetchArray($result);
// Get number of child links user can see in this category
@@ -184,62 +186,62 @@ function links_list($message)
// Format numbers for display
$display_count = '';
// don't show zeroes
- if ($E['count']>0) {
- $display_count = COM_numberFormat ($E['count']);
+ if ($E['count'] > 0) {
+ $display_count = COM_numberFormat($E['count']);
}
- if (($E['count']>0) && ($D['count']>0)) {
+ if (($E['count'] > 0) && ($D['count'] > 0)) {
$display_count .= ', ';
}
- if ($D['count']>0) {
- $display_count .= COM_numberFormat ($D['count']);
+ if ($D['count'] > 0) {
+ $display_count .= COM_numberFormat($D['count']);
}
// add brackets if child items exist
- if ($display_count<>'') {
- $display_count = '('.$display_count.')';
+ if ($display_count <> '') {
+ $display_count = '(' . $display_count . ')';
}
- $linklist->set_var ('category_name', $C['category']);
+ $linkList->set_var('category_name', $C['category']);
if ($_LI_CONF['show_category_descriptions']) {
- $linklist->set_var ('category_description', PLG_replaceTags( $C['description'] ));
+ $linkList->set_var('category_description', PLG_replaceTags($C['description']));
} else {
- $linklist->set_var ('category_description', '');
+ $linkList->set_var('category_description', '');
}
- $linklist->set_var (
+ $linkList->set_var(
'category_link',
- COM_buildURL($_CONF['site_url'] . '/links/index.php?category=' . rawurlencode ($C['cid']))
+ COM_buildURL($_CONF['site_url'] . '/links/index.php?category=' . rawurlencode($C['cid']))
);
- $linklist->set_var ('category_count', $display_count);
- $linklist->set_var ('width', floor (100 / $_LI_CONF['linkcols']));
+ $linkList->set_var('category_count', $display_count);
+ $linkList->set_var('width', floor(100 / $_LI_CONF['linkcols']));
if (!empty($cid) && ($cid == $C['cid'])) {
- $linklist->parse ('category_col', 'actcol', true);
+ $linkList->parse('category_col', 'actcol', true);
} else {
- $linklist->parse ('category_col', 'catcol', true);
+ $linkList->parse('category_col', 'catcol', true);
}
if ($i % $_LI_CONF['linkcols'] == 0) {
- $linklist->parse ('category_row', 'catrow', true);
- $linklist->set_var ('category_col', '');
+ $linkList->parse('category_row', 'catrow', true);
+ $linkList->set_var('category_col', '');
}
}
if ($nrows % $_LI_CONF['linkcols'] != 0) {
- $linklist->parse ('category_row', 'catrow', true);
+ $linkList->parse('category_row', 'catrow', true);
}
- $linklist->parse ('category_navigation', 'catnav', true);
+ $linkList->parse('category_navigation', 'catnav', true);
} else {
- $linklist->set_var ('category_navigation', '');
+ $linkList->set_var('category_navigation', '');
}
} else {
- $linklist->set_var ('category_navigation', '');
+ $linkList->set_var('category_navigation', '');
}
if ($_LI_CONF['linkcols'] == 0) {
- $linklist->set_var('category_dropdown', '');
+ $linkList->set_var('category_dropdown', '');
} else {
- $linklist->parse('category_dropdown', 'catdrop', true);
+ $linkList->parse('category_dropdown', 'catdrop', true);
}
- $linklist->set_var('cid', $cid);
- $linklist->set_var('cid_plain', $cid);
- $linklist->set_var('cid_encoded', rawurlencode($cid));
- $linklist->set_var('lang_addalink', $LANG_LINKS[116]);
+ $linkList->set_var('cid', $cid);
+ $linkList->set_var('cid_plain', $cid);
+ $linkList->set_var('cid_encoded', rawurlencode($cid));
+ $linkList->set_var('lang_addalink', $LANG_LINKS[116]);
// Build SQL for links
$sql = 'SELECT lid,cid,url,description,title,hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon';
@@ -250,9 +252,9 @@ function links_list($message)
} else {
$from_where .= " WHERE cid=''";
}
- $from_where .= COM_getPermSQL ('AND');
+ $from_where .= COM_getPermSQL('AND');
} else {
- $from_where .= COM_getPermSQL ();
+ $from_where .= COM_getPermSQL();
}
$order = ' ORDER BY cid ASC,title';
$limit = '';
@@ -264,57 +266,57 @@ function links_list($message)
}
$limit = ' LIMIT ' . $start . ',' . $_LI_CONF['linksperpage'];
}
- $result = DB_query ($sql . $from_where . $order . $limit);
- $nrows = DB_numRows ($result);
+ $result = DB_query($sql . $from_where . $order . $limit);
+ $nrows = DB_numRows($result);
if ($nrows == 0) {
if (($cid == $_LI_CONF['root']) && ($page <= 1) && $_LI_CONF['show_top10']) {
$result = DB_query("SELECT lid,url,title,description,hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['links']} WHERE (hits > 0)" . COM_getPermSQL('AND') . LINKS_getCategorySQL('AND') . " ORDER BY hits DESC LIMIT 10");
- $nrows = DB_numRows ($result);
+ $nrows = DB_numRows($result);
if ($nrows > 0) {
- $linklist->set_var ('link_details', '');
- $linklist->set_var ('link_category',
- $LANG_LINKS_STATS['stats_headline']);
+ $linkList->set_var('link_details', '');
+ $linkList->set_var('link_category',
+ $LANG_LINKS_STATS['stats_headline']);
for ($i = 0; $i < $nrows; $i++) {
- $A = DB_fetchArray ($result);
- prepare_link_item ($A, $linklist);
- $linklist->parse ('link_details', 'link', true);
+ $A = DB_fetchArray($result);
+ prepare_link_item($A, $linkList);
+ $linkList->parse('link_details', 'link', true);
}
- $linklist->parse ('category_links', 'catlinks', true);
+ $linkList->parse('category_links', 'catlinks', true);
}
}
- $linklist->set_var ('page_navigation', '');
+ $linkList->set_var('page_navigation', '');
} else {
$currentcid = '';
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
- if (strcasecmp ($A['cid'], $currentcid) != 0) {
+ if (strcasecmp($A['cid'], $currentcid) != 0) {
// print the category and link
if ($i > 0) {
- $linklist->parse('category_links', 'catlinks', true);
- $linklist->set_var('link_details', '');
+ $linkList->parse('category_links', 'catlinks', true);
+ $linkList->set_var('link_details', '');
}
$currentcid = $A['cid'];
$currentcategory = DB_getItem($_TABLES['linkcategories'],
- 'category', "cid = '" . DB_escapeString($currentcid) . "'");
+ 'category', "cid = '" . DB_escapeString($currentcid) . "'");
if ($A['cid'] == $_LI_CONF['root']) {
- $linklist->set_var('link_category', $LANG_LINKS['root']);
+ $linkList->set_var('link_category', $LANG_LINKS['root']);
} else {
- $linklist->set_var('link_category', $currentcategory);
+ $linkList->set_var('link_category', $currentcategory);
}
}
- prepare_link_item($A, $linklist);
- $linklist->parse('link_details', 'link', true);
+ prepare_link_item($A, $linkList);
+ $linkList->parse('link_details', 'link', true);
}
- $linklist->parse('category_links', 'catlinks', true);
+ $linkList->parse('category_links', 'catlinks', true);
- $result = DB_query ('SELECT COUNT(*) AS count ' . $from_where);
- list($numlinks) = DB_fetchArray ($result);
+ $result = DB_query('SELECT COUNT(*) AS count ' . $from_where);
+ list($numlinks) = DB_fetchArray($result);
$pages = 0;
if ($_LI_CONF['linksperpage'] > 0) {
$pages = (int) ($numlinks / $_LI_CONF['linksperpage']);
- if (($numlinks % $_LI_CONF['linksperpage']) > 0 ) {
+ if (($numlinks % $_LI_CONF['linksperpage']) > 0) {
$pages++;
}
}
@@ -324,16 +326,16 @@ function links_list($message)
} else {
$catlink = '';
}
- $linklist->set_var('page_navigation',
- COM_printPageNavigation($_CONF['site_url']
- . '/links/index.php' . $catlink, $page, $pages));
+ $linkList->set_var('page_navigation',
+ COM_printPageNavigation($_CONF['site_url']
+ . '/links/index.php' . $catlink, $page, $pages));
} else {
- $linklist->set_var ('page_navigation', '');
+ $linkList->set_var('page_navigation', '');
}
}
- $linklist->set_var ('blockfooter',COM_endBlock());
- $linklist->parse ('output', 'linklist');
- $display .= $linklist->finish ($linklist->get_var ('output'));
+ $linkList->set_var('blockfooter', COM_endBlock());
+ $linkList->parse('output', 'linklist');
+ $display .= $linkList->finish($linkList->get_var('output'));
$display = COM_createHTMLDocument($display, array('pagetitle' => $page_title));
return $display;
@@ -341,19 +343,18 @@ function links_list($message)
/**
-* Prepare a link item for rendering
-*
-* @param array $A link details
-* @param ref $template reference of the links template
-*
-*/
+ * Prepare a link item for rendering
+ *
+ * @param array $A link details
+ * @param ref $template reference of the links template
+ */
function prepare_link_item($A, &$template)
{
global $_CONF, $_LI_CONF, $LANG_ADMIN, $LANG_LINKS, $LANG_DIRECTION,
$_IMAGE_TYPE;
$url = COM_buildUrl($_CONF['site_url']
- . '/links/portal.php?what=link&item=' . $A['lid']);
+ . '/links/portal.php?what=link&item=' . $A['lid']);
$actualUrl = stripslashes($A['url']);
$title = stripslashes($A['title']);
@@ -364,7 +365,7 @@ function prepare_link_item($A, &$template)
$template->set_var('link_name_encoded', rawurlencode($title));
$template->set_var('link_hits', COM_numberFormat($A['hits']));
$template->set_var('link_description',
- PLG_replaceTags( COM_nl2br(stripslashes($A['description'])) ));
+ PLG_replaceTags(COM_nl2br(stripslashes($A['description']))));
$attr = array('title' => $actualUrl);
if (substr($actualUrl, 0, strlen($_CONF['site_url'])) != $_CONF['site_url']) {
@@ -382,23 +383,24 @@ function prepare_link_item($A, &$template)
if (!COM_isAnonUser() && !SEC_hasRights('links.edit')) {
$reporturl = $_CONF['site_url']
- . '/links/index.php?mode=report&lid=' . $A['lid'];
+ . '/links/index.php?mode=report&lid=' . $A['lid'];
$template->set_var('link_broken',
- COM_createLink($LANG_LINKS[117], $reporturl,
- array('class' => 'pluginSmallText',
- 'rel' => 'nofollow'))
+ COM_createLink($LANG_LINKS[117], $reporturl,
+ array('class' => 'pluginSmallText',
+ 'rel' => 'nofollow'))
);
} else {
$template->set_var('link_broken', '');
}
if ((SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'],
- $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3) &&
- SEC_hasRights('links.edit')) {
+ $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3) &&
+ SEC_hasRights('links.edit')
+ ) {
$editurl = $_CONF['site_admin_url']
- . '/plugins/links/index.php?mode=edit&lid=' . $A['lid'];
+ . '/plugins/links/index.php?mode=edit&lid=' . $A['lid'];
$template->set_var('link_edit',
- COM_createLink($LANG_ADMIN['edit'], $editurl));
+ COM_createLink($LANG_ADMIN['edit'], $editurl));
$edit_icon = " ";
$template->set_var('edit_icon', COM_createLink($edit_icon, $editurl));
@@ -410,7 +412,6 @@ function prepare_link_item($A, &$template)
// MAIN
-
$display = '';
$mode = '';
$root = $_LI_CONF['root'];
@@ -419,7 +420,7 @@ function prepare_link_item($A, &$template)
}
$message = array();
-if (($mode == 'report') && !COM_isAnonUser()) {
+if (($mode === 'report') && !COM_isAnonUser()) {
if (isset ($_GET['lid'])) {
$lid = COM_applyFilter($_GET['lid']);
}
@@ -429,18 +430,19 @@ function prepare_link_item($A, &$template)
list($url, $title) = DB_fetchArray($result);
$editurl = $_CONF['site_admin_url']
- . '/plugins/links/index.php?mode=edit&lid=' . $lid;
- $msg = $LANG_LINKS[119] . LB . LB . "$title, <$url>". LB . LB
- . $LANG_LINKS[120] . LB . '<' . $editurl . '>' . LB . LB
- . $LANG_LINKS[121] . $_USER['username'] . ', IP: '
- . $_SERVER['REMOTE_ADDR'];
+ . '/plugins/links/index.php?mode=edit&lid=' . $lid;
+ $msg = $LANG_LINKS[119] . LB . LB . "$title, <$url>" . LB . LB
+ . $LANG_LINKS[120] . LB . '<' . $editurl . '>' . LB . LB
+ . $LANG_LINKS[121] . $_USER['username'] . ', IP: '
+ . $_SERVER['REMOTE_ADDR'];
COM_mail($_CONF['site_mail'], $LANG_LINKS[118], $msg);
$message = array($LANG_LINKS[123], $LANG_LINKS[122]);
}
}
if (COM_isAnonUser() &&
- (($_CONF['loginrequired'] == 1) || ($_LI_CONF['linksloginrequired'] == 1))) {
+ (($_CONF['loginrequired'] == 1) || ($_LI_CONF['linksloginrequired'] == 1))
+) {
$display .= SEC_loginRequiredForm();
$display = COM_createHTMLDocument($display, array('pagetitle' => $LANG_LINKS[114]));
} else {
@@ -448,5 +450,3 @@ function prepare_link_item($A, &$template)
}
COM_output($display);
-
-?>
diff --git a/public_html/links/portal.php b/public_html/links/portal.php
index 94cf9e2db..cb275d6bb 100644
--- a/public_html/links/portal.php
+++ b/public_html/links/portal.php
@@ -50,9 +50,9 @@
*
*/
-/**
-* Geeklog common function library
-*/
+global $_CONF, $_PLUGINS, $_TABLES;
+
+// Geeklog common function library
require_once '../lib-common.php';
if (!in_array('links', $_PLUGINS)) {
@@ -60,16 +60,13 @@
exit;
}
-
// MAIN
-
$url = '';
COM_setArgNames(array('what', 'item'));
$what = COM_getArgument('what');
-if ($what == 'link') {
-
+if ($what === 'link') {
$item = COM_applyFilter(COM_getArgument('item'));
if (!empty($item)) {
// Hack: due to PLG_afterSaveSwitch settings, we may get
@@ -90,8 +87,7 @@
if (empty($url)) {
$url = $_CONF['site_url'];
}
+
header('HTTP/1.1 301 Moved');
header('Location: ' . $url);
header('Connection: close');
-
-?>
diff --git a/public_html/search.php b/public_html/search.php
index fc6fd90d3..6743c5ecf 100644
--- a/public_html/search.php
+++ b/public_html/search.php
@@ -31,8 +31,7 @@
// | |
// +---------------------------------------------------------------------------+
-require_once 'lib-common.php';
-require_once $_CONF['path_system'] . 'classes/search.class.php';
+require_once __DIR__ . '/lib-common.php';
$searchObj = new Search();
diff --git a/public_html/submit.php b/public_html/submit.php
index 42a23c3b3..469c6d3c8 100644
--- a/public_html/submit.php
+++ b/public_html/submit.php
@@ -285,7 +285,7 @@ function savestory ($A)
$story->loadSubmission();
// pseudo-formatted story text for the spam check
- $result = PLG_checkforSpam($story->GetSpamCheckFormat(), $_CONF['spamx']);
+ $result = PLG_checkforSpam($story->getSpamCheckFormat(), $_CONF['spamx']);
if ($result > 0) {
COM_updateSpeedlimit('submit');
COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden');
diff --git a/system/classes/gltext.class.php b/system/classes/gltext.class.php
index 33d24cb54..a2406ed44 100644
--- a/system/classes/gltext.class.php
+++ b/system/classes/gltext.class.php
@@ -33,7 +33,7 @@
* Constants for GLText
* Version of GLText engine
*/
-define('GLTEXT_FIRST_VERSION', 1);
+define('GLTEXT_FIRST_VERSION', 1);
define('GLTEXT_LATEST_VERSION', 2);
class GLText
@@ -41,46 +41,37 @@ class GLText
/**
* Returns text ready for the edit fields.
*
- * @param string $text Text to prepare for editing
- * @param string $postmode Indicates if text is html, wikitext or plaintext
- * @param int $version version of GLText engine
+ * @param string $text Text to prepare for editing
+ * @param string $postMode Indicates if text is html, wikitext or plaintext
+ * @param int $version version of GLText engine
* @return string Escaped String
* @access public
- *
*/
- public static function getEditText($text, $postmode, $version)
+ public static function getEditText($text, $postMode, $version)
{
if ($version == GLTEXT_FIRST_VERSION) {
-
// first version
// Remove any autotags the user doesn't have permission to use
$text = PLG_replaceTags($text, '', true);
- if ($postmode == 'plaintext') {
-
+ if ($postMode === 'plaintext') {
$text = COM_undoClickableLinks($text);
-
- } elseif ($postmode == 'wikitext') {
-
- $text = self::_editUnescape($text, $postmode);
-
+ } elseif ($postMode === 'wikitext') {
+ $text = self::_editUnescape($text, $postMode);
} else {
// html
- $text = str_replace('', '[code]', $text);
+ $text = str_replace('', '[code]', $text);
$text = str_replace('
', '[/code]', $text);
- $text = str_replace('', '[raw]', $text);
- $text = str_replace(' ', '[/raw]', $text);
- $text = self::_editUnescape($text, $postmode);
+ $text = str_replace('', '[raw]', $text);
+ $text = str_replace(' ', '[/raw]', $text);
+ $text = self::_editUnescape($text, $postMode);
$text = htmlspecialchars($text, ENT_QUOTES, COM_getEncodingt());
}
$text = self::_displayEscape($text);
-
} else {
-
// latest version
-
$text = htmlspecialchars($text, ENT_QUOTES, COM_getEncodingt());
}
@@ -90,56 +81,53 @@ public static function getEditText($text, $postmode, $version)
/**
* Returns text ready for display.
*
- * @param string $text Text to prepare for display
- * @param string $postmode Indicates if text is html, adveditor, wikitext or plaintext
- * @param int $version version of GLText engine
+ * @param string $text Text to prepare for display
+ * @param string $postMode Indicates if text is html, adveditor, wikitext or plaintext
+ * @param int $version version of GLText engine
* @return string Escaped String
* @access public
- *
*/
- public static function getDisplayText($text, $postmode, $version)
+ public static function getDisplayText($text, $postMode, $version)
{
if ($version == GLTEXT_FIRST_VERSION) {
-
// first version
-
- if ($postmode == 'plaintext') {
+ if ($postMode === 'plaintext') {
$text = COM_nl2br($text);
}
- if ($postmode == 'wikitext') {
- $text = self::_editUnescape($text, $postmode);
+ if ($postMode === 'wikitext') {
+ $text = self::_editUnescape($text, $postMode);
$text = self::renderWikiText($text);
}
-
} else {
-
// latest version
-
- if ($postmode == 'html' || $postmode == 'adveditor') {
-
+ if ($postMode === 'html' || $postMode === 'adveditor') {
// Get rid of any newline characters
$text = str_replace("\n", '', $text);
- $text = self::_handleSpecialTag_callback($text,
+ $text = self::_handleSpecialTag_callback(
+ $text,
array('[code]', '[/code]', '', '
'),
- '_escapeSPChars');
+ '_escapeSPChars'
+ );
- $text = self::_handleSpecialTag_callback($text,
+ $text = self::_handleSpecialTag_callback(
+ $text,
array('[raw]', '[/raw]', '', ' '),
- '_escapeSPChars');
+ '_escapeSPChars'
+ );
}
- if ($postmode == 'plaintext') {
+ if ($postMode === 'plaintext') {
$text = htmlspecialchars($text, ENT_QUOTES, COM_getEncodingt());
$text = COM_makeClickableLinks($text);
$text = COM_nl2br($text);
}
- if ($postmode == 'wikitext') {
- $text = self::_editUnescape($text, $postmode);
+ if ($postMode === 'wikitext') {
+ $text = self::_editUnescape($text, $postMode);
$text = self::renderWikiText($text);
-// $text = self::_htmLawed($text, 'story.edit');
+ // $text = self::_htmLawed($text, 'story.edit');
}
$text = COM_checkWords($text, 'story');
@@ -153,39 +141,46 @@ public static function getDisplayText($text, $postmode, $version)
/**
* Apply HTML filter to the text
*
- * @param string $text Text to prepare for store to databese
- * @param string $postmode Indicates if text is html, adveditor, wikitext or plaintext
- * @param string $permissions comma-separated list of rights which identify the current user as an "Admin"
- * @param int $version version of GLText engine
+ * @param string $text Text to prepare for store to databese
+ * @param string $postMode Indicates if text is html, adveditor, wikitext or plaintext
+ * @param string $permissions comma-separated list of rights which identify the current user as an "Admin"
+ * @param int $version version of GLText engine
* @return string Escaped String
* @access public
- *
*/
- public static function applyHTMLFilter($text, $postmode, $permissions, $version)
+ public static function applyHTMLFilter($text, $postMode, $permissions, $version)
{
global $_CONF;
if (($version != GLTEXT_FIRST_VERSION) &&
- ($postmode == 'html' || $postmode == 'adveditor')) {
-
+ ($postMode === 'html' || $postMode === 'adveditor')
+ ) {
if (!SEC_hasRights('htmlfilter.skip') &&
- (($_CONF['skip_html_filter_for_root'] != 1) || !SEC_inGroup('Root'))) {
-
- $text = self::_handleSpecialTag_callback($text,
+ (($_CONF['skip_html_filter_for_root'] != 1) || !SEC_inGroup('Root'))
+ ) {
+ $text = self::_handleSpecialTag_callback(
+ $text,
array('[code]', '[/code]', '[code2]', '[/code2]'),
- '_maskCode');
- $text = self::_handleSpecialTag_callback($text,
+ '_maskCode'
+ );
+ $text = self::_handleSpecialTag_callback(
+ $text,
array('[raw]', '[/raw]', '[raw2]', '[/raw2]'),
- '_maskCode');
+ '_maskCode'
+ );
$text = self::_htmLawed($text, $permissions);
- $text = self::_handleSpecialTag_callback($text,
+ $text = self::_handleSpecialTag_callback(
+ $text,
array('[code2]', '[/code2]', '[code]', '[/code]'),
- '_unmaskCode');
- $text = self::_handleSpecialTag_callback($text,
+ '_unmaskCode'
+ );
+ $text = self::_handleSpecialTag_callback(
+ $text,
array('[raw2]', '[/raw2]', '[raw]', '[/raw]'),
- '_unmaskCode');
+ '_unmaskCode'
+ );
}
}
@@ -195,49 +190,50 @@ public static function applyHTMLFilter($text, $postmode, $permissions, $version)
/**
* Returns text ready for preview.
*
- * @param string $text Text to prepare for store to databese
- * @param string $postmode Indicates if text is html, adveditor, wikitext or plaintext
- * @param string $permissions comma-separated list of rights which identify the current user as an "Admin"
- * @param int $version version of GLText engine
+ * @param string $text Text to prepare for store to databese
+ * @param string $postMode Indicates if text is html, adveditor, wikitext or plaintext
+ * @param string $permissions comma-separated list of rights which identify the current user as an "Admin"
+ * @param int $version version of GLText engine
* @return string Escaped String
* @access public
- *
*/
- public static function getPreviewText($text, $postmode, $permissions, $version)
+ public static function getPreviewText($text, $postMode, $permissions, $version)
{
- $text = self::applyHTMLFilter($text, $postmode, $permissions, $version);
- $text = self::getDisplayText($text, $postmode, $version);
+ $text = self::applyHTMLFilter($text, $postMode, $permissions, $version);
+ $text = self::getDisplayText($text, $postMode, $version);
return $text;
}
/**
* This function checks html tags.
- *
* Checks to see that the HTML tags are on the approved list and
* removes them if not.
*
- * @param string $str HTML to check
- * @param string $permissions comma-separated list of rights which identify the current user as an "Admin"
+ * @param string $str HTML to check
+ * @param string $permissions comma-separated list of rights which identify the current user as an "Admin"
* @return string Filtered HTML
* @access public
- *
*/
public static function checkHTML($str, $permissions = 'story.edit')
{
global $_CONF, $_USER;
-// $str = COM_stripslashes($str); // it should not be here
+ // $str = COM_stripslashes($str); // it should not be here
// Get rid of any newline characters
$str = str_replace("\n", '', $str);
- $str = self::_handleSpecialTag_callback($str,
+ $str = self::_handleSpecialTag_callback(
+ $str,
array('[code]', '[/code]', '', '
'),
- '_escapeSPChars');
- $str = self::_handleSpecialTag_callback($str,
+ '_escapeSPChars'
+ );
+ $str = self::_handleSpecialTag_callback(
+ $str,
array('[raw]', '[/raw]', '[raw2]', '[/raw2]'),
- '_escapeSPChars');
+ '_escapeSPChars'
+ );
// To begin with, why handle '$' and '\' as the special character?
//
@@ -248,7 +244,8 @@ public static function checkHTML($str, $permissions = 'story.edit')
// $str = str_replace( '$', '$', $str);
if (!SEC_hasRights('htmlfilter.skip') &&
- (($_CONF['skip_html_filter_for_root'] != 1) || !SEC_inGroup('Root'))) {
+ (($_CONF['skip_html_filter_for_root'] != 1) || !SEC_inGroup('Root'))
+ ) {
$str = self::_htmLawed($str, $permissions);
}
@@ -261,18 +258,17 @@ public static function checkHTML($str, $permissions = 'story.edit')
}
/**
- * Convert wiki-formatted text to (X)HTML
- *
- * @param string $wikitext wiki-formatted text
- * @return string XHTML formatted text
- *
- */
- public static function renderWikiText($wikitext)
+ * Convert wiki-formatted text to (X)HTML
+ *
+ * @param string $wikiText wiki-formatted text
+ * @return string XHTML formatted text
+ */
+ public static function renderWikiText($wikiText)
{
global $_CONF;
if (!$_CONF['wikitext_editor']) {
- return $wikitext;
+ return $wikiText;
}
$wiki = new Geeklog\Text\Wiki();
@@ -282,11 +278,9 @@ public static function renderWikiText($wikitext)
$wiki->disableRule('freelink');
$wiki->disableRule('interwiki');
- return $wiki->transform($wikitext, 'Xhtml');
+ return $wiki->transform($wikiText, 'Xhtml');
}
- // Private Methods:
-
private static function _htmLawed($str, $permissions)
{
global $_CONF, $_USER;
@@ -297,7 +291,7 @@ private static function _htmLawed($str, $permissions)
'balance' => 1, // Balance tags for well-formedness and proper nesting
'comment' => 3, // Allow HTML comment
'css_expression' => 1, // Allow dynamic CSS expression in "style" attributes
-// 'keep_bad' => 1, // Neutralize both tags and element content
+ // 'keep_bad' => 1, // Neutralize both tags and element content
'keep_bad' => 0, // Neutralize both tags and element content
'tidy' => 0, // Don't beautify or compact HTML code
'unique_ids' => 1, // Remove duplicate and/or invalid ids
@@ -305,8 +299,9 @@ private static function _htmLawed($str, $permissions)
);
if (isset($_CONF['allowed_protocols']) &&
- is_array($_CONF['allowed_protocols']) &&
- (count($_CONF['allowed_protocols']) > 0)) {
+ is_array($_CONF['allowed_protocols']) &&
+ (count($_CONF['allowed_protocols']) > 0)
+ ) {
$schemes = $_CONF['allowed_protocols'];
} else {
$schemes = array('http:', 'https:', 'ftp:');
@@ -316,19 +311,23 @@ private static function _htmLawed($str, $permissions)
$config['schemes'] = 'href: ' . $schemes . '; *: ' . $schemes;
if (empty($permissions) || !SEC_hasRights($permissions) ||
- empty($_CONF['admin_html'])) {
+ empty($_CONF['admin_html'])
+ ) {
$html = $_CONF['user_html'];
} else {
if ($_CONF['advanced_editor'] && $_USER['advanced_editor']) {
$html = array_merge_recursive($_CONF['user_html'],
- $_CONF['admin_html'],
- $_CONF['advanced_html']);
+ $_CONF['admin_html'],
+ $_CONF['advanced_html']);
} else {
$html = array_merge_recursive($_CONF['user_html'],
- $_CONF['admin_html']);
+ $_CONF['admin_html']);
}
}
+ $spec = array();
+ $elements = array();
+
foreach ($html as $tag => $attr) {
if (is_array($attr) && (count($attr) > 0)) {
$spec[] = $tag . '=' . implode(', ', array_keys($attr));
@@ -349,30 +348,30 @@ private static function _htmLawed($str, $permissions)
/**
* Escapes certain HTML for nicely encoded HTML.
*
- * @param string $text Text to escpae
+ * @param string $text Text to escape
* @return string Escaped string
* @access private
- *
*/
private static function _displayEscape($text)
{
return str_replace(
- array('$', '{', '}', '\\'),
- array('$', '{', '}', '\'), $text);
+ array('$', '{', '}', '\\'),
+ array('$', '{', '}', '\'),
+ $text
+ );
}
/**
- * Unescapes certain HTML for editing again.
+ * Unescape certain HTML for editing again.
*
- * @param string $in Text escaped to unescape for editing
- * @param string $postmode Indicates if text is html, wikitext or plaintext
+ * @param string $in Text escaped to unescape for editing
+ * @param string $postMode Indicates if text is html, wikitext or plaintext
* @return string Unescaped string
* @access private
- *
*/
- private static function _editUnescape($in, $postmode)
+ private static function _editUnescape($in, $postMode)
{
- if (!in_array($postmode, array('html', 'wikitext'))) {
+ if (!in_array($postMode, array('html', 'wikitext'))) {
// advanced editor or plaintext can handle themselves...
return $in;
}
@@ -391,7 +390,7 @@ private static function _editUnescape($in, $postmode)
// in rewrite phase 1.
//
// First, raw
- $in = self::_unescapeSpecialTag($in, array('[raw]', '[/raw]'));
+ $in = self::_unescapeSpecialTag($in, array('[raw]', '[/raw]'));
// Then, code
$in = self::_unescapeSpecialTag($in, array('[code]', '[/code]'));
@@ -399,17 +398,16 @@ private static function _editUnescape($in, $postmode)
}
/**
- * Callback funtion for escapes all special characters within a
+ * Callback function for escapes all special characters within a
* [code] ... [/code] section.
*
- * @param string $str the code section to encode
+ * @param string $str the code section to encode
* @return string String with the special characters encoded
* @access private
- *
*/
private static function _escapeSPChars($str)
{
- $search = array('&', '<', '>', '[', ']' );
+ $search = array('&', '<', '>', '[', ']');
$replace = array('&', '<', '>', '[', ']');
$str = str_replace($search, $replace, $str);
@@ -417,12 +415,11 @@ private static function _escapeSPChars($str)
}
/**
- * Callback funtion for mask text within a [code] ... [/code] section.
+ * Callback function for mask text within a [code] ... [/code] section.
*
- * @param string $str the code section to mask
+ * @param string $str the code section to mask
* @return string String with characters encoded
* @access private
- *
*/
private static function _maskCode($str)
{
@@ -430,12 +427,11 @@ private static function _maskCode($str)
}
/**
- * Callback funtion for unmask text within a [code] ... [/code] section.
+ * Callback function for unmask text within a [code] ... [/code] section.
*
- * @param string $str the code section to unmask
+ * @param string $str the code section to unmask
* @return string String with characters decoded
* @access private
- *
*/
private static function _unmaskCode($str)
{
@@ -469,10 +465,8 @@ private static function _handleSpecialTag_callback($str, $tags, $args)
$encoded = $tags[2] . $encoded . $tags[3];
$str = MBYTE_substr($str, 0, $start_pos) . $encoded
- . MBYTE_substr($str, $end_pos + $len_end);
-
+ . MBYTE_substr($str, $end_pos + $len_end);
} else { // missing [/code] or [/raw]
-
$part = MBYTE_substr($str, $start_pos + $len_start);
if (is_array($args)) {
$encoded = self::$function($part, $args);
@@ -491,34 +485,41 @@ private static function _handleSpecialTag_callback($str, $tags, $args)
private static function _unescapeSpecialTag($in, $tags)
{
- $inlower = MBYTE_strtolower($in);
- $start_pos = MBYTE_strpos($inlower, $tags[0]);
- if ($start_pos === false) return $in;
+ $inLower = MBYTE_strtolower($in);
+ $start_pos = MBYTE_strpos($inLower, $tags[0]);
+
+ if ($start_pos === false) {
+ return $in;
+ }
+
$buffer = $in;
$out = '';
+
while ($start_pos !== false) {
// Copy in to start to out
$out .= MBYTE_substr($buffer, 0, $start_pos);
// Find end
- $end_pos = MBYTE_strpos($inlower, $tags[1]);
+ $end_pos = MBYTE_strpos($inLower, $tags[1]);
if ($end_pos !== false) {
// Encode body and append to out
$encoded = html_entity_decode(
- MBYTE_substr($buffer, $start_pos, $end_pos - $start_pos));
+ MBYTE_substr($buffer, $start_pos, $end_pos - $start_pos)
+ );
$out .= $encoded . $tags[1];
$len_end = strlen($tags[1]);
// Nibble in
- $inlower = MBYTE_substr($inlower, $end_pos + $len_end);
- $buffer = MBYTE_substr($buffer, $end_pos + $len_end);
+ $inLower = MBYTE_substr($inLower, $end_pos + $len_end);
+ $buffer = MBYTE_substr($buffer, $end_pos + $len_end);
} else { // missing end
$len_start = strlen($tags[0]);
// Treat the remainder as code, but this should have been
// checked prior to calling:
$out .= html_entity_decode(
- MBYTE_substr($buffer, $start_pos + $len_start));
- $inlower = '';
+ MBYTE_substr($buffer, $start_pos + $len_start)
+ );
+ $inLower = '';
}
- $start_pos = MBYTE_strpos($inlower, $tags[0]);
+ $start_pos = MBYTE_strpos($inLower, $tags[0]);
}
// Append remainder:
if ($buffer != '') {
@@ -527,4 +528,35 @@ private static function _unescapeSpecialTag($in, $tags)
return $out;
}
+
+ /**
+ * Remove 4-6 byte UTF-8 characters, including emoji icons
+ *
+ * @param string $text
+ * @param string $replace
+ * @return string
+ */
+ public static function removeUtf8Icons($text, $replace = '')
+ {
+ global $_CONF, $_DB_dbms;
+ static $isRemove = null;
+
+ if ($isRemove === null) {
+ if ($_DB_dbms === 'mysql') {
+ if (strcasecmp($_CONF['default_charset'], 'utf-8') === 0) {
+ $isRemove = version_compare(DB_getVersion(), '5.5.3', '<');
+ } else {
+ $isRemove = true;
+ }
+ } else {
+ $isRemove = false;
+ }
+ }
+
+ if ($isRemove) {
+ $text = preg_replace('/[\xf0-\xfd][\x80-\xbf]{2}[\x80-\xbf]{1,3}/', $replace, $text);
+ }
+
+ return $text;
+ }
}
diff --git a/system/classes/search.class.php b/system/classes/search.class.php
index 2f7c20942..57c2ca498 100644
--- a/system/classes/search.class.php
+++ b/system/classes/search.class.php
@@ -35,10 +35,6 @@
die('This file can not be used on its own.');
}
-require_once $_CONF['path_system'] . 'classes/plugin.class.php';
-require_once $_CONF['path_system'] . 'classes/searchcriteria.class.php';
-require_once $_CONF['path_system'] . 'classes/listfactory.class.php';
-
/**
* Geeklog Search Class
*
@@ -75,7 +71,9 @@ public function __construct()
// Set search criteria
if (isset($_GET['query'])) {
- $this->_query = strip_tags(COM_stripslashes($_GET['query']));
+ $query = COM_stripslashes($_GET['query']);
+ $query = GLText::removeUtf8Icons($query);
+ $this->_query = strip_tags($query);
}
if (isset($_GET['topic'])) {
@@ -318,7 +316,7 @@ public function showForm()
/**
* Performs search on all stories
*
- * @return object plugin object
+ * @return array of object plugin object
*/
private function _searchStories()
{
@@ -390,7 +388,7 @@ private function _searchStories()
$sql .= $search_c->getDateRangeSQL('AND', 'c.date', $this->_dateStart, $this->_dateEnd);
list($sql, $ftsql) = $search_c->buildSearchSQL($this->_keyType, $query, $columns, $sql);
- $sql .= " GROUP BY id";
+ $sql .= " GROUP BY c.cid, c.title, c.comment, c.date, c.uid ";
$search_c->setSQL($sql);
$search_c->setFTSQL($ftsql);
@@ -486,9 +484,9 @@ public function doSearch()
$obj->setRowFunction(array($this, 'searchFormatCallback'));
// Start search timer
- $searchtimer = new timerobject();
- $searchtimer->setPrecision(4);
- $searchtimer->startTimer();
+ $searchTimer = new timerobject();
+ $searchTimer->setPrecision(4);
+ $searchTimer->startTimer();
// Have plugins do their searches
$page = isset($_GET['page']) ? COM_applyFilter($_GET['page'], true) : 1;
@@ -607,7 +605,7 @@ public function doSearch()
$results = $obj->ExecuteQueries();
// Searches are done, stop timer
- $searchtime = $searchtimer->stopTimer();
+ $searchtime = $searchTimer->stopTimer();
$escquery = htmlspecialchars($this->_query);
$escquery = str_replace(array('{', '}'), array('{', '}'), $escquery);
diff --git a/system/classes/story.class.php b/system/classes/story.class.php
index 7728169b6..63c96a2b1 100644
--- a/system/classes/story.class.php
+++ b/system/classes/story.class.php
@@ -46,8 +46,6 @@
* @author Michael Jervis, mike AT fuckingbrit DOT com
*/
-require_once 'gltext.class.php';
-
/**
* Constants for stories:
* Loading from database:
@@ -327,8 +325,6 @@ class Story
// End Variables.
/**************************************************************************/
- /**************************************************************************/
- // Public Methods:
/**
* Constructor, creates a story, taking a (geeklog) database object.
*
@@ -343,9 +339,9 @@ public function __construct($mode = 'admin')
* Check to see if there is any content in the story, for
* bothering to preview testing really.
*
- * @return boolean trim(title+intro+body) != ''
+ * @return bool trim(title+intro+body) != ''
*/
- function hasContent()
+ public function hasContent()
{
if (trim($this->_title) != '') {
return true;
@@ -367,20 +363,20 @@ function hasContent()
*
* @param $story array Story array from db
*/
- function loadFromArray($story)
+ public function loadFromArray($story)
{
/* Use the magic cheat array to quickly reload the whole story
* from the database result array, doing the quick stripslashes.
*/
reset($this->_dbFields);
- while (list($fieldname, $save) = each($this->_dbFields)) {
- $varname = '_' . $fieldname;
+ while (list($fieldName, $save) = each($this->_dbFields)) {
+ $varName = '_' . $fieldName;
- if (array_key_exists($fieldname, $story)) {
+ if (array_key_exists($fieldName, $story)) {
// This is meaningless, and have a negative effect. (bug #0001655)
// $this->{$varname} = stripslashes($story[$fieldname]);
- $this->{$varname} = $story[$fieldname];
+ $this->{$varName} = $story[$fieldName];
}
}
@@ -421,17 +417,18 @@ function loadFromArray($story)
* the exciting gubbins here.
* Only used from story admin and submit.php!
*
- * @param $sid string Story Identifier, valid geeklog story id from the db.
- * @return Integer from a constant.
+ * @param string $sid Story Identifier, valid geeklog story id from the db.
+ * @param string $mode 'edit'|'view'|'clone'|'editsubmission'
+ * @return int from a constant.
*/
- function loadFromDatabase($sid, $mode = 'edit')
+ public function loadFromDatabase($sid, $mode = 'edit')
{
global $_TABLES, $_CONF, $_USER, $topic;
$sid = DB_escapeString(COM_applyFilter($sid));
$sql = array();
- if (!empty($sid) && (($mode == 'edit') || ($mode == 'view') || ($mode == 'clone'))) {
+ if (!empty($sid) && (($mode === 'edit') || ($mode === 'view') || ($mode === 'clone'))) {
if (empty($topic)) {
$topic_sql = ' AND ta.tdefault = 1';
} else {
@@ -449,7 +446,7 @@ function loadFromDatabase($sid, $mode = 'edit')
$sql['pgsql'] = "SELECT s.*, UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) as expireunix, UNIX_TIMESTAMP(s.comment_expire) as cmt_expire_unix, u.username, u.fullname, u.photo, u.email, t.tid, t.topic, t.imageurl
FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t, {$_TABLES['topic_assignments']} AS ta
WHERE ta.type = 'article' AND ta.id = sid AND ta.tdefault = 1 AND (s.uid = u.uid) AND (ta.tid = t.tid) AND (sid = '$sid')";
- } elseif (!empty($sid) && ($mode == 'editsubmission')) {
+ } elseif (!empty($sid) && ($mode === 'editsubmission')) {
/* Original
$sql['mysql'] = 'SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, '
. 'u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl, t.group_id, ' . 't.perm_owner, t.perm_group, t.perm_members, t.perm_anon ' . 'FROM ' . $_TABLES['storysubmission'] . ' AS s, ' . $_TABLES['users'] . ' AS u, ' . $_TABLES['topics'] . ' AS t WHERE (s.uid = u.uid) AND' . ' (s.tid = t.tid) AND (sid = \'' . $sid . '\')';
@@ -465,7 +462,7 @@ function loadFromDatabase($sid, $mode = 'edit')
FROM {$_TABLES['storysubmission']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t, {$_TABLES['topic_assignments']} AS ta
WHERE (s.uid = u.uid) AND (ta.tid = t.tid) AND (sid = '$sid')
AND ta.type = 'article' AND ta.id = sid AND ta.tdefault = 1";
- } elseif ($mode == 'edit') {
+ } elseif ($mode === 'edit') {
$this->_sid = COM_makesid();
$this->_old_sid = $this->_sid;
@@ -492,8 +489,7 @@ function loadFromDatabase($sid, $mode = 'edit')
} else {
$this->_uid = $_USER['uid'];
}
- $this->_date = time();
- $this->_expire = time();
+ $this->_date = $this->_expire = time();
if ($_CONF['article_comment_close_enabled']) {
$this->_comment_expire = time() +
($_CONF['article_comment_close_days'] * 86400);
@@ -557,7 +553,7 @@ function loadFromDatabase($sid, $mode = 'edit')
$this->loadFromArgsArray($_POST);
}
- /* if we have SQL, load from it */
+ // if we have SQL, load from it
if (!empty($sql)) {
$result = DB_query($sql);
@@ -573,23 +569,25 @@ function loadFromDatabase($sid, $mode = 'edit')
* the DB. If the user doing the cloning is different from the
* original author, we need to fix those here.
*/
- if (($mode == 'clone') && ($this->_uid != $_USER['uid'])) {
+ if (($mode === 'clone') && ($this->_uid != $_USER['uid'])) {
$this->_uid = $_USER['uid'];
$story['owner_id'] = $this->_uid;
- $uresult = DB_query("SELECT username, fullname, photo, email FROM {$_TABLES['users']} WHERE uid = {$_USER['uid']}");
- list($this->_username, $this->_fullname, $this->_photo, $this->_email) = DB_fetchArray($uresult);
+ $uResult = DB_query("SELECT username, fullname, photo, email FROM {$_TABLES['users']} WHERE uid = {$_USER['uid']}");
+ list($this->_username, $this->_fullname, $this->_photo, $this->_email) = DB_fetchArray($uResult);
}
if (!isset($story['owner_id'])) {
$story['owner_id'] = 1;
}
- $access = SEC_hasAccess($story['owner_id'], $story['group_id'],
+ $access = SEC_hasAccess(
+ $story['owner_id'], $story['group_id'],
$story['perm_owner'], $story['perm_group'],
- $story['perm_members'], $story['perm_anon']);
+ $story['perm_members'], $story['perm_anon']
+ );
//$this->_access = min($access, SEC_hasTopicAccess($this->_tid));
//$this->_access = min($access, TOPIC_hasMultiTopicAccess('article', $sid));
- if ($mode != 'view') {
+ if ($mode !== 'view') {
// When editing an article they need access to all topics article is assigned to plus edit access to article itself
$this->_access = min($access, TOPIC_hasMultiTopicAccess('article', $sid));
} else {
@@ -599,7 +597,7 @@ function loadFromDatabase($sid, $mode = 'edit')
if ($this->_access == 0) {
return STORY_PERMISSION_DENIED;
- } elseif ($this->_access == 2 && $mode != 'view') {
+ } elseif ($this->_access == 2 && $mode !== 'view') {
return STORY_EDIT_DENIED;
} elseif ((($this->_access == 2) && ($mode == 'view')) && (($this->_draft_flag == 1) || ($this->_date > time()))) {
return STORY_INVALID_SID;
@@ -609,7 +607,7 @@ function loadFromDatabase($sid, $mode = 'edit')
}
}
- if ($mode == 'editsubmission') {
+ if ($mode === 'editsubmission') {
if (isset($_CONF['draft_flag'])) {
$this->_draft_flag = $_CONF['draft_flag'];
} else {
@@ -646,11 +644,9 @@ function loadFromDatabase($sid, $mode = 'edit')
$this->_numemails = 0;
$this->_statuscode = 0;
$this->_owner_id = $this->_uid;
-
- } elseif ($mode == 'clone') {
-
+ } elseif ($mode === 'clone') {
// new story, new sid ...
- $this->_sid = COM_makesid();
+ $this->_sid = COM_makeSid();
$this->_old_sid = $this->_sid;
// assign ownership to current user
@@ -662,13 +658,11 @@ function loadFromDatabase($sid, $mode = 'edit')
$this->_owner_id = $this->_uid;
// use current date + time
- $this->_date = time();
- $this->_expire = time();
+ $this->_date = $this->_expire = time();
// if the original story uses comment expire, update the time
if ($this->_comment_expire != 0) {
- $this->_comment_expire = time() +
- ($_CONF['article_comment_close_days'] * 86400);
+ $this->_comment_expire = time() + ($_CONF['article_comment_close_days'] * 86400);
}
// reset counters
@@ -678,7 +672,7 @@ function loadFromDatabase($sid, $mode = 'edit')
$this->_numemails = 0;
}
- $this->_sanitizeData();
+ $this->sanitizeData();
return STORY_LOADED_OK;
}
@@ -687,13 +681,12 @@ function loadFromDatabase($sid, $mode = 'edit')
* Saves the story in it's final state to the database.
* Handles all the SID magic etc.
*
- * @return Integer status result from a constant list.
+ * @return int status result from a constant list.
*/
- function saveToDatabase()
+ public function saveToDatabase()
{
global $_TABLES, $_DB_dbms;
-
$tids = TOPIC_getTopicIdsForObject('topic');
$archive_tid = DB_getItem($_TABLES['topics'], 'tid', 'archive_flag=1');
if (!empty($tids) && !empty($archive_tid)) {
@@ -727,8 +720,8 @@ function saveToDatabase()
$oldArticleExists = false;
$currentSidExists = false;
- /* Fix up old sid => new sid stuff */
- $checksid = DB_escapeString($this->_originalSid); // needed below
+ // Fix up old sid => new sid stuff
+ $checkSid = DB_escapeString($this->_originalSid); // needed below
if ($this->_sid != $this->_originalSid) {
/* The sid has changed. Load from request will have
@@ -738,9 +731,9 @@ function saveToDatabase()
* sid that was then thrown away) to reduce the sheer
* number of SQL queries we do.
*/
- $newsid = DB_escapeString($this->_sid);
+ $newSid = DB_escapeString($this->_sid);
- $sql = "SELECT 1 FROM {$_TABLES['stories']} WHERE sid='{$checksid}'";
+ $sql = "SELECT 1 FROM {$_TABLES['stories']} WHERE sid='{$checkSid}'";
$result = DB_query($sql);
if ($result && (DB_numRows($result) > 0)) {
@@ -748,21 +741,21 @@ function saveToDatabase()
}
if ($oldArticleExists) {
- /* Move Comments */
- $sql = "UPDATE {$_TABLES['comments']} SET sid='$newsid' WHERE type='article' AND sid='$checksid'";
+ // Move Comments
+ $sql = "UPDATE {$_TABLES['comments']} SET sid='$newSid' WHERE type='article' AND sid='$checkSid'";
DB_query($sql);
- /* Move Images */
- $sql = "UPDATE {$_TABLES['article_images']} SET ai_sid = '{$newsid}' WHERE ai_sid = '{$checksid}'";
+ // Move Images
+ $sql = "UPDATE {$_TABLES['article_images']} SET ai_sid = '{$newSid}' WHERE ai_sid = '{$checkSid}'";
DB_query($sql);
- /* Move trackbacks */
- $sql = "UPDATE {$_TABLES['trackback']} SET sid='{$newsid}' WHERE sid='{$checksid}' AND type='article'";
+ // Move trackbacks
+ $sql = "UPDATE {$_TABLES['trackback']} SET sid='{$newSid}' WHERE sid='{$checkSid}' AND type='article'";
DB_query($sql);
}
}
- /* Acquire Comment Count */
+ // Acquire Comment Count
$sql = "SELECT COUNT(1) FROM {$_TABLES['comments']} WHERE type='article' AND sid='{$this->_sid}'";
$result = DB_query($sql);
@@ -798,34 +791,34 @@ function saveToDatabase()
$this->_introtext,
$this->_postmode,
'story.edit',
- $this->_text_version);
+ $this->_text_version
+ );
$this->_bodytext = GLText::applyHTMLFilter(
$this->_bodytext,
$this->_postmode,
'story.edit',
- $this->_text_version);
+ $this->_text_version
+ );
/* This uses the database field array to generate a SQL Statement. This
* means that when adding new fields to save and load, all we need to do
* is add the field name to the array, and the code will magically cope.
*/
- while (list($fieldname, $save) = each($this->_dbFields)) {
+ while (list($fieldName, $save) = each($this->_dbFields)) {
if ($save === 1) {
- $varname = '_' . $fieldname;
- $fields .= $fieldname . ', ';
- if (($fieldname == 'date') || ($fieldname == 'expire') ||
- ($fieldname == 'comment_expire')
- ) {
+ $varName = '_' . $fieldName;
+ $fields .= $fieldName . ', ';
+ if (($fieldName === 'date') || ($fieldName === 'expire') || ($fieldName === 'comment_expire')) {
// let the DB server do this conversion (cf. timezone hack)
- $values .= 'FROM_UNIXTIME(' . $this->{$varname} . '), ';
+ $values .= 'FROM_UNIXTIME(' . $this->{$varName} . '), ';
} else {
- if ($this->{$varname} === '') {
+ if ($this->{$varName} === '') {
$values .= "'', ";
} else {
- if (is_numeric($this->{$varname})) {
- $values .= DB_escapeString($this->{$varname}) . ', ';
+ if (is_numeric($this->{$varName})) {
+ $values .= DB_escapeString($this->{$varName}) . ', ';
} else {
- $values .= '\'' . DB_escapeString($this->{$varname}) . '\', ';
+ $values .= '\'' . DB_escapeString($this->{$varName}) . '\', ';
}
}
}
@@ -841,16 +834,16 @@ function saveToDatabase()
TOPIC_saveTopicSelectionControl('article', $this->_sid);
if ($oldArticleExists) {
- /* Clean up the old story */
- DB_delete($_TABLES['stories'], 'sid', $checksid);
+ // Clean up the old story
+ DB_delete($_TABLES['stories'], 'sid', $checkSid);
// Delete Topic Assignments for this old article id since we just created new ones
- TOPIC_deleteTopicAssignments('article', $checksid);
+ TOPIC_deleteTopicAssignments('article', $checkSid);
}
- if ($this->type == 'submission') {
- /* there might be a submission, clean it up */
- DB_delete($_TABLES['storysubmission'], 'sid', $checksid);
+ if ($this->type === 'submission') {
+ // there might be a submission, clean it up
+ DB_delete($_TABLES['storysubmission'], 'sid', $checkSid);
}
return STORY_SAVED;
@@ -861,8 +854,11 @@ function saveToDatabase()
* the whole entire world. First it'll clean up that horrible Magic Quotes
* crap. Then it'll do all Geeklog's funky security stuff, anti XSS, anti
* SQL Injection. Yay.
+ *
+ * @param array $array
+ * @return int
*/
- function loadFromArgsArray(&$array)
+ public function loadFromArgsArray(array &$array)
{
global $_TABLES, $_CONF;
@@ -872,8 +868,7 @@ function loadFromArgsArray(&$array)
$retval = STORY_LOADED_OK; // default to success
-
- /* Load the trivial stuff: */
+ // Load the trivial stuff:
$this->_loadBasics($array);
// override the GLText version to the latest version
@@ -882,20 +877,19 @@ function loadFromArgsArray(&$array)
/* Check to see if we have permission to edit this sid, and that this
* sid is not a duplicate or anything horrible like that. ewww.
*/
- $sql
- = 'SELECT owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon ' . ' FROM ' . $_TABLES['stories']
- . ' WHERE sid=\'' . $this->_sid . '\'';
+ $sql = "SELECT owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon FROM {$_TABLES['stories']} "
+ . " WHERE sid='" . DB_escapeString($this->_sid) . "' ";
$result = DB_query($sql);
if ($result && (DB_numRows($result) > 0)) {
- /* Sid exists! Is it our article? */
+ //Sid exists! Is it our article?
if ($this->_sid != $this->_originalSid) {
// for story preview: don't abort
$retval = STORY_DUPLICATE_SID;
}
$article = DB_fetchArray($result);
- /* Check Security */
+ // Check Security
if (SEC_hasAccess($article['owner_id'], $article['group_id'],
$article['perm_owner'], $article['perm_group'],
$article['perm_members'], $article['perm_anon']) < 3
@@ -904,39 +898,42 @@ function loadFromArgsArray(&$array)
}
}
- $access = SEC_hasAccess($this->_owner_id, $this->_group_id, $this->_perm_owner, $this->_perm_group,
- $this->_perm_members, $this->_perm_anon);
+ $access = SEC_hasAccess(
+ $this->_owner_id, $this->_group_id,
+ $this->_perm_owner, $this->_perm_group,
+ $this->_perm_members, $this->_perm_anon
+ );
//if (($access < 3) || !SEC_hasTopicAccess($this->_tid) || !SEC_inGroup($this->_group_id)) {
if (($access < 3) || !TOPIC_hasMultiTopicAccess('topic') || !SEC_inGroup($this->_group_id)) {
return STORY_NO_ACCESS_PARAMS;
}
- /* Load up the topic name and icon */
+ // Load up the topic name and icon
$topic = DB_query("SELECT tid, topic, imageurl FROM {$_TABLES['topics']} WHERE tid='" . TOPIC_getTopicDefault('topic') . "'");
$topic = DB_fetchArray($topic);
$this->_tid = $topic['tid'];
$this->_topic = $topic['topic'];
$this->_imageurl = $topic['imageurl'];
- /* Load the title, page title */
+ // Load the title, page title
$this->_title = $this->_applyTitleFilter($array['title']);
$this->_page_title = $this->_applyTitleFilter($array['page_title']);
// fix for bug in advanced editor
if (in_array($array['postmode'], array('html', 'adveditor', 'wikitext'))) {
- if ($_CONF['advanced_editor'] && ($array['bodytext'] == ' ')) {
+ if ($_CONF['advanced_editor'] && ($array['bodytext'] === ' ')) {
$array['bodytext'] = '';
}
}
- /* Load the introtext, bodytext */
+ // Load the introtext, bodytext
$this->_introtext = $this->_applyTextFilter($array['introtext'], $array['postmode']);
$this->_bodytext = $this->_applyTextFilter($array['bodytext'], $array['postmode']);
$this->_advanced_editor_mode = 0;
if (in_array($array['postmode'], array('html', 'adveditor', 'wikitext'))) {
- if ($this->_postmode == 'adveditor') {
+ if ($this->_postmode === 'adveditor') {
$this->_advanced_editor_mode = 1;
$this->_postmode = 'html';
}
@@ -946,7 +943,7 @@ function loadFromArgsArray(&$array)
return STORY_EMPTY_REQUIRED_FIELDS;
}
- $this->_sanitizeData();
+ $this->sanitizeData();
return $retval;
}
@@ -954,7 +951,7 @@ function loadFromArgsArray(&$array)
/**
* Sets up basic data for a new user submission story
*/
- function initSubmission()
+ public function initSubmission()
{
global $_USER, $_CONF, $_TABLES, $topic;
@@ -994,9 +991,11 @@ function initSubmission()
}
/**
- * Loads a submitted story from postdata
+ * Loads a submitted story from post data
+ *
+ * @return int
*/
- function loadSubmission()
+ public function loadSubmission()
{
global $_CONF;
@@ -1046,13 +1045,13 @@ function loadSubmission()
}
}
- /* Load the introtext, bodytext */
+ // Load the introtext, bodytext
$this->_introtext = $this->_applyTextFilter($array['introtext'], $array['postmode']);
$this->_bodytext = $this->_applyTextFilter($array['bodytext'], $array['postmode']);
$this->_advanced_editor_mode = 0;
if (in_array($array['postmode'], array('html', 'adveditor'))) {
- if ($this->_postmode == 'adveditor') {
+ if ($this->_postmode === 'adveditor') {
$this->_advanced_editor_mode = 1;
$this->_postmode = 'html';
}
@@ -1074,7 +1073,7 @@ function loadSubmission()
*
* @return string Story formatted for spam check.
*/
- function GetSpamCheckFormat()
+ public function getSpamCheckFormat()
{
return "{$this->_title} {$this->_introtext}
{$this->_bodytext}
";
}
@@ -1084,9 +1083,10 @@ function GetSpamCheckFormat()
*
* @return integer result code explaining behaviour.
*/
- function saveSubmission()
+ public function saveSubmission()
{
global $_USER, $_CONF, $_TABLES;
+
$this->_sid = COM_makeSid();
if (COM_isAnonUser()) {
@@ -1095,27 +1095,26 @@ function saveSubmission()
$this->_uid = $_USER['uid'];
}
-
// Remove any autotags the user doesn't have permission to use
- $introtext = PLG_replaceTags($this->_introtext, '', true);
- $bodytext = PLG_replaceTags($this->_bodytext, '', true);
+ $introText = PLG_replaceTags($this->_introtext, '', true);
+ $bodyText = PLG_replaceTags($this->_bodytext, '', true);
if (!TOPIC_hasMultiTopicAccess('topic')) {
// user doesn't have access to one or more topics - bail
return STORY_NO_ACCESS_TOPIC;
}
-
if (($_CONF['storysubmission'] == 1) && !SEC_hasRights('story.submit')) {
$sid = DB_escapeString($this->_sid);
$title = DB_escapeString($this->_title);
- $introtext = DB_escapeString($introtext);
- $bodytext = DB_escapeString($bodytext);
- $postmode = DB_escapeString($this->_postmode);
+ $introText = DB_escapeString($introText);
+ $bodyText = DB_escapeString($bodyText);
+ $postMode = DB_escapeString($this->_postmode);
DB_save($_TABLES['storysubmission'], 'sid,uid,title,introtext,bodytext,date,postmode,text_version',
"$sid,{$this->_uid},'$title'," .
- "'$introtext','$bodytext',NOW(),'$postmode','{$this->_text_version}'");
+ "'$introText','$bodyText',NOW(),'$postMode','{$this->_text_version}'"
+ );
// Save Topics selected
TOPIC_saveTopicSelectionControl('article', $sid);
@@ -1123,7 +1122,7 @@ function saveSubmission()
return STORY_SAVED_SUBMISSION;
} else {
// post this story directly. First establish the necessary missing data.
- $this->_sanitizeData();
+ $this->sanitizeData();
if (!isset($_CONF['show_topic_icon'])) {
$_CONF['show_topic_icon'] = 1;
@@ -1199,15 +1198,13 @@ function saveSubmission()
* @param string $text Intro or Body text
* @return string processed text
*/
- function renderImageTags($text)
+ public function renderImageTags($text)
{
global $_CONF, $_TABLES, $LANG24;
// check if we have a (different) old sid - the article_images table
// will only be updated later! cf. bug #0001256
- if (!empty($this->_originalSid) &&
- ($this->_sid != $this->_originalSid)
- ) {
+ if (!empty($this->_originalSid) && ($this->_sid != $this->_originalSid)) {
$ai_sid = $this->_originalSid;
} else {
$ai_sid = $this->_sid;
@@ -1215,17 +1212,17 @@ function renderImageTags($text)
$result = DB_query("SELECT ai_filename FROM {$_TABLES['article_images']} "
. "WHERE ai_sid = '{$ai_sid}' ORDER BY ai_img_num");
- $nrows = DB_numRows($result);
+ $numRows = DB_numRows($result);
$stdImageLoc = true;
if (!strstr($_CONF['path_images'], $_CONF['path_html'])) {
$stdImageLoc = false;
}
- for ($i = 1; $i <= $nrows; $i++) {
+ for ($i = 1; $i <= $numRows; $i++) {
$A = DB_fetchArray($result);
- $imgpath = '';
+ $imgPath = '';
// If we are storing images on a "standard path" i.e. is
// available to the host web server, then the url to this
@@ -1236,33 +1233,30 @@ function renderImageTags($text)
// image from whereever else on the file system we're
// keeping them:
if ($stdImageLoc) {
- $imgpath = substr($_CONF['path_images'], strlen($_CONF['path_html']));
- $imgSrc = $_CONF['site_url'] . '/' . $imgpath . 'articles/' . $A['ai_filename'];
+ $imgPath = substr($_CONF['path_images'], strlen($_CONF['path_html']));
+ $imgSrc = $_CONF['site_url'] . '/' . $imgPath . 'articles/' . $A['ai_filename'];
} else {
$imgSrc = $_CONF['site_url'] . '/getimage.php?mode=articles&image=' . $A['ai_filename'];
}
- $sizeattributes = COM_getImgSizeAttributes($_CONF['path_images'] . 'articles/' . $A['ai_filename']);
+ $sizeAttributes = COM_getImgSizeAttributes($_CONF['path_images'] . 'articles/' . $A['ai_filename']);
// Build image tags for each flavour of the image:
- $img_noalign = ' ';
- $img_leftalgn = ' ';
- $img_rightalgn = ' ';
+ $img_noalign = ' ';
+ $img_leftalgn = ' ';
+ $img_rightalgn = ' ';
// Are we keeping unscaled images?
if ($_CONF['keep_unscaled_image'] == 1) {
// Yes we are, so, we need to find out what the filename
// of the original, unscaled image is:
- $lFilename_large = substr_replace($A['ai_filename'], '_original.',
- strrpos($A['ai_filename'], '.'), 1);
- $lFilename_large_complete = $_CONF['path_images'] . 'articles/' .
- $lFilename_large;
+ $lFilename_large = substr_replace($A['ai_filename'], '_original.', strrpos($A['ai_filename'], '.'), 1);
+ $lFilename_large_complete = $_CONF['path_images'] . 'articles/' . $lFilename_large;
// We need to map that filename to the right location
// or the fetch script:
if ($stdImageLoc) {
- $lFilename_large_URL = $_CONF['site_url'] . '/' . $imgpath .
- 'articles/' . $lFilename_large;
+ $lFilename_large_URL = $_CONF['site_url'] . '/' . $imgPath . 'articles/' . $lFilename_large;
} else {
$lFilename_large_URL = $_CONF['site_url'] .
'/getimage.php?mode=show&image=' .
@@ -1297,22 +1291,22 @@ function renderImageTags($text)
}
// And insert the unscaled mode images:
- if (($_CONF['allow_user_scaling'] == 1) and ($_CONF['keep_unscaled_image'] == 1)) {
+ if (($_CONF['allow_user_scaling'] == 1) && ($_CONF['keep_unscaled_image'] == 1)) {
if (file_exists($lFilename_large_complete)) {
$imgSrc = $lFilename_large_URL;
- $sizeattributes = COM_getImgSizeAttributes($lFilename_large_complete);
+ $sizeAttributes = COM_getImgSizeAttributes($lFilename_large_complete);
}
- $unscalednorm = '[unscaled' . $i . ']';
- $unscaledleft = '[unscaled' . $i . '_left]';
- $unscaledright = '[unscaled' . $i . '_right]';
+ $unscaledNorm = '[unscaled' . $i . ']';
+ $unscaledLeft = '[unscaled' . $i . '_left]';
+ $unscaledRight = '[unscaled' . $i . '_right]';
- $text = str_replace($unscalednorm,
- ' ', $text);
- $text = str_replace($unscaledleft,
- ' ', $text);
- $text = str_replace($unscaledright,
- ' ', $text);
+ $text = str_replace($unscaledNorm,
+ ' ', $text);
+ $text = str_replace($unscaledLeft,
+ ' ', $text);
+ $text = str_replace($unscaledRight,
+ ' ', $text);
}
}
@@ -1324,7 +1318,7 @@ function renderImageTags($text)
*
* @return array containing errors, or empty.
*/
- function checkAttachedImages()
+ public function checkAttachedImages()
{
global $_TABLES, $LANG24;
@@ -1332,9 +1326,7 @@ function checkAttachedImages()
// check if we have a (different) old sid - the article_images table
// will only be updated later! cf. bug #0001256
- if (!empty($this->_originalSid) &&
- ($this->_sid != $this->_originalSid)
- ) {
+ if (!empty($this->_originalSid) && ($this->_sid != $this->_originalSid)) {
$ai_sid = $this->_originalSid;
} else {
$ai_sid = $this->_sid;
@@ -1342,13 +1334,13 @@ function checkAttachedImages()
$result = DB_query("SELECT ai_filename FROM {$_TABLES['article_images']} "
. "WHERE ai_sid = '{$ai_sid}' ORDER BY ai_img_num");
- $nrows = DB_numRows($result);
+ $numRows = DB_numRows($result);
$errors = array();
- for ($i = 1; $i <= $nrows; $i++) {
+ for ($i = 1; $i <= $numRows; $i++) {
$A = DB_fetchArray($result);
// See how many times image $i is used in the fulltext of the article:
- $icount = substr_count($text, '[image' . $i . ']')
+ $iCount = substr_count($text, '[image' . $i . ']')
+ substr_count($text, '[image' . $i . '_left]')
+ substr_count($text, '[image' . $i . '_right]')
+ substr_count($text, '[unscaled' . $i . ']')
@@ -1357,7 +1349,7 @@ function checkAttachedImages()
// If the image we are currently looking at wasn't used, we need
// to log an error
- if ($icount == 0) {
+ if ($iCount == 0) {
// There is an image that wasn't used, create an error
$errors[] = $LANG24[48] . " #$i, {$A['ai_filename']}, " . $LANG24[53];
}
@@ -1371,9 +1363,9 @@ function checkAttachedImages()
* GL special syntax
*
* @param string $text Intro or Body text
- * @return string processed text
+ * @return string processed text
*/
- function replaceImages($text)
+ public function replaceImages($text)
{
global $_CONF, $_TABLES, $LANG24;
@@ -1384,18 +1376,18 @@ function replaceImages($text)
}
$count = 0;
- /* If we haven't already cached the images for this story, do so */
+ // If we haven't already cached the images for this story, do so
if (!is_array($this->_storyImages)) {
$result = DB_query("SELECT ai_filename FROM {$_TABLES['article_images']} WHERE " .
"ai_sid = '{$this->_sid}' ORDER BY ai_img_num");
- $nrows = DB_numRows($result);
+ $numRows = DB_numRows($result);
$this->_storyImages = array();
- for ($i = 1; $i <= $nrows; $i++) {
+ for ($i = 1; $i <= $numRows; $i++) {
$this->_storyImages[] = DB_fetchArray($result);
}
- $count = $nrows;
+ $count = $numRows;
} else {
$count = count($this->_storyImages);
}
@@ -1408,7 +1400,7 @@ function replaceImages($text)
$imageX_left = '[image' . ($i + 1) . '_left]';
$imageX_right = '[image' . ($i + 1) . '_right]';
- $sizeattributes = COM_getImgSizeAttributes($_CONF['path_images'] . 'articles/' . $A['ai_filename']);
+ $sizeAttributes = COM_getImgSizeAttributes($_CONF['path_images'] . 'articles/' . $A['ai_filename']);
$lLinkPrefix = '';
$lLinkSuffix = '';
@@ -1419,11 +1411,10 @@ function replaceImages($text)
$lFilename_large_complete = $_CONF['path_images'] . 'articles/' . $lFilename_large;
if ($stdImageLoc) {
- $imgpath = substr($_CONF['path_images'], strlen($_CONF['path_html']));
- $lFilename_large_URL = $_CONF['site_url'] . '/' . $imgpath . 'articles/' . $lFilename_large;
+ $imgPath = substr($_CONF['path_images'], strlen($_CONF['path_html']));
+ $lFilename_large_URL = $_CONF['site_url'] . '/' . $imgPath . 'articles/' . $lFilename_large;
} else {
- $lFilename_large_URL = $_CONF['site_url'] . '/getimage.php?mode=show&image='
- . $lFilename_large;
+ $lFilename_large_URL = $_CONF['site_url'] . '/getimage.php?mode=show&image=' . $lFilename_large;
}
if (file_exists($lFilename_large_complete)) {
@@ -1433,32 +1424,32 @@ function replaceImages($text)
}
if ($stdImageLoc) {
- $imgpath = substr($_CONF['path_images'], strlen($_CONF['path_html']));
- $imgSrc = $_CONF['site_url'] . '/' . $imgpath . 'articles/' . $A['ai_filename'];
+ $imgPath = substr($_CONF['path_images'], strlen($_CONF['path_html']));
+ $imgSrc = $_CONF['site_url'] . '/' . $imgPath . 'articles/' . $A['ai_filename'];
} else {
$imgSrc = $_CONF['site_url'] . '/getimage.php?mode=articles&image=' . $A['ai_filename'];
}
- $norm = $lLinkPrefix . ' ' . $lLinkSuffix;
- $left = $lLinkPrefix . ' '
+ $norm = $lLinkPrefix . ' ' . $lLinkSuffix;
+ $left = $lLinkPrefix . ' '
. $lLinkSuffix;
- $right = $lLinkPrefix . ' '
+ $right = $lLinkPrefix . ' '
. $lLinkSuffix;
$text = str_replace($norm, $imageX, $text);
$text = str_replace($left, $imageX_left, $text);
$text = str_replace($right, $imageX_right, $text);
- if (($_CONF['allow_user_scaling'] == 1) and ($_CONF['keep_unscaled_image'] == 1)) {
+ if (($_CONF['allow_user_scaling'] == 1) && ($_CONF['keep_unscaled_image'] == 1)) {
$unscaledX = '[unscaled' . ($i + 1) . ']';
$unscaledX_left = '[unscaled' . ($i + 1) . '_left]';
$unscaledX_right = '[unscaled' . ($i + 1) . '_right]';
if (file_exists($lFilename_large_complete)) {
- $sizeattributes = COM_getImgSizeAttributes($lFilename_large_complete);
- $norm = ' ';
- $left = ' ';
- $right = ' ';
+ $sizeAttributes = COM_getImgSizeAttributes($lFilename_large_complete);
+ $norm = ' ';
+ $left = ' ';
+ $right = ' ';
}
$text = str_replace($norm, $unscaledX, $text);
@@ -1476,7 +1467,7 @@ function replaceImages($text)
* @param bool $forDb boolean True if we want an 'DB_escapeString' version for the db
* @return string
*/
- function getSid($forDb = false)
+ public function getSid($forDb = false)
{
if ($forDb) {
return DB_escapeString($this->_sid);
@@ -1487,8 +1478,10 @@ function getSid($forDb = false)
/**
* Get the access level
+ *
+ * @return int
*/
- function getAccess()
+ public function getAccess()
{
return $this->_access;
}
@@ -1505,9 +1498,10 @@ function getAccess()
* @param string $item Item to fetch.
* @return mixed The clean and ready to use (in edit mode) value requested.
*/
- function EditElements($item = 'title')
+ public function EditElements($item = 'title')
{
global $_CONF;
+
switch (strtolower($item)) {
case 'unixdate':
$return = strtotime($this->_date);
@@ -1728,7 +1722,7 @@ function EditElements($item = 'title')
* @param string $item Item to fetch.
* @return mixed The clean and ready to use value requested.
*/
- function DisplayElements($item = 'title')
+ public function DisplayElements($item = 'title')
{
global $_CONF, $_TABLES;
@@ -1798,7 +1792,7 @@ function DisplayElements($item = 'title')
break;
case 'hits':
- $return = COM_NumberFormat($this->_hits);
+ $return = COM_numberFormat($this->_hits);
break;
@@ -1828,10 +1822,10 @@ function DisplayElements($item = 'title')
break;
default:
- $varname = '_' . $item;
+ $varName = '_' . $item;
- if (isset($this->{$varname})) {
- $return = $this->{$varname};
+ if (isset($this->{$varName})) {
+ $return = $this->{$varName};
}
break;
@@ -1846,10 +1840,11 @@ function DisplayElements($item = 'title')
* @param string $item Item to fetch. Valid only bodytext and introtext.
* @return string text for preview in edit mode
*/
- function getPreviewText($item)
+ public function getPreviewText($item)
{
- $text = (strtolower($item) == 'introtext') ?
- $this->_introtext : $this->_bodytext;
+ $text = (strtolower($item) === 'introtext')
+ ? $this->_introtext
+ : $this->_bodytext;
if ($this->_text_version == GLTEXT_FIRST_VERSION) {
$text = $this->replaceImages($text);
}
@@ -1869,11 +1864,12 @@ function getPreviewText($item)
*
* @return int access level for this story
*/
- function checkAccess()
+ public function checkAccess()
{
return SEC_hasAccess($this->_owner_id, $this->_group_id,
$this->_perm_owner, $this->_perm_group,
- $this->_perm_members, $this->_perm_anon);
+ $this->_perm_members, $this->_perm_anon
+ );
}
/**
@@ -1946,7 +1942,7 @@ public static function getRelatedArticlesByKeywords($articleId, $keywordList, $l
if (!$found) {
$work[] = array(
- 'sid' => $sid,
+ 'sid' => $sid,
'title' => $title,
'score' => 1,
);
@@ -1978,71 +1974,67 @@ public static function getRelatedArticlesByKeywords($articleId, $keywordList, $l
return $retval;
}
- // End Public Methods.
-
- // Private Methods:
-
/**
* Escapes certain HTML for nicely encoded HTML.
*
- * @access Private
- * @param string $in Text to escpae
- * @return string escaped string
+ * @param string $text text to escpae
+ * @return string escaped string
*/
- function _displayEscape($text)
+ private function _displayEscape($text)
{
return str_replace(
array('$', '{', '}', '\\'),
- array('$', '{', '}', '\'), $text);
+ array('$', '{', '}', '\'),
+ $text
+ );
}
/**
* Loads the basic details of an article into the internal
* variables, cleaning them up nicely.
*
- * @access Private
- * @param $array Array of POST/GET data (by ref).
- * @return Nothing.
+ * @param array $array Array of POST/GET data (by ref).
+ * @return void
*/
- function _loadBasics(&$array)
+ private function _loadBasics(array &$array)
{
/* For the really, really basic stuff, we can very easily load them
* based on an array that defines how to COM_applyFilter them.
*/
foreach ($this->_postFields as $key => $value) {
- $vartype = $value[0];
- $varname = $value[1];
+ $varType = $value[0];
+ $varName = $value[1];
// If we have a value
if (array_key_exists($key, $array)) {
// And it's alphanumeric or numeric, filter it and use it.
- if (($vartype == STORY_AL_ALPHANUM) || ($vartype == STORY_AL_NUMERIC)) {
- $this->{$varname} = COM_applyFilter($array[$key], $vartype);
- } elseif ($vartype == STORY_AL_ANYTHING) {
- $this->{$varname} = $array[$key];
+ if (($varType == STORY_AL_ALPHANUM) || ($varType == STORY_AL_NUMERIC)) {
+ $this->{$varName} = COM_applyFilter($array[$key], $varType);
+ } elseif ($varType == STORY_AL_ANYTHING) {
+ $this->{$varName} = $array[$key];
} elseif (($array[$key] === 'on') || ($array[$key] === 1)) {
// If it's a checkbox that is on
- $this->{$varname} = 1;
+ $this->{$varName} = 1;
} else {
// Otherwise, it must be a checkbox that is off:
- $this->{$varname} = 0;
+ $this->{$varName} = 0;
}
- } elseif (($vartype == STORY_AL_NUMERIC) || ($vartype == STORY_AL_CHECKBOX)) {
+ } elseif (($varType == STORY_AL_NUMERIC) || ($varType == STORY_AL_CHECKBOX)) {
// If we don't have a value, and have a numeric or text box, default to 0
- $this->{$varname} = 0;
+ $this->{$varName} = 0;
}
}
// SID's are a special case:
$sid = COM_sanitizeID($array['sid']);
if (isset($array['old_sid'])) {
- $oldsid = COM_sanitizeID($array['old_sid'], false);
+ $oldSid = COM_sanitizeID($array['old_sid'], false);
} else {
- $oldsid = '';
+ $oldSid = '';
}
if (empty($sid)) {
- $sid = $oldsid;
+ $sid = $oldSid;
}
if (empty($sid)) {
@@ -2050,9 +2042,9 @@ function _loadBasics(&$array)
}
$this->_sid = $sid;
- $this->_originalSid = $oldsid;
+ $this->_originalSid = $oldSid;
- /* Need to deal with the postdate and expiry date stuff */
+ // Need to deal with the postdate and expiry date stuff
$publish_ampm = '';
if (isset($array['publish_ampm'])) {
$publish_ampm = COM_applyFilter($array['publish_ampm']);
@@ -2070,13 +2062,13 @@ function _loadBasics(&$array)
$publish_second = COM_applyFilter($array['publish_second'], true);
}
- if ($publish_ampm == 'pm') {
+ if ($publish_ampm === 'pm') {
if ($publish_hour < 12) {
$publish_hour = $publish_hour + 12;
}
}
- if ($publish_ampm == 'am' AND $publish_hour == 12) {
+ if ($publish_ampm === 'am' && $publish_hour == 12) {
$publish_hour = '00';
}
@@ -2095,13 +2087,13 @@ function _loadBasics(&$array)
$this->_date = strtotime(
"$publish_month/$publish_day/$publish_year $publish_hour:$publish_minute:$publish_second");
- $archiveflag = 0;
+ $archiveFlag = 0;
if (isset($array['archiveflag'])) {
- $archiveflag = COM_applyFilter($array['archiveflag'], true);
+ $archiveFlag = COM_applyFilter($array['archiveflag'], true);
}
- /* Override status code if no archive flag is set: */
- if ($archiveflag != 1) {
+ // Override status code if no archive flag is set:
+ if ($archiveFlag != 1) {
$this->_statuscode = 0;
}
@@ -2114,23 +2106,22 @@ function _loadBasics(&$array)
$expire_month = COM_applyFilter($array['expire_month'], true);
$expire_day = COM_applyFilter($array['expire_day'], true);
- if ($expire_ampm == 'pm') {
+ if ($expire_ampm === 'pm') {
if ($expire_hour < 12) {
$expire_hour = $expire_hour + 12;
}
}
- if ($expire_ampm == 'am' AND $expire_hour == 12) {
+ if ($expire_ampm === 'am' && $expire_hour == 12) {
$expire_hour = '00';
}
- $expiredate
- = strtotime("$expire_month/$expire_day/$expire_year $expire_hour:$expire_minute:$expire_second");
+ $expireDate = strtotime("$expire_month/$expire_day/$expire_year $expire_hour:$expire_minute:$expire_second");
} else {
- $expiredate = time();
+ $expireDate = time();
}
- $this->_expire = $expiredate;
+ $this->_expire = $expireDate;
// comment expire time
if (isset($array['cmt_close_flag'])) {
@@ -2148,19 +2139,17 @@ function _loadBasics(&$array)
}
}
- if ($cmt_close_ampm == 'am' AND $cmt_close_hour == 12) {
+ if ($cmt_close_ampm === 'am' && $cmt_close_hour == 12) {
$cmt_close_hour = '00';
}
- $cmt_close_date
- = strtotime("$cmt_close_month/$cmt_close_day/$cmt_close_year $cmt_close_hour:$cmt_close_minute:$cmt_close_second");
-
+ $cmt_close_date = strtotime("$cmt_close_month/$cmt_close_day/$cmt_close_year $cmt_close_hour:$cmt_close_minute:$cmt_close_second");
$this->_comment_expire = $cmt_close_date;
} else {
$this->_comment_expire = 0;
}
- /* Then grab the permissions */
+ // Then grab the permissions
// Convert array values to numeric permission values
if (is_array($array['perm_owner']) ||
@@ -2186,23 +2175,40 @@ function _loadBasics(&$array)
}
}
- function _applyTitleFilter($title)
+ /**
+ * Apply filters to the title element
+ *
+ * @param string $title
+ * @return string
+ */
+ private function _applyTitleFilter($title)
{
- return htmlspecialchars(strip_tags(COM_checkWords($title, 'story')),
- ENT_QUOTES, COM_getEncodingt());
+ $retval = strip_tags(COM_checkWords($title, 'story'));
+ $retval = GLText::removeUtf8Icons($retval);
+ $retval = htmlspecialchars($retval, ENT_QUOTES, COM_getEncodingt());
+
+ return $retval;
}
- function _applyTextFilter($text, $postmode)
+ /**
+ * Apply filters to the text element
+ *
+ * @param string $text
+ * @param string $postMode
+ * @return string
+ */
+ private function _applyTextFilter($text, $postMode)
{
- if ($this->_text_version == GLTEXT_FIRST_VERSION) {
+ $text = GLText::removeUtf8Icons($text);
+ if ($this->_text_version == GLTEXT_FIRST_VERSION) {
// first version
// Remove any autotags the user doesn't have permission to use
$text = PLG_replaceTags($text, '', true);
$text = COM_checkWords($text, 'story');
- if (in_array($postmode, array('html', 'adveditor', 'wikitext'))) {
+ if (in_array($postMode, array('html', 'adveditor', 'wikitext'))) {
// html or wikitext
$text = GLText::checkHTML($text, 'story.edit');
} else {
@@ -2220,10 +2226,9 @@ function _applyTextFilter($text, $postmode)
}
/**
- * Perform some basic cleanups of data, dealing with empty required,
- * defaultable fields.
+ * Perform some basic cleanups of data, dealing with empty required, defaultable fields.
*/
- function _sanitizeData()
+ public function sanitizeData()
{
if (empty($this->_hits)) {
$this->_hits = 0;
@@ -2253,8 +2258,4 @@ function _sanitizeData()
$this->_show_topic_icon = 0;
}
}
-
- // End Private Methods.
-
- /**************************************************************************/
}
diff --git a/system/lib-comment.php b/system/lib-comment.php
index cd157be96..9388204f0 100644
--- a/system/lib-comment.php
+++ b/system/lib-comment.php
@@ -2,7 +2,7 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | Geeklog 2.0 |
+// | Geeklog 2.1 |
// +---------------------------------------------------------------------------+
// | lib-comment.php |
// | |
@@ -34,135 +34,132 @@
// | |
// +---------------------------------------------------------------------------+
-if (strpos(strtolower($_SERVER['PHP_SELF']), 'lib-comment.php') !== false) {
+global $_CONF;
+
+if (stripos($_SERVER['PHP_SELF'], basename(__FILE__)) !== false) {
die('This file can not be used on its own!');
}
if ($_CONF['allow_user_photo']) {
- /**
- * only needed for the USER_getPhoto function
- */
+ // only needed for the USER_getPhoto function
require_once $_CONF['path_system'] . 'lib-user.php';
}
-define('COMMENT_ON_SAME_PAGE',
- ($_CONF['comment_on_same_page'] && !CMT_isCommentPage()));
+define('COMMENT_ON_SAME_PAGE', ($_CONF['comment_on_same_page'] && !CMT_isCommentPage()));
$prefix = COMMENT_ON_SAME_PAGE ? 'cmt_' : '';
-define('CMT_CID', $prefix . 'cid');
-define('CMT_SID', $prefix . 'sid');
-define('CMT_PID', $prefix . 'pid');
-define('CMT_UID', $prefix . 'uid');
-define('CMT_TYPE', $prefix . 'type');
+define('CMT_CID', $prefix . 'cid');
+define('CMT_SID', $prefix . 'sid');
+define('CMT_PID', $prefix . 'pid');
+define('CMT_UID', $prefix . 'uid');
+define('CMT_TYPE', $prefix . 'type');
define('CMT_USERNAME', $prefix . 'username');
-define('CMT_MODE', $prefix . 'mode');
+define('CMT_MODE', $prefix . 'mode');
/**
-* This function displays the comment control bar
-*
-* Prints the control that allows the user to interact with Geeklog Comments
-*
-* @param string $sid ID of item in question
-* @param string $title Title of item
-* @param string $type Type of item (i.e. article, photo, etc)
-* @param string $order Order that comments are displayed in
-* @param string $mode Mode (nested, flat, etc.)
-* @param int $ccode Comment code: -1=no comments, 0=allowed, 1=closed
-* @return string HTML Formated comment bar
-* @see CMT_userComments
-*
-*/
-function CMT_commentBar( $sid, $title, $type, $order, $mode, $ccode = 0 )
+ * This function displays the comment control bar
+ * Prints the control that allows the user to interact with Geeklog Comments
+ *
+ * @param string $sid ID of item in question
+ * @param string $title Title of item
+ * @param string $type Type of item (i.e. article, photo, etc)
+ * @param string $order Order that comments are displayed in
+ * @param string $mode Mode (nested, flat, etc.)
+ * @param int $ccode Comment code: -1=no comments, 0=allowed, 1=closed
+ * @return string HTML Formated comment bar
+ * @see CMT_userComments
+ */
+function CMT_commentBar($sid, $title, $type, $order, $mode, $ccode = 0)
{
global $_CONF, $_TABLES, $_USER, $LANG01, $LANG03;
$is_comment_page = CMT_isCommentPage();
- $nrows = DB_count( $_TABLES['comments'], array( 'sid', 'type' ),
- array( $sid, $type ));
+ $nrows = DB_count($_TABLES['comments'], array('sid', 'type'),
+ array($sid, $type));
- $commentbar = COM_newTemplate($_CONF['path_layout'] . 'comment');
- $commentbar->set_file( array( 'commentbar' => 'commentbar.thtml' ));
- $commentbar->set_block('commentbar', 'commenteditform_jumplink');
+ $commentBar = COM_newTemplate($_CONF['path_layout'] . 'comment');
+ $commentBar->set_file(array('commentbar' => 'commentbar.thtml'));
+ $commentBar->set_block('commentbar', 'commenteditform_jumplink');
- $commentbar->set_var( 'lang_comments', $LANG01[3] );
- $commentbar->set_var( 'lang_refresh', $LANG01[39] );
- $commentbar->set_var( 'lang_reply', $LANG01[60] );
- $commentbar->set_var( 'lang_disclaimer', $LANG01[26] );
+ $commentBar->set_var('lang_comments', $LANG01[3]);
+ $commentBar->set_var('lang_refresh', $LANG01[39]);
+ $commentBar->set_var('lang_reply', $LANG01[60]);
+ $commentBar->set_var('lang_disclaimer', $LANG01[26]);
- if ( $ccode == 0 && !COMMENT_ON_SAME_PAGE) {
- $commentbar->set_var( 'reply_hidden_or_submit', 'submit' );
+ if ($ccode == 0 && !COMMENT_ON_SAME_PAGE) {
+ $commentBar->set_var('reply_hidden_or_submit', 'submit');
// $commentbar->set_var( 'show_link_to_commenteditform', 'display:none;' );
- $commentbar->set_var( 'jump_link_for_commenteditform', '' );
+ $commentBar->set_var('jump_link_for_commenteditform', '');
} else {
- $commentbar->set_var( 'reply_hidden_or_submit', 'hidden' );
- $commentbar->parse( 'jump_link_for_commenteditform', 'commenteditform_jumplink' );
+ $commentBar->set_var('reply_hidden_or_submit', 'hidden');
+ $commentBar->parse('jump_link_for_commenteditform', 'commenteditform_jumplink');
}
- $commentbar->set_var( 'num_comments', COM_numberFormat( $nrows ));
- $commentbar->set_var( 'comment_type', $type );
- $commentbar->set_var( 'sid', $sid );
+ $commentBar->set_var('num_comments', COM_numberFormat($nrows));
+ $commentBar->set_var('comment_type', $type);
+ $commentBar->set_var('sid', $sid);
$cmt_title = stripslashes($title);
- $commentbar->set_var('story_title', $cmt_title);
+ $commentBar->set_var('story_title', $cmt_title);
// Article's are pre-escaped.
if ($type != 'article') {
$cmt_title = htmlspecialchars($cmt_title);
}
- $commentbar->set_var('comment_title', $cmt_title);
+ $commentBar->set_var('comment_title', $cmt_title);
// Link to plugin defined link or lacking that a generic link
// that the plugin should support (hopefully)
list($plgurl, $plgid) = CMT_getCommentUrlId($type);
$articleUrl = "$plgurl?$plgid=$sid";
- $commentbar->set_var('article_url', $articleUrl);
+ $commentBar->set_var('article_url', $articleUrl);
if ($is_comment_page) {
$link = COM_createLink($cmt_title, $articleUrl,
- array('class' => 'non-ul b'));
- $commentbar->set_var('story_link', $link);
- $commentbar->set_var('start_storylink_anchortag',
- '');
- $commentbar->set_var('end_storylink_anchortag', ' ');
+ array('class' => 'non-ul b'));
+ $commentBar->set_var('story_link', $link);
+ $commentBar->set_var('start_storylink_anchortag',
+ '');
+ $commentBar->set_var('end_storylink_anchortag', ' ');
} else {
- $commentbar->set_var('story_link', $articleUrl);
+ $commentBar->set_var('story_link', $articleUrl);
}
- if (! COM_isAnonUser()) {
+ if (!COM_isAnonUser()) {
$username = $_USER['username'];
$fullname = $_USER['fullname'];
} else {
- $result = DB_query( "SELECT username,fullname FROM {$_TABLES['users']} WHERE uid = 1" );
- $N = DB_fetchArray( $result );
+ $result = DB_query("SELECT username,fullname FROM {$_TABLES['users']} WHERE uid = 1");
+ $N = DB_fetchArray($result);
$username = $N['username'];
$fullname = $N['fullname'];
}
- if( empty( $fullname )) {
+ if (empty($fullname)) {
$fullname = $username;
}
- $commentbar->set_var( 'user_name', $username );
- $commentbar->set_var( 'user_fullname', $fullname );
+ $commentBar->set_var('user_name', $username);
+ $commentBar->set_var('user_fullname', $fullname);
- if (! COM_isAnonUser()) {
- $author = COM_getDisplayName( $_USER['uid'], $username, $fullname );
- $commentbar->set_var( 'user_nullname', $author );
- $commentbar->set_var( 'author', $author );
- $commentbar->set_var( 'login_logout_url',
- $_CONF['site_url'] . '/users.php?mode=logout' );
- $commentbar->set_var( 'lang_login_logout', $LANG01[35] );
+ if (!COM_isAnonUser()) {
+ $author = COM_getDisplayName($_USER['uid'], $username, $fullname);
+ $commentBar->set_var('user_nullname', $author);
+ $commentBar->set_var('author', $author);
+ $commentBar->set_var('login_logout_url',
+ $_CONF['site_url'] . '/users.php?mode=logout');
+ $commentBar->set_var('lang_login_logout', $LANG01[35]);
} else {
- $commentbar->set_var( 'user_nullname', '' );
- $commentbar->set_var( 'login_logout_url',
- $_CONF['site_url'] . '/users.php?mode=new' );
- $commentbar->set_var( 'lang_login_logout', $LANG01[61] );
+ $commentBar->set_var('user_nullname', '');
+ $commentBar->set_var('login_logout_url',
+ $_CONF['site_url'] . '/users.php?mode=new');
+ $commentBar->set_var('lang_login_logout', $LANG01[61]);
}
$comment_url = $_CONF['site_url'] . '/comment.php';
if ($is_comment_page) {
- $commentbar->set_var( 'parent_url', $comment_url . '#comments' );
- $commentbar->set_var( 'editor_url', $comment_url . '#commenteditform' );
+ $commentBar->set_var('parent_url', $comment_url . '#comments');
+ $commentBar->set_var('editor_url', $comment_url . '#commenteditform');
$hidden = '';
- $commentmode = '';
+ $commentMode = '';
if (isset($_REQUEST[CMT_MODE])) {
- $commentmode = COM_applyFilter($_REQUEST[CMT_MODE]);
+ $commentMode = COM_applyFilter($_REQUEST[CMT_MODE]);
}
$cid = 0;
if (isset($_REQUEST[CMT_CID])) {
@@ -172,36 +169,35 @@ function CMT_commentBar( $sid, $title, $type, $order, $mode, $ccode = 0 )
if (isset($_REQUEST[CMT_PID])) {
$pid = COM_applyFilter($_REQUEST[CMT_PID], true);
}
- if (in_array($commentmode, array('view', $LANG03[28], $LANG03[34], $LANG03[14], 'edit'))) {
+ if (in_array($commentMode, array('view', $LANG03[28], $LANG03[34], $LANG03[14], 'edit'))) {
$hidden .= ' ';
$hidden .= ' ';
- }
- else if ( $commentmode == 'display' || empty($commentmode) ) {
+ } else if ($commentMode == 'display' || empty($commentMode)) {
$hidden .= ' ';
}
- $hidden .= ' ';
- $commentbar->set_var( 'hidden_field', $hidden );
- $commentbar->set_var( 'hidden_field_reply', '' );
- $commentbar->set_var( 'nprefix', '' );
+ $hidden .= ' ';
+ $commentBar->set_var('hidden_field', $hidden);
+ $commentBar->set_var('hidden_field_reply', '');
+ $commentBar->set_var('nprefix', '');
} else { // article and plugin
- $commentbar->set_var( 'parent_url', $articleUrl . '#comments' );
+ $commentBar->set_var('parent_url', $articleUrl . '#comments');
if (COMMENT_ON_SAME_PAGE) {
- $commentbar->set_var( 'editor_url', $articleUrl . '#commenteditform' );
- $commentbar->set_var( 'nprefix', 'cmd_' );
+ $commentBar->set_var('editor_url', $articleUrl . '#commenteditform');
+ $commentBar->set_var('nprefix', 'cmd_');
} else {
- $commentbar->set_var( 'editor_url', $comment_url . '#commenteditform' );
- $commentbar->set_var( 'nprefix', '' );
+ $commentBar->set_var('editor_url', $comment_url . '#commenteditform');
+ $commentBar->set_var('nprefix', '');
}
$hidden = ' ';
- $commentbar->set_var( 'hidden_field', $hidden );
- $commentbar->set_var( 'hidden_field_reply', $hidden );
+ $commentBar->set_var('hidden_field', $hidden);
+ $commentBar->set_var('hidden_field_reply', $hidden);
}
// Order
$selector = '' . LB
- . COM_optionList( $_TABLES['sortcodes'], 'code,name', $order )
- . LB . ' ';
- $commentbar->set_var( 'order_selector', $selector);
+ . COM_optionList($_TABLES['sortcodes'], 'code,name', $order)
+ . LB . '';
+ $commentBar->set_var('order_selector', $selector);
// Mode
if ($is_comment_page) {
@@ -210,32 +206,31 @@ function CMT_commentBar( $sid, $title, $type, $order, $mode, $ccode = 0 )
$selector = '';
}
$selector .= LB
- . COM_optionList( $_TABLES['commentmodes'], 'mode,name', $mode )
- . LB . ' ';
- $commentbar->set_var( 'mode_selector', $selector);
+ . COM_optionList($_TABLES['commentmodes'], 'mode,name', $mode)
+ . LB . '';
+ $commentBar->set_var('mode_selector', $selector);
- return $commentbar->finish( $commentbar->parse( 'output', 'commentbar' ));
+ return $commentBar->finish($commentBar->parse('output', 'commentbar'));
}
/**
-* This function prints &$comments (db results set of comments) in comment format
-* -For previews, &$comments is assumed to be an associative array containing
-* data for a single comment.
-*
-* @param array &$comments Database result set of comments to be printed
-* @param string $mode 'flat', 'threaded', etc
-* @param string $type Type of item (article, polls, etc.)
-* @param string $order How to order the comments 'ASC' or 'DESC'
-* @param boolean $delete_option if current user can delete comments
-* @param boolean $preview Preview display (for edit) or not
-* @param int $ccode Comment code: -1=no comments, 0=allowed, 1=closed
-* @param int $cpage page number of comments to display
-* @return string HTML Formated Comment
-*
-*/
-function CMT_getComment( &$comments, $mode, $type, $order, $delete_option = false, $preview = false, $ccode = 0,
- $cpage = 1 )
+ * This function prints &$comments (db results set of comments) in comment format
+ * -For previews, &$comments is assumed to be an associative array containing
+ * data for a single comment.
+ *
+ * @param array &$comments Database result set of comments to be printed
+ * @param string $mode 'flat', 'threaded', etc
+ * @param string $type Type of item (article, polls, etc.)
+ * @param string $order How to order the comments 'ASC' or 'DESC'
+ * @param boolean $delete_option if current user can delete comments
+ * @param boolean $preview Preview display (for edit) or not
+ * @param int $commentCode Comment code: -1=no comments, 0=allowed, 1=closed
+ * @param int $commentPage page number of comments to display
+ * @return string HTML Formatted Comment
+ */
+function CMT_getComment(&$comments, $mode, $type, $order, $delete_option = false, $preview = false, $commentCode = 0,
+ $commentPage = 1)
{
global $_CONF, $_TABLES, $_USER, $LANG01, $LANG03, $MESSAGE, $_IMAGE_TYPE;
@@ -243,21 +238,23 @@ function CMT_getComment( &$comments, $mode, $type, $order, $delete_option = fals
$retval = ''; // initialize return value
$template = COM_newTemplate($_CONF['path_layout'] . 'comment');
- $template->set_file( array( 'comment' => 'comment.thtml',
- 'thread' => 'thread.thtml' ));
+ $template->set_file(array(
+ 'comment' => 'comment.thtml',
+ 'thread' => 'thread.thtml',
+ ));
// generic template variables
- $template->set_var( 'lang_authoredby', $LANG01[42] );
- $template->set_var( 'lang_on', $LANG01[36] );
- $template->set_var( 'lang_permlink', $LANG01[120] );
- $template->set_var( 'order', $order );
-
- if( $ccode == 0 ) {
- $template->set_var( 'lang_replytothis', $LANG01[43] );
- $template->set_var( 'lang_reply', $LANG01[25] );
+ $template->set_var('lang_authoredby', $LANG01[42]);
+ $template->set_var('lang_on', $LANG01[36]);
+ $template->set_var('lang_permlink', $LANG01[120]);
+ $template->set_var('order', $order);
+
+ if ($commentCode == 0) {
+ $template->set_var('lang_replytothis', $LANG01[43]);
+ $template->set_var('lang_reply', $LANG01[25]);
} else {
- $template->set_var( 'lang_replytothis', '' );
- $template->set_var( 'lang_reply', '' );
+ $template->set_var('lang_replytothis', '');
+ $template->set_var('lang_reply', '');
}
// Make sure we have a default value for comment indentation
@@ -267,7 +264,7 @@ function CMT_getComment( &$comments, $mode, $type, $order, $delete_option = fals
if ($preview) {
$A = $comments;
- if (empty( $A['nice_date'])) {
+ if (empty($A['nice_date'])) {
$A['nice_date'] = time();
}
if (!isset($A['cid'])) {
@@ -280,7 +277,7 @@ function CMT_getComment( &$comments, $mode, $type, $order, $delete_option = fals
$A['photo'] = '';
}
}
- if (! isset($A['email'])) {
+ if (!isset($A['email'])) {
if (isset($_USER['email'])) {
$A['email'] = $_USER['email'];
} else {
@@ -289,47 +286,46 @@ function CMT_getComment( &$comments, $mode, $type, $order, $delete_option = fals
}
$mode = 'flat';
} else {
- $A = DB_fetchArray( $comments );
+ $A = DB_fetchArray($comments);
}
if (empty($A)) {
return '';
}
- $commentmode = '';
+ $commentMode = '';
if (isset($_REQUEST[CMT_MODE])) {
- $commentmode = COM_applyFilter($_REQUEST[CMT_MODE]);
+ $commentMode = COM_applyFilter($_REQUEST[CMT_MODE]);
}
- $submit = (($commentmode == $LANG03[29]) || ($commentmode == $LANG03[35]));
+ $submit = (($commentMode == $LANG03[29]) || ($commentMode == $LANG03[35]));
$token = '';
if ($delete_option && !$preview && !$submit) {
$token = SEC_createToken();
}
// check for comment edit
-
$row = 1;
+
do {
// check for comment edit
- $commentedit = DB_query("SELECT cid,uid,UNIX_TIMESTAMP(time) AS time FROM {$_TABLES['commentedits']} WHERE cid = {$A['cid']}");
- $B = DB_fetchArray($commentedit);
+ $commentEdit = DB_query("SELECT cid,uid,UNIX_TIMESTAMP(time) AS time FROM {$_TABLES['commentedits']} WHERE cid = {$A['cid']}");
+ $B = DB_fetchArray($commentEdit);
if ($B) { //comment edit present
// get correct editor name
if ($A['uid'] == $B['uid']) {
- $editname = $A['username'];
+ $editName = $A['username'];
} else {
- $editname = DB_getItem($_TABLES['users'], 'username',
- "uid={$B['uid']}");
+ $editName = DB_getItem($_TABLES['users'], 'username', "uid={$B['uid']}");
}
// add edit info to text
$A['comment'] .= '';
+ . strftime($_CONF['date'], $B['time']) . ' '
+ . $LANG03[31] . ' ' . $editName
+ . '';
}
// determines indentation for current comment
- if ($mode == 'threaded' || $mode == 'nested') {
+ if ($mode === 'threaded' || $mode === 'nested') {
$indent = ($A['indent'] - $A['pindent']) * $_CONF['comment_indent'];
// set the maximum indentation level to 16
if ($indent > 400) {
@@ -340,7 +336,7 @@ function CMT_getComment( &$comments, $mode, $type, $order, $delete_option = fals
// Filemgmt plugin is doing special processing.
// Therefore, I support specially, against my better judgment.
// May should delete this code part.
- if ($type == 'filemgmt') {
+ if ($type === 'filemgmt') {
$A['sid'] = str_replace('fileid_', '', $A['sid']);
}
@@ -353,14 +349,14 @@ function CMT_getComment( &$comments, $mode, $type, $order, $delete_option = fals
if ($A['uid'] > 1) {
$fullname = '';
- if (! empty($A['fullname'])) {
+ if (!empty($A['fullname'])) {
$fullname = $A['fullname'];
}
$fullname = COM_getDisplayName($A['uid'], $A['username'],
- $fullname);
+ $fullname);
$template->set_var('author_fullname', $fullname);
$template->set_var('author', $fullname);
- $alttext = $fullname;
+ $altText = $fullname;
$photo = '';
if ($_CONF['allow_user_photo']) {
@@ -369,86 +365,84 @@ function CMT_getComment( &$comments, $mode, $type, $order, $delete_option = fals
}
$photo = USER_getPhoto($A['uid'], $A['photo'], $A['email']);
}
- $profile_link = $_CONF['site_url']
- . '/users.php?mode=profile&uid=' . $A['uid'];
- if (! empty($photo)) {
+ $profile_link = $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'];
+ if (!empty($photo)) {
$template->set_var('author_photo', $photo);
$camera_icon = ' ';
$template->set_var('camera_icon',
- COM_createLink($camera_icon, $profile_link));
+ COM_createLink($camera_icon, $profile_link));
} else {
$template->set_var('author_photo', '');
$template->set_var('camera_icon', '');
}
- $template->set_var('start_author_anchortag',
- '' );
+ $template->set_var('start_author_anchortag', ' ');
$template->set_var('end_author_anchortag', ' ');
- $template->set_var('author_link',
- COM_createLink($fullname, $profile_link));
-
+ $template->set_var('author_link', COM_createLink($fullname, $profile_link));
} else {
// comment is from anonymous user
if (isset($A['name'])) {
$A['username'] = strip_tags($A['name']);
}
- $template->set_var( 'author', $A['username'] );
- $template->set_var( 'author_fullname', $A['username'] );
- $template->set_var( 'author_link', $A['username'] );
- $template->set_var( 'author_photo', '' );
- $template->set_var( 'camera_icon', '' );
- $template->set_var( 'start_author_anchortag', '' );
- $template->set_var( 'end_author_anchortag', '' );
+ $template->set_var('author', $A['username']);
+ $template->set_var('author_fullname', $A['username']);
+ $template->set_var('author_link', $A['username']);
+ $template->set_var('author_photo', '');
+ $template->set_var('camera_icon', '');
+ $template->set_var('start_author_anchortag', '');
+ $template->set_var('end_author_anchortag', '');
}
// hide reply link from anonymous users if they can't post replies
- $hidefromanon = false;
+ $hideFromAnon = false;
if (COM_isAnonUser() && (($_CONF['loginrequired'] == 1) ||
- ($_CONF['commentsloginrequired'] == 1))) {
- $hidefromanon = true;
+ ($_CONF['commentsloginrequired'] == 1))
+ ) {
+ $hideFromAnon = true;
}
// this will hide HTML that should not be viewed in preview mode
- if( $preview || $hidefromanon ) {
- $template->set_var( 'hide_if_preview', 'style="display:none"' );
+ if ($preview || $hideFromAnon) {
+ $template->set_var('hide_if_preview', 'style="display:none"');
} else {
- $template->set_var( 'hide_if_preview', '' );
+ $template->set_var('hide_if_preview', '');
}
// for threaded mode, add a link to comment parent
- if( $mode == 'threaded' && $A['pid'] != 0 && $indent == 0 ) {
+ if ($mode === 'threaded' && $A['pid'] != 0 && $indent == 0) {
$pid = DB_getItem($_TABLES['comments'], 'pid',
- "cid = '{$A['pid']}'");
+ "cid = '{$A['pid']}'");
if ($pid != 0) {
- $plink = $_CONF['site_url'] . '/comment.php?mode=display'
- . '&sid=' . $A['sid'] . '&type=' . $type
- . '&order=' . $order . '&pid=' . $pid
- . '&format=threaded';
+ $pLink = $_CONF['site_url'] . '/comment.php?mode=display'
+ . '&sid=' . $A['sid'] . '&type=' . $type
+ . '&order=' . $order . '&pid=' . $pid
+ . '&format=threaded';
} else {
- $plink = $_CONF['site_url'] . '/comment.php?mode=view'
- . '&sid=' . $A['sid'] . '&type=' . $type
- . '&order=' . $order . '&cid=' . $A['pid']
- . '&format=threaded';
+ $pLink = $_CONF['site_url'] . '/comment.php?mode=view'
+ . '&sid=' . $A['sid'] . '&type=' . $type
+ . '&order=' . $order . '&cid=' . $A['pid']
+ . '&format=threaded';
}
- $parent_link = COM_createLink($LANG01[44], $plink) . ' | ';
+ $parent_link = COM_createLink($LANG01[44], $pLink) . ' | ';
$template->set_var('parent_link', $parent_link);
} else {
$template->set_var('parent_link', '');
}
- $template->set_var( 'date', strftime( $_CONF['date'], $A['nice_date'] ));
- $template->set_var( 'sid', $A['sid'] );
- $template->set_var( 'type', $A['type'] );
+ $template->set_var('date', strftime($_CONF['date'], $A['nice_date']));
+ $template->set_var('sid', $A['sid']);
+ $template->set_var('type', $A['type']);
// COMMENT edit rights
$edit_option = false;
if (isset($A['uid']) && isset($_USER['uid'])
- && ($_USER['uid'] == $A['uid']) && ($_CONF['comment_edit'] == 1)
- && ((time() - $A['nice_date']) < $_CONF['comment_edittime'])
- && (DB_getItem($_TABLES['comments'], 'COUNT(*)',
- "pid = {$A['cid']}") == 0)) {
+ && ($_USER['uid'] == $A['uid']) && ($_CONF['comment_edit'] == 1)
+ && ((time() - $A['nice_date']) < $_CONF['comment_edittime'])
+ && (DB_getItem($_TABLES['comments'], 'COUNT(*)',
+ "pid = {$A['cid']}") == 0)
+ ) {
$edit_option = true;
if (empty($token) && !$preview && !$submit) {
$token = SEC_createToken();
@@ -458,109 +452,108 @@ function CMT_getComment( &$comments, $mode, $type, $order, $delete_option = fals
}
if (COMMENT_ON_SAME_PAGE) {
- list($plgurl, $plgid) = CMT_getCommentUrlId($type);
+ list($pluginUrl, $pluginId) = CMT_getCommentUrlId($type);
}
// edit link
$edit = '';
if ($edit_option) {
if (COMMENT_ON_SAME_PAGE) {
- $editlink = $plgurl . '?' . CMT_MODE . '=edit&' . CMT_CID . '='
- . $A['cid'] . "&$plgid=" . $A['sid'] . '&' . CMT_TYPE . '=' . $type
+ $editLink = $pluginUrl . '?' . CMT_MODE . '=edit&' . CMT_CID . '='
+ . $A['cid'] . "&$pluginId=" . $A['sid'] . '&' . CMT_TYPE . '=' . $type
. '&mode=' . $mode
. '&order=' . $order
- . '&cpage=' . $cpage
+ . '&cpage=' . $commentPage
. '#commenteditform';
} else {
- $editlink = $_CONF['site_url'] . '/comment.php?mode=edit&cid='
+ $editLink = $_CONF['site_url'] . '/comment.php?mode=edit&cid='
. $A['cid'] . '&sid=' . $A['sid'] . '&type=' . $type;
}
- $edit = COM_createLink($LANG01[4], $editlink) . ' | ';
+ $edit = COM_createLink($LANG01[4], $editLink) . ' | ';
}
// unsubscribe link
$unsubscribe = '';
if (($_CONF['allow_reply_notifications'] == 1) && !COM_isAnonUser()
- && isset($A['uid']) && isset($_USER['uid'])
- && ($_USER['uid'] == $A['uid'])) {
+ && isset($A['uid']) && isset($_USER['uid'])
+ && ($_USER['uid'] == $A['uid'])
+ ) {
$hash = DB_getItem($_TABLES['commentnotifications'], 'deletehash',
- "cid = {$A['cid']} AND uid = {$_USER['uid']}");
- if (! empty($hash)) {
+ "cid = {$A['cid']} AND uid = {$_USER['uid']}");
+ if (!empty($hash)) {
if (COMMENT_ON_SAME_PAGE) {
- $unsublink = $plgurl . '?' . CMT_MODE . "=unsubscribe&$plgid="
- . $A['sid'] . '&key=' . $hash;
+ $unsubLink = $pluginUrl . '?' . CMT_MODE . "=unsubscribe&$pluginId="
+ . $A['sid'] . '&key=' . $hash;
} else {
- $unsublink = $_CONF['site_url']
- . '/comment.php?mode=unsubscribe&key=' . $hash;
+ $unsubLink = $_CONF['site_url']
+ . '/comment.php?mode=unsubscribe&key=' . $hash;
}
- $unsubattr = array('title' => $LANG03[43]);
- $unsubscribe = COM_createLink($LANG03[42], $unsublink,
- $unsubattr) . ' | ';
+ $unsubAttr = array('title' => $LANG03[43]);
+ $unsubscribe = COM_createLink($LANG03[42], $unsubLink, $unsubAttr) . ' | ';
}
}
// if deletion is allowed, displays delete link
if ($delete_option) {
- $deloption = '';
+ $delOption = '';
// always place edit option first, if available
- if (! empty($edit)) {
- $deloption .= $edit;
+ if (!empty($edit)) {
+ $delOption .= $edit;
}
// actual delete option
if (COMMENT_ON_SAME_PAGE) {
- $dellink = $plgurl .'?' . CMT_MODE . '=delete&' . CMT_CID . '='
- . $A['cid'] . "&$plgid=" . $A['sid'] . '&' . CMT_TYPE . '=' . $type
+ $delLink = $pluginUrl . '?' . CMT_MODE . '=delete&' . CMT_CID . '='
+ . $A['cid'] . "&$pluginId=" . $A['sid'] . '&' . CMT_TYPE . '=' . $type
. '&' . CSRF_TOKEN . '=' . $token;
} else {
- $dellink = $_CONF['site_url'] . '/comment.php?mode=delete&cid='
+ $delLink = $_CONF['site_url'] . '/comment.php?mode=delete&cid='
. $A['cid'] . '&sid=' . $A['sid'] . '&type=' . $type
. '&' . CSRF_TOKEN . '=' . $token;
}
- $delattr = array('onclick' => "return confirm('{$MESSAGE[76]}');");
- $deloption .= COM_createLink($LANG01[28], $dellink, $delattr) . ' | ';
+ $delAttr = array('onclick' => "return confirm('{$MESSAGE[76]}');");
+ $delOption .= COM_createLink($LANG01[28], $delLink, $delAttr) . ' | ';
if (!empty($A['ipaddress'])) {
if (empty($_CONF['ip_lookup'])) {
- $deloption .= $A['ipaddress'] . ' | ';
+ $delOption .= $A['ipaddress'] . ' | ';
} else {
- $iplookup = str_replace('*', $A['ipaddress'],
- $_CONF['ip_lookup']);
- $deloption .= COM_createLink($A['ipaddress'], $iplookup) . ' | ';
+ $ipLookUp = str_replace('*', $A['ipaddress'], $_CONF['ip_lookup']);
+ $delOption .= COM_createLink($A['ipaddress'], $ipLookUp) . ' | ';
}
}
- if (! empty($unsubscribe)) {
- $deloption .= $unsubscribe;
+ if (!empty($unsubscribe)) {
+ $delOption .= $unsubscribe;
}
- $template->set_var('delete_option', $deloption);
+ $template->set_var('delete_option', $delOption);
} elseif ($edit_option) {
$template->set_var('delete_option', $edit . $unsubscribe);
- } elseif (! COM_isAnonUser()) {
- $reportthis = '';
+ } elseif (!COM_isAnonUser()) {
+ $reportThis = '';
if ($A['uid'] != $_USER['uid']) {
if (COMMENT_ON_SAME_PAGE) {
- $reportthis_link = $plgurl .'?' . CMT_MODE . '=report&' . CMT_CID . '=' . $A['cid']
+ $reportThisLink = $pluginUrl . '?' . CMT_MODE . '=report&' . CMT_CID . '=' . $A['cid']
. '&' . CMT_TYPE . '=' . $type;
} else {
- $reportthis_link = $_CONF['site_url']
+ $reportThisLink = $_CONF['site_url']
. '/comment.php?mode=report&cid=' . $A['cid']
. '&type=' . $type;
}
$report_attr = array('title' => $LANG01[110]);
- $reportthis = COM_createLink($LANG01[109], $reportthis_link,
- $report_attr) . ' | ';
+ $reportThis = COM_createLink($LANG01[109], $reportThisLink,
+ $report_attr) . ' | ';
}
- $template->set_var('delete_option', $reportthis . $unsubscribe);
+ $template->set_var('delete_option', $reportThis . $unsubscribe);
} else {
$template->set_var('delete_option', '');
}
//and finally: format the actual text of the comment, but check only the text, not sig or edit
$text = str_replace('', '', $text);
$text = str_replace('', '', $text);
@@ -569,35 +562,34 @@ function CMT_getComment( &$comments, $mode, $type, $order, $delete_option = fals
}
// highlight search terms if specified
- if( !empty( $_REQUEST['query'] )) {
- $A['comment'] = COM_highlightQuery( $A['comment'],
- $_REQUEST['query'] );
+ if (!empty($_REQUEST['query'])) {
+ $A['comment'] = COM_highlightQuery($A['comment'],
+ $_REQUEST['query']);
}
- $A['comment'] = str_replace( '$', '$', $A['comment'] );
- $A['comment'] = str_replace( '{', '{', $A['comment'] );
- $A['comment'] = str_replace( '}', '}', $A['comment'] );
+ $A['comment'] = str_replace('$', '$', $A['comment']);
+ $A['comment'] = str_replace('{', '{', $A['comment']);
+ $A['comment'] = str_replace('}', '}', $A['comment']);
// Replace any plugin autolink tags
- $A['comment'] = PLG_replaceTags( $A['comment'] );
+ $A['comment'] = PLG_replaceTags($A['comment']);
// create a reply to link
$reply_link = '';
- if ($ccode == 0) {
+ if ($commentCode == 0) {
if (COMMENT_ON_SAME_PAGE) {
- $reply_link = $plgurl ."?$plgid=" . $A['sid']
- . '&' . CMT_PID . '=' . $A['cid']
- . '&' . CMT_TYPE . '=' . $A['type']
- . '&mode=' . $mode
- . '&order=' . $order
- . '&cpage=' . $cpage
- . '#commenteditform';
+ $reply_link = $pluginUrl . "?$pluginId=" . $A['sid']
+ . '&' . CMT_PID . '=' . $A['cid']
+ . '&' . CMT_TYPE . '=' . $A['type']
+ . '&mode=' . $mode
+ . '&order=' . $order
+ . '&cpage=' . $commentPage
+ . '#commenteditform';
} else {
$reply_link = $_CONF['site_url'] . '/comment.php?sid=' . $A['sid']
- . '&pid=' . $A['cid'] . '&type=' . $A['type'];
+ . '&pid=' . $A['cid'] . '&type=' . $A['type'];
}
- $reply_option = COM_createLink($LANG01[43], $reply_link,
- array('rel' => 'nofollow')) . ' | ';
+ $reply_option = COM_createLink($LANG01[43], $reply_link, array('rel' => 'nofollow')) . ' | ';
$template->set_var('reply_option', $reply_option);
} else {
$template->set_var('reply_option', '');
@@ -605,118 +597,115 @@ function CMT_getComment( &$comments, $mode, $type, $order, $delete_option = fals
$template->set_var('reply_link', $reply_link);
// format title for display, must happen after reply_link is created
- $A['title'] = htmlspecialchars( $A['title'] );
- $A['title'] = str_replace( '$', '$', $A['title'] );
+ $A['title'] = htmlspecialchars($A['title']);
+ $A['title'] = str_replace('$', '$', $A['title']);
- $template->set_var( 'title', $A['title'] );
- $template->set_var( 'comments', $A['comment'] );
+ $template->set_var('title', $A['title']);
+ $template->set_var('comments', $A['comment']);
// parse the templates
- if( ($mode == 'threaded') && $indent > 0 ) {
- $template->set_var( 'pid', $A['pid'] );
- $retval .= $template->parse( 'output', 'thread' );
+ if (($mode === 'threaded') && $indent > 0) {
+ $template->set_var('pid', $A['pid']);
+ $retval .= $template->parse('output', 'thread');
} else {
- $template->set_var( 'pid', $A['cid'] );
- $retval .= $template->parse( 'output', 'comment' );
+ $template->set_var('pid', $A['cid']);
+ $retval .= $template->parse('output', 'comment');
}
$row++;
- } while( !$preview && ($A = DB_fetchArray( $comments )));
-
+ } while (!$preview && ($A = DB_fetchArray($comments)));
return $retval;
}
/**
-* This function displays the comments in a high level format.
-*
-* Begins displaying user comments for an item
-*
-* @param string $sid ID for item to show comments for
-* @param string $title Title of item
-* @param string $type Type of item (article, polls, etc.)
-* @param string $order How to order the comments 'ASC' or 'DESC'
-* @param string $mode comment mode (nested, flat, etc.)
-* @param int $pid id of parent comment
-* @param int $page page number of comments to display
-* @param boolean $cid true if $pid should be interpreted as a cid instead
-* @param boolean $delete_option if current user can delete comments
-* @param int $ccode Comment code: -1=no comments, 0=allowed, 1=closed
-* @return string HTML Formated Comments
-* @see CMT_commentBar
-*
-*/
-function CMT_userComments( $sid, $title, $type='article', $order='', $mode='', $pid = 0, $page = 1, $cid = false, $delete_option = false, $ccode = 0 )
+ * This function displays the comments in a high level format.
+ * Begins displaying user comments for an item
+ *
+ * @param string $sid ID for item to show comments for
+ * @param string $title Title of item
+ * @param string $type Type of item (article, polls, etc.)
+ * @param string $order How to order the comments 'ASC' or 'DESC'
+ * @param string $mode comment mode (nested, flat, etc.)
+ * @param int $pid id of parent comment
+ * @param int $page page number of comments to display
+ * @param boolean $cid true if $pid should be interpreted as a cid instead
+ * @param boolean $delete_option if current user can delete comments
+ * @param int $commentCode Comment code: -1=no comments, 0=allowed, 1=closed
+ * @return string HTML Formatted Comments
+ * @see CMT_commentBar
+ */
+function CMT_userComments($sid, $title, $type = 'article', $order = '', $mode = '', $pid = 0, $page = 1, $cid = false, $delete_option = false, $commentCode = 0)
{
global $_CONF, $_TABLES, $_USER, $LANG01;
$retval = '';
- if (! COM_isAnonUser()) {
- $result = DB_query( "SELECT commentorder,commentmode,commentlimit FROM {$_TABLES['usercomment']} WHERE uid = '{$_USER['uid']}'" );
- $U = DB_fetchArray( $result );
- if( empty( $order ) ) {
+ if (!COM_isAnonUser()) {
+ $result = DB_query("SELECT commentorder,commentmode,commentlimit FROM {$_TABLES['usercomment']} WHERE uid = '{$_USER['uid']}'");
+ $U = DB_fetchArray($result);
+ if (empty($order)) {
$order = $U['commentorder'];
}
- if( empty( $mode ) ) {
+ if (empty($mode)) {
$mode = $U['commentmode'];
}
$limit = $U['commentlimit'];
}
- if( $order != 'ASC' && $order != 'DESC' ) {
+ if ($order != 'ASC' && $order != 'DESC') {
$order = $_CONF['comment_order'];
}
- if( empty( $mode )) {
+ if (empty($mode)) {
$mode = $_CONF['comment_mode'];
}
- if( empty( $limit )) {
+ if (empty($limit)) {
$limit = $_CONF['comment_limit'];
}
- if( !is_numeric($page) || $page < 1 ) {
+ if (!is_numeric($page) || $page < 1) {
$page = 1;
}
- $start = $limit * ( $page - 1 );
+ $start = $limit * ($page - 1);
$template = COM_newTemplate($_CONF['path_layout'] . 'comment');
- $template->set_file( array( 'commentarea' => 'startcomment.thtml' ));
- $template->set_var( 'commentbar',
- CMT_commentBar( $sid, $title, $type, $order, $mode, $ccode ));
- $template->set_var( 'sid', $sid );
- $template->set_var( 'comment_type', $type );
- $template->set_var( 'area_id', 'commentarea' );
-
- if( $mode == 'nested' || $mode == 'threaded' || $mode == 'flat' ) {
+ $template->set_file(array('commentarea' => 'startcomment.thtml'));
+ $template->set_var('commentbar',
+ CMT_commentBar($sid, $title, $type, $order, $mode, $commentCode));
+ $template->set_var('sid', $sid);
+ $template->set_var('comment_type', $type);
+ $template->set_var('area_id', 'commentarea');
+
+ if ($mode === 'nested' || $mode === 'threaded' || $mode === 'flat') {
// build query
- switch( $mode ) {
+ switch ($mode) {
case 'flat':
- if( $cid ) {
+ if ($cid) {
$count = 1;
$q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, "
- . "UNIX_TIMESTAMP(c.date) AS nice_date "
- . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u "
- . "WHERE c.uid = u.uid AND c.cid = $pid AND type='{$type}'";
+ . "UNIX_TIMESTAMP(c.date) AS nice_date "
+ . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u "
+ . "WHERE c.uid = u.uid AND c.cid = $pid AND type='{$type}'";
} else {
- $count = DB_count( $_TABLES['comments'],
- array( 'sid', 'type' ), array( $sid, $type ));
+ $count = DB_count($_TABLES['comments'],
+ array('sid', 'type'), array($sid, $type));
$q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, "
- . "UNIX_TIMESTAMP(c.date) AS nice_date "
- . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u "
- . "WHERE c.uid = u.uid AND c.sid = '$sid' AND type='{$type}' "
- . "ORDER BY date $order LIMIT $start, $limit";
+ . "UNIX_TIMESTAMP(c.date) AS nice_date "
+ . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u "
+ . "WHERE c.uid = u.uid AND c.sid = '$sid' AND type='{$type}' "
+ . "ORDER BY date $order LIMIT $start, $limit";
}
break;
case 'nested':
case 'threaded':
default:
- if( $order == 'DESC' ) {
+ if ($order === 'DESC') {
$cOrder = 'c.rht DESC';
} else {
$cOrder = 'c.lft ASC';
@@ -724,33 +713,33 @@ function CMT_userComments( $sid, $title, $type='article', $order='', $mode='', $
// We can simplify the query, and hence increase performance
// when pid = 0 (when fetching all the comments for a given sid)
- if( $cid ) { // pid refers to commentid rather than parentid
+ if ($cid) { // pid refers to commentid rather than parentid
// count the total number of applicable comments
$q2 = "SELECT COUNT(*) "
. "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2 "
. "WHERE c.sid = '$sid' AND (c.lft >= c2.lft AND c.lft <= c2.rht) "
. "AND c2.cid = $pid AND c.type='{$type}'";
- $result = DB_query( $q2 );
- list( $count ) = DB_fetchArray( $result );
+ $result = DB_query($q2);
+ list($count) = DB_fetchArray($result);
$q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, c2.indent AS pindent, "
- . "UNIX_TIMESTAMP(c.date) AS nice_date "
- . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2, "
- . "{$_TABLES['users']} AS u "
- . "WHERE c.sid = '$sid' AND (c.lft >= c2.lft AND c.lft <= c2.rht) "
- . "AND c2.cid = $pid AND c.uid = u.uid AND c.type='{$type}' "
- . "ORDER BY $cOrder LIMIT $start, $limit";
+ . "UNIX_TIMESTAMP(c.date) AS nice_date "
+ . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2, "
+ . "{$_TABLES['users']} AS u "
+ . "WHERE c.sid = '$sid' AND (c.lft >= c2.lft AND c.lft <= c2.rht) "
+ . "AND c2.cid = $pid AND c.uid = u.uid AND c.type='{$type}' "
+ . "ORDER BY $cOrder LIMIT $start, $limit";
} else { // pid refers to parentid rather than commentid
- if( $pid == 0 ) { // the simple, fast case
+ if ($pid == 0) { // the simple, fast case
// count the total number of applicable comments
- $count = DB_count( $_TABLES['comments'],
- array( 'sid', 'type' ), array( $sid, $type ));
+ $count = DB_count($_TABLES['comments'],
+ array('sid', 'type'), array($sid, $type));
$q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, 0 AS pindent, "
- . "UNIX_TIMESTAMP(c.date) AS nice_date "
- . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u "
- . "WHERE c.sid = '$sid' AND c.uid = u.uid AND type='{$type}' "
- . "ORDER BY $cOrder LIMIT $start, $limit";
+ . "UNIX_TIMESTAMP(c.date) AS nice_date "
+ . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u "
+ . "WHERE c.sid = '$sid' AND c.uid = u.uid AND type='{$type}' "
+ . "ORDER BY $cOrder LIMIT $start, $limit";
} else {
// count the total number of applicable comments
$q2 = "SELECT COUNT(*) "
@@ -761,57 +750,57 @@ function CMT_userComments( $sid, $title, $type='article', $order='', $mode='', $
list($count) = DB_fetchArray($result);
$q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, c2.indent + 1 AS pindent, "
- . "UNIX_TIMESTAMP(c.date) AS nice_date "
- . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2, "
- . "{$_TABLES['users']} AS u "
- . "WHERE c.sid = '$sid' AND (c.lft > c2.lft AND c.lft < c2.rht) "
- . "AND c2.cid = $pid AND c.uid = u.uid AND c.type='{$type}' "
- . "ORDER BY $cOrder LIMIT $start, $limit";
+ . "UNIX_TIMESTAMP(c.date) AS nice_date "
+ . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2, "
+ . "{$_TABLES['users']} AS u "
+ . "WHERE c.sid = '$sid' AND (c.lft > c2.lft AND c.lft < c2.rht) "
+ . "AND c2.cid = $pid AND c.uid = u.uid AND c.type='{$type}' "
+ . "ORDER BY $cOrder LIMIT $start, $limit";
}
}
break;
}
- $thecomments = '';
- $result = DB_query( $q );
+ $theComments = '';
+ $result = DB_query($q);
if (DB_numRows($result) == 0) {
if ($page > 1) {
- list($plgurl, $plgid) = CMT_getCommentUrlId($type);
- $plglink = '';
- if (!empty($plgurl)) {
- $plglink = "$plgurl?$plgid=$sid";
+ list($pluginUrl, $pluginId) = CMT_getCommentUrlId($type);
+ $pluginLink = '';
+ if (!empty($pluginUrl)) {
+ $pluginLink = "$pluginUrl?$pluginId=$sid";
}
// Requested invalid page
- COM_handle404($plglink);
+ COM_handle404($pluginLink);
}
}
- $thecomments .= CMT_getComment( $result, $mode, $type, $order,
- $delete_option, false, $ccode, $page );
+ $theComments .= CMT_getComment($result, $mode, $type, $order,
+ $delete_option, false, $commentCode, $page);
// Pagination
- $tot_pages = ceil($count / $limit);
+ $tot_pages = ceil($count / $limit);
$is_comment_page = CMT_isCommentPage();
if ($is_comment_page) {
$pLink[0] = "comment.php?sid=$sid";
$pLink[0] .= "&" . CMT_TYPE . "=$type&order=$order&format=$mode";
} else {
- list($plgurl, $plgid) = CMT_getCommentUrlId($type);
- $pLink[0] = "$plgurl?$plgid=$sid";
+ list($pluginUrl, $pluginId) = CMT_getCommentUrlId($type);
+ $pLink[0] = "$pluginUrl?$pluginId=$sid";
$pLink[0] .= "&" . CMT_TYPE . "=$type&order=$order&mode=$mode";
}
$pLink[1] = "#comments";
$page_str = "cpage=";
$template->set_var('pagenav',
- COM_printPageNavigation($pLink, $page, $tot_pages, $page_str, false));
+ COM_printPageNavigation($pLink, $page, $tot_pages, $page_str, false));
- $template->set_var('comments', $thecomments);
+ $template->set_var('comments', $theComments);
if (COMMENT_ON_SAME_PAGE) {
- if ($ccode == 0) {
- $cmode = COM_applyFilter(COM_getArgument(CMT_MODE));
- $html = CMT_handleComment($cmode, $type, $title, $sid, $mode);
+ if ($commentCode == 0) {
+ $cMode = COM_applyFilter(COM_getArgument(CMT_MODE));
+ $html = CMT_handleComment($cMode, $type, $title, $sid, $mode);
$template->set_var('commenteditor', $html);
}
}
@@ -823,45 +812,43 @@ function CMT_userComments( $sid, $title, $type='article', $order='', $mode='', $
}
/**
-* Displays the comment form
-*
-* @param string $title Title of comment
-* @param string $comment Text of comment
-* @param string $sid ID of object comment belongs to
-* @param int $pid ID of parent comment
-* @param string $type Type of object comment is posted to
-* @param string $mode Mode, e.g. 'preview'
-* @param string $postmode Indicates if comment is plain text or HTML
-* @param string $format 'threaded', 'nested', or 'flat'
-* @param string $order 'ASC' or 'DESC' or blank
-* @param int $page Page number of comments to display
-* @return string HTML for comment form
-*
-*/
-function CMT_commentForm($title, $comment, $sid, $pid='0', $type, $mode, $postmode, $format='', $order='', $page='')
+ * Displays the comment form
+ *
+ * @param string $title Title of comment
+ * @param string $comment Text of comment
+ * @param string $sid ID of object comment belongs to
+ * @param int $pid ID of parent comment
+ * @param string $type Type of object comment is posted to
+ * @param string $mode Mode, e.g. 'preview'
+ * @param string $postMode Indicates if comment is plain text or HTML
+ * @param string $format 'threaded', 'nested', or 'flat'
+ * @param string $order 'ASC' or 'DESC' or blank
+ * @param int $page Page number of comments to display
+ * @return string HTML for comment form
+ */
+function CMT_commentForm($title, $comment, $sid, $pid = 0, $type, $mode, $postMode, $format = '', $order = '', $page = 0)
{
global $_CONF, $_TABLES, $_USER, $LANG01, $LANG03, $LANG12, $LANG_ADMIN
- , $LANG_ACCESS, $MESSAGE, $_SCRIPTS;
+ , $LANG_ACCESS, $MESSAGE, $_SCRIPTS;
$retval = '';
// never trust $uid ...
- if (empty ($_USER['uid'])) {
+ if (empty($_USER['uid'])) {
$uid = 1;
} else {
$uid = $_USER['uid'];
}
if (empty($format)) {
- if(isset($_REQUEST['format'])) {
+ if (isset($_REQUEST['format'])) {
$format = COM_applyFilter($_REQUEST['format']);
}
if (!in_array($format, array('threaded', 'nested', 'flat', 'nocomment'))) {
if (COM_isAnonUser()) {
$format = $_CONF['comment_mode'];
} else {
- $format = DB_getItem( $_TABLES['usercomment'], 'commentmode',
- "uid = $uid" );
+ $format = DB_getItem($_TABLES['usercomment'], 'commentmode', "uid = {$uid}");
}
}
}
@@ -879,36 +866,39 @@ function CMT_commentForm($title, $comment, $sid, $pid='0', $type, $mode, $postmo
}
}
- $commentuid = $uid;
+ $commentUid = $uid;
$table = '';
- if ($mode == 'edit' || $mode == $LANG03[28]) {
+ if ($mode === 'edit' || $mode === $LANG03[28]) {
$table = $_TABLES['comments'];
- } elseif ($mode == 'editsubmission' || $mode == $LANG03[34]) {
+ } elseif ($mode === 'editsubmission' || $mode == $LANG03[34]) {
$table = $_TABLES['commentsubmissions'];
}
if (!empty($table)) {
$cid = 0;
if (isset($_REQUEST[CMT_CID])) {
- $cid = COM_applyFilter ($_REQUEST[CMT_CID], true);
+ $cid = COM_applyFilter($_REQUEST[CMT_CID], true);
}
if ($cid <= 0) {
COM_redirect($_CONF['site_url'] . '/index.php');
}
- $commentuid = DB_getItem ($table, 'uid', "cid = '$cid'");
+ $commentUid = DB_getItem($table, 'uid', "cid = '$cid'");
}
if (COM_isAnonUser() &&
- (($_CONF['loginrequired'] == 1) || ($_CONF['commentsloginrequired'] == 1))) {
+ (($_CONF['loginrequired'] == 1) || ($_CONF['commentsloginrequired'] == 1))
+ ) {
$retval .= SEC_loginRequiredForm();
+
return $retval;
} else {
- COM_clearSpeedlimit ($_CONF['commentspeedlimit'], 'comment');
+ COM_clearSpeedlimit($_CONF['commentspeedlimit'], 'comment');
$last = 0;
- if ($mode != 'edit' && $mode != 'editsubmission'
- && $mode != $LANG03[28] && $mode != $LANG03[34]) {
+ if ($mode !== 'edit' && $mode !== 'editsubmission'
+ && $mode != $LANG03[28] && $mode != $LANG03[34]
+ ) {
// not edit mode or preview changes
- $last = COM_checkSpeedlimit ('comment');
+ $last = COM_checkSpeedlimit('comment');
}
if ($last > 0) {
@@ -918,70 +908,70 @@ function CMT_commentForm($title, $comment, $sid, $pid='0', $type, $mode, $postmo
$retval .= COM_showMessageText($LANG03[7] . $last . $LANG03[8], $LANG12[26]);
}
} else {
-
// Add JavaScript
$_SCRIPTS->setJavaScriptFile('postmode_control', '/javascript/postmode_control.js');
- if (($postmode != 'html') && ($postmode != 'plaintext')) {
- if (empty($postmode) && $_CONF['advanced_editor'] && $_USER['advanced_editor']) {
- $postmode = 'html';
- } elseif (empty($postmode)) {
- $postmode = $_CONF['postmode'];
+ if (($postMode !== 'html') && ($postMode !== 'plaintext')) {
+ if (empty($postMode) && $_CONF['advanced_editor'] && $_USER['advanced_editor']) {
+ $postMode = 'html';
+ } elseif (empty($postMode)) {
+ $postMode = $_CONF['postmode'];
}
}
$sig = '';
if ($uid > 1) {
- $sig = DB_getItem ($_TABLES['users'], 'sig', "uid = '$uid'");
+ $sig = DB_getItem($_TABLES['users'], 'sig', "uid = '$uid'");
}
// Note:
- // $comment / $newcomment is what goes into the preview / is
+ // $comment / $newComment is what goes into the preview / is
// actually stored in the database -> strip HTML
- // $commenttext is what the user entered and goes back into the
+ // $commentText is what the user entered and goes back into the
//