| Author |
Message |
Dawg RavenNuke(tm) Development Team

Joined: Nov 07, 2003 Posts: 889
|
Posted:
Fri Jun 05, 2009 5:46 am |
|
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 |
|
|
|
 |
Dawg RavenNuke(tm) Development Team

Joined: Nov 07, 2003 Posts: 889
|
Posted:
Fri Jun 05, 2009 5:52 am |
|
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
I will go read a little....
Dawg |
|
|
|
 |
Dawg RavenNuke(tm) Development Team

Joined: Nov 07, 2003 Posts: 889
|
Posted:
Fri Jun 05, 2009 6:06 am |
|
| Code: | | $domain= ($_SERVER['HTTP_HOST']); |
Seems to work for my installs....but will it work for everyone?
Dawg |
|
|
|
 |
Dawg RavenNuke(tm) Development Team

Joined: Nov 07, 2003 Posts: 889
|
Posted:
Fri Jun 05, 2009 6:17 am |
|
| 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: 6373 Location: Vsetin, Czech Republic
|
Posted:
Fri Jun 05, 2009 6:32 am |
|
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
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];
}
|
|
|
|
|
 |
Dawg RavenNuke(tm) Development Team

Joined: Nov 07, 2003 Posts: 889
|
Posted:
Fri Jun 05, 2009 6:42 am |
|
Is there something bad about doing the way I did it? It seems to work?
| Code: | | $domain= ($_SERVER['HTTP_HOST']); |
Dawg |
|
|
|
 |
Guardian2003 Site Admin

Joined: Aug 28, 2003 Posts: 6373 Location: Vsetin, Czech Republic
|
Posted:
Fri Jun 05, 2009 8:15 am |
|
No, nothing wrong with it, I was just slow typing  |
|
|
|
 |
Dawg RavenNuke(tm) Development Team

Joined: Nov 07, 2003 Posts: 889
|
Posted:
Fri Jun 05, 2009 12:13 pm |
|
Guardian2003,
Does this mean this block is ready to be released?
Dawg |
|
|
|
 |
Guardian2003 Site Admin

Joined: Aug 28, 2003 Posts: 6373 Location: Vsetin, Czech Republic
|
Posted:
Fri Jun 05, 2009 12:54 pm |
|
I don't see why not, looks good to me |
|
|
|
 |
Palbin Site Admin

Joined: Mar 30, 2006 Posts: 2455 Location: Pittsburgh, Pennsylvania
|
Posted:
Fri Jun 05, 2009 1:51 pm |
|
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. |
Last edited by Palbin on Fri Jun 05, 2009 2:34 pm; edited 1 time in total |
|
|
 |
Dawg RavenNuke(tm) Development Team

Joined: Nov 07, 2003 Posts: 889
|
Posted:
Fri Jun 05, 2009 2:09 pm |
|
I will update it later today and post a new version. Thank You for your help...!!
Dave |
|
|
|
 |
Dawg RavenNuke(tm) Development Team

Joined: Nov 07, 2003 Posts: 889
|
Posted:
Fri Jun 05, 2009 4:49 pm |
|
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 Site Admin

Joined: Mar 30, 2006 Posts: 2455 Location: Pittsburgh, Pennsylvania
|
Posted:
Fri Jun 05, 2009 6:32 pm |
|
I probably have a typo in there. I wouldn't worry about. Looks good to me  |
|
|
|
 |
sexycoder Spammer and overall low life

Joined: Feb 02, 2009 Posts: 82
|
Posted:
Fri Jun 05, 2009 6:36 pm |
|
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. |
|
|
|
 |
Dawg RavenNuke(tm) Development Team

Joined: Nov 07, 2003 Posts: 889
|
Posted:
Fri Jun 05, 2009 6:58 pm |
|
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
|
Posted:
Fri Jun 05, 2009 7:10 pm |
|
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. |
|
|
|
 |
sexycoder Spammer and overall low life

Joined: Feb 02, 2009 Posts: 82
|
Posted:
Fri Jun 05, 2009 11:28 pm |
|
| 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: 9133 Location: Arizona
|
Posted:
Sat Jun 06, 2009 10:10 am |
|
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.  |
|
|
|
 |
sexycoder Spammer and overall low life

Joined: Feb 02, 2009 Posts: 82
|
Posted:
Sat Jun 06, 2009 6:11 pm |
|
I agree with Montego. If we fix or create something we use new db instead of old dbi. No more old codes. |
|
|
|
 |
Dawg RavenNuke(tm) Development Team

Joined: Nov 07, 2003 Posts: 889
|
Posted:
Sat Jun 06, 2009 8:49 pm |
|
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 />';
};
};
?>
|
|
|
|
|
 |
|
|
|
|