Menu

#2 IP2C Upload don't work

open
baxr6
None
3
2008-08-23
2008-08-23
No

The IP2 Country Upload do not work.

It's a Problem with the request:
http://homepage/admin.php?op=Fusion&page_value=pro_iptoc

I have wrote a new File: pro_upload.php
Also i have change: pro_iptoc.php

Copy this Files to:
admin/modules/fusion_c

Change the File:
/admin/case/case.fusion.php

Search for:
include_once('admin/modules/fusion.php');

After insert:
case "pro_upload":
include_once('admin/modules/fusion_c/pro_upload.php');

Open the File
/admin/language/protector/lang-english.php

Search for:
//Ugrade to admin
Before insert:
define("_PS_CLOSE","Close");

Search for:
//New lang added Fusion
Before insert:
//IP 2 Country Page
define("_PS_IP2C_MANAGMENT", "IP 2 Country Management");
define("_PS_IP2C_COVER", "Covering");
define("_PS_IP2C_CTABLES", "country tables");
define("_PS_IP2C_NOTE", "Here can you update/install your Ip 2 Country db. Just download the latest list from");
define("_PS_IP2C_LASTUPDATE", "The database was last updated");
define("_PS_IP2C_DATE_IP2C", "Date from ip2c homepage");
define("_PS_IP2C_NOTE_UPLOAD", "Click Update: a new Window open, browse for the file ip-to-country.csv and then click Update again. The IP2C Table in your Database will be update automatic.");
define("_PS_IP2C_UPLOAD", "Upload");
define("_PS_IP2C_NOTE_FTP", "If the method above doesn't work then upload by ftp your ip-to-country.csv file to /includes/ps_upload folder and press the");
define("_PS_IP2C_USE_FTP", "Use Ftp Method");
define("_PS_IP2C_INFO", "Information !");
define("_PS_IP2C_ERROR_NO_FILE", "Please upload the newest ip-to-country.csv file!.<br />Can't update without that file.");
define("_PS_IP2C_TABLE_REMOVE", "The old values was removed from");
define("_PS_IP2C_TABLE", "Table");
define("_PS_IP2C_SUCCESS", "was successful updated and");
define("_PS_IP2C_DATA_INSERT", "data was inserted");
define("_PS_IP2C_ERROR_UPDATE", "There was some problem with the installation in the database because:");
define("_PS_IP2C_ALTERNATIV", "Going to alternative method....");
define("_PS_IP2C_GRABBING", "Grabbing the data from the file.....");
define("_PS_IP2C_ERROR", "Error .... ");
define("_PS_IP2C_VALUE", "The value");
define("_PS_IP2C_ERROR_DATA_INSERT", "wasn't inserted because:");
define("_PS_IP2C_ALTERNATIV_WORK", "Alternativ method worked and it took");
define("_PS_IP2C_SEC_AND", "sec and");
define("_PS_IP2C_ERROR_UPDATE2", "Sorry that din't worked because:");
define("_PS_IP2C_IP2C_CONTROL", "IP 2 Country Control");
define("_PS_IP2C_CHECK", "Check");
define("_PS_IP2C_IP_BELONG", "That ip belongs to");
define("_PS_IP2C_UPLOAD", "IP 2 Country Upload");
define("_PS_IP2C_ERROR_WRONG_FILE", "Sorry that was not the ip-to-country.csv file!");
define("_PS_IP2C_MOVE_FILE", "Trying to move the file to /includes/ps_upload/ip-to-country.csv");
define("_PS_IP2C_UPLOAD_SUCCESS", "File is uploaded to /includes/ps_upload");
define("_PS_IP2C_ERROR_CHMOD", "Error: You must upload the file ip-to-country.csv to the folder /includes/ps_upload. <br>You must set right persmission to the folder /includes/ps_upload.</strong><br /><i> (chmod it to 0777)</i>");
define("_PS_IP2C_ERROR_BIG", "ERROR: The file is to big!");
define("_PS_IP2C_FILE_SIZE", "The maximum size of the file is ");
define("_PS_IP2C_ERROR_TRANSFER", "ERROR Transfer the file: The file has not been fully received by the server! Please try again.");
define("_PS_IP2C_ERROR_SELECT", "You have no files to upload. Please use the file selection dialog to a file for upload.");
define("_PS_IP2C_INFORMATION", "Information");
define("_PS_IP2C_REMOVED", "The old values was removed!");
define("_PS_IP2C_BROWSE", "Browse for the file ip-to-country.csv and then click Update.");
define("_PS_IP2C_UPDATE", "Update");

Discussion

  • Frank Schulz

    Frank Schulz - 2008-08-23
    • priority: 5 --> 3
    • assigned_to: nobody --> baxr6
     
  • Frank Schulz

    Frank Schulz - 2008-08-23

    Logged In: YES
    user_id=2178441
    Originator: YES

    I can't upload the File this is the Code for pro_upload.php:

    <?php

    global $prefix, $db, $admin_file;

    if (!stristr($_SERVER['SCRIPT_NAME'], "".$admin_file.".php")) {
    die ("You can't access this file directly...");
    }

    $aid = substr("$aid", 0,25);
    $row = $db->sql_fetchrow($db->sql_query("SELECT radminsuper FROM ".$prefix."_authors WHERE aid='$aid'"));

    if ($row['radminsuper'] == 1) {
    OpenTable();
    echo "<p><center><strong>"._PS_IP2C_UPLOAD."</strong>";
    $worked = 0;

    if (!empty ($_FILES)) {
    $uploaddir = $_SERVER['DOCUMENT_ROOT']."/includes/ps_upload/";
    $uploadfile = $uploaddir . basename($_FILES['NewFile']['name']);

    switch ($_FILES['NewFile']['error']) {
    case UPLOAD_ERR_OK:
    if (is_uploaded_file ($_FILES['NewFile']['tmp_name'])) {
    if(($_FILES['NewFile']['name']) != 'ip-to-country.csv') {
    echo "<p><strong>"._PS_IP2C_ERROR_WRONG_FILE."</strong><p>";
    } ELSE {
    echo "<p>"._PS_IP2C_MOVE_FILE."<p>";
    move_uploaded_file($_FILES['NewFile']['tmp_name'], $uploadfile);
    if(file_exists($uploadfile)) {
    chmod($uploadfile, 0777);
    echo "<p>"._PS_IP2C_UPLOAD_SUCCESS."<p>";
    CloseTable();
    $worked = 1;
    } ELSE {
    echo "<p><strong>"._PS_IP2C_ERROR_CHMOD."<p>";
    }
    }
    }
    break;
    case UPLOAD_ERR_INI_SIZE:
    echo "<p>"._PS_IP2C_ERROR_BIG."";
    if (get_cfg_var ('max_filesize')) {
    echo "<p>"._PS_IP2C_FILE_SIZE." ".get_cfg_var ('max_filesize')." Bytes!";
    }
    break;
    case UPLOAD_ERR_PARTIAL:
    echo "<p>"._PS_IP2C_ERROR_TRANSFER."";
    break;
    case UPLOAD_ERR_NO_FILE:
    echo "<p>"._PS_IP2C_ERROR_SELECT."";
    break;
    }
    }

    if($worked == 1) {
    OpenTable();
    echo "<center><strong>"._PS_IP2C_INFORMATION."!</strong><p>";
    echo "<P>"._PS_IP2C_REMOVED."<p>";
    $db->sql_query( "TRUNCATE TABLE ".$prefix."_blocked_iptoc" );
    $sql = 'LOAD DATA LOCAL INFILE \'' . $uploadfile . '\' INTO TABLE ' . $prefix . '_blocked_iptoc FIELDS TERMINATED BY \',\' ENCLOSED BY \'"\' LINES TERMINATED BY \'\\r\\n\'';
    $result = $db -> sql_query($sql);
    if($result) {
    $result = $db -> sql_query("SELECT count(*) FROM ".$prefix."_blocked_iptoc");
    list($c_after) = $db -> sql_fetchrow($result);
    echo ""._PS_IP2C_TABLE." ".$prefix."_blocked_iptoc "
    . ""._PS_IP2C_SUCCESS." ".$c_after." "._PS_IP2C_DATA_INSERT.""
    . "<p><form><div align=\"center\">"
    . "<input type=\"button\" value=\"close\" onClick=\"window.close()\">"
    . "</form></div>";
    } else {
    echo ""._PS_IP2C_ERROR_UPDATE." " . mysql_error();
    $choice = 0;
    echo "<br />"._PS_IP2C_ALTERNATIV."";
    }
    if($choice == 0) {
    echo "<P>"._PS_IP2C_TABLE_REMOVE." ".$prefix."_blocked_iptoc "._PS_IP2C_TABLE."! <p>";
    $db->sql_query( "TRUNCATE TABLE ".$prefix."_blocked_iptoc" );
    echo "<p>"._PS_IP2C_GRABBING."<p>";
    $handle = fopen("$uploadfile", "r");

    $i = 0;
    set_time_limit ( 900 ) ;
    $time_start = time();

    while ($data = fgetcsv($handle, 4096, ",")) {
    $i++;
    $num = count($data);
    $data[4] = preg_quote($data[4], "'");
    $query = "INSERT INTO ".$prefix."_blocked_iptoc values('$data[0]', '$data[1]', '$data[2]', '$data[3]', '$data[4]')";
    $result2 = $db -> sql_query($query);
    if(!$result2) {
    echo "<strong>"._PS_IP2C_ERROR."</strong><br />"._PS_IP2C_VALUE." "
    . "$data[0]', '$data[1]', '$data[2]', '$data[3]', '$data[4] "
    . "@ row $i "._PS_IP2C_ERROR_DATA_INSERT." <br /> \n". mysql_error();
    echo "<br />";
    die();
    }
    }
    fclose ($handle);
    $time_end = time();
    $tot = $time_end - $time_start;
    }
    if($result2) {
    echo ""._PS_IP2C_ALTERNATIV_WORK." $tot "._PS_IP2C_SEC_AND." "
    . "( $i ) "._PS_IP2C_DATA_INSERT."."
    . "<p><form><div align=\"center\">"
    . "<input type=\"button\" value=\""._PS_CLOSE."\" onClick=\"window.close()\">"
    . "</form></div>";
    } else {
    echo ""._PS_IP2C_ERROR_UPDATE2." " . mysql_error();
    }

    echo "</center>";
    CloseTable();
    } ELSE {
    echo "<p>"._PS_IP2C_BROWSE.""
    . "<form enctype=\"multipart/form-data\" action=\"".$admin_file.".php?"
    . "op=pro_upload\"method=\"post\">"
    . "<input name=\"NewFile\" type=\"file\" size=\"25\" accept=\"text/*\">"
    . "<p><p><input type=\"submit\" value=\""._PS_IP2C_UPDATE."\"></form>";
    }

    @unlink($uploadfile);

    } else {
    echo "<center><h1>Access Denied You are Not A God Admin!!</h1></center>";
    }

    ?>

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.