Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> v2.3 RN Feedback/Suggestions
Author Message
Dawg
RavenNuke(tm) Development Team



Joined: Nov 07, 2003
Posts: 928

PostPosted: Fri Jun 05, 2009 5:46 am Reply with quote

I understand most of what you are saying....but these two?

Code:
for ($n=0; $n < sql_num_rows($result, $db); $n++) 

Code:
for ($n=0; $n < $db->sql_numrows($result); $n++) 


While these are written a little differently....I do not understand the difference. Is there some security issue with it? Is sql_num_rows old php vs sql_numrows new Php?

The var wrapping....

Are you saying anytime we call a var like that it should wrapped with the . ?
Code:
$content .= '<a href="' . $refered_from . '" title="' . $refered_from . '" target="_blank">' . $rfrom . '</a>'; 


If there is some reading about these issues I need to do to understand...feel free to post a link vs taking the time to explain. I do not mind reading.

Thank You for taking the time to help me understand.
Dawg
 
View user's profile Send private message
Dawg







PostPosted: Fri Jun 05, 2009 5:52 am Reply with quote

One last question while we are at it....

Is there a way we can Auto Detect the domain name for line 33? That would sure make it plug and play vs having to edit it to get it to work.

I am familier with
Code:
$_SERVER['HTTP_HOST']
but what we want is domainname.com not www.domainname.com

I will go read a little....

Dawg
 
Dawg







PostPosted: Fri Jun 05, 2009 6:06 am Reply with quote

Code:
$domain= ($_SERVER['HTTP_HOST']);


Seems to work for my installs....but will it work for everyone?

Dawg
 
Dawg







PostPosted: Fri Jun 05, 2009 6:17 am Reply with quote

Code:
<?php


/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* Last referers block for phpNuke portal                               */
/* Copyright (c) 2001 by Jack Kozbial (jack@internetintl.com            */
/* http://www.InternetIntl.com                                          */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
//Latest Referrer Block by Dawg with Help from the RN Staff
//Palbin
//Guardian2003
//Thank You for Your Time
//~~~~~~~~~~~~~RavenNuke ROCKS! ~~~~~~~~~~~~~~~~
/************************************************************************/


if ( !defined('BLOCK_FILE') ) {
   Header('Location: ../index.php');
   die();
}

global $prefix, $db, $admin, $admin_file;
//Add your Domain Name here with NO http:// or www
$domain= ($_SERVER['HTTP_HOST']);
//Set $Showtime
// Set to 1 for for both Date/time
//Set to 2 for Date
// Set to 3 for  Date
   $showtime= '3';
//How Many Referers to show?
$number= 30;
   
$querystr = "SELECT refered_from,date FROM ".$prefix."_nsnst_tracked_ips  WHERE refered_from NOT LIKE 'local' AND refered_from NOT LIKE 'on site' AND refered_from NOT LIKE 'none' AND refered_from NOT LIKE '%$domain%' ORDER BY date DESC LIMIT $number" ;
   $result = $db->sql_query($querystr) 
   or die ('invalid query in towndisplay');
   $numrows = $db->sql_numrows($result);
   for ($n=0; $n < $numrows; $n++)
   {
      list ($refered_from,$date) = $db->sql_fetchrow($result);
         if($refered_from !='on site' AND $refered_from !='none' AND $refered_from !='local') {
            if(strlen($refered_from) > 30) {
               $rfrom = substr($refered_from, 0, 30).'...';
            } else {
               $rfrom = $refered_from;
               }
            $content .= '<a href="' . $refered_from . '" title="' . $refered_from . '" target="_blank">' . $rfrom . '</a>';

            if ($showtime==1){
               $timestamp = strftime('%D - %r',$date);
               $content .= ' - $timestamp';
            }
            elseif($showtime==2){
               $timestamp = strftime('%D',$date);
               $content .= ' - $timestamp';
            }
            elseif($showtime==3){
               $content .= '';
            }
            $content .= '<br />';
         };
   };
?>
 
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Fri Jun 05, 2009 6:32 am Reply with quote

Actually if you add $nukeurl to the first global AND you are using PHP 5.x you can do this after it
Code:


$domain = parse_url($nukeurl, PHP_URL_HOST);

This should leave you with yoursite.com
I'm not sure how it handles sub-domains as I haven't tried it but it might be something you can use so there is no need to edit the file Smile

If your stuck with/need to support PHP4.x you might be able to use a regex to cleanse it like this (not tested)
Code:


global $nukeurl;
$pattern = '/\w+\..{2,3}(?:\..{2,3})?(?:$|(?=\/))/i';
if (preg_match($pattern, $nukeurl, $domain) === 1) {
    echo $domain[0];
}
 
View user's profile Send private message Send e-mail
Dawg







PostPosted: Fri Jun 05, 2009 6:42 am Reply with quote

Is there something bad about doing the way I did it? It seems to work?

Code:
$domain= ($_SERVER['HTTP_HOST']); 


Dawg
 
Guardian2003







PostPosted: Fri Jun 05, 2009 8:15 am Reply with quote

No, nothing wrong with it, I was just slow typing Smile
 
Dawg







PostPosted: Fri Jun 05, 2009 12:13 pm Reply with quote

Guardian2003,
Does this mean this block is ready to be released?

Dawg
 
Guardian2003







PostPosted: Fri Jun 05, 2009 12:54 pm Reply with quote

I don't see why not, looks good to me
 
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Fri Jun 05, 2009 1:51 pm Reply with quote

You have two lines that look like this:
Code:


$content .= ' - $timestamp';

This won't work. It needs to be this when using single quotes.
Code:


$content .= ' - ' . $timestamp;


This is a little picky, but if you want to follow our (RN Team) general coding format:
Code:


$querystr = "SELECT refered_from,date FROM ".$prefix."_nsnst_tracked_ips  WHERE refered_from NOT LIKE 'local' AND refered_from NOT LIKE 'on site' AND refered_from NOT LIKE 'none' AND refered_from NOT LIKE '%$domain%' ORDER BY date DESC LIMIT $number" ;


Code:


$querystr = 'SELECT `refered_from`, `date` FROM `' . $prefix . '_nsnst_tracked_ips` WHERE `refered_from` NOT LIKE "local" AND `refered_from` NOT LIKE "on site" AND `refered_from` NOT LIKE "none" AND `refered_from` NOT LIKE "%$domain%" ORDER BY `date` DESC LIMIT ' . $number;


I'll try and type out the explanation you requested above some time tonight.

_________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan.

Last edited by Palbin on Fri Jun 05, 2009 2:34 pm; edited 1 time in total 
View user's profile Send private message
Dawg







PostPosted: Fri Jun 05, 2009 2:09 pm Reply with quote

I will update it later today and post a new version. Thank You for your help...!!

Dave
 
Dawg







PostPosted: Fri Jun 05, 2009 4:49 pm Reply with quote

I could not get the SQL to work right....

I "Think" I have the rest of the edits....

Code:
<?php


/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
//Latest Referrer Block by Dawg with Help from the RN Staff
//Palbin
//Guardian2003
//Thank You for Your Time
//~~~~~~~~~~~~~RavenNuke ROCKS! ~~~~~~~~~~~~~~~~
/************************************************************************/


if ( !defined('BLOCK_FILE') ) {
   Header('Location: ../index.php');
   die();
}
global $prefix, $db;

$domain= ($_SERVER['HTTP_HOST']);
//Set $Showtime
//Set to 1 for for both Date/time
//Set to 2 for Date
// Set to 3 for  Off
$showtime= '1';
//How Many Referers to show?
$number= 30;
//No Edits needed below this line
$querystr = "SELECT refered_from,date FROM ".$prefix."_nsnst_tracked_ips  WHERE refered_from NOT LIKE 'local' AND refered_from NOT LIKE 'on site' AND refered_from NOT LIKE 'none' AND refered_from NOT LIKE '%$domain%' ORDER BY date DESC LIMIT $number" ;
   
   $result = $db->sql_query($querystr) 
   or die ('invalid query in towndisplay');
   $numrows = $db->sql_numrows($result);
   for ($n=0; $n < $numrows; $n++)
   {
      list ($refered_from,$date) = $db->sql_fetchrow($result);
         if($refered_from !='on site' AND $refered_from !='none' AND $refered_from !='local') {
            if(strlen($refered_from) > 30) {
               $rfrom = substr($refered_from, 0, 30).'...';
            } else {
               $rfrom = $refered_from;
               }
            $content .= '<a href="' . $refered_from . '" title="' . $refered_from . '" target="_blank">' . $rfrom . '</a>';

            if ($showtime==1){
               $timestamp = strftime('%D - %r',$date);
               $content .= ' - ' . $timestamp;
            }
            elseif($showtime==2){
               $timestamp = strftime('%D',$date);
               $content .= ' - ' . $timestamp;
            }
            elseif($showtime==3){
               $content .= '';
            }
            $content .= '<br />';
         };
   };
?>


Dawg
 
Palbin







PostPosted: Fri Jun 05, 2009 6:32 pm Reply with quote

I probably have a typo in there. I wouldn't worry about. Looks good to me Smile
 
sexycoder
Spammer and overall low life



Joined: Feb 02, 2009
Posts: 82

PostPosted: Fri Jun 05, 2009 6:36 pm Reply with quote

Hi Palbin

Is it possible to stretch out the links. it width the blocks because of the long links and doesnt look pretty but the block is working now.
 
View user's profile Send private message
Dawg







PostPosted: Fri Jun 05, 2009 6:58 pm Reply with quote

If 30 is to long....edit these two lines to make them as long as you like.

Code:
            if(strlen($refered_from) > 30) {

               $rfrom = substr($refered_from, 0, 30).'...';
 
evaders99
Former Moderator in Good Standing



Joined: Apr 30, 2004
Posts: 3221

PostPosted: Fri Jun 05, 2009 7:10 pm Reply with quote

In reference to your first question

sql_num_rows($result, $db)
is the same as
$db->sql_numrows($result)

But second is the preferred method as this is the new database abstraction layer. The old one really should not be used in any new scripts.

_________________
- Only registered users can see links on this board! Get registered or login! -

Need help? Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
sexycoder







PostPosted: Fri Jun 05, 2009 11:28 pm Reply with quote

Very Happy
Quote:
If 30 is to long....edit these two lines to make them as long as you like


Thanks. I didnt notice of this.
 
montego
Site Admin



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

PostPosted: Sat Jun 06, 2009 10:10 am Reply with quote

To echo Evaders' point, we ALWAYS need to be using the $db-> go forward. We really want to "kill" the old sql_layer over time. No use having two and quite frankly, if a script is still using the old sql layer, I question whether its active enough development wise to ensure its being patched for bugs and security problems. Wink

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
sexycoder







PostPosted: Sat Jun 06, 2009 6:11 pm Reply with quote

I agree with Montego. If we fix or create something we use new db instead of old dbi. No more old codes.
 
Dawg







PostPosted: Sat Jun 06, 2009 8:49 pm Reply with quote

I added a note about setting the desired width of the referrer links.


Code:
<?php 


/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
//Latest Referrer Block by Dawg with Help from the RN Staff
//Palbin
//Guardian2003
//Thank You for Your Time
//~~~~~~~~~~~~~RavenNuke ROCKS! ~~~~~~~~~~~~~~~~
/************************************************************************/


if ( !defined('BLOCK_FILE') ) {
   Header('Location: ../index.php');
   die();
}
global $prefix, $db;

$domain= ($_SERVER['HTTP_HOST']);
//Set $Showtime
//Set to 1 for for both Date/time
//Set to 2 for Date
// Set to 3 for  Off
$showtime= '1';
//How Many Referers to show?
$number= 30;
//No Edits needed below this line
$querystr = "SELECT refered_from,date FROM ".$prefix."_nsnst_tracked_ips  WHERE refered_from NOT LIKE 'local' AND refered_from NOT LIKE 'on site' AND refered_from NOT LIKE 'none' AND refered_from NOT LIKE '%$domain%' ORDER BY date DESC LIMIT $number" ;
   
   $result = $db->sql_query($querystr) 
   or die ('invalid query in towndisplay');
   $numrows = $db->sql_numrows($result);
   for ($n=0; $n < $numrows; $n++)
   {
      list ($refered_from,$date) = $db->sql_fetchrow($result);
         if($refered_from !='on site' AND $refered_from !='none' AND $refered_from !='local') {

//Set the number below to the desired width
            if(strlen($refered_from) > 30) {
               $rfrom = substr($refered_from, 0, 30).'...';
//End Edit desired width number
            } else {
               $rfrom = $refered_from;
               }
            $content .= '<a href="' . $refered_from . '" title="' . $refered_from . '" target="_blank">' . $rfrom . '</a>';

            if ($showtime==1){
               $timestamp = strftime('%D - %r',$date);
               $content .= ' - ' . $timestamp;
            }
            elseif($showtime==2){
               $timestamp = strftime('%D',$date);
               $content .= ' - ' . $timestamp;
            }
            elseif($showtime==3){
               $content .= '';
            }
            $content .= '<br />';
         };
   };
?>
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> v2.3 RN Feedback/Suggestions

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 ©