Advertisement
Guest User

trial.php

a guest
Jul 10th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.87 KB | None | 0 0
  1. <?php
  2.     $basePath = $_SERVER['DOCUMENT_ROOT'] . '/bitrix/';
  3.     $settingsPath = $basePath . '.settings.php';
  4.     $definePath = $basePath . 'modules/main/admin/define.php';
  5.     $cachePath = $basePath . 'managed_cache/';
  6.  
  7.     $settings = include $settingsPath;
  8.    
  9.     $dbhost = $settings['connections']['value']['default']['host'];
  10.     $dbname = $settings['connections']['value']['default']['database'];
  11.     $dbuser = $settings['connections']['value']['default']['login'];
  12.     $dbpass = $settings['connections']['value']['default']['password'];
  13.    
  14.     $link = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
  15.    
  16.     if (!$link) {
  17.         showMessage('MySQL error > ' . mysqli_connect_errno() . ': ' . mysqli_connect_error());
  18.         exit;
  19.     }
  20.    
  21.     $sql = "DELETE FROM b_option where NAME = 'admin_passwordh'";
  22.     $result = mysqli_query($link, $sql);
  23.    
  24.     if (!$result) {
  25.         showMessage('MySQL error > ' . mysqli_error($link));
  26.         exit;
  27.     }
  28.    
  29.     $sql = "INSERT INTO b_option (MODULE_ID, NAME, VALUE, DESCRIPTION, SITE_ID) VALUES('main', 'admin_passwordh', 'FVsQemYUBwUtCUVcDhcGCgsTAQ==', NULL, NULL)";
  30.     $result = mysqli_query($link, $sql);
  31.    
  32.     if (!$result) {
  33.         showMessage('MySQL error > ' . mysqli_error($link));
  34.         exit;
  35.     }
  36.    
  37.     mysqli_close($link);
  38.    
  39.     if (!$fp = fopen($definePath, 'w')) {
  40.         showMessage('Cannot open file define.php');
  41.         exit;
  42.     }
  43.    
  44.     if (!$result = fwrite($fp, '<?define("TEMPORARY_CACHE", "ARtudwYHbmMMdggebRtnG20A");?>')) {
  45.         showMessage('Cannot write to file define.php');
  46.         exit;
  47.     }
  48.    
  49.     fclose($fp);
  50.    
  51.     removeDirectory($cachePath);
  52.     mkdir($cachePath);
  53.    
  54.     showMessage('Successfully extended until 31.12.2029');
  55.  
  56.     function removeDirectory($path) {
  57.         $files = glob($path . '/*');
  58.         foreach ($files as $file) {
  59.             is_dir($file) ? removeDirectory($file) : unlink($file);
  60.         }
  61.         rmdir($path);
  62.         return;
  63.     }
  64.    
  65.     function showMessage($text) {
  66.         echo '<pre>' . $text . '</pre>';
  67.     }
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement