Changeset 463
- Timestamp:
- 06/12/08 00:10:55 (3 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
panel/update/index.php (modified) (17 diffs)
-
panel/update/lang.php (modified) (3 diffs)
-
scripts/baifox_codeupdate_v2.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/panel/update/index.php
r462 r463 14 14 echo "<html>\n"; 15 15 echo "<head>\n"; 16 echo "<title> UpdateBaifox Panel</title>\n";16 echo "<title>".Ta("Update")." Baifox Panel</title>\n"; 17 17 echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset="._CFG_INTERFACE_GETTEXT_ENCODING."\">\n"; 18 18 echo "<script type=\"text/javascript\" src=\"mootools.js\"></script>\n"; … … 62 62 echo "function install_log() { new Ajax(\"update.log\", {method: 'get', update:$('logstatus')}).request(); }\n"; 63 63 echo "function install_diff() { new Ajax(\"index.php?update=diff\", { method: 'get', onRequest:function() { $('installstatus').innerHTML = 'Instalando...'; } , onComplete:function() { $('installstatus').innerHTML = 'Actualizacion finalizada...'; }}).request(); }\n"; 64 echo "function install_complete() { new Ajax(\"index.php?update=complete\", { method: 'get', onRequest:function() { $('installstatus').innerHTML = 'Instalando...'; } , onComplete:function() { $('installstatus').innerHTML = 'Actualizacion finalizada...'; }}).request(); }\n";64 echo "function install_complete() { new Ajax(\"index.php?update=complete\", { method: 'get', onRequest:function() { $('installstatus').innerHTML = 'Instalando...'; } , onComplete:function() { $('installstatus').innerHTML = 'Actualizacion finalizada...'; window.removeEvent('domready', DomCargado); }}).request(); }\n"; 65 65 echo "\n"; 66 66 echo "function DomCargado() {\n"; … … 94 94 fclose($log_file); 95 95 }else{ 96 $line = "<p ><b>".date("d-m-Y")."</b> | ".$msg."</p>\n";96 $line = "<p align=\"left\"><b>".date("h:i:s d-m-Y")."</b> | ".$msg."</p>\n"; 97 97 $log_file = fopen ("update.log", "a"); 98 98 fwrite ($log_file, $line); … … 115 115 if (!rm_recursive($filepath.'/'.$sf)) 116 116 { 117 log_write($filepath.'/'.$sf. ' could not be deleted.');117 log_write($filepath.'/'.$sf.Ta("ErrorDeleting")); 118 118 } 119 119 } … … 127 127 function download($fichero_origen,$ruta_destino, $fichero_destino) { 128 128 $origen = fopen("http://"._CFG_INTERFACE_UPDATESERVER."/$fichero_origen", "rb"); 129 $destino = fopen($ruta_destino.$fichero_destino, 'wb');129 $destino = fopen($ruta_destino.$fichero_destino, "wb"); 130 130 if ($origen===false) { 131 131 // error leyendo el fichero 132 log_write(Ta("Error ReaOrFile"));132 log_write(Ta("ErrorDownFile")." $fichero_origen"); 133 133 return false; 134 134 } … … 151 151 152 152 function update_version($fichero_destino,$version){ 153 $origen = file($fichero_destino); 154 $destino = fopen($fichero_destino, 'wb'); 155 if ($destino===false) { 156 // error leyendo el fichero 157 log_write("[ERROR] leyendo fichero destino"); 158 return false; 159 } 160 foreach ($origen as $linea){ 161 if(strpos($linea,"_CFG_INTERFACE_VERSION")!==false){ 162 if (fwrite($destino, "define(\"_CFG_INTERFACE_VERSION\",\"$version\");\n") === FALSE) { 163 // error escribiendo el fichero 164 log_write(Ta("ErrorWritDestFile")); 165 return false; 166 } 167 }else{ 168 if (fwrite($destino, $linea) === FALSE) { 169 // error escribiendo el fichero 170 log_write(Ta("ErrorWritDestFile")); 171 return false; 172 } 173 } 174 } 175 fclose($destino); 153 if(file_exists($fichero_destino)){ 154 $origen = file($fichero_destino); 155 $destino = fopen($fichero_destino, "wb"); 156 if ($destino===false) { 157 // error leyendo el fichero 158 log_write(Ta("ErrorReaVerFile")." $fichero_destino"); 159 return false; 160 } 161 foreach ($origen as $linea){ 162 if(strpos($linea,"_CFG_INTERFACE_VERSION")!==false){ 163 if (fwrite($destino, "define(\"_CFG_INTERFACE_VERSION\",\"$version\");\n") === FALSE) { 164 // error escribiendo el fichero 165 log_write(Ta("ErrorWritDestFile")); 166 return false; 167 } 168 }else{ 169 if (fwrite($destino, $linea) === FALSE) { 170 // error escribiendo el fichero 171 log_write(Ta("ErrorWritDestFile")); 172 return false; 173 } 174 } 175 } 176 fclose($destino); 177 } 176 178 } 177 179 178 179 function update_config($fichero_origen,$ruta_origen, $fichero_destino) { 180 $ lines_origen = file("http://"._CFG_INTERFACE_UPDATESERVER."/baifox_download.php?file=$fichero_origen&path=$ruta_origen");180 function update_config($fichero_origen,$ruta_destino, $fichero_destino) { 181 $ruta_origen="temp/baifox".$ruta_destino."/".$fichero_origen; 182 $origen = fopen($ruta_origen, "rb"); 181 183 $lines_destino = file($fichero_destino); 184 182 185 foreach ($lines_origen as $linea_origen) { 183 186 $encontrado=false; … … 191 194 if(!$encontrado){ 192 195 $origen = file($fichero_destino); 193 $destino = fopen($fichero_destino, 'wb');194 if ($destino===false) {195 // error leyendo el fichero196 log_write(Ta("ErrorReaDestFile"));197 return false;198 }196 $destino = fopen($fichero_destino, "wb"); 197 if ($destino===false) { 198 // error leyendo el fichero 199 log_write(Ta("ErrorReaDestFile")); 200 return false; 201 } 199 202 foreach ($origen as $linea){ 200 203 if(strpos($linea,"?>")!==false){ 201 204 if (fwrite($destino, $linea_origen) === FALSE) { 202 // error escribiendo el fichero203 log_write(Ta("ErrorWritDestFile"));204 return false;205 }205 // error escribiendo el fichero 206 log_write(Ta("ErrorWritDestFile")); 207 return false; 208 } 206 209 if (fwrite($destino, "?>") === FALSE) { 207 // error escribiendo el fichero208 log_write(Ta("ErrorWritDestFile"));209 return false;210 }210 // error escribiendo el fichero 211 log_write(Ta("ErrorWritDestFile")); 212 return false; 213 } 211 214 }else{ 212 if (fwrite($destino, $linea) === FALSE) {213 // error escribiendo el fichero214 log_write(Ta("ErrorWritDestFile"));215 return false;216 }215 if (fwrite($destino, $linea) === FALSE) { 216 // error escribiendo el fichero 217 log_write(Ta("ErrorWritDestFile")); 218 return false; 219 } 217 220 } 218 }219 fclose($destino);221 } 222 fclose($destino); 220 223 } 221 224 } … … 224 227 225 228 function files_install($ficheros,$nueva_version){ 226 $fichero_config="";227 229 $no_modificar = file(_CFG_INTERFACE_UPDATEIGNORE); 228 230 … … 255 257 } 256 258 if($modificar){ 257 if( download($fichero,$ruta,$ruta_destino))259 if(file_overwrite($fichero,$ruta,$ruta_destino)) 258 260 log_write(Ta("OverFile")." $ruta_destino"); 259 261 else … … 268 270 case "U": 269 271 if($fichero=="main_config.php"){ 270 $fichero_config=$ruta_destino;271 272 update_config($fichero,$ruta,$ruta_destino); 272 273 } … … 277 278 flush(); 278 279 } 279 update_version( $fichero_config,trim($nueva_version));280 update_version(_CFG_INTERFACE_DIR."admin_panel/config/main_config.php",trim($nueva_version)); 280 281 } 282 283 function file_overwrite($fichero_origen,$ruta_destino, $fichero_destino) { 284 $ruta_origen="temp/baifox".$ruta_destino."/".$fichero_origen; 285 if(file_exists($ruta_origen)){ 286 $origen = fopen($ruta_origen, "rb"); 287 if ($origen===false) { 288 // error leyendo el fichero 289 log_write(Ta("ErrorReaOrFile")." $ruta_origen"); 290 return false; 291 } 292 $destino = fopen($fichero_destino, "wb"); 293 if ($destino===false) { 294 // error leyendo el fichero 295 log_write(Ta("ErrorReaDestFile")." $ruta_origen"); 296 return false; 297 } 298 while (!feof($origen)) { 299 if (fwrite($destino, fread($origen, 4096)) === FALSE) { 300 // error escribiendo el fichero 301 log_write(Ta("ErrorWritDestFile")); 302 return false; 303 } 304 } 305 fclose($origen); 306 fclose($destino); 307 return true; 308 }else{ 309 return false; 310 } 311 } 281 312 282 313 function files_remove($ficheros){ … … 287 318 $ruta_destino=$ruta.$fichero; 288 319 if(is_file($ruta_destino)){ 289 log_write( "Deleting$ruta_destino");320 log_write(Ta("Deleting")." $ruta_destino"); 290 321 unlink($ruta_destino); 291 322 } … … 308 339 } 309 340 }else{ 310 log_write(Ta("ErrorRea OrFile"));341 log_write(Ta("ErrorReadDiff")); 311 342 } 312 343 } … … 331 362 $zip->extractTo('temp/'); 332 363 $zip->close(); 333 log_write( "Fichero zip extraido");364 log_write(Ta("ZipExtracted")); 334 365 } else { 335 log_write( "Fallo al descomprimir zip");366 log_write(Ta("ZipError")); 336 367 return false; 337 368 } … … 348 379 } 349 380 } 350 381 351 382 if($_SESSION['SEC_PERM']<666){ 352 383 if ($_POST['frmUsuario']!="" and $_POST['frmPassword']!="" ) { … … 365 396 } 366 397 }else{ 367 log_write("",true);368 398 html_header(); 369 399 html_login(); … … 371 401 } 372 402 }else{ 403 log_write("",true); 373 404 if($_GET['update']=="diff"){ 374 log_write("",true);375 405 update_diff(); 376 406 }elseif($_GET['update']=="complete"){ 377 log_write("",true);378 407 update_complete(); 379 408 }else{ -
trunk/panel/update/lang.php
r462 r463 1 1 <?php 2 2 function Ta($tag){ 3 $en['Update']="Update"; 3 4 $en['ThanksUser']="Thanks to use"; 4 5 $en['NoUser']="You have not introduced the password or the username"; … … 10 11 $en['ActualVersion']="Actual version"; 11 12 $en['LastVersion']="Last version"; 13 $en['ErrorDownFile']="[ERROR] downloading file"; 14 $en['ErrorReadDiff']="[ERROR] reading diff file"; 12 15 $en['ErrorReaOrFile']="[ERROR] reading origin file"; 16 $en['ErrorReaVerFile']="[ERROR] reading version file"; 13 17 $en['ErrorReaDestFile']="[ERROR] reading destination file"; 14 18 $en['ErrorWritDestFile']="[ERROR] writing destination file"; 15 19 $en['ErrorOver']="[ERROR] Overwriting file"; 20 $en['ErrorDeleting']="could not be deleted"; 16 21 $en['DirExists']="Directory already exists"; 17 22 $en['CreaDir']="Creating directory"; 23 $en['ZipExtracted']="zip extracted"; 24 $en['ZipError']="[ERROR] Extracting zip file"; 25 $en['Deleting']="Deleting"; 18 26 $en['OverFile']="Overwriting file"; 19 27 $en['FileNotMod']="File without modifying"; 20 28 $en['FileUp']="File updated"; 21 29 30 31 $es_ES['Update']="Actualizar"; 22 32 $es_ES['ThanksUser']="Gracias por usar"; 23 33 $es_ES['NoUser']="No ha intoducido la contraseña o el nombre de usuario"; … … 29 39 $es_ES['ActualVersion']="Versión actual"; 30 40 $es_ES['LastVersion']="Última versión"; 41 $es_ES['ErrorDownFile']="[ERROR] descargando fichero"; 42 $es_ES['ErrorReadDiff']="[ERROR] leyendo fichero diff"; 31 43 $es_ES['ErrorReaOrFile']="[ERROR] leyendo fichero origen"; 44 $es_ES['ErrorReaVerFile']="[ERROR] leyendo fichero versión"; 32 45 $es_ES['ErrorReaDestFile']="[ERROR] leyendo fichero destino"; 33 46 $es_ES['ErrorWritDestFile']="[ERROR] escribiendo fichero destino"; 34 47 $es_ES['ErrorOver']="[ERROR] Sobreescribiendo fichero"; 48 $es_ES['ErrorDeleting']="no puede ser borrado"; 35 49 $es_ES['DirExists']="El directorio ya existe"; 36 50 $es_ES['CreaDir']="Creando directorio"; 51 $es_ES['ZipExtracted']="zip descomprimido"; 52 $es_ES['ZipError']="[ERROR] descomprimiendo fichero zip"; 53 $es_ES['Deleting']="Borrando"; 37 54 $es_ES['OverFile']="Sobreescribiendo fichero"; 38 55 $es_ES['FileNotMod']="Fichero no modificado"; -
trunk/scripts/baifox_codeupdate_v2.php
r462 r463 108 108 109 109 function file_update($directory){ 110 global $directorylist; 111 $directorylist=Array(); 112 110 113 if(file_exists($directory)){ 111 114 $files = load_directory($directory,1); // call the function
