PHP Web Host - Quality Web Hosting For All PHP Applications Sign up for PayPal and start accepting credit card payments instantly
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
Dawg
RavenNuke(tm) Development Team


Joined: Nov 07, 2003
Posts: 889

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

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
RavenNuke(tm) Development Team


Joined: Nov 07, 2003
Posts: 889

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

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
Only registered users can see links on this board!
Get registered or login to the forums!


I will go read a little....

Dawg
View user's profile Send private message
Dawg
RavenNuke(tm) Development Team


Joined: Nov 07, 2003
Posts: 889

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

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


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

Dawg
View user's profile Send private message
Dawg
RavenNuke(tm) Development Team


Joined: Nov 07, 2003
Posts: 889

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

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 />';
         };
   };
?>
View user's profile Send private message
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6373
Location: Vsetin, Czech Republic

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

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 Visit poster's website
Dawg
RavenNuke(tm) Development Team


Joined: Nov 07, 2003
Posts: 889

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

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

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


Dawg
View user's profile Send private message
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6373
Location: Vsetin, Czech Republic

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

No, nothing wrong with it, I was just slow typing Smile
View user's profile Send private message Send e-mail Visit poster's website
Dawg
RavenNuke(tm) Development Team


Joined: Nov 07, 2003
Posts: 889

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

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

Dawg
View user's profile Send private message
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6373
Location: Vsetin, Czech Republic

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

I don't see why not, looks good to me
View user's profile Send private message Send e-mail Visit poster's website
Palbin
Site Admin


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

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

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
View user's profile Send private message
Dawg
RavenNuke(tm) Development Team


Joined: Nov 07, 2003
Posts: 889

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

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

Dave
View user's profile Send private message
Dawg
RavenNuke(tm) Development Team


Joined: Nov 07, 2003
Posts: 889

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

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
View user's profile Send private message
Palbin
Site Admin


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

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

I probably have a typo in there. I wouldn't worry about. Looks good to me Smile
View user's profile Send private message
sexycoder
Spammer and overall low life


Joined: Feb 02, 2009
Posts: 82

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

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
RavenNuke(tm) Development Team


Joined: Nov 07, 2003
Posts: 889

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

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).'...';
View user's profile Send private message
evaders99
Former Moderator in Good Standing


Joined: Apr 30, 2004
Posts: 3221

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

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.
View user's profile Send private message Visit poster's website
sexycoder
Spammer and overall low life


Joined: Feb 02, 2009
Posts: 82

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

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.
View user's profile Send private message
montego
Site Admin


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

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

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
View user's profile Send private message Visit poster's website
sexycoder
Spammer and overall low life


Joined: Feb 02, 2009
Posts: 82

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

I agree with Montego. If we fix or create something we use new db instead of old dbi. No more old codes.
View user's profile Send private message
Dawg
RavenNuke(tm) Development Team


Joined: Nov 07, 2003
Posts: 889

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

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 />';
         };
   };
?>
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic

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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum