403Webshell
Server IP : 208.122.213.31  /  Your IP : 216.73.216.45
Web Server : Apache
System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64
User : WHMCS_MIA_382 ( 1001)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/httpd/html/baberankings.com.bak/community/plugins/autoupdate/include/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/httpd/html/baberankings.com.bak/community/plugins/autoupdate/include/functions.inc.php
<?php

if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');

function autoupdate_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))
        {
          autoupdate_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 autoupdate_add_index($path)
{
  if (is_dir($path))
  {
    $fh = opendir($path);
    while ($file = readdir($fh))
    {
      if ($file != '.' and $file != '..')
      {
        $pathfile = $path . '/' . $file;
        if (is_dir($pathfile))
        {
          autoupdate_add_index($pathfile);
        }
      }
    }
    $fp = @fopen($path.'/index.php', 'w');
    @fwrite($fp, AU_DEFAULT_INDEX);
    @fclose($fp);
    closedir($fh);
  }
}

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))
      {
        autoupdate_deltree($path, true);
      }
    }
  }
}

function move_local_files($dir)
{
  global $page, $cfgBase, $cfgUser, $cfgPassword, $cfgHote, $prefixeTable;

  if ((!is_dir($dir) and !mkdir($dir, 0777))
    or (!is_dir($dir.'/config') and !mkdir($dir.'/config'))
    or (!is_dir($dir.'/css') and !mkdir($dir.'/css'))
    or (!is_dir($dir.'/language') and !mkdir($dir.'/language')))
  {
    autoupdate_deltree($dir);
    array_push($page['errors'], l10n('Unable to write new local directory.'));
    return;
  }

  // Add index.php
  autoupdate_add_index($dir);

  // mysql.inc.php
  $file = PHPWG_ROOT_PATH.'include/mysql.inc.php';
  if (is_readable($file))
  {
    $file_content = '<?php
$conf[\'dblayer\'] = \'mysql\';
$conf[\'db_base\'] = \''.$cfgBase.'\';
$conf[\'db_user\'] = \''.$cfgUser.'\';
$conf[\'db_password\'] = \''.$cfgPassword.'\';
$conf[\'db_host\'] = \''.$cfgHote.'\';

$prefixeTable = \''.$prefixeTable.'\';

define(\'PHPWG_INSTALLED\', true);';
    if (defined('PWG_CHARSET'))
    {
      $file_content.= '
define(\'PWG_CHARSET\', \'utf-8\');
define(\'DB_CHARSET\', \'utf8\');
define(\'DB_COLLATE\', \'\');';
    }
    $file_content.= '
?>';
    $new_config_file = $dir.'/config/database.inc.php';

    if (!($fp = @fopen($new_config_file, 'w'))
      or !@fwrite($fp, $file_content)
      or !@fclose($fp))
    {
      array_push($page['errors'], l10n('Unable to write new local directory.'));
      return;
    }
    @chmod($new_config_file, 0755);
  }

  // config_local.inc.php
  $file = PHPWG_ROOT_PATH.'include/config_local.inc.php';
  if (is_readable($file))
  {
    copy($file, $dir.'/config/config.inc.php');
    @chmod($file, 0755);
  }

  // languages
  $language_dir = opendir(PHPWG_ROOT_PATH.'language');
  while ($file = readdir($language_dir))
  {
    $path = PHPWG_ROOT_PATH.'language/'.$file;
    if (!is_link($path) and is_dir($path) and is_readable($path.'/local.lang.php'))
    {
      $content = file_get_contents($path.'/local.lang.php');
      $langdef = explode('.',$file);
      if (count($langdef)>1)
      {
        $content = utf8_encode($content);
      }
      $filename = $dir.'/language/'.$langdef[0].'.lang.php';
      $fp = @fopen($filename, 'w');
      @fwrite($fp, $content);
      @fclose($fp);
      @chmod($filename, 0755);
    }
  }
  closedir($language_dir);

  // template-common/local-layout.css
  $file = PHPWG_ROOT_PATH.'template-common/local-layout.css';
  if (is_readable($file))
  {
    copy($file, $dir.'/css/rules.css');
    @chmod($file, 0755);
  }

  // template/xxx/local-layout.css
  $known_templates = array(
    'yoga'     => 'default',
    'floPure'  => 'Pure_default',
    'floOs'    => 'OS_default',
    'gally'    => 'gally-default',
    'simple'   => 'simple',
  );

  foreach ($known_templates as $old_tpl => $new_tpl)
  {
    $file = PHPWG_ROOT_PATH.'template/'.$old_tpl.'/local-layout.css';
    if (is_readable($file))
    {
      copy($file, $dir.'/css/'.$new_tpl.'-rules.css');
      @chmod($file, 0755);
    }
  }
}

function autoupdate_save_template_dir()
{
  global $page, $conf;

  $path = $conf['local_data_dir'].'/autoupdate';

  if (@mkgetdir($path)
    and ($zip = tempnam($path, 'zip'))
    and ($archive = new pclZip($zip))
    and ($v_list = $archive->add(PHPWG_ROOT_PATH.'template', PCLZIP_OPT_REMOVE_PATH, PHPWG_ROOT_PATH))
    and is_array($v_list)
    and !empty($v_list))
  {
    $http_headers = array(
      'Content-Length: '.@filesize($zip),
      'Content-Type: application/zip',
      'Content-Disposition: attachment; filename="template.zip";',
      'Content-Transfer-Encoding: binary',
      );

    foreach ($http_headers as $header) {
      header($header);
    }

    @readfile($zip);
    autoupdate_deltree($conf['local_data_dir'].'/autoupdate');
    exit();
  }
  else
  {
    array_push($page['errors'], l10n('Unable to send template directory.'));
  }
}

function autoupdate_dump_database()
{
  global $page, $conf, $cfgBase;

  if (version_compare(PHPWG_VERSION, '2.1', '<'))
  {
    $conf['db_base'] = $cfgBase;
  }

  include(AUTOUPDATE_PATH.'include/mysqldump.php');

  $path = $conf['local_data_dir'].'/autoupdate';

  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 !isset($_POST['includeHistory']))
        {
          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);
    autoupdate_deltree($conf['local_data_dir'].'/autoupdate');
    exit();
  }
  else
  {
    array_push($page['errors'], l10n('Unable to dump database.'));
  }
}

function autoupdate_upgrade_to($upgrade_to, &$step)
{
  global $page, $conf, $template;

  if (!version_compare($_POST['upgrade_to'], PHPWG_VERSION, '>'))
  {
    redirect(get_admin_plugin_menu_link(AUTOUPDATE_PATH . '/autoupdate.php'));
  }

  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 (version_compare(PHPWG_VERSION, '2.1', '<'))
    {
      move_local_files(PHPWG_ROOT_PATH.'local');
    }
  }

  if (empty($page['errors']))
  {
    $path = $conf['local_data_dir'].'/autoupdate';
    $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))
        {
          process_obsolete_list($obsolete_list);
          autoupdate_deltree($conf['local_data_dir'].'/autoupdate');
          invalidate_user_cache(true);
          $template->delete_compiled_templates();
          unset($_SESSION['need_update']);
          if ($step == 2)
          {
            array_push($page['infos'], sprintf(l10n('autoupdate_success'), $upgrade_to));
            $step = -1;
          }
          else
          {
            redirect(PHPWG_ROOT_PATH.'upgrade.php?now=');
          }
        }
        else
        {
          file_put_contents($conf['local_data_dir'].'/autoupdate/log_error.txt', $error);
          $relative_path = trim(str_replace(dirname(dirname(dirname(dirname(__FILE__)))), '', $conf['local_data_dir']), '/\\');
          array_push($page['errors'], sprintf(l10n('autoupdate_extract_fail'), PHPWG_ROOT_PATH.$relative_path.'/autoupdate/log_error.txt'));
        }
      }
      else
      {
        autoupdate_deltree($conf['local_data_dir'].'/autoupdate');
        array_push($page['errors'], l10n('autoupdate_fail'));
      }
    }
    else
    {
      array_push($page['errors'], l10n('Piwigo cannot retrieve upgrade file from server'));
    }
  }
}

if (!function_exists('is_webmaster'))
{
  function is_webmaster($user_status = '')
  {
    return is_autorize_status(ACCESS_WEBMASTER, $user_status);
  }
}

define('AU_DEFAULT_INDEX', file_get_contents(AUTOUPDATE_PATH.'index.php'));
?>

Youez - 2016 - github.com/yon3zu
LinuXploit