Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Exclamation I need your help even if you

    Hello
    Sorry for my poor English

    In my country a great number of people who understand the PHP language, but none of these people, I do not advise.
    I do not even answer

    I have a server set up Nod32, a private server for updates
    In the early stages of my work.

    NOD32 I'll update and upload files to my server manually.

    In a Google search and I was faced with the following code:

    PHP Code:
    #!/usr/bin/php
    <?php

    // recheck completion of every datafile each execution :  false - faster - mimics NOD32; true - slower, safer - for unstable networks
    $force_check false;

    // clean-up old unused *.nup files - saves disk space:  false | true
    $clean_unused true;

    // show individual downloaded files in log:  false | true
    $debug false;

    // unrar method - empty - use internal php mod_rar v2 or higher; use any string as an external command - 'unrar-free'
    // - external command will be called eg. `unrar-free -x /tmp/file.rar /tmp/`
    $unrar_method '';

    // list of update servers to use
    $eset_server_list '
    update.eset.com
    um10.eset.com
    93.184.71.27
    um12.eset.com
    89.202.157.227
    um14.eset.com
    62.67.184.68
    um16.eset.com
    90.183.101.10
    um18.eset.com
    89.202.149.36
    um10.eset.com
    93.184.71.27
    um12.eset.com
    89.202.157.227
    um14.eset.com
    89.202.149.36
    um16.eset.com
    u47.eset.com
    u48.eset.com
    u49.eset.com
    um10.eset.com
    93.184.71.27
    um12.eset.com
    89.202.157.227
    um14.eset.com
    89.202.149.36
    '
    ;

    // local shared folder
    $base_path '/var/www/nod32';

    // update path suffix
    $base_suffix '/3';

    // eg. we can access `http://nod32.server.tld` to physical path `/var/www/nod32` [$base_path]
    // if [base_suffix] = `/3`, it means we need to enter `http://nod32.server.tld/3` into NOD32 update path
    // beware, you must use a rewrite or apache virtualhost if you don't want to mix your web with NOD32 files
    //  - NOD32 uses absolute path /download to get its data files

    // temporary path, must exist and be writeable
    $tmp '/tmp';

    // Username and password sent to you by e-mail from ESET
    $user '';
    $pass '';


    ///////////////////////////////////////////////
    //      DO NOT EDIT BELOW THIS LINE
    ///////////////////////////////////////////////


    echo '------------------------'."\n"
        
    .'-  NodUpdate by Ashus  -'."\n"
        
    .'------------------------'."\n"."\n"
        
    .'Launched: '.date('Y-m-d H:i:s')."\n";

    // check all files if last update was not successfull
    if (is_file($tmp.'/nod32update.force-check.tmp'))
        {
        echo 
    'Note: Full forced check detected from previous unsuccessful run.'."\n";
        
    $force_check true;
        
    unlink($tmp.'/nod32update.force-check.tmp');
        }

    // prepare list of eset update servers
    $eset_server_list explode("\n",trim($eset_server_list));

    function 
    SelectRandomServer()
        {
        global 
    $eset_server_list$eset_server;
        
    $eset_server trim($eset_server_list[mt_rand(0,count($eset_server_list)-1)]);
        }

    // curl init
    $ch curl_init();
    curl_setopt($chCURLOPT_HEADERfalse);
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
    curl_setopt($chCURLOPT_CONNECTTIMEOUT30);
    curl_setopt($chCURLOPT_TIMEOUT900);
    curl_setopt($chCURLOPT_HTTP_VERSIONCURL_HTTP_VERSION_1_1);
    curl_setopt($chCURLOPT_USERAGENT'ESS Update (Windows; U; 32bit; VDB 6825; BPC 4.0.474.0; OS: 6.1.7600 SP 0.0 NT; CH 1.1; LNG 1029; x64c; UPD AUTOSELECT; APP ess; BEO 1; CPU 161612; ASP 0.0)');
    curl_setopt($chCURLOPT_HTTPHEADER, array('X-NOD32-Mode: passive'));


    // download update.ver meta info
    for ($i=3;$i>0;$i--)
        {
        
    SelectRandomServer();

        if (
    $debug)
            {echo 
    ' - trying to download http://'.$eset_server.'/eset_upd/update.ver'."\n";}

        
    curl_setopt($chCURLOPT_URL'http://'.$eset_server.'/eset_upd/update.ver');
        
    $data curl_exec($ch);
        if (! 
    $data)
            {
            echo 
    'Could not connect to server '.$eset_server.'.'."\n";
            if (
    $i==1)
                {die(
    'Maximum tries reached. Bye.'."\n");}
            } else {
            echo 
    'Successfully connected to server '.$eset_server.'.'."\n";
            break;
            }
        }

    if ( (
    is_file($base_path.$base_suffix.'/update.ver')) &&
        (
    md5_file($base_path.$base_suffix.'/update.ver'true) == md5($data,true)) )
        {
        if (
    $force_check)
            {
            echo 
    'Note: Update.ver checksum is the same, however force checking is enabled.'."\n";
            } else {
            die(
    'Update.ver checksum is the same, update not needed. Bye.'."\n");
            }
        }

    file_put_contents($tmp.'/nod32update.rar'$data);


    if (
    strlen($unrar_method) == 0)
        {
        
    // extract update.ver from RAR to variable   uses PECL mod_rar 2.0
        
    $rar_arch rar_open($tmp.'/nod32update.rar');
        if (
    $rar_arch === FALSE)
            die(
    'Could not extract update.ver. Bye.'."\n");

        list(
    $rar_entry) = rar_list($rar_arch);
        
    $rar_stream $rar_entry->getStream();
        
    $update_ver stream_get_contents($rar_stream);
        
    fclose($rar_stream);
        
    rar_close($rar_arch);

        } else {

        
    // external exec
        
    if (is_file($tmp.'/update.ver'))
            {
    unlink($tmp.'/update.ver');}
        
    $res3 exec($unrar_method.' -x "'.$tmp.'/nod32update.rar" "'.$tmp.'/"'$res2$res);
        if ((
    $res != 0) || (!is_file($tmp.'/update.ver')))
            {
            die(
    'Update.ver failed to extract ['.$res3.']. Bye.'."\n");
            }

        
    $update_ver file_get_contents($tmp.'/update.ver');
        
    unlink($tmp.'/update.ver');
        }



    // find all update files
    preg_match_all('`\sfile=(.*\.nup)\s`'$update_ver$update_files);
    $update_files $update_files[1];


    // download new and updated files
    curl_setopt($chCURLOPT_USERPWD$user.':'.$pass);

    $all_ok true;
    $updated_files 0;
    $total_size 0;

    foreach (
    $update_files as $upd_file)
        {
        
    // download only file info
        
    curl_setopt($chCURLOPT_HEADERtrue);
        
    curl_setopt($chCURLOPT_NOBODYtrue);
        
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue); // resets direct FILE output
        
    curl_setopt($chCURLOPT_URL'http://'.$eset_server.$upd_file);
        
    $data curl_exec($ch);

        
    $time_modified 0;
        if (
    preg_match('`\sLast\-Modified\: (.*)$`im'$data$time))
            {
            
    $time_modified strtotime(trim($time[1]));
            } else {
            echo 
    'Failed to receive modification time of from header of '.$upd_file.'. Downloading again.'."\n";
            }

        
    $size = -1;
        if (
    preg_match('`\Content\-Length\: (.*)$`im'$data$size))
            {
            
    $size = (float) (trim($size[1]));
            } else {
            echo 
    'Failed to receive filesize from header of '.$upd_file.'.'."\n";
            }

        if ( (! 
    is_file($base_path.$upd_file)) ||
            (
    $time_modified filemtime($base_path.$upd_file)) ||
            (
    $size != filesize($base_path.$upd_file)) )
            {

            
    // download complete file
            
    if ($debug)
                {echo 
    ' - downloading: '.$upd_file.''."\n";}

            
    curl_setopt($chCURLOPT_HEADERfalse);
            
    curl_setopt($chCURLOPT_NOBODYfalse);

            
    $dir dirname($base_path.$upd_file);
            if (! 
    is_dir($dir))
                {
    mkdir($dir0777true);}

            
    $df fopen($base_path.$upd_file'w');
            
    curl_setopt($chCURLOPT_FILE$df);
            
    curl_exec($ch);
            
    fclose($df);

            
    clearstatcache();
            
    $size_real filesize($base_path.$upd_file);
            
    $updated_files++;

            if (
    $size_real == $size)
                {
                
    touch($base_path.$upd_file$time_modified);
                } else {
                
    touch($base_path.$upd_file, ($time_modified-3600));
                
    $all_ok false;
                echo 
    'Warning: Filesize of '.$upd_file.' is different than expected, will be retried on next run.'."\n";
                }

            
    $total_size += $size_real;
            }
        }

    // update meta file
    $dir $base_path.$base_suffix;
    if (! 
    is_dir($dir))
        {
    mkdir($dir0777true);}
    rename($tmp.'/nod32update.rar'$base_path.$base_suffix.'/update.ver');


    function 
    bytes($a) {
        
    $unim = array("B","KB","MB","GB","TB","PB");
        
    $c 0;
        while (
    $a>=1024) {
            
    $c++;
            
    $a $a/1024;
        }
        return 
    number_format($a,($c 0),","," ")." ".$unim[$c];
        }

    if (! 
    $all_ok)
        {
        echo 
    'Note: Forcing full check on next run.'."\n";
        
    file_put_contents($tmp.'/nod32update.force-check.tmp','');
        }

    echo ((
    $updated_files>0)?'Successfully updated '.$updated_files.' files in size of '.bytes($total_size).'.'
            
    :'All files successfully checked.')."\n";


    // clean the old, outdated nup files
    if ($clean_unused)
        {
        
    $removed_files 0;
        
    $total_size 0;

        function 
    file_array($path$exclude ".|.."$include '*.nup')
            {
            
    $path rtrim($path"/") . "/";
            
    $folder_handle opendir($path);
            
    $exclude_array explode("|"$exclude);
            
    $result = array();
            while(
    false !== ($filename readdir($folder_handle))) {
                if (!
    in_array(strtolower($filename), $exclude_array))  {
                    if(
    is_dir($path.$filename."/")) {
                        
    $result array_merge($resultfile_array($path.$filename$exclude$include));
                        } else {
                        if (
    preg_match('`^'.strtr(preg_quote($include,'`'),array('\*'=>'.*?''\?'=>'.')).'$`i'$filename))
                            {
    $result[] = $path.$filename;}
                        }
                    }
                }
            return 
    $result;
            }

        
    $existing_files file_array($base_path);

        foreach (
    $existing_files as $curfile)
            {
            
    $curfile str_replace($base_path''$curfile);
            if (! 
    in_array($curfile$update_filestrue))
                {
                
    $size filesize($base_path.$curfile);
                if (
    unlink($base_path.$curfile))
                    {
                    
    $removed_files++;
                    
    $total_size += $size;
                    } else {
                    echo 
    'Could not remove unused file ('.$curfile.').'."\n";
                    }
                }
            }

        echo 
    'Clean-up complete.'.(($removed_files>0)?' '.$removed_files.' files in size of '.bytes($total_size).' were removed.':' No files were removed.')."\n";
        }

    ?>
    This code is related to the year 2010

    I need your help to complete and fix the problem with this code, I am

    One other example:
    PHP Code:
    #Script settings
    #User name and password
    USER_NAME=YOUR_USER_NAME
    PASSWORD
    =YOUR_PASS_WORD
    #Language code to download (0 for all)
    language=1033
     
    #download components or not, 0 no , 1 yes.
    component=1
     
    #Server address (root), no trailing slash
    SERVER="http://update.eset.com"
     
    #Path to update.ver on server
    UPDATE='eset_upd/update.ver'
     
    #Path to save update into
    SAVETO="/home/f0rud/upd" 
    I am entering the code requires a username and password to get the update file and folder on the server to save

    All files updated to include 32-bit and 64 bit versions of NOD32 Antivirus or ESET Smart Security to download

  • #2
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Not someone help me?

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,474
    Thanks
    63
    Thanked 537 Times in 524 Posts
    You need help to fix the year 2010 but you've not even told us what the problem is.

    You've supplied code and not told us what it is suppose to do or what it is for.

    How are we supposed to help?
    I can't really think of anything to write here now...

  • Users who have thanked tangoforce for this post:

    90ts70 (02-01-2012)

  • #4
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post
    yea,You have to spot out the error that code produces before we can help..

  • Users who have thanked razzbee for this post:

    90ts70 (02-01-2012)

  • #5
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    5
    Thanked 0 Times in 0 Posts
    I'm not familiar with PHP
    I request help from people who are professionals

    Your friends want to try this code if you have the problem solved.

    PHP Code:
    #!/usr/bin/php
    <?php

    // recheck completion of every datafile each execution :  false - faster - mimics NOD32; true - slower, safer - for unstable networks
    $force_check false;

    // clean-up old unused *.nup files - saves disk space:  false | true
    $clean_unused true;

    // show individual downloaded files in log:  false | true
    $debug false;

    // unrar method - empty - use internal php mod_rar v2 or higher; use any string as an external command - 'unrar-free'
    // - external command will be called eg. `unrar-free -x /tmp/file.rar /tmp/`
    $unrar_method '';

    // list of update servers to use
    $eset_server_list '
    update.eset.com
    um10.eset.com
    93.184.71.27
    um12.eset.com
    89.202.157.227
    um14.eset.com
    62.67.184.68
    um16.eset.com
    90.183.101.10
    um18.eset.com
    89.202.149.36
    um10.eset.com
    93.184.71.27
    um12.eset.com
    89.202.157.227
    um14.eset.com
    89.202.149.36
    um16.eset.com
    u47.eset.com
    u48.eset.com
    u49.eset.com
    um10.eset.com
    93.184.71.27
    um12.eset.com
    89.202.157.227
    um14.eset.com
    89.202.149.36
    '
    ;

    // local shared folder
    $base_path '/var/www/nod32';

    // update path suffix
    $base_suffix '/3';

    // eg. we can access `http://nod32.server.tld` to physical path `/var/www/nod32` [$base_path]
    // if [base_suffix] = `/3`, it means we need to enter `http://nod32.server.tld/3` into NOD32 update path
    // beware, you must use a rewrite or apache virtualhost if you don't want to mix your web with NOD32 files
    //  - NOD32 uses absolute path /download to get its data files

    // temporary path, must exist and be writeable
    $tmp '/tmp';

    // Username and password sent to you by e-mail from ESET
    $user '';
    $pass '';


    ///////////////////////////////////////////////
    //      DO NOT EDIT BELOW THIS LINE
    ///////////////////////////////////////////////


    echo '------------------------'."\n"
        
    .'-  NodUpdate by Ashus  -'."\n"
        
    .'------------------------'."\n"."\n"
        
    .'Launched: '.date('Y-m-d H:i:s')."\n";

    // check all files if last update was not successfull
    if (is_file($tmp.'/nod32update.force-check.tmp'))
        {
        echo 
    'Note: Full forced check detected from previous unsuccessful run.'."\n";
        
    $force_check true;
        
    unlink($tmp.'/nod32update.force-check.tmp');
        }

    // prepare list of eset update servers
    $eset_server_list explode("\n",trim($eset_server_list));

    function 
    SelectRandomServer()
        {
        global 
    $eset_server_list$eset_server;
        
    $eset_server trim($eset_server_list[mt_rand(0,count($eset_server_list)-1)]);
        }

    // curl init
    $ch curl_init();
    curl_setopt($chCURLOPT_HEADERfalse);
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
    curl_setopt($chCURLOPT_CONNECTTIMEOUT30);
    curl_setopt($chCURLOPT_TIMEOUT900);
    curl_setopt($chCURLOPT_HTTP_VERSIONCURL_HTTP_VERSION_1_1);
    curl_setopt($chCURLOPT_USERAGENT'ESS Update (Windows; U; 32bit; VDB 6825; BPC 4.0.474.0; OS: 6.1.7600 SP 0.0 NT; CH 1.1; LNG 1029; x64c; UPD AUTOSELECT; APP ess; BEO 1; CPU 161612; ASP 0.0)');
    curl_setopt($chCURLOPT_HTTPHEADER, array('X-NOD32-Mode: passive'));


    // download update.ver meta info
    for ($i=3;$i>0;$i--)
        {
        
    SelectRandomServer();

        if (
    $debug)
            {echo 
    ' - trying to download http://'.$eset_server.'/eset_upd/update.ver'."\n";}

        
    curl_setopt($chCURLOPT_URL'http://'.$eset_server.'/eset_upd/update.ver');
        
    $data curl_exec($ch);
        if (! 
    $data)
            {
            echo 
    'Could not connect to server '.$eset_server.'.'."\n";
            if (
    $i==1)
                {die(
    'Maximum tries reached. Bye.'."\n");}
            } else {
            echo 
    'Successfully connected to server '.$eset_server.'.'."\n";
            break;
            }
        }

    if ( (
    is_file($base_path.$base_suffix.'/update.ver')) &&
        (
    md5_file($base_path.$base_suffix.'/update.ver'true) == md5($data,true)) )
        {
        if (
    $force_check)
            {
            echo 
    'Note: Update.ver checksum is the same, however force checking is enabled.'."\n";
            } else {
            die(
    'Update.ver checksum is the same, update not needed. Bye.'."\n");
            }
        }

    file_put_contents($tmp.'/nod32update.rar'$data);


    if (
    strlen($unrar_method) == 0)
        {
        
    // extract update.ver from RAR to variable   uses PECL mod_rar 2.0
        
    $rar_arch rar_open($tmp.'/nod32update.rar');
        if (
    $rar_arch === FALSE)
            die(
    'Could not extract update.ver. Bye.'."\n");

        list(
    $rar_entry) = rar_list($rar_arch);
        
    $rar_stream $rar_entry->getStream();
        
    $update_ver stream_get_contents($rar_stream);
        
    fclose($rar_stream);
        
    rar_close($rar_arch);

        } else {

        
    // external exec
        
    if (is_file($tmp.'/update.ver'))
            {
    unlink($tmp.'/update.ver');}
        
    $res3 exec($unrar_method.' -x "'.$tmp.'/nod32update.rar" "'.$tmp.'/"'$res2$res);
        if ((
    $res != 0) || (!is_file($tmp.'/update.ver')))
            {
            die(
    'Update.ver failed to extract ['.$res3.']. Bye.'."\n");
            }

        
    $update_ver file_get_contents($tmp.'/update.ver');
        
    unlink($tmp.'/update.ver');
        }



    // find all update files
    preg_match_all('`\sfile=(.*\.nup)\s`'$update_ver$update_files);
    $update_files $update_files[1];


    // download new and updated files
    curl_setopt($chCURLOPT_USERPWD$user.':'.$pass);

    $all_ok true;
    $updated_files 0;
    $total_size 0;

    foreach (
    $update_files as $upd_file)
        {
        
    // download only file info
        
    curl_setopt($chCURLOPT_HEADERtrue);
        
    curl_setopt($chCURLOPT_NOBODYtrue);
        
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue); // resets direct FILE output
        
    curl_setopt($chCURLOPT_URL'http://'.$eset_server.$upd_file);
        
    $data curl_exec($ch);

        
    $time_modified 0;
        if (
    preg_match('`\sLast\-Modified\: (.*)$`im'$data$time))
            {
            
    $time_modified strtotime(trim($time[1]));
            } else {
            echo 
    'Failed to receive modification time of from header of '.$upd_file.'. Downloading again.'."\n";
            }

        
    $size = -1;
        if (
    preg_match('`\Content\-Length\: (.*)$`im'$data$size))
            {
            
    $size = (float) (trim($size[1]));
            } else {
            echo 
    'Failed to receive filesize from header of '.$upd_file.'.'."\n";
            }

        if ( (! 
    is_file($base_path.$upd_file)) ||
            (
    $time_modified filemtime($base_path.$upd_file)) ||
            (
    $size != filesize($base_path.$upd_file)) )
            {

            
    // download complete file
            
    if ($debug)
                {echo 
    ' - downloading: '.$upd_file.''."\n";}

            
    curl_setopt($chCURLOPT_HEADERfalse);
            
    curl_setopt($chCURLOPT_NOBODYfalse);

            
    $dir dirname($base_path.$upd_file);
            if (! 
    is_dir($dir))
                {
    mkdir($dir0777true);}

            
    $df fopen($base_path.$upd_file'w');
            
    curl_setopt($chCURLOPT_FILE$df);
            
    curl_exec($ch);
            
    fclose($df);

            
    clearstatcache();
            
    $size_real filesize($base_path.$upd_file);
            
    $updated_files++;

            if (
    $size_real == $size)
                {
                
    touch($base_path.$upd_file$time_modified);
                } else {
                
    touch($base_path.$upd_file, ($time_modified-3600));
                
    $all_ok false;
                echo 
    'Warning: Filesize of '.$upd_file.' is different than expected, will be retried on next run.'."\n";
                }

            
    $total_size += $size_real;
            }
        }

    // update meta file
    $dir $base_path.$base_suffix;
    if (! 
    is_dir($dir))
        {
    mkdir($dir0777true);}
    rename($tmp.'/nod32update.rar'$base_path.$base_suffix.'/update.ver');


    function 
    bytes($a) {
        
    $unim = array("B","KB","MB","GB","TB","PB");
        
    $c 0;
        while (
    $a>=1024) {
            
    $c++;
            
    $a $a/1024;
        }
        return 
    number_format($a,($c 0),","," ")." ".$unim[$c];
        }

    if (! 
    $all_ok)
        {
        echo 
    'Note: Forcing full check on next run.'."\n";
        
    file_put_contents($tmp.'/nod32update.force-check.tmp','');
        }

    echo ((
    $updated_files>0)?'Successfully updated '.$updated_files.' files in size of '.bytes($total_size).'.'
            
    :'All files successfully checked.')."\n";


    // clean the old, outdated nup files
    if ($clean_unused)
        {
        
    $removed_files 0;
        
    $total_size 0;

        function 
    file_array($path$exclude ".|.."$include '*.nup')
            {
            
    $path rtrim($path"/") . "/";
            
    $folder_handle opendir($path);
            
    $exclude_array explode("|"$exclude);
            
    $result = array();
            while(
    false !== ($filename readdir($folder_handle))) {
                if (!
    in_array(strtolower($filename), $exclude_array))  {
                    if(
    is_dir($path.$filename."/")) {
                        
    $result array_merge($resultfile_array($path.$filename$exclude$include));
                        } else {
                        if (
    preg_match('`^'.strtr(preg_quote($include,'`'),array('\*'=>'.*?''\?'=>'.')).'$`i'$filename))
                            {
    $result[] = $path.$filename;}
                        }
                    }
                }
            return 
    $result;
            }

        
    $existing_files file_array($base_path);

        foreach (
    $existing_files as $curfile)
            {
            
    $curfile str_replace($base_path''$curfile);
            if (! 
    in_array($curfile$update_filestrue))
                {
                
    $size filesize($base_path.$curfile);
                if (
    unlink($base_path.$curfile))
                    {
                    
    $removed_files++;
                    
    $total_size += $size;
                    } else {
                    echo 
    'Could not remove unused file ('.$curfile.').'."\n";
                    }
                }
            }

        echo 
    'Clean-up complete.'.(($removed_files>0)?' '.$removed_files.' files in size of '.bytes($total_size).' were removed.':' No files were removed.')."\n";
        }

    ?>
    I launched my private server updade NOD32
    And at this rate I know that this script will download the files on the server node updates
    Last edited by 90ts70; 02-01-2012 at 04:03 PM.

  • #6
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    5
    Thanked 0 Times in 0 Posts
    I'm not familiar with PHP
    I request help from people who are professionals

    Your friends want to try this code if you have the problem solved.

    PHP Code:
    #!/usr/bin/php
    <?php

    // recheck completion of every datafile each execution :  false - faster - mimics NOD32; true - slower, safer - for unstable networks
    $force_check false;

    // clean-up old unused *.nup files - saves disk space:  false | true
    $clean_unused true;

    // show individual downloaded files in log:  false | true
    $debug false;

    // unrar method - empty - use internal php mod_rar v2 or higher; use any string as an external command - 'unrar-free'
    // - external command will be called eg. `unrar-free -x /tmp/file.rar /tmp/`
    $unrar_method '';

    // list of update servers to use
    $eset_server_list '
    update.eset.com
    um10.eset.com
    93.184.71.27
    um12.eset.com
    89.202.157.227
    um14.eset.com
    62.67.184.68
    um16.eset.com
    90.183.101.10
    um18.eset.com
    89.202.149.36
    um10.eset.com
    93.184.71.27
    um12.eset.com
    89.202.157.227
    um14.eset.com
    89.202.149.36
    um16.eset.com
    u47.eset.com
    u48.eset.com
    u49.eset.com
    um10.eset.com
    93.184.71.27
    um12.eset.com
    89.202.157.227
    um14.eset.com
    89.202.149.36
    '
    ;

    // local shared folder
    $base_path '/var/www/nod32';

    // update path suffix
    $base_suffix '/3';

    // eg. we can access `http://nod32.server.tld` to physical path `/var/www/nod32` [$base_path]
    // if [base_suffix] = `/3`, it means we need to enter `http://nod32.server.tld/3` into NOD32 update path
    // beware, you must use a rewrite or apache virtualhost if you don't want to mix your web with NOD32 files
    //  - NOD32 uses absolute path /download to get its data files

    // temporary path, must exist and be writeable
    $tmp '/tmp';

    // Username and password sent to you by e-mail from ESET
    $user '';
    $pass '';


    ///////////////////////////////////////////////
    //      DO NOT EDIT BELOW THIS LINE
    ///////////////////////////////////////////////


    echo '------------------------'."\n"
        
    .'-  NodUpdate by Ashus  -'."\n"
        
    .'------------------------'."\n"."\n"
        
    .'Launched: '.date('Y-m-d H:i:s')."\n";

    // check all files if last update was not successfull
    if (is_file($tmp.'/nod32update.force-check.tmp'))
        {
        echo 
    'Note: Full forced check detected from previous unsuccessful run.'."\n";
        
    $force_check true;
        
    unlink($tmp.'/nod32update.force-check.tmp');
        }

    // prepare list of eset update servers
    $eset_server_list explode("\n",trim($eset_server_list));

    function 
    SelectRandomServer()
        {
        global 
    $eset_server_list$eset_server;
        
    $eset_server trim($eset_server_list[mt_rand(0,count($eset_server_list)-1)]);
        }

    // curl init
    $ch curl_init();
    curl_setopt($chCURLOPT_HEADERfalse);
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
    curl_setopt($chCURLOPT_CONNECTTIMEOUT30);
    curl_setopt($chCURLOPT_TIMEOUT900);
    curl_setopt($chCURLOPT_HTTP_VERSIONCURL_HTTP_VERSION_1_1);
    curl_setopt($chCURLOPT_USERAGENT'ESS Update (Windows; U; 32bit; VDB 6825; BPC 4.0.474.0; OS: 6.1.7600 SP 0.0 NT; CH 1.1; LNG 1029; x64c; UPD AUTOSELECT; APP ess; BEO 1; CPU 161612; ASP 0.0)');
    curl_setopt($chCURLOPT_HTTPHEADER, array('X-NOD32-Mode: passive'));


    // download update.ver meta info
    for ($i=3;$i>0;$i--)
        {
        
    SelectRandomServer();

        if (
    $debug)
            {echo 
    ' - trying to download http://'.$eset_server.'/eset_upd/update.ver'."\n";}

        
    curl_setopt($chCURLOPT_URL'http://'.$eset_server.'/eset_upd/update.ver');
        
    $data curl_exec($ch);
        if (! 
    $data)
            {
            echo 
    'Could not connect to server '.$eset_server.'.'."\n";
            if (
    $i==1)
                {die(
    'Maximum tries reached. Bye.'."\n");}
            } else {
            echo 
    'Successfully connected to server '.$eset_server.'.'."\n";
            break;
            }
        }

    if ( (
    is_file($base_path.$base_suffix.'/update.ver')) &&
        (
    md5_file($base_path.$base_suffix.'/update.ver'true) == md5($data,true)) )
        {
        if (
    $force_check)
            {
            echo 
    'Note: Update.ver checksum is the same, however force checking is enabled.'."\n";
            } else {
            die(
    'Update.ver checksum is the same, update not needed. Bye.'."\n");
            }
        }

    file_put_contents($tmp.'/nod32update.rar'$data);


    if (
    strlen($unrar_method) == 0)
        {
        
    // extract update.ver from RAR to variable   uses PECL mod_rar 2.0
        
    $rar_arch rar_open($tmp.'/nod32update.rar');
        if (
    $rar_arch === FALSE)
            die(
    'Could not extract update.ver. Bye.'."\n");

        list(
    $rar_entry) = rar_list($rar_arch);
        
    $rar_stream $rar_entry->getStream();
        
    $update_ver stream_get_contents($rar_stream);
        
    fclose($rar_stream);
        
    rar_close($rar_arch);

        } else {

        
    // external exec
        
    if (is_file($tmp.'/update.ver'))
            {
    unlink($tmp.'/update.ver');}
        
    $res3 exec($unrar_method.' -x "'.$tmp.'/nod32update.rar" "'.$tmp.'/"'$res2$res);
        if ((
    $res != 0) || (!is_file($tmp.'/update.ver')))
            {
            die(
    'Update.ver failed to extract ['.$res3.']. Bye.'."\n");
            }

        
    $update_ver file_get_contents($tmp.'/update.ver');
        
    unlink($tmp.'/update.ver');
        }



    // find all update files
    preg_match_all('`\sfile=(.*\.nup)\s`'$update_ver$update_files);
    $update_files $update_files[1];


    // download new and updated files
    curl_setopt($chCURLOPT_USERPWD$user.':'.$pass);

    $all_ok true;
    $updated_files 0;
    $total_size 0;

    foreach (
    $update_files as $upd_file)
        {
        
    // download only file info
        
    curl_setopt($chCURLOPT_HEADERtrue);
        
    curl_setopt($chCURLOPT_NOBODYtrue);
        
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue); // resets direct FILE output
        
    curl_setopt($chCURLOPT_URL'http://'.$eset_server.$upd_file);
        
    $data curl_exec($ch);

        
    $time_modified 0;
        if (
    preg_match('`\sLast\-Modified\: (.*)$`im'$data$time))
            {
            
    $time_modified strtotime(trim($time[1]));
            } else {
            echo 
    'Failed to receive modification time of from header of '.$upd_file.'. Downloading again.'."\n";
            }

        
    $size = -1;
        if (
    preg_match('`\Content\-Length\: (.*)$`im'$data$size))
            {
            
    $size = (float) (trim($size[1]));
            } else {
            echo 
    'Failed to receive filesize from header of '.$upd_file.'.'."\n";
            }

        if ( (! 
    is_file($base_path.$upd_file)) ||
            (
    $time_modified filemtime($base_path.$upd_file)) ||
            (
    $size != filesize($base_path.$upd_file)) )
            {

            
    // download complete file
            
    if ($debug)
                {echo 
    ' - downloading: '.$upd_file.''."\n";}

            
    curl_setopt($chCURLOPT_HEADERfalse);
            
    curl_setopt($chCURLOPT_NOBODYfalse);

            
    $dir dirname($base_path.$upd_file);
            if (! 
    is_dir($dir))
                {
    mkdir($dir0777true);}

            
    $df fopen($base_path.$upd_file'w');
            
    curl_setopt($chCURLOPT_FILE$df);
            
    curl_exec($ch);
            
    fclose($df);

            
    clearstatcache();
            
    $size_real filesize($base_path.$upd_file);
            
    $updated_files++;

            if (
    $size_real == $size)
                {
                
    touch($base_path.$upd_file$time_modified);
                } else {
                
    touch($base_path.$upd_file, ($time_modified-3600));
                
    $all_ok false;
                echo 
    'Warning: Filesize of '.$upd_file.' is different than expected, will be retried on next run.'."\n";
                }

            
    $total_size += $size_real;
            }
        }

    // update meta file
    $dir $base_path.$base_suffix;
    if (! 
    is_dir($dir))
        {
    mkdir($dir0777true);}
    rename($tmp.'/nod32update.rar'$base_path.$base_suffix.'/update.ver');


    function 
    bytes($a) {
        
    $unim = array("B","KB","MB","GB","TB","PB");
        
    $c 0;
        while (
    $a>=1024) {
            
    $c++;
            
    $a $a/1024;
        }
        return 
    number_format($a,($c 0),","," ")." ".$unim[$c];
        }

    if (! 
    $all_ok)
        {
        echo 
    'Note: Forcing full check on next run.'."\n";
        
    file_put_contents($tmp.'/nod32update.force-check.tmp','');
        }

    echo ((
    $updated_files>0)?'Successfully updated '.$updated_files.' files in size of '.bytes($total_size).'.'
            
    :'All files successfully checked.')."\n";


    // clean the old, outdated nup files
    if ($clean_unused)
        {
        
    $removed_files 0;
        
    $total_size 0;

        function 
    file_array($path$exclude ".|.."$include '*.nup')
            {
            
    $path rtrim($path"/") . "/";
            
    $folder_handle opendir($path);
            
    $exclude_array explode("|"$exclude);
            
    $result = array();
            while(
    false !== ($filename readdir($folder_handle))) {
                if (!
    in_array(strtolower($filename), $exclude_array))  {
                    if(
    is_dir($path.$filename."/")) {
                        
    $result array_merge($resultfile_array($path.$filename$exclude$include));
                        } else {
                        if (
    preg_match('`^'.strtr(preg_quote($include,'`'),array('\*'=>'.*?''\?'=>'.')).'$`i'$filename))
                            {
    $result[] = $path.$filename;}
                        }
                    }
                }
            return 
    $result;
            }

        
    $existing_files file_array($base_path);

        foreach (
    $existing_files as $curfile)
            {
            
    $curfile str_replace($base_path''$curfile);
            if (! 
    in_array($curfile$update_filestrue))
                {
                
    $size filesize($base_path.$curfile);
                if (
    unlink($base_path.$curfile))
                    {
                    
    $removed_files++;
                    
    $total_size += $size;
                    } else {
                    echo 
    'Could not remove unused file ('.$curfile.').'."\n";
                    }
                }
            }

        echo 
    'Clean-up complete.'.(($removed_files>0)?' '.$removed_files.' files in size of '.bytes($total_size).' were removed.':' No files were removed.')."\n";
        }

    ?>

    I launched my private server updade NOD32
    And at this rate I know that this script will download the files on the server node updates

  • #7
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,474
    Thanks
    63
    Thanked 537 Times in 524 Posts
    What exactly is the fault with the code?

    What do you expect it to do? What is it actually doing?

    You are going round in circles. What is NOD32?

    What is this problem with 2010?

    You are not helping yourself.
    I can't really think of anything to write here now...

  • Users who have thanked tangoforce for this post:

    90ts70 (02-01-2012)

  • #8
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,474
    Thanks
    63
    Thanked 537 Times in 524 Posts
    I am advising you to post your reply in public because someone else might be able to help you.

    It doesn't mean I take sole responsibility for your issue and you should PM me. I don't want you to PM me with your answers, I want you to post them HERE in this thread.

    Thank you.
    I can't really think of anything to write here now...

  • Users who have thanked tangoforce for this post:

    90ts70 (02-01-2012)

  • #9
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    5
    Thanked 0 Times in 0 Posts
    ok please forward my mssages to me for shared here

  • #10
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,474
    Thanks
    63
    Thanked 537 Times in 524 Posts
    Quote Originally Posted by 90ts70 View Post
    ok please forward my mssages to me for shared here
    What? - I am not your slave, personal assistant or translator.

    Your PM didn't even answer my questions properly and most of it didn't even make sense either. You're the one asking for help, how about you stop being lazy and put in some effort?
    I can't really think of anything to write here now...

  • #11
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    According to wikipedia, ESET NOD32 (commonly referred to simply as "NOD32") is apparently a Slovakian antivirus software package. This seems to fit with the server list present in the code provided by the OP (lots of references to eset.com, which is the home site of ESET NOD32).

    So, we can at least put that matter to rest. The OP is working with an antivirus update for his server - perhaps needing a cron job or similar to auto-update his virus definitions?

    As for the specific problem being encountered and any relation to the year 2010, I have no idea so far...

    Edit: Just noticed this bit of text tucked in at the bottom of the OP's first PHP script box:

    I launched my private server updade NOD32
    And at this rate I know that this script will download the files on the server node updates
    Sounds like maybe the definition update package will download properly but won't apply itself to the server's installation of NOD32? But then again maybe I'm just grasping at straws at this point.
    Last edited by Rowsdower!; 02-02-2012 at 02:01 PM.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • Users who have thanked Rowsdower! for this post:

    90ts70 (02-02-2012)

  • #12
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Thank you
    The problem was solved when I need to delete the admin's post

    I poured out my order to this location


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •