assign("io_error","1"); $smarty->assign("filename",$filename); $smarty->assign("main","edit_file_message"); } elseif ($REQUEST_METHOD=="POST" && $mode=="restore" && $filename) { # # This facility restores the corrupted template from the repository # if (!@copy($templates_repository.$filename, $root_dir.$filename)) $smarty->assign("io_error","1"); $smarty->assign("filename",$filename); $smarty->assign("main","edit_file_message"); } elseif ($REQUEST_METHOD=="POST" && $mode=="restore_all") { # # Restore all files from $template_repository # $files_to_restore = list_all_templates ($templates_repository,""); if(!empty($files_to_restore)) { foreach($files_to_restore as $file_to_restore => $file_status) { echo "Restoring $file_to_restore - "; if (!@copy($templates_repository.$file_to_restore, $root_dir.$file_to_restore)) echo " FAILED TO RESTORE"; else echo " successfully restored"; echo "
\n"; flush(); } exit; } else { $smarty->assign("io_error","3"); $smarty->assign ("main", "copy_file_message"); } } elseif ($REQUEST_METHOD=="POST" && $mode=="compile_all") { # # Compile all files from $template_repository # set_time_limit(1800); $files_to_restore = list_all_templates ($root_dir,""); if(!empty($files_to_restore)) { # # Generate search and replace arrays for preg_replace # $search_array = array(); $search1_array = array(); $replace_array = array(); $replace1_array = array(); $language_entries = func_query("select name, value from $sql_tbl[languages] where code='$language'"); foreach($language_entries as $language_entry) { $search_array[]="'{.lng\.$language_entry[name]}'"; $search1_array[]="'.lng\.$language_entry[name](\W)'"; $replace_array[]=$language_entry["value"]; $replace1_array[]="\"$language_entry[value]\"\\1"; } # # Perform compilation # foreach($files_to_restore as $file_to_restore => $file_status) { echo "Compiling $file_to_restore - "; if(is_writable($root_dir.$file_to_restore) && is_readable($root_dir.$file_to_restore)) { $file_strings = file($root_dir.$file_to_restore); $fp = fopen($root_dir.$file_to_restore, "w"); # # Patching head.tpl to disable languages