Changeset 463

Show
Ignore:
Timestamp:
06/12/08 00:10:55 (3 months ago)
Author:
fidojones
Message:

ultimas pruebas del sistema de actualizaciones

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/panel/update/index.php

    r462 r463  
    1414                echo "<html>\n"; 
    1515                echo "<head>\n"; 
    16                 echo "<title>Update Baifox Panel</title>\n"; 
     16                echo "<title>".Ta("Update")." Baifox Panel</title>\n"; 
    1717                echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset="._CFG_INTERFACE_GETTEXT_ENCODING."\">\n"; 
    1818                echo "<script type=\"text/javascript\" src=\"mootools.js\"></script>\n"; 
     
    6262                echo "function install_log() { new Ajax(\"update.log\", {method: 'get', update:$('logstatus')}).request(); }\n"; 
    6363                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"; 
    6565                echo "\n"; 
    6666                echo "function DomCargado() {\n"; 
     
    9494                        fclose($log_file); 
    9595                }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"; 
    9797                        $log_file = fopen ("update.log", "a"); 
    9898                        fwrite ($log_file, $line); 
     
    115115                                        if (!rm_recursive($filepath.'/'.$sf)) 
    116116                                        { 
    117                                                 log_write($filepath.'/'.$sf.' could not be deleted.'); 
     117                                                log_write($filepath.'/'.$sf.Ta("ErrorDeleting")); 
    118118                                        } 
    119119                                } 
     
    127127         function download($fichero_origen,$ruta_destino, $fichero_destino) { 
    128128                $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"); 
    130130                if ($origen===false) { 
    131131                        // error leyendo el fichero 
    132                         log_write(Ta("ErrorReaOrFile")); 
     132                        log_write(Ta("ErrorDownFile")." $fichero_origen"); 
    133133                        return false; 
    134134                } 
     
    151151 
    152152    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                } 
    176178    } 
    177179 
    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"); 
    181183                $lines_destino = file($fichero_destino); 
     184 
    182185                foreach ($lines_origen as $linea_origen) { 
    183186                        $encontrado=false; 
     
    191194                                if(!$encontrado){ 
    192195                                        $origen = file($fichero_destino); 
    193                                         $destino = fopen($fichero_destino, 'wb'); 
    194                                         if ($destino===false) { 
    195                                                 // error leyendo el fichero 
    196                                                         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                                        } 
    199202                                        foreach ($origen as $linea){ 
    200203                                                if(strpos($linea,"?>")!==false){ 
    201204                                                        if (fwrite($destino, $linea_origen) === FALSE) { 
    202                                                         // error escribiendo el fichero 
    203                                                         log_write(Ta("ErrorWritDestFile")); 
    204                                         return false; 
    205                                         } 
     205                                                                // error escribiendo el fichero 
     206                                                                log_write(Ta("ErrorWritDestFile")); 
     207                                                                return false; 
     208                                                        } 
    206209                                                        if (fwrite($destino, "?>") === FALSE) { 
    207                                                         // error escribiendo el fichero 
    208                                                         log_write(Ta("ErrorWritDestFile")); 
    209                                         return false; 
    210                                         } 
     210                                                                // error escribiendo el fichero 
     211                                                                log_write(Ta("ErrorWritDestFile")); 
     212                                                                return false; 
     213                                                        } 
    211214                                                }else{ 
    212                                         if (fwrite($destino, $linea) === FALSE) { 
    213                                                         // error escribiendo el fichero 
    214                                                         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                                                        } 
    217220                                                } 
    218                                         } 
    219                                         fclose($destino); 
     221                                } 
     222                                    fclose($destino); 
    220223                                } 
    221224                        } 
     
    224227     
    225228    function files_install($ficheros,$nueva_version){ 
    226                 $fichero_config=""; 
    227229                        $no_modificar = file(_CFG_INTERFACE_UPDATEIGNORE); 
    228230                         
     
    255257                                                } 
    256258                                                if($modificar){ 
    257                                                         if(download($fichero,$ruta,$ruta_destino)) 
     259                                                        if(file_overwrite($fichero,$ruta,$ruta_destino)) 
    258260                                                                log_write(Ta("OverFile")." $ruta_destino"); 
    259261                                                        else 
     
    268270                                        case "U": 
    269271                                                if($fichero=="main_config.php"){ 
    270                                                         $fichero_config=$ruta_destino; 
    271272                                                        update_config($fichero,$ruta,$ruta_destino); 
    272273                                                } 
     
    277278                                flush(); 
    278279                        } 
    279                         update_version($fichero_config,trim($nueva_version)); 
     280                        update_version(_CFG_INTERFACE_DIR."admin_panel/config/main_config.php",trim($nueva_version)); 
    280281    } 
     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        } 
    281312 
    282313        function files_remove($ficheros){ 
     
    287318                        $ruta_destino=$ruta.$fichero; 
    288319                        if(is_file($ruta_destino)){ 
    289                                 log_write("Deleting $ruta_destino"); 
     320                                log_write(Ta("Deleting")." $ruta_destino"); 
    290321                                unlink($ruta_destino); 
    291322                        } 
     
    308339                        } 
    309340                }else{ 
    310                         log_write(Ta("ErrorReaOrFile")); 
     341                        log_write(Ta("ErrorReadDiff")); 
    311342                } 
    312343        } 
     
    331362                                        $zip->extractTo('temp/'); 
    332363                                        $zip->close(); 
    333                                         log_write("Fichero zip extraido"); 
     364                                        log_write(Ta("ZipExtracted")); 
    334365                                } else { 
    335                                         log_write("Fallo al descomprimir zip"); 
     366                                        log_write(Ta("ZipError")); 
    336367                                        return false; 
    337368                                } 
     
    348379                        } 
    349380        } 
    350          
     381 
    351382        if($_SESSION['SEC_PERM']<666){ 
    352383                if ($_POST['frmUsuario']!="" and $_POST['frmPassword']!="" ) { 
     
    365396                        } 
    366397                }else{ 
    367                         log_write("",true); 
    368398                        html_header(); 
    369399                        html_login(); 
     
    371401                } 
    372402        }else{ 
     403                log_write("",true); 
    373404                if($_GET['update']=="diff"){ 
    374                         log_write("",true); 
    375405                        update_diff(); 
    376406                }elseif($_GET['update']=="complete"){ 
    377                         log_write("",true); 
    378407                        update_complete(); 
    379408                }else{ 
  • trunk/panel/update/lang.php

    r462 r463  
    11<?php 
    22function Ta($tag){ 
     3        $en['Update']="Update"; 
    34        $en['ThanksUser']="Thanks to use"; 
    45        $en['NoUser']="You have not introduced the password or the username"; 
     
    1011        $en['ActualVersion']="Actual version"; 
    1112        $en['LastVersion']="Last version"; 
     13        $en['ErrorDownFile']="[ERROR] downloading file"; 
     14        $en['ErrorReadDiff']="[ERROR] reading diff file"; 
    1215        $en['ErrorReaOrFile']="[ERROR] reading origin file"; 
     16        $en['ErrorReaVerFile']="[ERROR] reading version file"; 
    1317        $en['ErrorReaDestFile']="[ERROR] reading destination file"; 
    1418        $en['ErrorWritDestFile']="[ERROR] writing destination file"; 
    1519        $en['ErrorOver']="[ERROR] Overwriting file"; 
     20        $en['ErrorDeleting']="could not be deleted"; 
    1621        $en['DirExists']="Directory already exists"; 
    1722        $en['CreaDir']="Creating directory"; 
     23        $en['ZipExtracted']="zip extracted"; 
     24        $en['ZipError']="[ERROR] Extracting zip file"; 
     25        $en['Deleting']="Deleting"; 
    1826        $en['OverFile']="Overwriting file"; 
    1927        $en['FileNotMod']="File without modifying"; 
    2028        $en['FileUp']="File updated"; 
    2129 
     30 
     31        $es_ES['Update']="Actualizar"; 
    2232        $es_ES['ThanksUser']="Gracias por usar"; 
    2333        $es_ES['NoUser']="No ha intoducido la contrase&ntilde;a o el nombre de usuario"; 
     
    2939        $es_ES['ActualVersion']="Versi&oacute;n actual"; 
    3040        $es_ES['LastVersion']="&Uacute;ltima versi&oacute;n"; 
     41        $es_ES['ErrorDownFile']="[ERROR] descargando fichero"; 
     42        $es_ES['ErrorReadDiff']="[ERROR] leyendo fichero diff"; 
    3143        $es_ES['ErrorReaOrFile']="[ERROR] leyendo fichero origen"; 
     44        $es_ES['ErrorReaVerFile']="[ERROR] leyendo fichero versión"; 
    3245        $es_ES['ErrorReaDestFile']="[ERROR] leyendo fichero destino"; 
    3346        $es_ES['ErrorWritDestFile']="[ERROR] escribiendo fichero destino"; 
    3447        $es_ES['ErrorOver']="[ERROR] Sobreescribiendo fichero"; 
     48        $es_ES['ErrorDeleting']="no puede ser borrado"; 
    3549        $es_ES['DirExists']="El directorio ya existe"; 
    3650        $es_ES['CreaDir']="Creando directorio"; 
     51        $es_ES['ZipExtracted']="zip descomprimido"; 
     52        $es_ES['ZipError']="[ERROR] descomprimiendo fichero zip"; 
     53        $es_ES['Deleting']="Borrando"; 
    3754        $es_ES['OverFile']="Sobreescribiendo fichero"; 
    3855        $es_ES['FileNotMod']="Fichero no modificado"; 
  • trunk/scripts/baifox_codeupdate_v2.php

    r462 r463  
    108108         
    109109        function file_update($directory){ 
     110                global $directorylist; 
     111                $directorylist=Array(); 
     112                 
    110113                if(file_exists($directory)){ 
    111114                        $files = load_directory($directory,1); // call the function