Advertisement
Guest User

Bitrix Key Updater

a guest
Mar 15th, 2017
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.86 KB | None | 0 0
  1. <?php
  2. function dirDel($dir)
  3. {  
  4.     if ($objs = glob($dir."/*")) {foreach($objs as $obj) {is_dir($obj) ? dirDel($obj) : unlink($obj);}}
  5.     if(file_exists($dir)) rmdir($dir);
  6. }
  7.  
  8. $host = 'localhost';
  9. $db = 'bitrix_67';
  10. $charset = 'utf-8';
  11. $user = 'rooot2';
  12. $pass = 'RootPass';
  13. $dsn = "mysql:host=$host;dbname=$db";
  14.  
  15. $new_db_key = 'FVkQfGYUBgYtCUVcABcCCgsTAQ==';
  16. $new_file_key = 'ARtqeQYHb2MMdAgebRtkG2sA';
  17. $new_lic_key = 'S16-NA-V3WT2OPONA2GDTD5';
  18.  
  19. $opt = array(
  20.     PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
  21.     PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
  22. );
  23. try {
  24.     $pdo = new PDO($dsn, $user, $pass, $opt);
  25.     $stmt = $pdo->query('SELECT `VALUE` FROM b_option WHERE `NAME` = "admin_passwordh"');
  26.     echo "\n<br> DB_KEY:\n<br>";
  27.     while ($row = $stmt->fetch())
  28.     {
  29.         echo var_dump($row) . "\n<br>";
  30.     }
  31.    
  32.     $stmt = $pdo->query('UPDATE `b_option` SET `VALUE` = "'.$new_db_key.'" WHERE `NAME`="admin_passwordh"');
  33.     $stmt->execute();
  34. } catch (PDOException $e) {
  35.     die('Подключение не удалось: ' . $e->getMessage());
  36. }
  37. echo "\n<br> DEFINE_KEY:\n<br>";
  38. if(file_exists("./bitrix/modules/main/admin/define.php"))
  39. {
  40.     $f = fopen("./bitrix/modules/main/admin/define.php","r+");
  41.     if($f) {
  42.         while(!feof($f)) echo "\n".htmlspecialchars(fgets($f));
  43.         ftruncate($f,0);
  44.         rewind($f);
  45.         fwrite($f,'<?define("TEMPORARY_CACHE", "'.$new_file_key.'");?>');
  46.         fclose($f);
  47.     }
  48. }
  49. echo "\n<br> LICENSE_KEY:\n<br>";
  50. if(file_exists("./bitrix/license_key.php"))
  51. {
  52.     $f = fopen("./bitrix/license_key.php","r+");
  53.     if($f) {
  54.         while(!feof($f)) echo "\n".htmlspecialchars(fgets($f));
  55.         ftruncate($f,0);
  56.         rewind($f);
  57.         fwrite($f,'<? $LICENSE_KEY = "'.$new_lic_key.'"; ?>');
  58.         fclose($f);
  59.     }
  60. }
  61.  
  62. dirDel("./bitrix/managed_cache/*");
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement