Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Blocks
Author Message
hicuxunicorniobestbuildpc
The Mouse Is Extension Of Arm



Joined: Aug 13, 2009
Posts: 1122

PostPosted: Sat Oct 12, 2013 5:03 am Reply with quote

I've been checking the whole block today and I decided to convert the whole block to single quotes. I would like to hear from you if we could make any other change. This one has a mod included.

Code:
<?php

/*************************************************************************/
/* Tableless CSS Sprite Powered Info Box Block by                        */
/* SpasticDonkey - web-cms-designs.com                                   */
/* Inspired by: Info Box for RavenNuke by nukecoder.com                  */
/* RavenWebServices User Info Block [ Only registered users can see links on this board! Get registered or login! ]             */
/* nukeNAV by nukeSEO nukeseo.com                                        */
/* Icons adapted from the Crystal project [ Only registered users can see links on this board! Get registered or login! ] and  */
/* the Tango Desktop Project tango.freedesktop.org/Tango_Desktop_Project */
/* Intended for use on RavenNuke(tm) v2.5+                               */
/*************************************************************************/
if ( !defined('BLOCK_FILE') ) {
    Header('Location: ../index.php');
    die();
}
date_default_timezone_set('Europe/Amsterdam');
if (!isset($side)) { $side = ''; }
if ($side == 'c' || $side == 'd' || $side == 't') { $IBCentermode = true; } else { $IBCentermode = false; }
if (!defined('PHP_EOL')) define ('PHP_EOL', strtoupper(substr(PHP_OS,0,3) == 'WIN') ? "\r\n" : "\n");
/*********************************************************************************************************/
/* Setup - Use these settings to control how the user info block displays to users/admins/anonymous.     */
/*********************************************************************************************************/
/* MEMBER TOTALS SECTION */
$membercounter_view  = 1;  // MEMBER TOTALS SECTION: Who can view? 0=everyone 1=user-only 2=admin-only 3=disable
$zero_in_column_view = 2;  // If zero registrations during period show column to: 0=everyone 1=user-only 2=admin-only 3=disable
/* RECENT MEMBER SECTION */
$recent_member_view  = 1; // RECENT MEMBER SECTION: Who can view? 0=everyone 1=user-only 2=admin-only 3=disable
$recent_member_count = 1; // how many newest members to show to all
$recent_member_user  = 2; // how many newest members to show to users
$recent_member_admin = 4; // how many newest members to show to admins
/* ONLINE NOW SECTION */
$who_is_online_view  = 0; // ONLINE NOW SECTION: Who can view? 0=everyone 1=user-only 2=admin-only 3=disable
$show_guest_guest    = 2; // show online guests to 0=everyone 1=user-only 2=admin-only 3=disable
$max_display_guests  = 40; // maximum number of online guests to display
$max_display_members = 40; // maximum number of online members to display
$showonlinecount     = 1; // total count of online guests/members: Who can view? 0=everyone 1=user-only 2=admin-only 3=disable
$max_session_mins    = 60; // how long before inactive users are dropped from online list
/* LAST SEEN MEMBER SECTION */
$lastseen_user_view  = 0; // LAST SEEN MEMBER SECTION: Who can view? 0=everyone 1=user-only 2=admin-only 3=disable
$lastseen_count      = 2; // how many last seen members to show to all
$lastseen_count_user = 4; // how many last seen members to show to users
$lastseen_count_admn = 6; // how many last seen members to show to admins
/* SERVER TRAFFIC SECTION */
$servertraffic_view  = 0;  // SERVER TRAFFIC SECTION: Who can view? 0=everyone 1=user-only 2=admin-only 3=disable
$traffic_year_view   = 1;  // Traffic stats by year: Who can view? 0=everyone 1=user-only 2=admin-only 3=disable
$how_many_years      = 2;  // how many years to display in traffic stats
/* GENERAL BLOCK SETTINGS */
$nameMaxLength       = 13; // Max length for username display.  Will truncate with ...
$langMaxLength       = 17; // Max length for some problem language defines.  Will display in smaller font-size
$LargeSectionIcons   = true; // use 32x32 icons for the sections
$display_lost_pass   = true; // set to false to hide the lost password link (displays in smaller font in some languages)
$pm_colorbox_notice  = true; // if set to true, users will only be notified of private messages once per session
$UsemodalLogin       = true; // modal login popup - nukeNAV module must be ACTIVE!
$UseSearchPopUp      = true; // modal search popup - nukeNAV and Search modules must be ACTIVE!
$whoisUseModal       = true; //admin ip lookup in modal window
$OnlineGuestsModal   = true; //compact the online guests into one modal link
$whoisServerString   = 'whois.domaintools.com/'; //admin ip lookup
if ($IBCentermode) { // <- do not edit
/*********************************************************************************************************/
/* CENTER BLOCK SETTINGS (only used when in center position, overrides settings above)                   */
/*********************************************************************************************************/
$membercounter_view  = 0;
$zero_in_column_view = 2;
$recent_member_view  = 0;
$recent_member_count = 2;
$recent_member_user  = 2;
$recent_member_admin = 2;
$who_is_online_view  = 0;
$show_guest_guest    = 0;
$max_display_guests  = 20;
$max_display_members = 6;
$showonlinecount     = 0;
$lastseen_user_view  = 0;
$lastseen_count      = 6;
$lastseen_count_user = 6;
$lastseen_count_admn = 6;
$servertraffic_view  = 0;
$traffic_year_view   = 0;
$how_many_years      = 2;
$LargeSectionIcons   = true;
} // <- do not edit
/*********************************************************************************************************/
/* Sprite Settings - For more info see http://www.rtsforce.com/InfoBox-CSS/                              */
/*********************************************************************************************************/
$IBtran          = 'images/transparent.gif'; // source for the transparent gif sprite container
$IBicon          = 'IBWhite'; // default classes for icons (changed by theme below unless $MultiThemeMode = false)
$rnIBicon        = 'rnIBicon'; // default classes for icons (changed by theme below unless $MultiThemeMode = false)
$MultiThemeMode  = true; // false to disable loading theme specific icons, and ignore array settings below - see readme
$rnIBWhite       = array('3D-Fantasy', 'DeepBlue', 'ExtraLite', 'NukeNews', 'Slash', 'SlashOcean', 'Traditional'); // Themes with white block backgrounds
$rnIBGray        = array('Anagram', 'Karate', 'Milo'); // Themes with gray block backgrounds
$rnIBCreme       = array('Sunset'); // Themes with creme block backgrounds
$rnIBSimplyBlue  = array('SimplyBlue'); // Themes with sky blue block backgrounds
$rnIBSandJourney = array('Sand_Journey'); // Themes with sand block backgrounds
$rnIBBlueBlog    = array('Blue_Blog'); // Themes with taupe block backgrounds
$rnIBCTRN        = array('CT_RN'); // Themes with crimson backgrounds
$rnIBRavenIce    = array('RavenIce', 'fisubice'); // Themes with off-white/blue block backgrounds
$rnIBKaput       = array('Kaput'); // Themes with blue/gray block backgrounds
$rnIBBlack       = array(); // Themes with black block backgrounds
$rnIBExtra       = array(); // An extra group for other themes (use class rnIBExtra and IBExtra to define your sprite background - see readme)
/*********************************************************************************************************/
/* You should not need to modify anything below this line                                                */
/*********************************************************************************************************/
global $db, $prefix, $ya_config, $anonymous, $nukeurl, $user_prefix, $user, $sitekey, $gfx_chk, $admin, $currentlang, $language, $startdate, $name, $nukeurl;
//Translation
$translang='en'; //for a list of language codes, visit https://sites.google.com/site/tomihasa/google-language-codes
$ThemeSel = get_theme();
if (file_exists('themes/' . $ThemeSel . '/module.php')) {
   include('themes/' . $ThemeSel . '/module.php');
   if (is_active("$default_module") AND file_exists('modules/' . $default_module . '/index.php')) {
      $def_module = $default_module;
   } else {
      $def_module = '';
   }
}

$row = $db->sql_fetchrow($db->sql_query('SELECT `main_module` FROM `' . $prefix . '_main`'));
$main_module = $row['main_module'];

/* If the module doesn't exist, it will be removed from the database automaticaly */
$result2 = $db->sql_query('SELECT `title` FROM `' . $prefix . '_modules`');
while ($row2 = $db->sql_fetchrow($result2)) {
   $title = stripslashes($row2['title']);
   $a = 0;
   $handle=opendir('modules');
   while ($file = readdir($handle)) {
      if ($file == $title) {
      $a = 1;
      }
   }
   closedir($handle);
   if ($a == 0) {
      $db->sql_query('DELETE FROM `' . $prefix . '_modules` WHERE `title` = \'' . $title . '\'');
   }
}
/* If you copied a new module is the /modules/ directory, it will be added to the database */
   $handle=opendir('modules');
   while ($file = readdir($handle)) {
      if ( (!preg_match("/[.]/",$file)) ) {
         $modlist .= "$file ";
      }
   }
   closedir($handle);
   $modlist = explode(' ', $modlist);
   sort($modlist);
   for ($i=0; $i < sizeof($modlist); $i++) {
      if($modlist[$i] != '') {
         $row4 = $db->sql_fetchrow($db->sql_query('SELECT `mid` FROM `' . $prefix . '_modules` WHERE `title` = \'' . $modlist[$i] . '\''));
         $mid = intval($row4['mid']);
         $mod_uname = preg_replace("/_/", " ", $modlist[$i]);
         if ($mid == '') {
            $db->sql_query('INSERT INTO `' . $prefix . '_modules` VALUES (NULL, ' . $modlist[$i] . ', ' . $mod_uname . ', 0, 0, 1)');
         }
      }
   }

        $current=$_SERVER['REQUEST_URI'];
        if ($translang!='pl'){
        $content ='<a rel="nofollow" href="http://translate.google.com/translate?u=' . $nukeurl . $current . '&amp;sl=' . $translang . '&amp;tl=pl&amp;hl=' . $translang . '&amp;ie=UTF-8"><img src="images/blocks/langpics/pl.png" alt="Polish" title="Polish" /></a>&nbsp;';
}
if ($translang!='es'){
 $content .='<a rel="nofollow" href="http://translate.google.com/translate?u=' . $nukeurl . $current . '&amp;sl=' . $translang . '&amp;tl=es&amp;hl=' . $translang . '&amp;ie=UTF-8"><img src="images/blocks/langpics/sp.png" alt="Spanish" title="Spanish" /></a>&nbsp;';
}
if ($translang!='nl'){
$content .='<a rel="nofollow" href="http://translate.google.com/translate?u=' . $nukeurl . $current . '&amp;sl=' . $translang . '&amp;tl=nl&amp;hl=' . $translang . '&amp;ie=UTF-8"><img src="images/blocks/langpics/dt.png" alt="Dutch" title="Dutch" /></a>&nbsp;';
}
if ($translang!='fr'){
$content .='<a rel="nofollow" href="http://translate.google.com/translate?u=' . $nukeurl . $current . '&amp;sl=' . $translang . '&amp;tl=fr&amp;hl=' . $translang . '&amp;ie=UTF-8"><img src="images/blocks/langpics/fr.png" alt="French" title="French" /></a>&nbsp;';
}
if ($translang!='it'){
$content .='<a rel="nofollow" href="http://translate.google.com/translate?u=' . $nukeurl . $current . '&amp;sl=' . $translang . '&amp;tl=it&amp;hl=' . $translang . '&amp;ie=UTF-8"><img src="images/blocks/langpics/it.png" alt="Italian" title="Italian" /></a>&nbsp;';
}
if ($translang!='de'){
$content .='<a rel="nofollow" href="http://translate.google.com/translate?u=' . $nukeurl . $current . '&amp;sl=' . $translang . '&amp;tl=de&amp;hl=' . $translang . '&amp;ie=UTF-8"><img src="images/blocks/langpics/gr.png" alt="German" title="German" /></a>&nbsp;';
}
if ($translang!='en'){
$content .='<a rel="nofollow" href="http://translate.google.com/translate?u=' . $nukeurl . $current . '&amp;sl=' . $translang . '&amp;tl=en&amp;hl=' . $translang . '&amp;ie=UTF-8"><img src="images/blocks/langpics/en.png" alt="English" title="English" /></a>&nbsp;';
}
if ($translang!='pt'){
$content .='<a rel="nofollow" href="http://translate.google.com/translate?u=' . $nukeurl . $current . '&amp;sl=' . $translang . '&amp;tl=pt&amp;hl=' . $translang . '&amp;ie=UTF-8"><img src="images/blocks/langpics/pt.png" alt="Portuguese" title="Portuguese" /></a>&nbsp;';
}
if ($translang!='fi'){
$content .='<a rel="nofollow" href="http://translate.google.com/translate?u=' . $nukeurl . $current . '&amp;sl=' . $translang . '&amp;tl=fi&amp;hl=' . $translang . '&amp;ie=UTF-8"><img src="images/blocks/langpics/fi.png" alt="Finnish" title="Finnish" /></a>';
}


//This is hard coded links you want to show above of the dropdown menu.

   $content  .= '<br /><br /><a rel="nofollow" href="' . $nukeurl . '" title="Home">&nbsp;&nbsp;<img src="images/blocks/langpics/Home.png" alt="Home" />&nbsp;<b>Home:</b></a><br />
   <a rel="nofollow" href="donate.html">&nbsp;&nbsp;<img src="images/blocks/langpics/donate.png" alt="Donate" />&nbsp;<b>Donate:</b></a><br /><a rel="nofollow" href="forums.html" title="Forums">&nbsp;&nbsp;<img src="images/blocks/langpics/forum.png" alt="Forum" />&nbsp;<b>Forums:</b></a><br /><br />';
   $content .= '<div class="text-center"><select size="1" name="name" onchange="top.location.href=this.options[this.selectedIndex].value">';
   $content .= '<option>Menu</option>';
   $result3 = $db->sql_query('SELECT `title`, `custom_title`, `view` FROM `' . $prefix . '_modules` WHERE `active` = 1 AND `title` != \'' . $def_module . '\' AND `inmenu` = 1 ORDER BY `custom_title` ASC');
   while ($row3 = $db->sql_fetchrow($result3)) {
      $m_title = stripslashes($row3['title']);
      $custom_title = $row3['custom_title'];
      $view = intval($row3['view']);
      $m_title2 = str_replace("_", " ", $m_title);
      if ($custom_title != "") {
         $m_title2 = $custom_title;
      }
      if ($m_title != $main_module) {
         if ((is_admin($admin) AND $view == 2) OR $view != 2) {
            $selected = '';
            $content .= '<option value="modules.php?name=' . $m_title . '">&nbsp;&bull;&nbsp;' . $m_title2 . '</option>';
         }
      }
   }
   $content .= '</select></div><br />';


if(file_exists('language/infobox/lang-' . $currentlang . '.php')) {
   include_once 'language/infobox/lang-' . $currentlang . '.php';
} elseif(file_exists('language/infobox/lang-' . $language . '.php')) {
   include_once 'language/infobox/lang-' . $language . '.php';
} else {
   include_once 'language/infobox/lang-english.php';
}
if (!isset($name)) { $name = ''; }
if ($IBCentermode) {
   $ListClass = 'IBblock-center';
   addJSToBody('includes/jquery/jquery.masonry.min.js', 'file');
   addJSToBody('includes/jquery/jquery.userinfo.js', 'file');
} else {
   $ListClass = 'IBblock';
}
if (!isset($ya_config)) $ya_config = ya_get_configs();
if ($MultiThemeMode){
   $ThemeSel = get_theme();
   if (in_array($ThemeSel, $rnIBWhite)) {$rnIBicon = 'rnIBWhite';$IBicon = 'IBWhite';}
   else if (in_array($ThemeSel, $rnIBGray)) {$rnIBicon = 'rnIBGray';$IBicon = 'IBGray';}
   else if (in_array($ThemeSel, $rnIBCreme)) {$rnIBicon = 'rnIBCreme';$IBicon = 'IBCreme';}
   else if (in_array($ThemeSel, $rnIBSimplyBlue)) {$rnIBicon = 'rnIBSimplyBlue';$IBicon = 'IBSimplyBlue';}
   else if (in_array($ThemeSel, $rnIBSandJourney)) {$rnIBicon = 'rnIBSandJourney';$IBicon = 'IBSandJourney';}
   else if (in_array($ThemeSel, $rnIBBlueBlog)) {$rnIBicon = 'rnIBBlueBlog';$IBicon = 'IBBlueBlog';}
   else if (in_array($ThemeSel, $rnIBCTRN)) {$rnIBicon = 'rnIBCT-RN';$IBicon = 'IBCT-RN';}
   else if (in_array($ThemeSel, $rnIBRavenIce)) {$rnIBicon = 'rnIBRavenIce';$IBicon = 'IBRavenIce';}
   else if (in_array($ThemeSel, $rnIBKaput)) {$rnIBicon = 'rnIBKaput';$IBicon = 'IBKaput';}
   else if (in_array($ThemeSel, $rnIBBlack)) {$rnIBicon = 'rnIBBlack';$IBicon = 'IBBlack';}
   else if (in_array($ThemeSel, $rnIBExtra)) {$rnIBicon = 'rnIBExtra';$IBicon = 'IBExtra';}
   else {$rnIBicon = 'rnIBicon';$IBicon = 'IBWhite';}
}
if ($LargeSectionIcons) {$IBadjust = 'LG';$IBicon = 'IBBigIcons';} else {$IBadjust = '';}
if (is_admin($admin)) {
   $viewlevel = 2;
   $lastseen_count=$lastseen_count_admn;
   $recent_member_count=$recent_member_admin;
} else if (is_user($user)) {
   $viewlevel = 1;
   $lastseen_count=$lastseen_count_user;
   $recent_member_count=$recent_member_user;
} else {
   $viewlevel = 0;
}
$anonyname = 'Anonymous';
$displayname = '';
$show_pms = 0;
$onlinenames = array();

$content .= '<!-- Start Info -->
<div id="' . $ListClass . '"><div class="fullwidth">
';

// get user info/show login
if (is_user($user)) {
   $uinfo = cookiedecode($user);
   $displayname = check_html($uinfo[1], 'nohtml');
   $content .= '<div class="IBinfosection" id="IBsection1">' . PHP_EOL;
   $content .= '<div><a href="modules.php?name=Your_Account&amp;op=edituser" class="IBuser' . $IBadjust . '" title="' . _FSIYOURACCOUNT . '"><img src="' . $IBtran . '" class="' . $IBicon . '" alt="' . _FSIYOURACCOUNT . '" /><span class="IBtextpad">' . $displayname . '</span></a></div>' . PHP_EOL;
   $content .= '<ul class="rninfobox">' . PHP_EOL;
   if ($whoisUseModal){$iblinktype = 'class="IBmodal"';} else {$iblinktype = 'target="_blank"';}
   $content .= '<li class="' . $rnIBicon . ' IByourip" title="' . _YOURIP . ' ' . $_SERVER['REMOTE_ADDR'] . '"><span class="thick"><a ' . $iblinktype . ' href="http://' . $whoisServerString . $_SERVER['REMOTE_ADDR'] . '" title="' . _YOURIP . ' ' . $_SERVER['REMOTE_ADDR'] . '">' . $_SERVER['REMOTE_ADDR'] . '</a></span></li>' . PHP_EOL;

   if (is_active('Forums')) {
      $adjustment = strlen(html_entity_decode(_INFOBOX_EGOPOSTS));
      if ($adjustment>=$langMaxLength){$getsmall = ' smaller';} else {$getsmall = '';}
      $content .= '<li class="' . $rnIBicon . ' IByourposts' . $getsmall . '" title="' . _INFOBOX_EGOPOSTS . '"><a href="forums.html?amp;file=search&amp;search_id=egosearch" title="' . _INFOBOX_EGOPOSTS . '">' . _INFOBOX_EGOPOSTS . '</a></li>' . PHP_EOL;
   }
   if ($ya_config['allowusertheme']=='1') {
      $content .= '<li class="' . $rnIBicon . ' IBchangetheme" title="' . _INFOBOX_CHANGETHEME . '"><a href="modules.php?name=Your_Account&amp;op=chgtheme" title="' . _INFOBOX_CHANGETHEME . '">' . _INFOBOX_CHANGETHEME . '</a></li>' . PHP_EOL;
   }
   if (is_active('nukeNAV') and is_active('Search') and $UseSearchPopUp) $content .= '<li class="' . $rnIBicon . ' IBsearch" title="' . _SEARCH . '"><a href="modules.php?name=nukeNAV&amp;op=search" class="colorbox" title="">' . _SEARCH . '</a></li>' . PHP_EOL;
   $content .= '<li class="' . $rnIBicon . ' IBlogout" title="' . _LOGOUT . '"><a href="modules.php?name=Your_Account&amp;op=logout" title="' . _LOGOUT . '">' . _LOGOUT . '</a></li>' . PHP_EOL;
   $content .= '</ul>' . PHP_EOL;
   $content .= '</div>' . PHP_EOL;

   // check new pms
   $sql = 'SELECT `privmsgs_to_userid` FROM `' . $prefix . '_bbprivmsgs` WHERE `privmsgs_to_userid` = \'' . intval($uinfo[0]) . '\' AND (`privmsgs_type` = 5 OR `privmsgs_type` = 1)';
   if (!($result = $db->sql_query($sql))) {
      // error
      die('error checking new pms');
   }
   $new_pms = $db->sql_numrows($result);
   $db->sql_freeresult($result);

   // check old pms
   $sql = 'SELECT `privmsgs_to_userid` FROM `' . $prefix . '_bbprivmsgs` WHERE `privmsgs_to_userid` = \'' . intval($uinfo[0]) . '\' AND (`privmsgs_type` = 0)';
   if (!($result = $db->sql_query($sql))) {
      // error
      die('error checking old pms');
   }
   $old_pms = $db->sql_numrows($result);
   $db->sql_freeresult($result);

   $show_pms = $new_pms+$old_pms;
   if ($show_pms > 0 AND is_active('Private_Messages')) {
   $content .= '<div class="IBinfosection" id="IBsection2">' . PHP_EOL;
   $content .= '<div><img src="' . $IBtran . '" class="' . $IBicon . ' IBpms' . $IBadjust . '" alt="' . _BPM . '" /><span class="IBtextpad thick">' . _BPM . '</span></div>' . PHP_EOL;
   $content .= '<ul class="rninfobox">' . PHP_EOL;
   $content .= '<li class="' . $rnIBicon . ' IBnewpms" title="' . _BPM . '"><a href="modules.php?name=Private_Messages" title="' . _BPM . '">' . _BUNREAD . ': ' . $new_pms . '</a></li>' . PHP_EOL;
   $content .= '<li class="' . $rnIBicon . ' IBoldpms" title="' . _BREAD . '"> ' . _BREAD . ': <span class="thick">' . $old_pms . '</span></li>' . PHP_EOL;
   $content .= '</ul>' . PHP_EOL;
   $content .= '</div>' . PHP_EOL;
      if (($pm_colorbox_notice && $new_pms > 0) and (!isset($_COOKIE["youhaveapm"])) and ($name!='Private_Messages')) {
         setcookie('youhaveapm', 'checked');
         $content .= '<div id="IByesnewpm" style="display:none">' . PHP_EOL;
         $content .= '<div id="IBnewmessages">' . PHP_EOL;
         $content .= '<span class="IBCBtext"><img src="' . $IBtran . '" class="' . $IBicon . ' IBoldpms" alt="' . _NEWPMSG . '" /> ' . _YOUHAVE . ' <a href="modules.php?name=Private_Messages">' . $new_pms . ' ' . _NEWPMSG . '.</a></span>' . PHP_EOL;
         $content .= '</div>' . PHP_EOL;
         $content .= '</div>' . PHP_EOL;
      }
   }
} else {
   $content .= '<div class="IBinfosection" id="IBsection3">' . PHP_EOL;
   $content .= '<div><a href="modules.php?name=Your_Account" title="' . _FSIYOURACCOUNT . '" class="IBglobe' . $IBadjust . '"><img src="' . $IBtran . '" class="' . $IBicon . ' IBglobe' . $IBadjust . '" alt="' . $anonymous . '" /><span class="IBtextpad">' . $anonymous . '</span></a></div>' . PHP_EOL;
   $content .= '<ul class="rninfobox">' . PHP_EOL;
   $content .= '<li class="' . $rnIBicon . ' IByourip IBguestip" title="' . _YOURIP . ' ' . $_SERVER['REMOTE_ADDR'] . '"><span class="thick">' . $_SERVER['REMOTE_ADDR'] . '</span></li>' . PHP_EOL;
   $content .= '<li class="' . $rnIBicon . ' IByourposts" title="' . _BREG . '"><a href="modules.php?name=Your_Account&amp;op=new_user">' . _BREG . '</a></li>' . PHP_EOL;
   if (is_active('nukeNAV') and is_active('Search') and $UseSearchPopUp) $content .= '<li class="' . $rnIBicon . ' IBsearch" title="' . _SEARCH . '"><a href="modules.php?name=nukeNAV&amp;op=search" class="colorbox" title="">' . _SEARCH . '</a></li>' . PHP_EOL;
   if ($UsemodalLogin){
      $content .= '<li class="' . $rnIBicon . ' IBlogout" title="' . _LOGIN . '"><a href="modules.php?name=nukeNAV&amp;op=login" class="colorbox">' . _LOGIN . '</a></li>' . PHP_EOL;
   } else {
      $content .= '<li class="' . $rnIBicon . ' IBlogout" title="' . _LOGIN . '"><a href="modules.php?name=Your_Account">' . _LOGIN . '</a></li>' . PHP_EOL;
   }
   if ($display_lost_pass) {
      $adjustment = strlen(html_entity_decode(_PASSWORDLOST));
      if ($adjustment>=$langMaxLength){$getsmall = ' smaller';} else {$getsmall = '';}
      $content .= '<li class="' . $rnIBicon . ' IBonlineguest' . $getsmall . '" title="' . _PASSWORDLOST . '"><a href="modules.php?name=Your_Account&amp;op=pass_lost">' . _PASSWORDLOST . '</a></li>' . PHP_EOL;
   }
   $content .= '</ul>' . PHP_EOL;
   $content .= '</div>' . PHP_EOL;
}

if ($viewlevel>=$membercounter_view) {
   // MEMBER COUNTS
   $sql = 'SELECT `username` FROM `' . $user_prefix . '_users_temp`';
   $result = $db->sql_query($sql);
   $waiting = $db->sql_numrows($result);

   $content .= '<div class="IBinfosection" id="IBsection4">' . PHP_EOL;
   $content .= '<div><img src="' . $IBtran . '" class="' . $IBicon . ' IBmembers' . $IBadjust . '" alt="' . _BMEM . '" /><span class="IBtextpad thick">' . _BMEM . '</span></div>' . PHP_EOL;

    // 0001856: User Info block enhancements
    $IBgetmonth = _UMONTH;
    $IBgetyear = _YEAR;

    // get new member info
   $timestamp = time();
   $today = date('M d, Y');
   $yesterday = date('M d, Y', ($timestamp - 86400) );
   $this_month = date('M');
   $this_year = date('Y');

   // today
   $sql = 'SELECT COUNT(`user_id`) FROM `' . $user_prefix . '_users` WHERE `user_regdate` = \'' . $today . '\'';
   if (!($result = $db->sql_query($sql))) {
      // error
      die('error getting todays users');
   }
   list($new_today) = $db->sql_fetchrow($result);
   $db->sql_freeresult($result);

   // yesterday
   $sql = 'SELECT COUNT(`user_id`) FROM `' . $user_prefix . '_users` WHERE `user_regdate` = \'' . $yesterday . '\'';
   if (!($result = $db->sql_query($sql))) {
      // error
      die('error getting yesterdays users');
   }
   list($new_yesterday) = $db->sql_fetchrow($result);
   $db->sql_freeresult($result);

   // this month
   $sql = 'SELECT COUNT(`user_id`) FROM `' . $user_prefix . '_users` WHERE SUBSTRING(`user_regdate`, 1, 4) = \'' . $this_month . '\' AND SUBSTRING(`user_regdate`, 9, 12) = \'' . $this_year . '\'';
   if (!($result = $db->sql_query($sql))){
      // error
      die('error getting this months users');
   }
   list($new_month) = $db->sql_fetchrow($result);
   $db->sql_freeresult($result);

   // this year
   $sql = 'SELECT COUNT(`user_id`) FROM `' . $user_prefix . '_users` WHERE SUBSTRING(`user_regdate`, 9, 12) = \'' . $this_year . '\'';
   if (!($result = $db->sql_query($sql))) {
      // error
      die('error getting this years users');
   }
   list($new_year) = $db->sql_fetchrow($result);
   $db->sql_freeresult($result);

   // all time
   $sql = 'SELECT COUNT(`user_id`) FROM `' . $user_prefix . '_users`';
   if (!($result = $db->sql_query($sql))) {
      // error
      die('error getting total users');
   }
   if (is_admin($admin) AND @file_exists('modules/Resend_Email/index.php')) {
      $waitLink = '<a href="modules.php?name=Resend_Email" title="' . _TTL_RESENDEMAIL . '">' . _WAITLINK . ': <span class="thick">' . $waiting . '</span></a>';
   } else {
      $waitLink = _WAITLINK . ': <span class="thick">' . $waiting . '</span>';
   }
   list($total_users) = $db->sql_fetchrow($result);
   $db->sql_freeresult($result);

   $content .= '<ul class="rninfobox">' . PHP_EOL;
   if (($new_today==0 AND $viewlevel>=$zero_in_column_view) OR ($new_today!=0)) {
      $content .= '<li class="' . $rnIBicon . ' IBtoday" title="' . _INFOBOX_BTD . '">' . _INFOBOX_BTD . ': <span class="thick">' . $new_today . '</span></li>' . PHP_EOL;
   }
   if (($new_yesterday==0 AND $viewlevel>=$zero_in_column_view) OR ($new_yesterday!=0)) {
      $adjustment = strlen(html_entity_decode(_INFOBOX_BYD));
      if ($adjustment>=$langMaxLength){$getsmall = ' smaller';} else {$getsmall = '';}
      $content .= '<li class="' . $rnIBicon . ' IByesterday' . $getsmall . '" title="' . _INFOBOX_BYD . '">' . _INFOBOX_BYD . ': <span class="thick">' . $new_yesterday . '</span></li>' . PHP_EOL;
   }
   if (($new_month==0 AND $viewlevel>=$zero_in_column_view) OR ($new_month!=0)) {
      $content .= '<li class="' . $rnIBicon . ' IBmonth" title="' . _UMONTH . '">' . $IBgetmonth . ': <span class="thick">' . $new_month . '</span></li>' . PHP_EOL;
   }
   if (($new_year==0 AND $viewlevel>=$zero_in_column_view) OR ($new_year!=0)) {
      $content .= '<li class="' . $rnIBicon . ' IByear" title="' . _YEAR . '">' . $IBgetyear . ': <span class="thick">' . $new_year . '</span></li>' . PHP_EOL;
   }
   $content .= '<li class="' . $rnIBicon . ' IBtotalusers" title="' . _BTT . '">' . _BTT . ': <span class="thick">' . $total_users . '</span></li>' . PHP_EOL;
   if (($waitLink==0 AND $viewlevel>=$zero_in_column_view) OR ($waitLink!=0)) {
      $content .= '<li class="' . $rnIBicon . ' IBwaiting" title="' . _WAITLINK . '">' . $waitLink . '</li>' . PHP_EOL;
   }
   $content .= '</ul></div>' . PHP_EOL;
}

// NEWEST MEMBERS
if ($viewlevel>=$recent_member_view) {
   $sql = 'SELECT `username` FROM `' . $user_prefix . '_users` WHERE `username` != \'' . $anonyname . '\' ORDER BY `user_id` DESC LIMIT ' . intval($recent_member_count);
   if (!($result = $db->sql_query($sql))) {
      // error
      die('error getting latest users');
   }
   $latestusers = $db->sql_numrows($result = $db->sql_query($sql));
   $content .= '<div class="IBinfosection" id="IBsection5">' . PHP_EOL;
   $content .= '<div><img src="' . $IBtran . '" class="' . $IBicon . ' IBnewusers' . $IBadjust . '" alt="' . _INFOBOX_NEW_MEMBERS . '" /><span class="IBtextpad thick">' . _INFOBOX_NEW_MEMBERS . '</span></div>' . PHP_EOL;
   if ($latestusers > 0){
      $content .= '<ul class="rninfobox">' . PHP_EOL;
      $newusercounter = 0;
   }
   while($row = $db->sql_fetchrow($result)) {
      $newusercounter += 1;
      $TruncateUser = strlen($row['username'])<=$nameMaxLength?$row['username']:substr($row['username'],0,$nameMaxLength).'...'; // 2.2.0
      $lastusername = $row['username'];
      $content .= '<li class="' . $rnIBicon . ' IBmembernew" title="' . _ALT_CHKPROFILE . $lastusername . '"><a href="modules.php?name=Your_Account&amp;op=userinfo&amp;username=' . $row['username'] . '" title="' . _ALT_CHKPROFILE . $lastusername . '">' . $TruncateUser . '</a></li>' . PHP_EOL;
      if ($newusercounter==$latestusers){
         $content .= '</ul>' . PHP_EOL;
      }
   }
   $db->sql_freeresult($result);
   $content .= '</div>' . PHP_EOL;
}
$m = 0;
if ($viewlevel>=$who_is_online_view) {
   // WHOS ONLINE
   $members = '';
   $guests = '';
   $m = $g = 0;
    $sql = 'SELECT `uname`, `time`, `host_addr`, `guest` FROM `' . $prefix . '_session` WHERE `time` > \'' . ( time() - ($max_session_mins * 60) ) . '\' ORDER BY `guest` ASC,`time` DESC';
   if (!($result = $db->sql_query($sql))) {
      // error
      die('error getting online users');
   }
   $content .= '<div class="IBinfosection" id="IBsection6">' . PHP_EOL;
   $content .= '<div><img src="' . $IBtran . '" class="' . $IBicon . ' IBmembers' . $IBadjust . $IBadjust . '" alt="' . _BON . '" /><span class="IBtextpad thick">' . _BON . '</span>&nbsp;</div>' . PHP_EOL;
   while($row = $db->sql_fetchrow($result)) {
      if ($row['guest'] == 0) {
         $m++;
         if ($m <= $max_display_members) {
            $TruncateUser = strlen($row['uname'])<=$nameMaxLength?$row['uname']:substr($row['uname'],0,$nameMaxLength).'...'; // 2.2.0
            $lastusername = $row['uname'];
            $onlinenames[] = $lastusername;

            $members .= '<li class="' . $rnIBicon . ' IBonline2" title="' . _BON . '"><a href="modules.php?name=Your_Account&amp;op=userinfo&amp;username=' . $row['uname'] . '" title="' . _ALT_CHKPROFILE . $lastusername . '">' . $TruncateUser . '</a></li>' . PHP_EOL;
         }
      } else {
         $g++;
         if ($viewlevel>=$show_guest_guest && $g <= $max_display_guests) {
            if (is_admin($admin)) {
               if ($whoisUseModal){
                  $uname = '<a class="IBmodal" href="http://' . $whoisServerString . $row['uname'] . '">' . $row['uname'] . '</a>';
               } else {
                  $uname = '<a target="_blank" href="http://' . $whoisServerString . $row['uname'] . '">' . $row['uname'] . '</a>';
               }
            } else {
               // hide last 2 octets of guest ip's.
               $ip = explode('.', $row['uname']);
               $uname = $ip[0] . '.' . $ip[1] . '.' . preg_replace("/(0|1|2|3|4|5|6|7|8|9)/", "x", $ip[2]) . '.' . preg_replace("/(0|1|2|3|4|5|6|7|8|9)/", "x", $ip[3]);
            }
            $guests .= '<li class="' . $rnIBicon . ' IBonlineguest" title="' . _BON . '">' . $uname . '</li>' . PHP_EOL;
         }
      }
   }
   $db->sql_freeresult($result);
   if (($viewlevel>=$showonlinecount) AND (($m > 0) OR ($g > 0 AND !$OnlineGuestsModal))) {
      $content .= '<div class="IBsmallnotes">';
      if ($m > 0) {
         $content .= _BMEM . ':<span class="thick">' . $m . '</span>';
      }
      if ($g > 0 AND !$OnlineGuestsModal) {
        //if (($g > 0 AND $OnlineGuestsModal) AND ($viewlevel>=$show_guest_guest)) {
         $content .= ' ' . _BVIS . ':<span class="thick">' . $g . '</span>';
      }
      $content .= '&nbsp;</div>' . PHP_EOL;
   }

   if (($m > 0) OR ($viewlevel>=$show_guest_guest && $g > 0)) {
      if ($g > 0 AND $OnlineGuestsModal AND $viewlevel == 2) {
         $content .= '<div style="display:none">' . PHP_EOL;
         $content .= '<div id="IBGuestsView" style="margin-left:20px;">' . PHP_EOL;
         $content .= '<h1>' . _BON . '</h1>' . PHP_EOL;
         $content .= '<ul class="rninfobox">' . PHP_EOL;
         $content .= $guests;
         $content .= '</ul>' . PHP_EOL;
         $content .= '</div>' . PHP_EOL;
         $content .= '</div>' . PHP_EOL;
      }
      $content .= '<ul class="rninfobox">' . PHP_EOL;
   }
   //if ($g > 0 AND $OnlineGuestsModal) {
   if (($g > 0 AND $OnlineGuestsModal) AND ($viewlevel>=$show_guest_guest)) {
      $content .= '<li class="' . $rnIBicon . ' IBonlineguest" title="' . _BON . '">';
      if ($viewlevel == 2) {
         $content .= '<a class="IBGuestsModal" href="#">' . $g . ' ' . _BVIS . '</a>';
      } else {
         $content .= $g . ' ' . _BVIS;
      }
      $content .= '</li>' . PHP_EOL;
   }
   if ($m > 0) {
      $content .= $members;
   }
   if ($g > 0 AND !$OnlineGuestsModal) {
      $content .= $guests;
   }
   if (($m > 0) OR ($viewlevel>=$show_guest_guest && $g > 0)) {
      $content .= '</ul>' . PHP_EOL;
   }
   $content .= '</div>' . PHP_EOL;
}
// LAST SEEN MEMBERS
if ($viewlevel>=$lastseen_user_view) {
   $lastseennumber = intval($lastseen_count)+$m;
   if (is_user($user)) {
      $exclusion = 'AND `username` != \'' . $displayname . '\' ';
   } else {
      $exclusion = '';
   }
   $sql = 'SELECT `username`, `lastsitevisit` FROM `' . $user_prefix . '_users` WHERE `username` != \'' . $anonyname . '\' ' . $exclusion . 'ORDER BY `lastsitevisit` DESC LIMIT ' . $lastseennumber;
   $latestusers = $db->sql_numrows($result = $db->sql_query($sql));
   $latestusercounter = 1;
   if ($latestusers > 0) {
      $latuse = '<div class="IBinfosection" id="IBsection7">' . PHP_EOL;
      $latuse .= '<div><img src="' . $IBtran . '" class="' . $IBicon . ' IBlastseen' . $IBadjust . '" alt="' . _INFOBOX_LAST_SEEN . '" /><span class="IBtextpad thick">' . _INFOBOX_LAST_SEEN . '</span></div>' . PHP_EOL;
      $latuse .= '<ul class="rninfobox">' . PHP_EOL;
      while( $row = $db->sql_fetchrow($result) ) {
         if ($latestusercounter <= $lastseen_count) {
            $TruncateUser = strlen($row['username'])<=$nameMaxLength?$row['username']:substr($row['username'],0,$nameMaxLength).'...'; // 2.2.0
            $lastusername = $row['username'];
            $row['lastsitevisit'] = date('d F Y H:i', $row['lastsitevisit']);
            if (!in_array($lastusername, $onlinenames)){
               $latestusercounter += 1;
               $latuse .= '<li class="' . $rnIBicon . ' IBonline"><a href="modules.php?name=Your_Account&amp;op=userinfo&amp;username=' . $row['username'] . '" title="' . _INFOBOX_LAST_SEEN . ': ' . $row['lastsitevisit'] . '">' . $TruncateUser . '</a></li>' . PHP_EOL;
            }
         }
      }
      $latuse .= '</ul>' . PHP_EOL;
      $db->sql_freeresult($result);
      $latuse .= '</div>' . PHP_EOL;
   }
   if ($latestusercounter > 1) $content .= $latuse;
}
// SERVER TRAFFIC
if ($viewlevel>=$servertraffic_view) {
   $content .= '<div class="IBinfosection" id="IBsection8">' . PHP_EOL;
   $content .= '<div><img src="' . $IBtran . '" class="' . $IBicon . ' IBtraffic' . $IBadjust . '" alt="' . _INFOBOX_SERVERTRAFFIC . '" /><span class="IBtextpad thick">' . _INFOBOX_SERVERTRAFFIC . '</span></div>' . PHP_EOL;
   $content .= '<ul class="rninfobox">' . PHP_EOL;
   $totalhits = 0;
   $result = $db->sql_query('SELECT sum(`hits`) FROM `' . $prefix . '_stats_year`');
   list($totalhits) = $db->sql_fetchrow($result);
   $content .= '<li class="' . $rnIBicon . ' IBtotalhits" title="' . _WERECEIVED . ' ' . number_format($totalhits,0) . ' ' . _PAGESVIEWS . ' ' . $startdate . '">' . _INFOBOX_TOTALHITS.number_format($totalhits,0) . '</li>' . PHP_EOL;
   $today = 0;
   $todayDST = date('I',time())*3600;
   $t_time = time()-$todayDST;
   $t_year = date('Y', $t_time);
   $t_month = date('n', $t_time);
   $t_date = date('j', $t_time);
   $result = $db->sql_query('SELECT `hits` FROM `' . $prefix . '_stats_date` WHERE `year` = \'' . $t_year . '\' AND month = \'' . $t_month . '\' AND `date` = ' . $t_date);
   list($today) = $db->sql_fetchrow($result);
   $content .= '<li class="' . $rnIBicon . ' IBtodayhits" title="' . _INFOBOX_TODAYHITS.number_format($today,0) . '">' . _INFOBOX_TODAYHITS.number_format($today,0) . '</li>' . PHP_EOL;
   if ($how_many_years>0 AND $viewlevel>=$traffic_year_view) {
      $sql = 'SELECT `year`, `hits` FROM `' . $prefix . '_stats_year` ORDER BY `year` DESC LIMIT ' . intval($how_many_years);
      $result = $db->sql_query($sql);
      while ($row = $db->sql_fetchrow($result)) {
         $content .= '<li class="' . $rnIBicon . ' IByearlyhits" title="' . $row['year'] . ': ' . number_format($row['hits']) . '">' . $row['year'] . ': ' . number_format($row['hits']) . '</li>' . PHP_EOL;
      }
   }
   $content .= '</ul>' . PHP_EOL;
   $content .= '</div>' . PHP_EOL;
}
// SERVER DATE/TIME
$content .= '<div class="IBinfosection" id="IBsection9">' . PHP_EOL;
$content .= '<div><img src="' . $IBtran . '" class="' . $IBicon . ' IBserver' . $IBadjust . '" alt="' . _INFOBOX_SERVERINFO . '" /><span class="IBtextpad thick">' . _INFOBOX_SERVERINFO . '</span></div>' . PHP_EOL;
$content .= '<ul class="rninfobox">' . PHP_EOL;
$content .= '<li class="' . $rnIBicon . ' IBserdate" title="' . _SERDT . '">' . date('M d, Y') . '</li>' . PHP_EOL;
$content .= '<li class="' . $rnIBicon . ' IBtime" title="' . _SERDT . '">' . date('h:i a T') . '</li>' . PHP_EOL;

$content .= '</ul>' . PHP_EOL;
$content .= '</div>' . PHP_EOL;
$content .= '</div></div>' . PHP_EOL;

// make sure content does not float outside the block
$content .= '<div class="block-spacer">&nbsp;</div>' . PHP_EOL;
$content .= '<!-- END Info -->' . PHP_EOL;
 
View user's profile Send private message
spasticdonkey
RavenNuke(tm) Development Team



Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA

PostPosted: Sat Oct 12, 2013 5:03 pm Reply with quote

this block has significant changes in the next release, as it will be using font awesome instead of sprites; and is dropping the theme specific loading of icons. It's hard to see exactly what you have changed as you have customized the block. There may be a few lingering uses of double quotes in some function calls, but the majority of the block has single quoted strings already.
 
View user's profile Send private message Visit poster's website
hicuxunicorniobestbuildpc







PostPosted: Sat Oct 12, 2013 5:08 pm Reply with quote

Take the original and compare it with Winmerge and u will see all what I did. Thanks for replying.
 
spasticdonkey







PostPosted: Sat Oct 12, 2013 11:22 pm Reply with quote

code posted in the forums gets changed (tabs replaced by spaces, etc) so I can't really do a comparison as every line would likely be different. At a glance though, it looks alright what you have done. I don't have a problem with backticks in db queries or changing out a few occurrences of double quotes.
 
hicuxunicorniobestbuildpc







PostPosted: Sun Oct 13, 2013 7:56 am Reply with quote

Example of double quotes I changed

Code:
if (file_exists("themes/$ThemeSel/module.php")) {

   include("themes/$ThemeSel/module.php");
   if (is_active("$default_module") AND file_exists("modules/$default_module/index.php")) {
      $def_module = $default_module;
   } else {
      $def_module = "";
   }
}

$row = $db->sql_fetchrow($db->sql_query("SELECT main_module FROM ".$prefix."_main"));
$main_module = $row['main_module'];

/* If the module doesn't exist, it will be removed from the database automaticaly */
$result2 = $db->sql_query("SELECT title FROM " . $prefix . "_modules");
while ($row2 = $db->sql_fetchrow($result2)) {
   $title = stripslashes($row2['title']);
   $a = 0;
   $handle=opendir('modules');
   while ($file = readdir($handle)) {
      if ($file == $title) {
      $a = 1;
      }
   }


Replace with

Code:
if (file_exists('themes/' . $ThemeSel . '/module.php')) {

   include('themes/' . $ThemeSel . '/module.php');
   if (is_active("$default_module") AND file_exists('modules/' . $default_module . '/index.php')) {
      $def_module = $default_module;
   } else {
      $def_module = '';
   }
}

$row = $db->sql_fetchrow($db->sql_query('SELECT `main_module` FROM `' . $prefix . '_main`'));
$main_module = $row['main_module'];

/* If the module doesn't exist, it will be removed from the database automaticaly */
$result2 = $db->sql_query('SELECT `title` FROM `' . $prefix . '_modules`');
while ($row2 = $db->sql_fetchrow($result2)) {
   $title = stripslashes($row2['title']);
   $a = 0;
   $handle=opendir('modules');
   while ($file = readdir($handle)) {
      if ($file == $title) {
      $a = 1;
      }
   }
   closedir($handle);
   if ($a == 0) {
      $db->sql_query('DELETE FROM `' . $prefix . '_modules` WHERE `title` = \'' . $title . '\'');
   }
}


Note: I understand it is not a big change but since I am cleaning all Double Quotes and cleaning codes from old files I see the result of better performance and believe me files are loading faster thank before.
 
neralex
Site Admin



Joined: Aug 22, 2007
Posts: 1772

PostPosted: Sun Oct 13, 2013 8:32 am Reply with quote

These little change brings for this file only milliseconds, i don't believe it, that you can see the result of faster loading. Its only important for big modules, there you have many functions in big files.

_________________
Github: RavenNuke 
View user's profile Send private message
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Sun Oct 13, 2013 9:45 am Reply with quote

Nice job in converting from double to single quotes. While some experts disagree that it has any benefit, I personally have seen such a drastic difference once we made such a monumental shift with RN code, that I cannot discount personal experience. HOWEVER, much of the original PHP-Nuke was riddled with PHP Warnings - unbelievable number. We gained a bunch of performance also by just removing all of those. Even if the display of these are suppressed, PHP is still chewing up cycles trapping them.

One thing you may want to look at is where is $default_module getting passed/valued? I do not see it defined anywhere and it is not in the globals. Don't just add it to the globals! You need to identify how its to be used and where it is being set. What flagged me to even look at it is we've gotten rid of the "$somevar" type nonsense through most of the code. None of this type of quote encapsulation is needed with proper filtering on all inputs - Know Thy Input - Smile

Since you asked, a couple of other suggestions (some general in nature) that I will make:

1) Watch your loops - these can really kill your performance too. Do not use a function in the "for". For example, you have this:

Code:


sort($modlist);
for ($i=0; $i < sizeof($modlist); $i++) {


Every iteration of the "for" has to re-evaluate that "sizeof". Do this instead:

Code:


sort($modlist);
$j = sizeof($modlist);
for ($i=0; $i < $j; $i++) {


2) Duplicate string concatenation - like much around performance, one must always consider the cost of the BEFORE as compared to the AFTER code. For example, you have this:

Code:


$ThemeSel = get_theme();
if (file_exists('themes/' . $ThemeSel . '/module.php')) {
   include('themes/' . $ThemeSel . '/module.php');
   if (is_active("$default_module") AND file_exists('modules/' . $default_module . '/index.php')) {
      $def_module = $default_module;
   } else {
      $def_module = '';
   }
}


Why concatenate the same string twice - i.e., "'themes/' . $ThemeSel . '/module.php'"? My rule of thumb is if its a large concatenation or one that is used more than twice, always assign it to a variable and then use the variable. It is possible that the variable assignment could cost more in terms of CPU cycles than duplicate string catenation, but I have no personal study to draw upon which is why I just use my rule.

3) NEVER trust your input - basic security tenent. It can creap in many different ways. Additional URI elements can be introduced, for example, using specially crafted links to unsuspecting users. For example, you make this assignment here, but do no filtering of the data.

Code:


$current=$_SERVER['REQUEST_URI'];


You will need to decide what to filter and how to do it. I'm just raising the concern. $_SERVER['REMOTE_ADDR'] is another example and is almost worse because it is extremely to make that almost anything (take a look at how NukeSentinel cleanses this). *** Before folks jump all over my case, I fully understand that it takes skill to do these things... but with millions of hackers globally, what percentage are you willing to accept who have this skill... and time on their hands... when you can do a few regex checks to weed out the "simpler" stuff... Wink

4) For block content, always pre-initialize the $content variable right up front. The time I see $content = 'something' isn't until its wrapped inside an IF. What if the IF statement is false? I would always put this line early on in the block code prior to any further maniuplation and then ALL subsequent assignments should use ".=":

Code:


$content = '';


5) Watch inner loop SQL queries - You do not have any of these here, so this is a more general "to watch for" item. MySQL is a very powerful query engine and is going to far more efficient at joining tables up with related rows and their columns of data. With OUTER LOOPS in MySQL, you can, in many cases (but not all, so have to be careful), remove the need for doing the inner loop within PHP. An example might be doing a display of news articles such as latest NN articles per news topic (such as in a tree structure). I've seen code that will first query against new topics and cycle through them. For each topic, a new query is issued to the get articles for the given topic. With just a little extra coding skill, one could have let MySQL join up all the topics/articles into one query and still while loop through the rows watching for topic breaks...

---------

Not rules... just more observations. No reason why this:

Code:


$mod_uname = preg_replace("/_/", " ", $modlist[$i]);


Cannot be:

Code:


$mod_uname = preg_replace('/_/', ' ', $modlist[$i]);


You do have to be careful when single-quotes are also within the search/replace nodes, but that is the only time.

----

You will also see us in the new CMS we're working on removing the stripslashes() function from the reads out of the DB such as this:

Code:


$title = stripslashes($row2['title']);


With proper escaping of data into the DB, there are no extraneous slashes to remove. So, what if your data actually had valid slashes in them such as a file path? Those would be removed unwantedly. It will take some time for us to rid ourselves of this old bandaid, but we'll get there.

----

The whole checking for deleted modules and new modules is really a very DB and file system intensive process. I don't think it makes good sense to do that much processing upon every use of the module, which would be EVERY hit - especially in this case - to the website. Personally, I would remove those. I see that we have already done so.

----

I know some really like adding " . PHP_EOL" to the end of every HTML line. I'm not apposed to it, but if you want to eak every ounce of speed out, it is unnecessary. There are nice plug-ins to browsers that will re-format your HTML for you where you can select indentation only even. So, because of this, I don't use it. But, again, not an issue.

-----

That is all I have time for... didn't review it thoroughly. But this should be some good food-for-thought. You asked. Smile

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
montego







PostPosted: Sun Oct 13, 2013 9:46 am Reply with quote

neralex wrote:
These little change brings for this file only milliseconds, i don't believe it, that you can see the result of faster loading. Its only important for big modules, there you have many functions in big files.


neralex,

The point really being, however, that the sum total of all these little tweaks is what makes it noticeable. I agree that taking each individually means little... Wink

It also can make a bigger difference on the user front-end for anonymous content. The less processing PHP has to do will only allow it to handle more load, including search engine crawlers.
 
hicuxunicorniobestbuildpc







PostPosted: Sun Oct 13, 2013 12:07 pm Reply with quote

Thanks Montego for taking the time. I've been reading what u posted but I will do it again.

I didn't know I could do this change.

Code:
$mod_uname = preg_replace("/_/", " ", $modlist[$i]); 


Replacing for this one. I will do it but actually I don't know if I can do it all the time but I will try as always.

Code:
$mod_uname = preg_replace('/_/', ' ', $modlist[$i]); 
 
montego







PostPosted: Mon Oct 14, 2013 7:15 am Reply with quote

hicuxunicorniobestbuildpc, as I mentioned, the only time where you have to be careful is if you need to use a single quote as a part of your actual pattern. In that case, you just need to escape it. Wink
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©