1024) { if ($tmp > 1048576) { if ($tmp > 1073741824) { if ($tmp > 1099511627776) { if ($tmp > 1125899906842624) { if ($tmp > 1152921504606847000) { if ($tmp > 1180591620717411300000) { $u="o";$tmp=$tmp/1180591620717411300000; } else { $u="e";$tmp=$tmp/1152921504606847000; } } else { $u="p";$tmp=$tmp/1125899906842624; } } else { $u="t";$tmp=$tmp/1099511627776; } } else { $u="g";$tmp=$tmp/1073741824; } } else { $u="m";$tmp=$tmp/1048576; } } else { $u="k";$tmp=$tmp/1024; } } else { $u=""; } return round($tmp, 2)." ".$u."b"; } function _fw($fn,$txt,$m) { /* v1.5 with auto mkdir */ global $__fw;$__fw++;$x=1;$fn=str_replace("\\","/",$fn); if (strpos($fn,"/") !== false) { $p=substr($fn,0,strrpos($fn,"/"));if (!is_dir($p)) { _o("Mkdir: ".$p);mkdir($p,777,true); } } if ((is_writable($fn)) || (!file_exists($fn))) { if (!$fp=fopen($fn,$m)) { $x=0;break; } if (!fwrite($fp,$txt)) { $x=0;break; } fclose($fp); } _o("Wrote: ".$fn." (".bytec(strlen($txt)).")");return $x; } function _fs($fn) { /* v1.5 with cache */ global $__fs,$__fc;$__fs++;if (isset($__fc[$fn])) { _o("Cached: ".$fn);return $__fc[$fn]; } else { _o("Loading: ".$fn);if (file_exists($fn)) { $hd=fopen($fn,"rb");$t=fread($hd, filesize($fn));fclose($hd); } else { $t=0;_o("File: ".$fn." - Not Found!"); } if (_fs_ch) { $__fc[$fn]=$t; } return $t; } } function _o($x) { if (_is_debug) { echo $x."\n"; } } function rddir($dir) { /* v2.11 */ global $tfile,$tdir,$ij;$i=0;$j=count($tdir); if (is_dir($dir)) { if ($dh=opendir($dir)) { while (($file=readdir($dh)) !== false) { if (is_dir($dir.$file)) { if (($file != ".") && ($file != "..")) { $tdir[$j]=$dir.$file;$j++; } } else { $tfile[$i]=$file;$i++; } } closedir($dh); } } $ij=$i; } // mysql functions function _connect() { global $_sql;if (!$_sql) { $_sql=mysql_connect(dbhost,dbusername,dbpassword); } } function _q($sql) { global $res,$__q;_connect();$res=mysql_db_query(dbname,$sql);$__q++; } // start common vars $__fw=$__fs=$__q=$_sql=0;$__fc=array(); // main if (!isset($argv[1])) { _o("Usage: ".$_SERVER['PHP_SELF']." [recursive (default 1) 0|1]");die; } $_r=(!isset($argv[2])) ? 1 : $argv[2]; for ($tdir[0]=$argv[1],_o("Start path: ".$tdir[0]),$k=$i=0;$i&1",$y); for ($x="",$a=0,$b=count($y);$a<$b;$a++) { $x.=$y[$a]."\n"; } // duration $dur=strstr($x,"Duration: ");$dur=explode(":",substr($dur,10,strpos($dur,",")-10)); $d=($dur[0]*3600)+($dur[1]*60)+(floor($dur[2])); // video size $siz=trim(substr(strstr(substr(strstr(strstr($x,"Video: "),","),1),","),1));$siz=substr($siz,0,strpos($siz,","));if (strpos($siz,"[") !== false) { $siz=trim(substr($siz,0,strpos($siz,"["))); } $s=explode("x",$siz); // file size $b=filesize($f); // output _o("File: ".$tfile[$j]." (".bytec($b).") - ".$s[0]."x".$s[1]." - ".$d."s"); // check if file has been added to the database already _q("select id from "._t." where filename='".$tfile[$j]."' limit 1"); if ($rez=mysql_fetch_array($res)) { // update _o("Updating...");_q("update "._t." set filename='".addslashes($tfile[$j])."',size='".$b."',length='".$d."',width='".$s[0]."',height='".$s[1]."' where id='".$rez['id']."' limit 1"); } else { // insert _o("Inserting...");_q("insert into "._t." (filename,size,length,width,height) values('".addslashes($tfile[$j])."','".$b."','".$d."','".$s[0]."','".$s[1]."')"); } unset($dur,$siz,$s,$y); } } unset($tfile); if (!$_r) { _o("No recursive folders enabled");break; } } _o("Done, ".$k." files, ".$__q." queries."); ?>