thesavior
04-27-2006, 03:46 AM
I am trying to open a tar, and copy the files into the main directory.
this is my code:
<?php
$file['size'] = $_FILES['style_package']['size'];
$file['error'] = $_FILES['style_package']['error'];
$file['name'] = $_FILES['style_package']['name'];
$file['tmp_name'] = $_FILES['style_package']['tmp_name'];
if(substr($file['name'], -4) == '.php' && $cur_project['PowerBBmod'] == 0) $file['name'] .= 's';
switch ($file['error'])
{
case 1:
case 2:
$errors[] = $file['name'].': Too large ini';
break;
case 3:
$errors[] = $file['name'].': Partial upload';
break;
}
if($file['size'] > 0 && empty($errors))
{
$filename = $file['tmp_name'];
$fp = fopen($filename,"rb");
$tar_file = fread($fp,filesize($filename));
fclose($fp);
$tar_length = strlen($tar_file);
$main_offset = 0;
$outbuffer = '';
$error = 0;
$lastdir = '';
while($main_offset < $tar_length)
{
if(substr($tar_file,$main_offset,512) == str_repeat(chr(0),512)) break;
$position = strpos(substr($tar_file,$main_offset,100),chr(0));
$filename = substr(substr($tar_file,$main_offset,100),0,$position);
$filesize = octdec(substr($tar_file,$main_offset + 124,12));
$filecontents = substr($tar_file,$main_offset + 512,$filesize);
if($filesize > 0)
{
if(is_file($filename))
{
$outbuffer .= "\t\t\t\t\t".'<li><strong>File already existed:</strong> '.$filename.' - Not unpacked</li>'."\n";
$error = 1;
}
else
{
$f = fopen($filename, 'w');
fwrite($f, $filecontents);
fclose($f);
$outbuffer .= "\t\t\t\t\t".'<li>Unpacked file: '.$filename.'</li>'."\n";
}
}
else
{
$dirs = explode('/', $filename);
foreach($dirs as $dir)
{
$cdir = $lastdir.$dir;
if(@mkdir($cdir))
{
$outbuffer .= "\t\t\t\t\t".'<li>Created directory: '.$filename.'</li>'."\n";
$f = fopen($filename.'/index.html', 'w');
fwrite($f, "<html>\n<head>\n<title>.</title>\n</head>\n<body>\n.\n</body>\n</html>");
fclose($f);
}
$lastdir = $cdir.'/';
}
$lastdir = '';
}
$main_offset += 512 + (ceil($filesize / 512) * 512);
?>
and these are the errors im getting:
Warning: fopen(img/Night/adminmenu.png) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/b.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/bg.png) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/cat_center.jpg) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/center.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/code.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/color.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/h.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/headerbg.png) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/header_forums2.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/header_forums3.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/hr.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/i.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/img.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/index.html) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/is.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/left.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
and the list goes on and on. What I am thinking, is that it isn't reading the tar, it is trying to read something else. I could be wrong, but can someone take a look at this?
this is my code:
<?php
$file['size'] = $_FILES['style_package']['size'];
$file['error'] = $_FILES['style_package']['error'];
$file['name'] = $_FILES['style_package']['name'];
$file['tmp_name'] = $_FILES['style_package']['tmp_name'];
if(substr($file['name'], -4) == '.php' && $cur_project['PowerBBmod'] == 0) $file['name'] .= 's';
switch ($file['error'])
{
case 1:
case 2:
$errors[] = $file['name'].': Too large ini';
break;
case 3:
$errors[] = $file['name'].': Partial upload';
break;
}
if($file['size'] > 0 && empty($errors))
{
$filename = $file['tmp_name'];
$fp = fopen($filename,"rb");
$tar_file = fread($fp,filesize($filename));
fclose($fp);
$tar_length = strlen($tar_file);
$main_offset = 0;
$outbuffer = '';
$error = 0;
$lastdir = '';
while($main_offset < $tar_length)
{
if(substr($tar_file,$main_offset,512) == str_repeat(chr(0),512)) break;
$position = strpos(substr($tar_file,$main_offset,100),chr(0));
$filename = substr(substr($tar_file,$main_offset,100),0,$position);
$filesize = octdec(substr($tar_file,$main_offset + 124,12));
$filecontents = substr($tar_file,$main_offset + 512,$filesize);
if($filesize > 0)
{
if(is_file($filename))
{
$outbuffer .= "\t\t\t\t\t".'<li><strong>File already existed:</strong> '.$filename.' - Not unpacked</li>'."\n";
$error = 1;
}
else
{
$f = fopen($filename, 'w');
fwrite($f, $filecontents);
fclose($f);
$outbuffer .= "\t\t\t\t\t".'<li>Unpacked file: '.$filename.'</li>'."\n";
}
}
else
{
$dirs = explode('/', $filename);
foreach($dirs as $dir)
{
$cdir = $lastdir.$dir;
if(@mkdir($cdir))
{
$outbuffer .= "\t\t\t\t\t".'<li>Created directory: '.$filename.'</li>'."\n";
$f = fopen($filename.'/index.html', 'w');
fwrite($f, "<html>\n<head>\n<title>.</title>\n</head>\n<body>\n.\n</body>\n</html>");
fclose($f);
}
$lastdir = $cdir.'/';
}
$lastdir = '';
}
$main_offset += 512 + (ceil($filesize / 512) * 512);
?>
and these are the errors im getting:
Warning: fopen(img/Night/adminmenu.png) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/b.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/bg.png) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/cat_center.jpg) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/center.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/code.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/color.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/h.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/headerbg.png) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/header_forums2.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/header_forums3.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/hr.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/i.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/img.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/index.html) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/is.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
Warning: fwrite(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 60
Warning: fclose(): supplied argument is not a valid stream resource in /raid5/home/eli/public_html/forum/admin_themes.php on line 61
Warning: fopen(img/Night/left.gif) [function.fopen]: failed to open stream: No such file or directory in /raid5/home/eli/public_html/forum/admin_themes.php on line 59
and the list goes on and on. What I am thinking, is that it isn't reading the tar, it is trying to read something else. I could be wrong, but can someone take a look at this?