Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> NukeSentinel™
Author Message
BobMarion
Former Admin in Good Standing


Joined: Oct 30, 2002
Posts: 1037
Location: RedNeck Land (known as Kentucky)

PostPosted: Mon Aug 22, 2005 1:35 pm Reply with quote

This function was introduced in NukeSentinel(tm) 2.2.0 as a better method of importing the IP to Country data and to also allow admins to block out entire countries. This graphic overview covers Import to IP2Country

Image

Image

Image

Image

Image

Image

Image

Image

Image

Import to Blocked Ranges follows the same basic steps except that you only click on hte countries you want to block out not all countries.

_________________
Bob Marion
Codito Ergo Sum
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Send e-mail Visit poster's website
goatherder
New Member
New Member


Joined: May 09, 2006
Posts: 1

PostPosted: Tue May 09, 2006 2:53 pm Reply with quote

Hi,

Sorry for posting in a sticky but is there a way to import ALL ip2country tables rather than click on one at a time?

Thanks.
 
View user's profile Send private message
macpo80
New Member
New Member


Joined: May 26, 2006
Posts: 3

PostPosted: Mon May 29, 2006 12:27 pm Reply with quote

wow i wished i never touched this now i have 39 pages of canada to unblock.... sheesh
 
View user's profile Send private message
gregexp
The Mouse Is Extension Of Arm


Joined: Feb 21, 2006
Posts: 1497
Location: In front of a screen....HELP! lol

PostPosted: Mon May 29, 2006 10:09 pm Reply with quote

could u explain why u have to unblock 39 pages od canada?

_________________
For those who stand shall NEVER fall and those who fall shall RISE once more!! 
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
montego
Site Admin


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

PostPosted: Tue May 30, 2006 6:06 am Reply with quote

Sounds like he imported into "BLocked Ranges" instead of "IP2Country".

Smack

_________________
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
evaders99
Former Moderator in Good Standing


Joined: Apr 30, 2004
Posts: 3221

PostPosted: Sun Aug 13, 2006 3:55 am Reply with quote

Someone was asking for an IMPORT ALL function.. and so was I. So I took the attempt to write one. Seems to work quite well... but it may not be Sentinel standard code formating. Sorry, if Bob Marion wants to add it - he can Smile

Code:


in admin/modules/nukesentinel/ABImportIP2Country.php


FIND


}
echo "$importmess<br>\n";


REPLACE WITH

  echo "$importmess<br>\n";
} elseif (isset($importall) AND ($importall == 1)) {
  $handle=opendir("import");
  while($file = readdir($handle)) {
    if($file != "." and $file != ".." AND !stristr($file, ".ht")) {
      $file = str_replace(".data", "", $file);
      $importlist .= "$file ";
    }
  }
  closedir($handle);
  $importlist = explode(" ", $importlist);
  sort($importlist);
  for($i=0; $i < sizeof($importlist); $i++) {
    if($importlist[$i]!="") {
      $importer = $importlist[$i];
      if($importer>"") { echo "<center class='title'><b>".str_replace("_", " ", $importer)." "._AB_ADDED."!</b></center><br />\n"; }
     // Read and import Country Data
     $import_data = @file("import/".$importer.".data");
     $import_data = implode($import_data);
     if(!$import_data OR $import_data == "") {
       echo "<center><b>"._AB_UNAVAILABLE."</b></center>\n";
     } else {
       $import_data - str_replace("\r", "", $import_data);
       $import_data = explode("\n", $import_data);
       $import_count = count($import_data);
       $importmess = _AB_EVERYTHINGSUCCEESFULLY."<br>\n";
       for($j=0; $j<$import_count; $j++) {
         $import_data[$j] = trim($import_data[$j]);
         if($import_data[$j] > "") {
           $grabline = explode("||", $import_data[$j]);
           list($grabline[4]) = $db->sql_fetchrow($db->sql_query("SELECT `country` FROM `".$prefix."_nsnst_countries` WHERE `c2c`='".$grabline[3]."'"));
           if($grabline[0] == "--") {
             $db->sql_query("DELETE FROM `".$prefix."_nsnst_ip2country` WHERE `c2c`='".$grabline[3]."'");
             $db->sql_query("OPTIMIZE TABLE `".$prefix."_nsnst_ip2country`");
           } else {
             if(!get_magic_quotes_runtime()) { $grabline[4] = addslashes($grabline[4]); }
             $grabline[ip_lo] = long2ip($grabline[0]);
             $grabline[ip_hi] = long2ip($grabline[1]);
             $datainserted = False;
             $datainserted = $db->sql_query("INSERT INTO `".$prefix."_nsnst_ip2country` VALUES('$grabline[0]', '$grabline[1]', '$grabline[2]', '$grabline[3]', '$grabline[4]')");
             if(!$datainserted) {
               echo "<b>$grabline[ip_lo] - $grabline[ip_hi] "._AB_NOTINSERTED." ".$prefix."_nsnst_ip2country</b><br>\n";
               $importmess = "";
             }
           }
         }
       }
     }     
     echo "$importmess<br>\n";    
    }
  }
}
echo "<center><form action='".$admin_file.".php?op=ABImportIP2Country' method='post'>\n";
echo "<input type='hidden' name='importall' value='1'>";
echo "<input type='submit' value='"._AB_IMPORTDATA." ALL'>";
echo "</form></center>";



This will add a new button that reads "Import Data All" - it may take some time to process depending on how well your server handles that many queries.

_________________
- 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
evaders99
PostPosted: Mon Aug 14, 2006 9:41 am Reply with quote

For servers that timeout during the whole thing, I've done a Javasc ript hack to automatically go through the list. It will save having to click each country manually.

This hack will change the functionality though - automatically going to the next in the list and submitting it. To stop the process, you will need to click out of that page. You could add a delay or a perhaps even a better run/stop button. But this is a basic basic hack

Code:


in admin/modules/nukesentinel/functions.php

FIND

  echo "<center><form action='".$admin_file.".php?op=".$xop."' method='post'>\n";

REPLACE WITH

  echo "<center><form name='myform' action='".$admin_file.".php?op=".$xop."' method='post'>\n";

FIND

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

BEFORE, ADD

  $selectflag = 0;

FIND

      if($importlist[$i]==$importer) { echo " selected"; }

REPLACE WITH

      if($selectflag == 1) { echo " selected"; $selectflag = 0; }
      if($importlist[$i]==$importer) { $selectflag = 1; }

FIND

  echo "</form></center>";

AFTER, ADD

  if ($importer>"") {
     echo "<sc ript language=\"JavaSc ript\">\n";
     echo "document.myform.submit();\n";
     echo "</sc ript>\n";
  }


Note that all "sc ript" with the spaces need to remove the space.
 
montego
PostPosted: Mon Aug 14, 2006 7:22 pm Reply with quote

Yeah, I've been considering doing something with BigDump (or writing my own) and some additional PHP script to do this all in one shot outside of NS.... have only gotten to the "thinking stage" of development... Smile
 
evaders99
PostPosted: Tue Aug 15, 2006 2:48 am Reply with quote

Probably SQL files may be faster, as it doesn't have to process the import files themselves. That's also a good thought for a seperate installer
 
BobMarion
PostPosted: Thu Aug 17, 2006 9:43 pm Reply with quote

As long as you have no issue with it I will add this to 2.5.03 Smile

evaders99 wrote:
For servers that timeout during the whole thing, I've done a Javasc ript hack to automatically go through the list. It will save having to click each country manually.

This hack will change the functionality though - automatically going to the next in the list and submitting it. To stop the process, you will need to click out of that page. You could add a delay or a perhaps even a better run/stop button. But this is a basic basic hack

Code:


in admin/modules/nukesentinel/functions.php

FIND

  echo "<center><form action='".$admin_file.".php?op=".$xop."' method='post'>\n";

REPLACE WITH

  echo "<center><form name='myform' action='".$admin_file.".php?op=".$xop."' method='post'>\n";

FIND

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

BEFORE, ADD

  $selectflag = 0;

FIND

      if($importlist[$i]==$importer) { echo " selected"; }

REPLACE WITH

      if($selectflag == 1) { echo " selected"; $selectflag = 0; }
      if($importlist[$i]==$importer) { $selectflag = 1; }

FIND

  echo "</form></center>";

AFTER, ADD

  if ($importer>"") {
     echo "<sc ript language=\"JavaSc ript\">\n";
     echo "document.myform.submit();\n";
     echo "</sc ript>\n";
  }


Note that all "sc ript" with the spaces need to remove the space.
 
evaders99
PostPosted: Sat Aug 19, 2006 2:23 am Reply with quote

Sure I don't mind. Better, if you want to enhance it with anything I've suggested go ahead Smile

(Weird the quick reply is setting off Sentinel, but the Post Reply works fine)
 
jay99
New Member
New Member


Joined: Jul 08, 2006
Posts: 14

PostPosted: Mon Oct 09, 2006 10:58 am Reply with quote

Ok, but in this sticky, where is it listed where to upload the new IP to Country data?

I put it in various places inventing nifty names like "Import" or Import folder, data but it always returns Data file is unavailable or is empty.

I chmod everything also...

I only post after 3 solid hours of searching.

Thanks in advance.
 
View user's profile Send private message
evaders99
PostPosted: Mon Oct 09, 2006 11:03 am Reply with quote

The folder named "import" - it is off the phpNuke root folder
 
montego
PostPosted: Mon Oct 09, 2006 9:08 pm Reply with quote

It should also say the same in the installation readme. Wink

Quote:

Uploading Files:
----------------
NukeSentinel(tm) Files in Directories: FTP Upload to:
html/import/*.* ----------------> root/import/*.* See IMPORT.txt for info.
* root = the root directory of your site.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> NukeSentinel™

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 ©