Author |
Message |
Dawg
RavenNuke(tm) Development Team
![](modules/Forums/images/avatars/46907b8543f928e08c8d7.gif)
Joined: Nov 07, 2003
Posts: 928
|
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 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Dawg
![](modules/Forums/images/avatars/gallery/blank.gif)
|
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 www.domainname.com
I will go read a little....
Dawg |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Dawg
![](modules/Forums/images/avatars/gallery/blank.gif)
|
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 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Dawg
![](modules/Forums/images/avatars/gallery/blank.gif)
|
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 />';
};
};
?>
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Guardian2003
Site Admin
![](modules/Forums/images/avatars/125904890252d880f79f312.png)
Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam
|
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];
}
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Dawg
![](modules/Forums/images/avatars/gallery/blank.gif)
|
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 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Guardian2003
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Jun 05, 2009 8:15 am |
|
No, nothing wrong with it, I was just slow typing ![Smile](modules/Forums/images/smiles/icon_smile.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Dawg
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Jun 05, 2009 12:13 pm |
|
Guardian2003,
Does this mean this block is ready to be released?
Dawg |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Guardian2003
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Jun 05, 2009 12:54 pm |
|
I don't see why not, looks good to me |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
Site Admin
![](modules/Forums/images/avatars/Dilbert/Dilbert_-_Dogbert_King.gif)
Joined: Mar 30, 2006
Posts: 2583
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. |
_________________ "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 |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Dawg
![](modules/Forums/images/avatars/gallery/blank.gif)
|
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 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Dawg
![](modules/Forums/images/avatars/gallery/blank.gif)
|
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 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Jun 05, 2009 6:32 pm |
|
I probably have a typo in there. I wouldn't worry about. Looks good to me ![Smile](modules/Forums/images/smiles/icon_smile.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
sexycoder
Spammer and overall low life
![](modules/Forums/images/avatars/gallery/blank.gif)
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. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Dawg
![](modules/Forums/images/avatars/gallery/blank.gif)
|
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).'...';
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
evaders99
Former Moderator in Good Standing
![](modules/Forums/images/avatars/803d73f6452557b947721.jpg)
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. |
_________________ - 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! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
sexycoder
![](modules/Forums/images/avatars/gallery/blank.gif)
|
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. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
montego
Site Admin
![](modules/Forums/images/avatars/0c0adf824792d6d341ef4.gif)
Joined: Aug 29, 2004
Posts: 9457
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. ![Wink](modules/Forums/images/smiles/icon_wink.gif) |
_________________ 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! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
sexycoder
![](modules/Forums/images/avatars/gallery/blank.gif)
|
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. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Dawg
![](modules/Forums/images/avatars/gallery/blank.gif)
|
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 />';
};
};
?>
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|