...

View Full Version : I need your help even if you



90ts70
01-31-2012, 08:18 PM
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:



#!/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($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 900);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_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($ch, CURLOPT_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($ch, CURLOPT_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($ch, CURLOPT_USERPWD, $user.':'.$pass);

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

foreach ($update_files as $upd_file)
{
// download only file info
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // resets direct FILE output
curl_setopt($ch, CURLOPT_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($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);

$dir = dirname($base_path.$upd_file);
if (! is_dir($dir))
{mkdir($dir, 0777, true);}

$df = fopen($base_path.$upd_file, 'w');
curl_setopt($ch, CURLOPT_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($dir, 0777, true);}
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 ? 2 : 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($result, file_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_files, true))
{
$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:


#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

90ts70
02-01-2012, 11:34 AM
Not someone help me?

tangoforce
02-01-2012, 12:46 PM
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?

razzbee
02-01-2012, 01:15 PM
yea,You have to spot out the error that code produces before we can help..

90ts70
02-01-2012, 02:57 PM
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.



#!/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($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 900);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_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($ch, CURLOPT_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($ch, CURLOPT_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($ch, CURLOPT_USERPWD, $user.':'.$pass);

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

foreach ($update_files as $upd_file)
{
// download only file info
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // resets direct FILE output
curl_setopt($ch, CURLOPT_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($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);

$dir = dirname($base_path.$upd_file);
if (! is_dir($dir))
{mkdir($dir, 0777, true);}

$df = fopen($base_path.$upd_file, 'w');
curl_setopt($ch, CURLOPT_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($dir, 0777, true);}
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 ? 2 : 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($result, file_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_files, true))
{
$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

90ts70
02-01-2012, 02:57 PM
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.



#!/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($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 900);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_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($ch, CURLOPT_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($ch, CURLOPT_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($ch, CURLOPT_USERPWD, $user.':'.$pass);

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

foreach ($update_files as $upd_file)
{
// download only file info
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // resets direct FILE output
curl_setopt($ch, CURLOPT_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($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);

$dir = dirname($base_path.$upd_file);
if (! is_dir($dir))
{mkdir($dir, 0777, true);}

$df = fopen($base_path.$upd_file, 'w');
curl_setopt($ch, CURLOPT_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($dir, 0777, true);}
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 ? 2 : 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($result, file_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_files, true))
{
$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

tangoforce
02-01-2012, 07:50 PM
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.

tangoforce
02-01-2012, 09:10 PM
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.

90ts70
02-01-2012, 09:15 PM
ok please forward my mssages to me for shared here

tangoforce
02-01-2012, 09:44 PM
ok please forward my mssages to me for shared here

:eek: 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?

Rowsdower!
02-02-2012, 12:57 PM
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...

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.

90ts70
02-02-2012, 04:28 PM
Thank you
The problem was solved when I need to delete the admin's post

I poured out my order to this location



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum