<?
function rdir($dir) {
if ($handle=opendir($dir)) {
while (($file=readdir($handle))<>false) {
if (is_file($dir."/".$file)) {
if ($file<>'.htaccess') {
chmod($dir."/".$file,0777); unlink($dir."/".$file);}}
elseif (is_dir($dir."/".$file)&&($file<>".")&&($file<>".."))
{chmod($dir."/".$file,0777); rdir($dir."/".$file);}
} closedir($handle);
chmod($dir,0777);
if (rmdir($dir)) {return true;} else {return false;}}}
function markImage ( $image, $saveto )
{
global $copyright;
$q = 100; //quality
$pinfo = pathinfo ( $image );
$ext = strtolower ( $pinfo['extension'] );
switch ( $ext )
{
case 'gif':
$i = imagecreatefromgif ( $image );
$createfunc='imagegif';
break;
case 'jpg': case 'jpeg':
$i = imagecreatefromjpeg ( $image );
$createfunc='imagejpeg';
break; break;
case 'png':
$i = imagecreatefrompng ( $image );
$createfunc='imagepng';
break;
default:
RETURN FALSE;
break;
}
//$white = imagecolorallocate ( $i, 255, 10, 15 );
//imagestring ( $i, 3, 2, 1, $copyright, $white);
$i2 = imagecreatefrompng ( '../inc/mark.png' );
imagejpeg ( $i, '../tmp/tmp.jpeg' );
$i = imagecreatefromjpeg ( '../tmp/tmp.jpeg');
imagecopyresampled ( $i, $i2, 0, 0, 0, 0, imagesx ( $i ), imagesy ( $i ), imagesx ( $i2 ), imagesy ( $i2 ) );
@unlink ( '../tmp/tmp.jpeg' );
//header ( "Content-type: image/png" );
//imagepng ( $i, $saveto );
$createfunc($i,$saveto,$q);
RETURN;
}
require_once('pclzip.lib.php');
function make_jad($jarsource,$jardestination,$jarurl)
{
global $config;
//echo "$jarsource|$jardestination|$jarurl";
$zip = new PclZip($jarsource);
$c = $zip->extract(PCLZIP_OPT_BY_NAME,"META-INF/MANIFEST.MF", PCLZIP_OPT_EXTRACT_AS_STRING);
$c = $c[0]['content'];
$filename = basename($jarsource);
if($c)
{
$jn=str_replace(".jar", ".jad", $filename);
$c=trim(str_replace("\r\n","\n",$c));
$a=explode("\n",$c);
unset($c);
foreach($a as $s)
{
if(strpos($s,"MIDlet-Jar-Size:")===false && strpos($s,"MIDlet-Jar-URL:")===false && strpos($s,"MIDlet-Vendor:")===false && strpos($s,"MIDlet-Info-URL:")===false && strpos($s,"MIDlet-Description:")===false && strpos($s,"MIDlet-Delete-Confirm:")===false)
{
$c.=$s."\n";
}
}
$c.="MIDlet-Jar-Size: ".filesize($jarsource)."\n";
$c.="MIDlet-Jar-URL: ".$jarurl."\n";
$c.="MIDlet-Vendor: ".$config['site']."(".$config['jad'].")\n";
$c.="MIDlet-Info-URL: ".$config['jad']."\n";
$c.="MIDlet-Description: Лучшие игры на ".$config['site']." \n";
$c.="MIDlet-Delete-Confirm: Бесплатные игры на ".$config['site']." \n";
$jadsource="$jardestination/$jn";
$fp=fopen($jadsource,"a+");
fputs($fp,$c);
fclose($fp);
@chmod ($jadsource, 0777);
return $jadsource;
}
else return false;
}
?>