Last active
August 3, 2016 15:09
-
-
Save gvozdb/c93b4dcf33f8b646ab1a to your computer and use it in GitHub Desktop.
Скрипт создающий sudo юзера для MODX Revo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Подключаем | |
define('MODX_API_MODE', true); | |
$i=0; | |
$current_dir = dirname(__FILE__) .'/'; | |
$index_php = $current_dir .'index.php'; | |
while (!file_exists($index_php) && $i < 9) | |
{ | |
$current_dir = dirname(dirname($index_php)) .'/'; | |
$index_php = $current_dir .'index.php'; | |
$i++; | |
} | |
if (file_exists($index_php)) { require_once $index_php; } | |
else { print "Не удалось найти MODX"; die; } | |
$user = empty($_GET['user']) ? 'user'. rand(99,9999) : $_GET['user']; | |
$pass = empty($_GET['pass']) ? rand(10000000,99999999) : $_GET['pass']; | |
$u = $modx->newObject('modUser'); | |
$u->fromArray(array( | |
'username' => $user, | |
'password' => $pass, | |
'active' => 1, | |
'primary_group' => 1, | |
)); | |
$u->setSudo(1); | |
$p = $modx->newObject('modUserProfile'); | |
$p->fromArray(array( | |
'fullname' => $user, | |
'email' => $user.'@mail.ru', | |
)); | |
$u->addOne($p); | |
$u->save(); | |
if (!empty($u->username)) { | |
print '<p><b>user:</b> '. $user .'</p><p><b>pass:</b> '. $pass .'</p>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment