<? function format_date($date_for_format){
$date_for_format=explode("/",$date_for_format);
$date_for_format=array_reverse($date_for_format);
$date_for_format=implode("-", $date_for_format);
return $date_for_format;
}
function format_datei($date_for_format){
$date_for_format=explode("-",$date_for_format);
$date_for_format=array_reverse($date_for_format);
$date_for_format=implode("/", $date_for_format);
return $date_for_format;
}
function maintain_content($module_id,$type){
$result1 = mysql_query ("SELECT * FROM left_content WHERE module_id='$module_id' AND type='$type'")
	or die (mysql_error());
while($line1=mysql_fetch_array($result1)){
mysql_query ("DELETE FROM left_content WHERE catdom_module_id='$line1[catdom_module_id]'")
or die(mysql_error());
$result2 = mysql_query ("SELECT * FROM left_content WHERE catdom_id='$line1[catdom_id]' AND location='$line1[location]' ORDER BY module_order_seq ASC")
	or die (mysql_error());
$count=1;while($line2=mysql_fetch_array($result2)){
$module_order_seq=sprintf("%03.0f", $count);
$result3 = mysql_query ("UPDATE left_content SET  module_order_seq='$module_order_seq' WHERE catdom_module_id='$line2[catdom_module_id]'")
	or die (mysql_error());
$count++;}
}
}
function random_char($string) 
{ 
$length = strlen($string); 
$position = mt_rand(0, $length - 1); 
return($string[$position]); 
} 
function random_string ($charset_string, $length) 
{ 
$return_string = random_char($charset_string); 
for ($x = 1; $x < $length; $x++) 
$return_string .= random_char($charset_string); 
return($return_string); 
} 
//seed random generator 
mt_srand((double)microtime() * 1000000); 
$charset = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTWXYZ"; 
?>
<?php
   function copy_dir($_s_dir,$_d_dir) {
       if(!is_dir($_s_dir)) {
         return FALSE;
       }
       $_od = getcwd(); // Devemos guardar o diretorio atual...
       chdir($_s_dir);
       $_d = @opendir("./");
       $_ret = TRUE;
       while (($_l=readdir($_d))!==FALSE) {
         if(substr($_l,0,1)=="." AND strlen($_l)<=2) {
             continue;
         }
         if(is_dir($_l)) { 
             mkdir("$_d_dir/$_l");
             if(!copy_dir("$_s_dir/$_l","$_d_dir/$_l")) {
               $_ret = FALSE;
             }
         }
         else {
             if(!copy($_l,"$_d_dir/$_l")) {
               $_ret = FALSE;
             }
         }
       }
       closedir($_d);
       chdir($_od);
       return $_ret;
   }
?>