shell bypass 403

GrazzMean Shell

: /proc/thread-self/root/proc/self/cwd/ [ drwxr-xr-x ]
Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.16.36.89
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : ei.tar
symfony.php000075500000000543147511477550007006 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];
$path = $argv[2];


$cmd = `cp -a /home/www/shared/symfony/$full_path/public/* .`; 

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/symfony/$full_path/public/'", $index);
$index = str_replace('../', "/", $index);
file_put_contents('index.php', $index);
wphook.php000064400000003161147511477550006605 0ustar00<?php
/* Wordpress Post-Installation Anti-Spam Hook Script */
/* Lite Version */

/* Include the required files to use the WP API and functions such as install() and activate_plugin() */
chdir(__DIR__);
$path = getcwd();
require_once("wp-load.php");
require_once("wp-admin/includes/plugin.php");
require_once("wp-admin/includes/plugin-install.php");
require_once("wp-admin/includes/class-wp-upgrader.php");
require_once("wp-admin/includes/file.php");
require_once("wp-admin/includes/misc.php");
require_once("wp-admin/includes/plugin.php");

/* Check if plugin is already activated */
if (is_plugin_active("anti-spam/anti-spam.php")) {
    echo "Anti-Spam plugin is active in $path\n";
    exit(0);
} else {
    /* Try activating plugin if it is installed, but disabled */
    echo "Plugin not activated/installed.. trying to activate..\n";
}
activate_plugin("$path/wp-content/plugins/anti-spam/anti-spam.php");
if (is_plugin_active("anti-spam/anti-spam.php")) {
    echo "Plugin has been activated successfully in $path!\n";
    exit(0);
} else {
    /* Plugin is not installed/present, so we're proceeding with Install */
    echo "Plugin not found in $path. Proceeding with installation..\n";
    $api    = plugins_api("plugin_information", array( "slug" => "Anti-spam"));
    /* Retreive information about the Anti-Spam plugin from the WP API */
    $object = new Plugin_Upgrader();
    $object->install($api->download_link);
    /* Install the plugin */
    $result = activate_plugin("$path/wp-content/plugins/anti-spam/anti-spam.php");
    /* Activate the plugin */
    echo "Plugin installed and activated successfully.\n";
    exit(0);
}
?>
drupal7.php000064400000000525147511477550006655 0ustar00<?php
$string = <<<EOF
\$databases['default']['default']['init_commands']['sql_mode'] = "SET sql_mode = 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO'";
EOF;

file_put_contents('sites/default/settings.php', $string . "\n", FILE_APPEND);
mambo.php000064400000000174147511477550006372 0ustar00<?php

/* Mambo only works properly with PHP 5.2 */

file_put_contents('.htaccess', 'SetENV PHP_VERSION 5', FILE_APPEND);


ei-tools.php000064400000027337147511477550007044 0ustar00<?php

$supported_scripts = array('wordpress', 'joomla');

function set_script_template($script, $template_name, $details) {
	if (empty($script)) err(__FUNCTION__ . '() empty script parameter');
	if (empty($template_name)) err(__FUNCTION__ . '() empty template_name parameter');
	if (empty($details)) err(__FUNCTION__ . '() empty details parameter');

	script_supported($script);

	$db = get_ei_db($details, $script);

	switch(strtolower($script)) {
		case "joomla":
			$queries = array(
				"UPDATE `" . $details['prefix'] . "template_styles` SET home = 0",
				"UPDATE `" . $details['prefix'] . "template_styles` SET home = 1 WHERE template = '{$template_name}'",
			);	
		break;
		case "wordpress":
			$queries = array(
				"UPDATE `" . $details['prefix'] . "options` SET `option_value` = '{$template_name}' WHERE `option_name` IN ('template', 'stylesheet')",
				"DELETE FROM " . $details['prefix'] . "options WHERE option_name = 'current_theme'",
				"INSERT INTO `" . $details['prefix'] . "options` (`option_name`,`option_value`,`autoload`) VALUES ('current_theme','{$template_name}','yes')",
			);
		break;
	}

	if (!$db->doTransactions($queries))
		err($db->getLastError());

	return true;
}

function script_config_file($script, $path) {
	script_supported($script);

	if (empty($path))
		err(__FUNCTION__ . '() Missing path parameter.');

	switch(strtolower($script)) {
		case "wordpress":
			$config_file = $path . 'wp-config.php';
		break;
		case "joomla":
			$config_file = $path . 'configuration.php';
		break;
	}
	
	return $config_file;
}

function script_supported($script) {
	$debug = debug_backtrace();
	if (empty($script)) err($debug['1'] . '() empty script parameter');

	if (!in_array($script, $GLOBALS['supported_scripts']))
		err($debug['1'] . '() script ' . $script . ' not supported.');
}

function set_script_password($script, $password, $details) {
	if (empty($password)) err(__FUNCTION__ . '() empty password parameter');
	if (empty($script)) err(__FUNCTION__ . '() empty script parameter');
	
	script_supported($script);
		
	$db = get_ei_db($details, $script);
	
	switch(strtolower($script)) {
		case "joomla":
			$q = "UPDATE {$details['prefix']}users SET password = md5('" . $db->escape($password) . "') WHERE id = (SELECT MIN(user_id) FROM {$details['prefix']}user_usergroup_map WHERE group_id = 8)";
		break;
		case "wordpress":
			$q = "UPDATE {$details['prefix']}users SET user_pass = md5('" . $db->escape($password) . "') WHERE ID = (SELECT MIN(user_id) FROM {$details['prefix']}usermeta WHERE meta_key = 'wp_capabilities' AND meta_value like '%s:13:\"administrator\"%')";
		break;
	}
	
	if (!$db->query($q))
		err($db->getLastError());

	return true;
}

function get_script_config($script, $file) {
	if (!file_exists($file))
		err('Missing config file ' . $file);

	if (!$data = file_get_contents($file)) 
		err('Empty config file ' . $file);

	script_supported($script);

	$details = array('prefix' => '');
	switch(strtolower($script)) {
		case "joomla":
			foreach(explode("\n", $data) as $line) {
				if (preg_match('/public\s\$(host|user|password|db|dbprefix)((\s+)?)\=((\s+)?)(\'|")(.*)(\'|")/i', $line, $matches) && !empty($matches['1']) && !empty($matches['7'])) {
					if (strtolower($matches['1']) == 'dbprefix')
						$details['prefix'] = $matches['7'];
					else
						$details[strtolower($matches['1'])] = $matches['7'];
				}
			}
			foreach(array('host', 'user', 'password', 'db') as $k)
				 if (empty($details[$k]))
					 err('[' . $script . '] ' . $k . ' could not be found');
		break;
		case "wordpress":
			foreach(explode("\n", $data) as $line) {
				// db settings
				if (preg_match('/define\((\'|")DB_(name|user|password|host)(\'|"),(\s)?(\'|")(.*)(\'|")\);/i', $line, $matches) && !empty($matches['2']) && !empty($matches['6']))
					$details[strtolower($matches['2'])] = $matches['6'];
				elseif (preg_match('/^\$table_prefix((\s)+)?\=((\s)+)?(\'|")(.*)(\'|")\;$/i', $line, $matches) && !empty($matches['6']))
					$details['prefix'] = $matches['6'];
			}

			foreach(array('host', 'user', 'password', 'name') as $k)
				if (empty($details[$k]))
					err('[' . $script . '] ' . $k . ' could not be found');
		break;
	}
	return $details;
}

function get_ei_db($details, $script) {
	
	script_supported($script);
	
	switch(strtolower($script)) {
		case "joomla":
			foreach(array('host', 'user', 'password', 'db') as $k) 
					if (empty($details[$k]))
						err('missing_db_' . $k);
			return new SQL($details['host'], $details['user'], $details['password'], $details['db']);
		break;
		case "wordpress":
			foreach(array('host', 'user', 'password', 'name') as $k)
				if (empty($details[$k]))
						err('missing_db_' . $k);
				return new SQL($details['host'], $details['user'], $details['password'], $details['name']);
		break;
	}

	if (!$db)
		err($db->error);

	return $db;
}

function pr($a) { echo print_r($a, true) . PHP_EOL; }
function err($msg, $code = 0) { 
	echo "\nERROR: " . $msg . "\n\n";
	exit;
	throw new Exception($msg, $code); 
}

// SQL part
class sql {
    private $conn = null;
    
    function __construct($host, $user, $pass, $dbname, $debug = false, $persistent = false) {
        // mysqli reconnect
        ini_set('mysqli.reconnect', 1);
        
        if ($persistent)
            $host = 'p:' . $host;
        
        $this->conn = new mysqli($host, $user, $pass, $dbname);
        if ($this->conn != null)
            $this->conn->query("SET NAMES utf8");
		else {
			err(mysqli_error($this->conn));
            die("Unable to connect to database. \n " . mysqli_error($this->conn));
        }
    }
    
    function __destruct() {
        $this->conn->close();
    }
    
    function buildWhere($params) {
        $where = array();
        
        foreach($params as $k => $v) {
            if (!is_string($v) && !is_numeric($v))
                continue;
                
            if (preg_match('/^@/', $k)) {
                if (preg_match('/^@(OR|LIKE|ILIKE)@(.*)/i', $k, $matches)) {
                    pr($matches);
                    exit;
                    $where[] = array(
                        'condition' => preg_replace('/^@(.*)@/', '', $k) . " = " . $v,
                        'condition_key' => $matches[1],
                    );
                } else {
                    $where[] = array(
                        'condition' => preg_replace('/^@/', '', $k) . " = " . $v,
                    );
                }
            } else {
                $where[] = array(
                    'condition' => $k . " = '" . self::escape($v) . "'",
                );
            }
        }
        
        if (empty($where))
            return '';
        
        $return = '';
        
        foreach($where as $k => $v)
            $return .= $v['condition'] . (!empty($where[$k+1]) ? (empty($v['condition_key']) ? ' AND ' : $v['condition']) : '');
        
        return ' WHERE ' . $return;
    }
    
    public function insert($table, $params, $return_query = false) {
        if (empty($table) || empty($params) || !is_array($params))
            return false;

        $keys = $values = array();

        foreach($params as $k => $v) {
            if ($k == 'key') $k = '`' . $k . '`';
            $keys[] = self::escape(preg_replace('/^@/', '', $k));
            $values[] = preg_match('/^@/', $k) ? $v :  "'" . self::escape($v) . "'";
        }
        
        $q = "INSERT INTO {$table}(" . implode(', ', $keys) . ") VALUES(" . implode(', ', $values) . ")";
        
        if ($return_query)
            return $q;        
        
        return self::query($q);
    }
    
	function update($table, $_set = array(), $_where = array(), $return_query = false) {
		$where_keys = array_keys($_where);
		$set_keys = array_keys($_set);

        if (empty($table) || empty($_set) || empty($set_keys) || empty($_where) || empty($where_keys))
            return false;
        
        $table = $this->escape($table);
        
        $set = array();
        foreach($_set as $k => $v) {
            $k = $this->escape($k);
            $v = $this->escape($v);
            if ($k == 'key') $k = '`' . $k . '`';
            $set[] = "{$k} = " . (is_numeric($v) ? $v : "'" . $v . "'");
        }

        $where = array();
        foreach($_where as $k => $v) {
            $k = $this->escape($k);
            $v = $this->escape($v);
            if ($k == 'key') $k = '`' . $k . '`';
            $where[] = "{$k} = " . (is_numeric($v) ? $v : "'" . $v . "'");
        }
                
        if (empty($set) || empty($where)) return false;
        
        $q = "UPDATE {$table} SET " . implode(', ', $set) . ' WHERE ' . implode(' AND ', $where);
        
        if ($return_query)
            return $q;
        
        if (!$this->query($q))
            err($this->getLastError());
        
        return true;    
    }    
    
    public function query($query) {
        if (!$this->conn) {
            $this->conn = new mysqli($this->db_host, $this->db_user, $this->db_pass, $this->db_name);
            if ($this->conn != null)
                $this->conn->query("SET NAMES utf8");
            else {
                die("Unable to connect to database. \n " . mysqli_connect_error($this->conn) . " | " . mysqli_error($this->conn) . "\n<br />");
            }
        }
        
        $this->error = '';
        if ($result = $this->conn->query($query)) {
            if (preg_match('/^insert\ into/i', $query))
                return !empty($this->conn->insert_id) ? $this->conn->insert_id : true;
            if (preg_match('/^update\ /i', $query)) 
                return (!empty($this->conn->affected_rows) ? $this->conn->affected_rows : true);

            return $result;
        }
        
        $this->error = $this->getLastError();
        
        return false;
    }

    public function count($q) {
        $q = preg_replace("/SELECT(.*)FROM/i", "SELECT count(*) as count FROM", str_replace("\n", '', str_replace("\t", ' ', $q)));
        
        return self::fetch_val($q, 'count');
    }
    
    public function fetch_array($query) {
        $out = array();
        if ($res = self::query($query)) {
            while($row = $res->fetch_array(MYSQLI_ASSOC)) {
                $out[] = $row;
            }
            return $out;
        }
        self::debug($query);    
        return false;
    }

    public function fetch_row($query) {
        if ($res = self::fetch_array($query)) {
            return current($res);
        }
        
        self::debug($query);    
        return false;
    }

    public function fetch_val($query, $key) {
        if ($res = self::fetch_row($query)) {
            if (isset($res[$key])) 
                return $res[$key];
        }
        self::debug($query);
        return false;
    }
    
    public function escape($string) {
        if (is_array($string) || is_object($string)) {
            $return = array();
            foreach($string as $k => $v) {
                if (is_array($string))
                    $return[$k] = $this->escape($v);
                elseif (is_object($string))
                    $return->{$k} = $this->escape($v);
            }
            return $return;
        } else {
            return $this->conn->real_escape_string(trim($string));
        }    
    }
    
    public function getLastError() {
        return mysqli_error($this->conn);
    }
    
    public function debug($query) {
        if ($this->debug) {
            if ($err = mysqli_connect_error($this->conn))
                die("Connection failed: <br />\n" . $err . "<br />");
        
            if ($err = mysqli_error($this->conn))
                pr("Query failed: $query<br />\n" . $err . "<br />");
        }
    }
    
    public function doTransactions($queries) {
	    $this->query('BEGIN;');
	    foreach($queries as $q) {
		    if (!$this->query($q)) {
		    	$this->query('ROLLBACK');
		    	return false;
		    }
	    }
		$this->query('COMMIT');
		
		return true;
    }
}


laravel.php000075500000001542147511477550006730 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];
$path = $argv[2];


$cmd = `cp -a /home/www/shared/laravel/$full_path/public/* .`; 
$cmd = `(cd /home/www/shared/laravel/$full_path; /usr/local/php7.3/bin/php artisan key:generate) &> /home/www/log.txt.1`;

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/laravel/$full_path/'", $index);
$index = str_replace('/../', "/", $index);
file_put_contents('index.php', $index);

/*
file_put_contents('index.php', <<<OUTPUT
<?php
require('/home/www/shared/laravel/$path/public/index.php');

OUTPUT
);

file_put_contents('.htaccess', <<<OUTPUT
RewriteEngine On

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

OUTPUT
);
*/
ci.php000075500000000545147511477550005677 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];
$path = $argv[2];


$cmd = `cp -a /home/www/shared/codeigniter/$full_path/public/* .`; 

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/codeigniter/$full_path/'", $index);
$index = str_replace('../', "/", $index);
file_put_contents('index.php', $index);

suitcrm.php000064400000000563147511477550006767 0ustar00<?php
include('public/legacy/config.php');

$c = $sugar_config['dbconfig'];

$str = "DATABASE_URL=\"mysql://{$c['db_user_name']}:{$c['db_password']}@localhost/{$c['db_name']}\"\n";
$str .= "APP_SECRET=\"" . bin2hex(openssl_random_pseudo_bytes(12)) . "\"\n";
file_put_contents('.env.local', $str);

file_put_contents('index.php', "<?php header('location: public/'); ?>");
old/ei.php000064400000004765147511477550006464 0ustar00<?php
define('CONFIG_FILE', 'ei_config.php');
define('MYSQL_CONFIG', 'ei_my.cnf');

if (!($config = file_get_contents(CONFIG_FILE)))
	exit("Can't read " . CONFIG_FILES . "\n");

if (!($config = json_decode($config, true)))
	exit("Can't decode " . CONFIG_FILE . "\n");

$prefix = $config['prefix'];
$suffix = $config['suffix'];
$params = $config['params'];
$db = $config['sql'];

foreach ($config['files'] as $file) {
	replace_params($file, $prefix, $suffix, $params, $db);
}

if (!empty($config['sql'])) {
	$database = $config['sql']['dbname'];
	$username = $config['sql']['dbuser'];
	$password = $config['sql']['dbpass'];
	file_put_contents(MYSQL_CONFIG, <<<MYSQL
[client]
user=$username
password=$password
MYSQL);
	foreach ($config['sql']['files'] as $sql_file) {
		replace_params($sql_file, $prefix, $suffix, $params, $db);


		$cmd = sprintf("mysql --defaults-file=%s %s < %s 2>&1", MYSQL_CONFIG, $database, $sql_file);
		$output = [];
		$ret = 0;
		exec($cmd, $output, $ret);

		if ($ret !== 0) {
			echo "mysql dump insert failure\n";
		} else {
			//unlink(MYSQL_CONFIG);
			//unlink($sql_file);
		}
	}
}

//unlink(CONFIG_FILE);

function replace_params($file, $prefix, $suffix, $params, $db) {
	$file = './' . $file;
	echo "replacing $file\n";
	if (!($content = file_get_contents($file))) {
		echo "Can't read $file\n";
		return false;
	}

	$vars = [];

	foreach ($db as $k => $v) { // db details
		if (is_string($v))
			$params[$k] = ['value' => $v];
	}

	//print_r($params);
	//replace vars in vars
	foreach ($params as $k1 => $v1) {
		foreach ($params as $k2 => $v2) {
			$params[$k2]['value'] = str_replace($prefix . $k1 . $suffix, $v1['value'], $params[$k2]['value']);
		}
	}

	//print_r($params);
	//calculate values
	foreach ($params as $k => $v) {
		$vars[$k] = escape(@$v['escape'], param($k, $v));
	}

	//print_r($vars);

	foreach ($vars as $k => $v)
		$content = str_replace($prefix . $k . $suffix, $v, $content);

	file_put_contents($file, $content);
}

function param($k, $v) {
	$options = !empty($v['options']) ? $v['options'] : [];
	$ret = $v['value'];
	foreach ($options as $option) {
		switch ($option) {
			case 'eval':
				$ret = eval($ret);
				break;
			case 'md5':
				$ret = md5($v['value']);
				break;
			//case 'hidden':
			//default:
			//	$ret = $v['value'];
		}
	}

	return $ret;
}

function escape_single_quotes($value) {
	return addcslashes($value, "'");
}

function escape_double_quotes($value) {
	return addcslashes($value, '"');
}

function escape($func, $value) {
	return $func ? $func($value) : $value;
}
.htaccess000064400000000330147511477550006356 0ustar00RewriteEngine On

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]yii.php000075500000000477147511477550006102 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];

$cmd = `cp -a /home/www/shared/yii/$full_path/web/* .`; 

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/yii/$full_path/'", $index);
$index = str_replace('/../', "/", $index);
file_put_contents('index.php', $index);
podcast.php000075500000001045147511477550006735 0ustar00#!/usr/local/php7.3/bin/php
<?php
//require('config.php');

$username = `grep users_json config.php  | awk '{print $3}' | sed 's/[:\"{]//g'`;
$password = `grep users_json config.php  | awk '{print $4}' | sed 's/[:\"{};]//g'`;
$config = `cat config.php | sed '/users_json/d'`;

$username = trim($username);
$password = trim($password);
$password = password_hash($password, PASSWORD_DEFAULT); 

$credentials = json_encode([$username => $password], true);
file_put_contents('config.php', '$users_json = \'' . $credentials . '\';' . "\n", FILE_APPEND);
set-password.php000075500000023265147511477550007743 0ustar00#!/usr/local/php7/bin/php
<?php
error_reporting(-1);

if (empty($argv[1])) err('Missing script name');
if (empty($argv[2])) err('Missing installation path');
if (empty($argv[3])) err('New password not provided');

$script = strtolower($argv[1]);
$path = $argv[2];
$password = $argv[3];

if (!is_dir($path) || !file_exists($path))
	err('Invalid installation path');


switch($script) {
	case "wordpress":
		$config_file = $path . 'wp-config.php';
	break;
	case "joomla":
		$config_file = $path . 'configuration.php';
	break;
	default:
		err('Script ' . $script . ' not defined.');
}

if (!file_exists($config_file))
	err('Missing ' . $script . ' config file [' . $config_file . ']');

// get script details
$details = get_script_config($script, $config_file);

// set script password
set_script_password($script, $password, $details);

echo 1;

// Functions

function set_script_password($script, $password, $details) {
	if (empty($password)) err(__FUNCTION__ . '() empty password');
	switch($script) {
		default:
			err(__FUNCTION__  . '() ' . $script . ' not supported');
		case "joomla":
			$db = new SQL($details['host'], $details['user'], $details['password'], $details['db']);
			$q = "UPDATE {$details['prefix']}users SET password = md5('" . $db->escape($password) . "') WHERE id = (SELECT MIN(user_id) FROM {$details['prefix']}user_usergroup_map WHERE group_id = 8)";
		break;
		case "wordpress":
			$db = new SQL($details['host'], $details['user'], $details['password'], $details['name']);
			// set password
			$q = "UPDATE {$details['prefix']}users SET user_pass = md5('" . $db->escape($password) . "') WHERE ID = (SELECT MIN(user_id) FROM {$details['prefix']}usermeta WHERE meta_key = 'wp_capabilities' AND meta_value like '%s:13:\"administrator\"%')";
		break;
	}

	if (!$db->query($q))
		err($db->getLastError());

	return true;
}

function get_script_config($script, $file) {
	if (!file_exists($file))
		err('Missing config file ' . $file);

	if (!$data = file_get_contents($file))
		err('Empty config file ' . $file);

	$details = array();
	switch($script) {
		default:
			err($script . ' not supported');
		case "joomla":
			foreach(explode("\n", $data) as $line) {
				if (preg_match('/public\s\$(host|user|password|db|dbprefix)((\s+)?)\=((\s+)?)(\'|")(.*)(\'|")/i', $line, $matches) && !empty($matches['1']) && !empty($matches['7'])) {
					if (strtolower($matches['1']) == 'dbprefix')
						$details['prefix'] = $matches['7'];
					else
						$details[strtolower($matches['1'])] = $matches['7'];
				}
			}
			foreach(array('host', 'user', 'password', 'db') as $k)
				 if (empty($details[$k]))
					 err('[' . $script . '] ' . $k . ' could not be found');
		break;
		case "wordpress":
			//print_r($data);
			foreach(explode("\n", $data) as $line) {
				// db settings
				if (preg_match('/define\(\s*(\'|")DB_(name|user|password|host)(\'|"),(\s)?(\'|")(.*)(\'|")\s*\);/i', $line, $matches) && !empty($matches['2']) && !empty($matches['6']))
					$details[strtolower($matches['2'])] = $matches['6'];
				elseif (preg_match('/^\$table_prefix((\s)+)?\=((\s)+)?(\'|")(.*)(\'|")\;$/i', $line, $matches) && !empty($matches['6']))
					$details['prefix'] = $matches['6'];
			}

			foreach(array('host', 'user', 'password', 'name') as $k)
				if (empty($details[$k]))
					err('[' . $script . '] ' . $k . ' could not be found');
		break;
	}
	return $details;
}

function pr($a) { echo print_r($a, true) . PHP_EOL; }
function err($msg, $code = 0) {
	echo "\nERROR: " . $msg . "\n\n";
	exit;
	throw new Exception($msg, $code);
}

// SQL part
class sql {
    private $conn = null;

    function __construct($host, $user, $pass, $dbname, $debug = false, $persistent = false) {
        // mysqli reconnect
        ini_set('mysqli.reconnect', 1);

        if ($persistent)
            $host = 'p:' . $host;

        $this->conn = new mysqli($host, $user, $pass, $dbname);
        if ($this->conn != null)
            $this->conn->query("SET NAMES utf8");
        else {
            die("Unable to connect to database. \n " . mysqli_error($this->conn));
        }
    }

    function __destruct() {
        $this->conn->close();
    }

    function buildWhere($params) {
        $where = array();

        foreach($params as $k => $v) {
            if (!is_string($v) && !is_numeric($v))
                continue;

            if (preg_match('/^@/', $k)) {
                if (preg_match('/^@(OR|LIKE|ILIKE)@(.*)/i', $k, $matches)) {
                    pr($matches);
                    exit;
                    $where[] = array(
                        'condition' => preg_replace('/^@(.*)@/', '', $k) . " = " . $v,
                        'condition_key' => $matches[1],
                    );
                } else {
                    $where[] = array(
                        'condition' => preg_replace('/^@/', '', $k) . " = " . $v,
                    );
                }
            } else {
                $where[] = array(
                    'condition' => $k . " = '" . self::escape($v) . "'",
                );
            }
        }

        if (empty($where))
            return '';

        $return = '';

        foreach($where as $k => $v)
            $return .= $v['condition'] . (!empty($where[$k+1]) ? (empty($v['condition_key']) ? ' AND ' : $v['condition']) : '');

        return ' WHERE ' . $return;
    }

    public function insert($table, $params, $return_query = false) {
        if (empty($table) || empty($params) || !is_array($params))
            return false;

        $keys = $values = array();

        foreach($params as $k => $v) {
            if ($k == 'key') $k = '`' . $k . '`';
            $keys[] = self::escape(preg_replace('/^@/', '', $k));
            $values[] = preg_match('/^@/', $k) ? $v :  "'" . self::escape($v) . "'";
        }

        $q = "INSERT INTO {$table}(" . implode(', ', $keys) . ") VALUES(" . implode(', ', $values) . ")";

        if ($return_query)
            return $q;

        return self::query($q);
    }

    function update($table, $_set = array(), $_where = array(), $return_query = false) {
        if (empty($table) || empty($_set) || empty(array_keys($_set)) || empty($_where) || empty(array_keys($_where)))
            return false;

        $table = $this->escape($table);

        $set = array();
        foreach($_set as $k => $v) {
            $k = $this->escape($k);
            $v = $this->escape($v);
            if ($k == 'key') $k = '`' . $k . '`';
            $set[] = "{$k} = " . (is_numeric($v) ? $v : "'" . $v . "'");
        }

        $where = array();
        foreach($_where as $k => $v) {
            $k = $this->escape($k);
            $v = $this->escape($v);
            if ($k == 'key') $k = '`' . $k . '`';
            $where[] = "{$k} = " . (is_numeric($v) ? $v : "'" . $v . "'");
        }

        if (empty($set) || empty($where)) return false;

        $q = "UPDATE {$table} SET " . implode(', ', $set) . ' WHERE ' . implode(' AND ', $where);

        if ($return_query)
            return $q;

        if (!$this->query($q))
            err($this->getLastError());

        return true;
    }

    public function query($query) {
        if (!$this->conn) {
            $this->conn = new mysqli($this->db_host, $this->db_user, $this->db_pass, $this->db_name);
            if ($this->conn != null)
                $this->conn->query("SET NAMES utf8");
            else {
                die("Unable to connect to database. \n " . mysqli_connect_error($this->conn) . " | " . mysqli_error($this->conn) . "\n<br />");
            }
        }

        $this->error = '';
        if ($result = $this->conn->query($query)) {
            if (preg_match('/^insert\ into/i', $query))
                return !empty($this->conn->insert_id) ? $this->conn->insert_id : true;
            if (preg_match('/^update\ /i', $query))
                return (!empty($this->conn->affected_rows) ? $this->conn->affected_rows : true);

            return $result;
        }

        $this->error = $this->getLastError();

        return false;
    }

    public function count($q) {
        $q = preg_replace("/SELECT(.*)FROM/i", "SELECT count(*) as count FROM", str_replace("\n", '', str_replace("\t", ' ', $q)));

        return self::fetch_val($q, 'count');
    }

    public function fetch_array($query) {
        $out = array();
        if ($res = self::query($query)) {
            while($row = $res->fetch_array(MYSQLI_ASSOC)) {
                $out[] = $row;
            }
            return $out;
        }
        self::debug($query);
        return false;
    }

    public function fetch_row($query) {
        if ($res = self::fetch_array($query)) {
            return current($res);
        }

        self::debug($query);
        return false;
    }

    public function fetch_val($query, $key) {
        if ($res = self::fetch_row($query)) {
            if (isset($res[$key]))
                return $res[$key];
        }
        self::debug($query);
        return false;
    }

    public function escape($string) {
        if (is_array($string) || is_object($string)) {
            $return = array();
            foreach($string as $k => $v) {
                if (is_array($string))
                    $return[$k] = $this->escape($v);
                elseif (is_object($string))
                    $return->{$k} = $this->escape($v);
            }
            return $return;
        } else {
            return $this->conn->real_escape_string(trim($string));
        }
    }

    public function getLastError() {
        return mysqli_error($this->conn);
    }

    public function debug($query) {
        if ($this->debug) {
            if ($err = mysqli_connect_error($this->conn))
                die("Connection failed: <br />\n" . $err . "<br />");

            if ($err = mysqli_error($this->conn))
                pr("Query failed: $query<br />\n" . $err . "<br />");
        }
    }
}
moodle.php000064400000000357147511477550006561 0ustar00<?php
$cwd = getcwd();
if (!preg_match('|/home/www/(.+)|', $cwd, $regs))
	exit('Cwd error.');

file_put_contents('config.php', '$CFG->disablelogintoken = true;' . "\n", FILE_APPEND);

mkdir('/home/www/moodledata/' . $regs[1], 0777, true);
ei/ci.php000075500000000545147511477550006274 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];
$path = $argv[2];


$cmd = `cp -a /home/www/shared/codeigniter/$full_path/public/* .`; 

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/codeigniter/$full_path/'", $index);
$index = str_replace('../', "/", $index);
file_put_contents('index.php', $index);

ei/ei-tools.php000064400000027337147511477550007441 0ustar00<?php

$supported_scripts = array('wordpress', 'joomla');

function set_script_template($script, $template_name, $details) {
	if (empty($script)) err(__FUNCTION__ . '() empty script parameter');
	if (empty($template_name)) err(__FUNCTION__ . '() empty template_name parameter');
	if (empty($details)) err(__FUNCTION__ . '() empty details parameter');

	script_supported($script);

	$db = get_ei_db($details, $script);

	switch(strtolower($script)) {
		case "joomla":
			$queries = array(
				"UPDATE `" . $details['prefix'] . "template_styles` SET home = 0",
				"UPDATE `" . $details['prefix'] . "template_styles` SET home = 1 WHERE template = '{$template_name}'",
			);	
		break;
		case "wordpress":
			$queries = array(
				"UPDATE `" . $details['prefix'] . "options` SET `option_value` = '{$template_name}' WHERE `option_name` IN ('template', 'stylesheet')",
				"DELETE FROM " . $details['prefix'] . "options WHERE option_name = 'current_theme'",
				"INSERT INTO `" . $details['prefix'] . "options` (`option_name`,`option_value`,`autoload`) VALUES ('current_theme','{$template_name}','yes')",
			);
		break;
	}

	if (!$db->doTransactions($queries))
		err($db->getLastError());

	return true;
}

function script_config_file($script, $path) {
	script_supported($script);

	if (empty($path))
		err(__FUNCTION__ . '() Missing path parameter.');

	switch(strtolower($script)) {
		case "wordpress":
			$config_file = $path . 'wp-config.php';
		break;
		case "joomla":
			$config_file = $path . 'configuration.php';
		break;
	}
	
	return $config_file;
}

function script_supported($script) {
	$debug = debug_backtrace();
	if (empty($script)) err($debug['1'] . '() empty script parameter');

	if (!in_array($script, $GLOBALS['supported_scripts']))
		err($debug['1'] . '() script ' . $script . ' not supported.');
}

function set_script_password($script, $password, $details) {
	if (empty($password)) err(__FUNCTION__ . '() empty password parameter');
	if (empty($script)) err(__FUNCTION__ . '() empty script parameter');
	
	script_supported($script);
		
	$db = get_ei_db($details, $script);
	
	switch(strtolower($script)) {
		case "joomla":
			$q = "UPDATE {$details['prefix']}users SET password = md5('" . $db->escape($password) . "') WHERE id = (SELECT MIN(user_id) FROM {$details['prefix']}user_usergroup_map WHERE group_id = 8)";
		break;
		case "wordpress":
			$q = "UPDATE {$details['prefix']}users SET user_pass = md5('" . $db->escape($password) . "') WHERE ID = (SELECT MIN(user_id) FROM {$details['prefix']}usermeta WHERE meta_key = 'wp_capabilities' AND meta_value like '%s:13:\"administrator\"%')";
		break;
	}
	
	if (!$db->query($q))
		err($db->getLastError());

	return true;
}

function get_script_config($script, $file) {
	if (!file_exists($file))
		err('Missing config file ' . $file);

	if (!$data = file_get_contents($file)) 
		err('Empty config file ' . $file);

	script_supported($script);

	$details = array('prefix' => '');
	switch(strtolower($script)) {
		case "joomla":
			foreach(explode("\n", $data) as $line) {
				if (preg_match('/public\s\$(host|user|password|db|dbprefix)((\s+)?)\=((\s+)?)(\'|")(.*)(\'|")/i', $line, $matches) && !empty($matches['1']) && !empty($matches['7'])) {
					if (strtolower($matches['1']) == 'dbprefix')
						$details['prefix'] = $matches['7'];
					else
						$details[strtolower($matches['1'])] = $matches['7'];
				}
			}
			foreach(array('host', 'user', 'password', 'db') as $k)
				 if (empty($details[$k]))
					 err('[' . $script . '] ' . $k . ' could not be found');
		break;
		case "wordpress":
			foreach(explode("\n", $data) as $line) {
				// db settings
				if (preg_match('/define\((\'|")DB_(name|user|password|host)(\'|"),(\s)?(\'|")(.*)(\'|")\);/i', $line, $matches) && !empty($matches['2']) && !empty($matches['6']))
					$details[strtolower($matches['2'])] = $matches['6'];
				elseif (preg_match('/^\$table_prefix((\s)+)?\=((\s)+)?(\'|")(.*)(\'|")\;$/i', $line, $matches) && !empty($matches['6']))
					$details['prefix'] = $matches['6'];
			}

			foreach(array('host', 'user', 'password', 'name') as $k)
				if (empty($details[$k]))
					err('[' . $script . '] ' . $k . ' could not be found');
		break;
	}
	return $details;
}

function get_ei_db($details, $script) {
	
	script_supported($script);
	
	switch(strtolower($script)) {
		case "joomla":
			foreach(array('host', 'user', 'password', 'db') as $k) 
					if (empty($details[$k]))
						err('missing_db_' . $k);
			return new SQL($details['host'], $details['user'], $details['password'], $details['db']);
		break;
		case "wordpress":
			foreach(array('host', 'user', 'password', 'name') as $k)
				if (empty($details[$k]))
						err('missing_db_' . $k);
				return new SQL($details['host'], $details['user'], $details['password'], $details['name']);
		break;
	}

	if (!$db)
		err($db->error);

	return $db;
}

function pr($a) { echo print_r($a, true) . PHP_EOL; }
function err($msg, $code = 0) { 
	echo "\nERROR: " . $msg . "\n\n";
	exit;
	throw new Exception($msg, $code); 
}

// SQL part
class sql {
    private $conn = null;
    
    function __construct($host, $user, $pass, $dbname, $debug = false, $persistent = false) {
        // mysqli reconnect
        ini_set('mysqli.reconnect', 1);
        
        if ($persistent)
            $host = 'p:' . $host;
        
        $this->conn = new mysqli($host, $user, $pass, $dbname);
        if ($this->conn != null)
            $this->conn->query("SET NAMES utf8");
		else {
			err(mysqli_error($this->conn));
            die("Unable to connect to database. \n " . mysqli_error($this->conn));
        }
    }
    
    function __destruct() {
        $this->conn->close();
    }
    
    function buildWhere($params) {
        $where = array();
        
        foreach($params as $k => $v) {
            if (!is_string($v) && !is_numeric($v))
                continue;
                
            if (preg_match('/^@/', $k)) {
                if (preg_match('/^@(OR|LIKE|ILIKE)@(.*)/i', $k, $matches)) {
                    pr($matches);
                    exit;
                    $where[] = array(
                        'condition' => preg_replace('/^@(.*)@/', '', $k) . " = " . $v,
                        'condition_key' => $matches[1],
                    );
                } else {
                    $where[] = array(
                        'condition' => preg_replace('/^@/', '', $k) . " = " . $v,
                    );
                }
            } else {
                $where[] = array(
                    'condition' => $k . " = '" . self::escape($v) . "'",
                );
            }
        }
        
        if (empty($where))
            return '';
        
        $return = '';
        
        foreach($where as $k => $v)
            $return .= $v['condition'] . (!empty($where[$k+1]) ? (empty($v['condition_key']) ? ' AND ' : $v['condition']) : '');
        
        return ' WHERE ' . $return;
    }
    
    public function insert($table, $params, $return_query = false) {
        if (empty($table) || empty($params) || !is_array($params))
            return false;

        $keys = $values = array();

        foreach($params as $k => $v) {
            if ($k == 'key') $k = '`' . $k . '`';
            $keys[] = self::escape(preg_replace('/^@/', '', $k));
            $values[] = preg_match('/^@/', $k) ? $v :  "'" . self::escape($v) . "'";
        }
        
        $q = "INSERT INTO {$table}(" . implode(', ', $keys) . ") VALUES(" . implode(', ', $values) . ")";
        
        if ($return_query)
            return $q;        
        
        return self::query($q);
    }
    
	function update($table, $_set = array(), $_where = array(), $return_query = false) {
		$where_keys = array_keys($_where);
		$set_keys = array_keys($_set);

        if (empty($table) || empty($_set) || empty($set_keys) || empty($_where) || empty($where_keys))
            return false;
        
        $table = $this->escape($table);
        
        $set = array();
        foreach($_set as $k => $v) {
            $k = $this->escape($k);
            $v = $this->escape($v);
            if ($k == 'key') $k = '`' . $k . '`';
            $set[] = "{$k} = " . (is_numeric($v) ? $v : "'" . $v . "'");
        }

        $where = array();
        foreach($_where as $k => $v) {
            $k = $this->escape($k);
            $v = $this->escape($v);
            if ($k == 'key') $k = '`' . $k . '`';
            $where[] = "{$k} = " . (is_numeric($v) ? $v : "'" . $v . "'");
        }
                
        if (empty($set) || empty($where)) return false;
        
        $q = "UPDATE {$table} SET " . implode(', ', $set) . ' WHERE ' . implode(' AND ', $where);
        
        if ($return_query)
            return $q;
        
        if (!$this->query($q))
            err($this->getLastError());
        
        return true;    
    }    
    
    public function query($query) {
        if (!$this->conn) {
            $this->conn = new mysqli($this->db_host, $this->db_user, $this->db_pass, $this->db_name);
            if ($this->conn != null)
                $this->conn->query("SET NAMES utf8");
            else {
                die("Unable to connect to database. \n " . mysqli_connect_error($this->conn) . " | " . mysqli_error($this->conn) . "\n<br />");
            }
        }
        
        $this->error = '';
        if ($result = $this->conn->query($query)) {
            if (preg_match('/^insert\ into/i', $query))
                return !empty($this->conn->insert_id) ? $this->conn->insert_id : true;
            if (preg_match('/^update\ /i', $query)) 
                return (!empty($this->conn->affected_rows) ? $this->conn->affected_rows : true);

            return $result;
        }
        
        $this->error = $this->getLastError();
        
        return false;
    }

    public function count($q) {
        $q = preg_replace("/SELECT(.*)FROM/i", "SELECT count(*) as count FROM", str_replace("\n", '', str_replace("\t", ' ', $q)));
        
        return self::fetch_val($q, 'count');
    }
    
    public function fetch_array($query) {
        $out = array();
        if ($res = self::query($query)) {
            while($row = $res->fetch_array(MYSQLI_ASSOC)) {
                $out[] = $row;
            }
            return $out;
        }
        self::debug($query);    
        return false;
    }

    public function fetch_row($query) {
        if ($res = self::fetch_array($query)) {
            return current($res);
        }
        
        self::debug($query);    
        return false;
    }

    public function fetch_val($query, $key) {
        if ($res = self::fetch_row($query)) {
            if (isset($res[$key])) 
                return $res[$key];
        }
        self::debug($query);
        return false;
    }
    
    public function escape($string) {
        if (is_array($string) || is_object($string)) {
            $return = array();
            foreach($string as $k => $v) {
                if (is_array($string))
                    $return[$k] = $this->escape($v);
                elseif (is_object($string))
                    $return->{$k} = $this->escape($v);
            }
            return $return;
        } else {
            return $this->conn->real_escape_string(trim($string));
        }    
    }
    
    public function getLastError() {
        return mysqli_error($this->conn);
    }
    
    public function debug($query) {
        if ($this->debug) {
            if ($err = mysqli_connect_error($this->conn))
                die("Connection failed: <br />\n" . $err . "<br />");
        
            if ($err = mysqli_error($this->conn))
                pr("Query failed: $query<br />\n" . $err . "<br />");
        }
    }
    
    public function doTransactions($queries) {
	    $this->query('BEGIN;');
	    foreach($queries as $q) {
		    if (!$this->query($q)) {
		    	$this->query('ROLLBACK');
		    	return false;
		    }
	    }
		$this->query('COMMIT');
		
		return true;
    }
}


ei/set-password.php000075500000023265147511477550010340 0ustar00#!/usr/local/php7/bin/php
<?php
error_reporting(-1);

if (empty($argv[1])) err('Missing script name');
if (empty($argv[2])) err('Missing installation path');
if (empty($argv[3])) err('New password not provided');

$script = strtolower($argv[1]);
$path = $argv[2];
$password = $argv[3];

if (!is_dir($path) || !file_exists($path))
	err('Invalid installation path');


switch($script) {
	case "wordpress":
		$config_file = $path . 'wp-config.php';
	break;
	case "joomla":
		$config_file = $path . 'configuration.php';
	break;
	default:
		err('Script ' . $script . ' not defined.');
}

if (!file_exists($config_file))
	err('Missing ' . $script . ' config file [' . $config_file . ']');

// get script details
$details = get_script_config($script, $config_file);

// set script password
set_script_password($script, $password, $details);

echo 1;

// Functions

function set_script_password($script, $password, $details) {
	if (empty($password)) err(__FUNCTION__ . '() empty password');
	switch($script) {
		default:
			err(__FUNCTION__  . '() ' . $script . ' not supported');
		case "joomla":
			$db = new SQL($details['host'], $details['user'], $details['password'], $details['db']);
			$q = "UPDATE {$details['prefix']}users SET password = md5('" . $db->escape($password) . "') WHERE id = (SELECT MIN(user_id) FROM {$details['prefix']}user_usergroup_map WHERE group_id = 8)";
		break;
		case "wordpress":
			$db = new SQL($details['host'], $details['user'], $details['password'], $details['name']);
			// set password
			$q = "UPDATE {$details['prefix']}users SET user_pass = md5('" . $db->escape($password) . "') WHERE ID = (SELECT MIN(user_id) FROM {$details['prefix']}usermeta WHERE meta_key = 'wp_capabilities' AND meta_value like '%s:13:\"administrator\"%')";
		break;
	}

	if (!$db->query($q))
		err($db->getLastError());

	return true;
}

function get_script_config($script, $file) {
	if (!file_exists($file))
		err('Missing config file ' . $file);

	if (!$data = file_get_contents($file))
		err('Empty config file ' . $file);

	$details = array();
	switch($script) {
		default:
			err($script . ' not supported');
		case "joomla":
			foreach(explode("\n", $data) as $line) {
				if (preg_match('/public\s\$(host|user|password|db|dbprefix)((\s+)?)\=((\s+)?)(\'|")(.*)(\'|")/i', $line, $matches) && !empty($matches['1']) && !empty($matches['7'])) {
					if (strtolower($matches['1']) == 'dbprefix')
						$details['prefix'] = $matches['7'];
					else
						$details[strtolower($matches['1'])] = $matches['7'];
				}
			}
			foreach(array('host', 'user', 'password', 'db') as $k)
				 if (empty($details[$k]))
					 err('[' . $script . '] ' . $k . ' could not be found');
		break;
		case "wordpress":
			//print_r($data);
			foreach(explode("\n", $data) as $line) {
				// db settings
				if (preg_match('/define\(\s*(\'|")DB_(name|user|password|host)(\'|"),(\s)?(\'|")(.*)(\'|")\s*\);/i', $line, $matches) && !empty($matches['2']) && !empty($matches['6']))
					$details[strtolower($matches['2'])] = $matches['6'];
				elseif (preg_match('/^\$table_prefix((\s)+)?\=((\s)+)?(\'|")(.*)(\'|")\;$/i', $line, $matches) && !empty($matches['6']))
					$details['prefix'] = $matches['6'];
			}

			foreach(array('host', 'user', 'password', 'name') as $k)
				if (empty($details[$k]))
					err('[' . $script . '] ' . $k . ' could not be found');
		break;
	}
	return $details;
}

function pr($a) { echo print_r($a, true) . PHP_EOL; }
function err($msg, $code = 0) {
	echo "\nERROR: " . $msg . "\n\n";
	exit;
	throw new Exception($msg, $code);
}

// SQL part
class sql {
    private $conn = null;

    function __construct($host, $user, $pass, $dbname, $debug = false, $persistent = false) {
        // mysqli reconnect
        ini_set('mysqli.reconnect', 1);

        if ($persistent)
            $host = 'p:' . $host;

        $this->conn = new mysqli($host, $user, $pass, $dbname);
        if ($this->conn != null)
            $this->conn->query("SET NAMES utf8");
        else {
            die("Unable to connect to database. \n " . mysqli_error($this->conn));
        }
    }

    function __destruct() {
        $this->conn->close();
    }

    function buildWhere($params) {
        $where = array();

        foreach($params as $k => $v) {
            if (!is_string($v) && !is_numeric($v))
                continue;

            if (preg_match('/^@/', $k)) {
                if (preg_match('/^@(OR|LIKE|ILIKE)@(.*)/i', $k, $matches)) {
                    pr($matches);
                    exit;
                    $where[] = array(
                        'condition' => preg_replace('/^@(.*)@/', '', $k) . " = " . $v,
                        'condition_key' => $matches[1],
                    );
                } else {
                    $where[] = array(
                        'condition' => preg_replace('/^@/', '', $k) . " = " . $v,
                    );
                }
            } else {
                $where[] = array(
                    'condition' => $k . " = '" . self::escape($v) . "'",
                );
            }
        }

        if (empty($where))
            return '';

        $return = '';

        foreach($where as $k => $v)
            $return .= $v['condition'] . (!empty($where[$k+1]) ? (empty($v['condition_key']) ? ' AND ' : $v['condition']) : '');

        return ' WHERE ' . $return;
    }

    public function insert($table, $params, $return_query = false) {
        if (empty($table) || empty($params) || !is_array($params))
            return false;

        $keys = $values = array();

        foreach($params as $k => $v) {
            if ($k == 'key') $k = '`' . $k . '`';
            $keys[] = self::escape(preg_replace('/^@/', '', $k));
            $values[] = preg_match('/^@/', $k) ? $v :  "'" . self::escape($v) . "'";
        }

        $q = "INSERT INTO {$table}(" . implode(', ', $keys) . ") VALUES(" . implode(', ', $values) . ")";

        if ($return_query)
            return $q;

        return self::query($q);
    }

    function update($table, $_set = array(), $_where = array(), $return_query = false) {
        if (empty($table) || empty($_set) || empty(array_keys($_set)) || empty($_where) || empty(array_keys($_where)))
            return false;

        $table = $this->escape($table);

        $set = array();
        foreach($_set as $k => $v) {
            $k = $this->escape($k);
            $v = $this->escape($v);
            if ($k == 'key') $k = '`' . $k . '`';
            $set[] = "{$k} = " . (is_numeric($v) ? $v : "'" . $v . "'");
        }

        $where = array();
        foreach($_where as $k => $v) {
            $k = $this->escape($k);
            $v = $this->escape($v);
            if ($k == 'key') $k = '`' . $k . '`';
            $where[] = "{$k} = " . (is_numeric($v) ? $v : "'" . $v . "'");
        }

        if (empty($set) || empty($where)) return false;

        $q = "UPDATE {$table} SET " . implode(', ', $set) . ' WHERE ' . implode(' AND ', $where);

        if ($return_query)
            return $q;

        if (!$this->query($q))
            err($this->getLastError());

        return true;
    }

    public function query($query) {
        if (!$this->conn) {
            $this->conn = new mysqli($this->db_host, $this->db_user, $this->db_pass, $this->db_name);
            if ($this->conn != null)
                $this->conn->query("SET NAMES utf8");
            else {
                die("Unable to connect to database. \n " . mysqli_connect_error($this->conn) . " | " . mysqli_error($this->conn) . "\n<br />");
            }
        }

        $this->error = '';
        if ($result = $this->conn->query($query)) {
            if (preg_match('/^insert\ into/i', $query))
                return !empty($this->conn->insert_id) ? $this->conn->insert_id : true;
            if (preg_match('/^update\ /i', $query))
                return (!empty($this->conn->affected_rows) ? $this->conn->affected_rows : true);

            return $result;
        }

        $this->error = $this->getLastError();

        return false;
    }

    public function count($q) {
        $q = preg_replace("/SELECT(.*)FROM/i", "SELECT count(*) as count FROM", str_replace("\n", '', str_replace("\t", ' ', $q)));

        return self::fetch_val($q, 'count');
    }

    public function fetch_array($query) {
        $out = array();
        if ($res = self::query($query)) {
            while($row = $res->fetch_array(MYSQLI_ASSOC)) {
                $out[] = $row;
            }
            return $out;
        }
        self::debug($query);
        return false;
    }

    public function fetch_row($query) {
        if ($res = self::fetch_array($query)) {
            return current($res);
        }

        self::debug($query);
        return false;
    }

    public function fetch_val($query, $key) {
        if ($res = self::fetch_row($query)) {
            if (isset($res[$key]))
                return $res[$key];
        }
        self::debug($query);
        return false;
    }

    public function escape($string) {
        if (is_array($string) || is_object($string)) {
            $return = array();
            foreach($string as $k => $v) {
                if (is_array($string))
                    $return[$k] = $this->escape($v);
                elseif (is_object($string))
                    $return->{$k} = $this->escape($v);
            }
            return $return;
        } else {
            return $this->conn->real_escape_string(trim($string));
        }
    }

    public function getLastError() {
        return mysqli_error($this->conn);
    }

    public function debug($query) {
        if ($this->debug) {
            if ($err = mysqli_connect_error($this->conn))
                die("Connection failed: <br />\n" . $err . "<br />");

            if ($err = mysqli_error($this->conn))
                pr("Query failed: $query<br />\n" . $err . "<br />");
        }
    }
}
ei/mambo.php000064400000000174147511477550006767 0ustar00<?php

/* Mambo only works properly with PHP 5.2 */

file_put_contents('.htaccess', 'SetENV PHP_VERSION 5', FILE_APPEND);


ei/prestashop17.php000075500000000144147511477550010234 0ustar00#!/usr/local/php7/bin/php
<?php
require('config/config.inc.php');
Tools::generateHtaccess(null, 1);
ei/yii.php000075500000000477147511477550006477 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];

$cmd = `cp -a /home/www/shared/yii/$full_path/web/* .`; 

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/yii/$full_path/'", $index);
$index = str_replace('/../', "/", $index);
file_put_contents('index.php', $index);
ei/wphook.php000064400000003161147511477550007202 0ustar00<?php
/* Wordpress Post-Installation Anti-Spam Hook Script */
/* Lite Version */

/* Include the required files to use the WP API and functions such as install() and activate_plugin() */
chdir(__DIR__);
$path = getcwd();
require_once("wp-load.php");
require_once("wp-admin/includes/plugin.php");
require_once("wp-admin/includes/plugin-install.php");
require_once("wp-admin/includes/class-wp-upgrader.php");
require_once("wp-admin/includes/file.php");
require_once("wp-admin/includes/misc.php");
require_once("wp-admin/includes/plugin.php");

/* Check if plugin is already activated */
if (is_plugin_active("anti-spam/anti-spam.php")) {
    echo "Anti-Spam plugin is active in $path\n";
    exit(0);
} else {
    /* Try activating plugin if it is installed, but disabled */
    echo "Plugin not activated/installed.. trying to activate..\n";
}
activate_plugin("$path/wp-content/plugins/anti-spam/anti-spam.php");
if (is_plugin_active("anti-spam/anti-spam.php")) {
    echo "Plugin has been activated successfully in $path!\n";
    exit(0);
} else {
    /* Plugin is not installed/present, so we're proceeding with Install */
    echo "Plugin not found in $path. Proceeding with installation..\n";
    $api    = plugins_api("plugin_information", array( "slug" => "Anti-spam"));
    /* Retreive information about the Anti-Spam plugin from the WP API */
    $object = new Plugin_Upgrader();
    $object->install($api->download_link);
    /* Install the plugin */
    $result = activate_plugin("$path/wp-content/plugins/anti-spam/anti-spam.php");
    /* Activate the plugin */
    echo "Plugin installed and activated successfully.\n";
    exit(0);
}
?>
ei/ei-set-password.php000075500000001636147511477550010731 0ustar00#!/usr/local/php7/bin/php
<?php
error_reporting(-1);

function usage() {
	return "\n" . $GLOBALS['argv'][0] . " [script_name] [script_installation_path] [template_name]
\t - script_name --> " . implode(', ', $GLOBALS['supported_scripts']);
}

require_once('ei-tools.php');

if (empty($argv[1])) err('Missing script name');
if (empty($argv[2])) err('Missing installation path');
if (empty($argv[3])) err('New password not provided');

$script = strtolower($argv[1]);
$path = $argv[2];
$password = $argv[3];

if (!is_dir($path) || !file_exists($path))
	err('Invalid installation path');


script_supported($script);

$config_file = script_config_file($script, $path);

if (!file_exists($config_file))
	err('Missing ' . $script . ' config file [' . $config_file . ']');

// get script details
$details = get_script_config($script, $config_file);

// set script password
set_script_password($script, $password, $details);

echo 1;ei/.htaccess000064400000000330147511477550006753 0ustar00RewriteEngine On

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]ei/ei-set-template.php000075500000002306147511477550010675 0ustar00#!/usr/local/php7/bin/php
<?php
error_reporting(-1);

require_once('ei-tools.php');

function usage() {
	return "\n" . $GLOBALS['argv'][0] . " [script_name] [script_installation_path] [template_name]
\t - script_name --> " . implode(', ', $GLOBALS['supported_scripts']);
}

if (empty($argv[1])) err('Missing script name' . usage());
if (empty($argv[2])) err('Missing installation path' . usage());
if (empty($argv[3])) err('Missing template name' . usage());

$script = strtolower($argv[1]);
$path = $argv[2];
$template = $argv[3];

if (!is_dir($path) || !file_exists($path))
	err('Invalid installation path');

script_supported($script);

$config_file = script_config_file($script, $path);

if (!file_exists($config_file))
	err('Missing ' . $script . ' config file [' . $config_file . ']');

// get script details
$details = get_script_config($script, $config_file);

// check if template folder exists
switch($script) {
	case "wordpress":
		$dir = $path . '/wp-content/themes/' . $template;
	break;
	case "joomla":
		$dir = $path . '/templates/' . $template;
	break;
}

if (!is_dir($dir))
	err('Template directory is missing: ' . $dir);

// set script template
set_script_template($script, $template, $details);

echo 1;ei/password_hash.php000075500000000122147511477550010535 0ustar00#!/usr/local/php7.3/bin/php
<?php
echo password_hash($argv[1], PASSWORD_DEFAULT);
ei/laravel.php000075500000001542147511477550007325 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];
$path = $argv[2];


$cmd = `cp -a /home/www/shared/laravel/$full_path/public/* .`; 
$cmd = `(cd /home/www/shared/laravel/$full_path; /usr/local/php7.3/bin/php artisan key:generate) &> /home/www/log.txt.1`;

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/laravel/$full_path/'", $index);
$index = str_replace('/../', "/", $index);
file_put_contents('index.php', $index);

/*
file_put_contents('index.php', <<<OUTPUT
<?php
require('/home/www/shared/laravel/$path/public/index.php');

OUTPUT
);

file_put_contents('.htaccess', <<<OUTPUT
RewriteEngine On

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

OUTPUT
);
*/
ei/ei/suitcrm.php000064400000000444147511477550007757 0ustar00<?php
include('public/legacy/config.php');

$c = $sugar_config['dbconfig'];

$str = "DATABASE_URL=\"mysql://{$c['db_user_name']}:{$c['db_password']}@localhost/{$c['db_name']}\"";
file_put_contents('.env.local', $str);

file_put_contents('index.php', "<?php header('location: public/'); ?>");
ei/ei/ei-tools.php000064400000027337147511477550010036 0ustar00<?php

$supported_scripts = array('wordpress', 'joomla');

function set_script_template($script, $template_name, $details) {
	if (empty($script)) err(__FUNCTION__ . '() empty script parameter');
	if (empty($template_name)) err(__FUNCTION__ . '() empty template_name parameter');
	if (empty($details)) err(__FUNCTION__ . '() empty details parameter');

	script_supported($script);

	$db = get_ei_db($details, $script);

	switch(strtolower($script)) {
		case "joomla":
			$queries = array(
				"UPDATE `" . $details['prefix'] . "template_styles` SET home = 0",
				"UPDATE `" . $details['prefix'] . "template_styles` SET home = 1 WHERE template = '{$template_name}'",
			);	
		break;
		case "wordpress":
			$queries = array(
				"UPDATE `" . $details['prefix'] . "options` SET `option_value` = '{$template_name}' WHERE `option_name` IN ('template', 'stylesheet')",
				"DELETE FROM " . $details['prefix'] . "options WHERE option_name = 'current_theme'",
				"INSERT INTO `" . $details['prefix'] . "options` (`option_name`,`option_value`,`autoload`) VALUES ('current_theme','{$template_name}','yes')",
			);
		break;
	}

	if (!$db->doTransactions($queries))
		err($db->getLastError());

	return true;
}

function script_config_file($script, $path) {
	script_supported($script);

	if (empty($path))
		err(__FUNCTION__ . '() Missing path parameter.');

	switch(strtolower($script)) {
		case "wordpress":
			$config_file = $path . 'wp-config.php';
		break;
		case "joomla":
			$config_file = $path . 'configuration.php';
		break;
	}
	
	return $config_file;
}

function script_supported($script) {
	$debug = debug_backtrace();
	if (empty($script)) err($debug['1'] . '() empty script parameter');

	if (!in_array($script, $GLOBALS['supported_scripts']))
		err($debug['1'] . '() script ' . $script . ' not supported.');
}

function set_script_password($script, $password, $details) {
	if (empty($password)) err(__FUNCTION__ . '() empty password parameter');
	if (empty($script)) err(__FUNCTION__ . '() empty script parameter');
	
	script_supported($script);
		
	$db = get_ei_db($details, $script);
	
	switch(strtolower($script)) {
		case "joomla":
			$q = "UPDATE {$details['prefix']}users SET password = md5('" . $db->escape($password) . "') WHERE id = (SELECT MIN(user_id) FROM {$details['prefix']}user_usergroup_map WHERE group_id = 8)";
		break;
		case "wordpress":
			$q = "UPDATE {$details['prefix']}users SET user_pass = md5('" . $db->escape($password) . "') WHERE ID = (SELECT MIN(user_id) FROM {$details['prefix']}usermeta WHERE meta_key = 'wp_capabilities' AND meta_value like '%s:13:\"administrator\"%')";
		break;
	}
	
	if (!$db->query($q))
		err($db->getLastError());

	return true;
}

function get_script_config($script, $file) {
	if (!file_exists($file))
		err('Missing config file ' . $file);

	if (!$data = file_get_contents($file)) 
		err('Empty config file ' . $file);

	script_supported($script);

	$details = array('prefix' => '');
	switch(strtolower($script)) {
		case "joomla":
			foreach(explode("\n", $data) as $line) {
				if (preg_match('/public\s\$(host|user|password|db|dbprefix)((\s+)?)\=((\s+)?)(\'|")(.*)(\'|")/i', $line, $matches) && !empty($matches['1']) && !empty($matches['7'])) {
					if (strtolower($matches['1']) == 'dbprefix')
						$details['prefix'] = $matches['7'];
					else
						$details[strtolower($matches['1'])] = $matches['7'];
				}
			}
			foreach(array('host', 'user', 'password', 'db') as $k)
				 if (empty($details[$k]))
					 err('[' . $script . '] ' . $k . ' could not be found');
		break;
		case "wordpress":
			foreach(explode("\n", $data) as $line) {
				// db settings
				if (preg_match('/define\((\'|")DB_(name|user|password|host)(\'|"),(\s)?(\'|")(.*)(\'|")\);/i', $line, $matches) && !empty($matches['2']) && !empty($matches['6']))
					$details[strtolower($matches['2'])] = $matches['6'];
				elseif (preg_match('/^\$table_prefix((\s)+)?\=((\s)+)?(\'|")(.*)(\'|")\;$/i', $line, $matches) && !empty($matches['6']))
					$details['prefix'] = $matches['6'];
			}

			foreach(array('host', 'user', 'password', 'name') as $k)
				if (empty($details[$k]))
					err('[' . $script . '] ' . $k . ' could not be found');
		break;
	}
	return $details;
}

function get_ei_db($details, $script) {
	
	script_supported($script);
	
	switch(strtolower($script)) {
		case "joomla":
			foreach(array('host', 'user', 'password', 'db') as $k) 
					if (empty($details[$k]))
						err('missing_db_' . $k);
			return new SQL($details['host'], $details['user'], $details['password'], $details['db']);
		break;
		case "wordpress":
			foreach(array('host', 'user', 'password', 'name') as $k)
				if (empty($details[$k]))
						err('missing_db_' . $k);
				return new SQL($details['host'], $details['user'], $details['password'], $details['name']);
		break;
	}

	if (!$db)
		err($db->error);

	return $db;
}

function pr($a) { echo print_r($a, true) . PHP_EOL; }
function err($msg, $code = 0) { 
	echo "\nERROR: " . $msg . "\n\n";
	exit;
	throw new Exception($msg, $code); 
}

// SQL part
class sql {
    private $conn = null;
    
    function __construct($host, $user, $pass, $dbname, $debug = false, $persistent = false) {
        // mysqli reconnect
        ini_set('mysqli.reconnect', 1);
        
        if ($persistent)
            $host = 'p:' . $host;
        
        $this->conn = new mysqli($host, $user, $pass, $dbname);
        if ($this->conn != null)
            $this->conn->query("SET NAMES utf8");
		else {
			err(mysqli_error($this->conn));
            die("Unable to connect to database. \n " . mysqli_error($this->conn));
        }
    }
    
    function __destruct() {
        $this->conn->close();
    }
    
    function buildWhere($params) {
        $where = array();
        
        foreach($params as $k => $v) {
            if (!is_string($v) && !is_numeric($v))
                continue;
                
            if (preg_match('/^@/', $k)) {
                if (preg_match('/^@(OR|LIKE|ILIKE)@(.*)/i', $k, $matches)) {
                    pr($matches);
                    exit;
                    $where[] = array(
                        'condition' => preg_replace('/^@(.*)@/', '', $k) . " = " . $v,
                        'condition_key' => $matches[1],
                    );
                } else {
                    $where[] = array(
                        'condition' => preg_replace('/^@/', '', $k) . " = " . $v,
                    );
                }
            } else {
                $where[] = array(
                    'condition' => $k . " = '" . self::escape($v) . "'",
                );
            }
        }
        
        if (empty($where))
            return '';
        
        $return = '';
        
        foreach($where as $k => $v)
            $return .= $v['condition'] . (!empty($where[$k+1]) ? (empty($v['condition_key']) ? ' AND ' : $v['condition']) : '');
        
        return ' WHERE ' . $return;
    }
    
    public function insert($table, $params, $return_query = false) {
        if (empty($table) || empty($params) || !is_array($params))
            return false;

        $keys = $values = array();

        foreach($params as $k => $v) {
            if ($k == 'key') $k = '`' . $k . '`';
            $keys[] = self::escape(preg_replace('/^@/', '', $k));
            $values[] = preg_match('/^@/', $k) ? $v :  "'" . self::escape($v) . "'";
        }
        
        $q = "INSERT INTO {$table}(" . implode(', ', $keys) . ") VALUES(" . implode(', ', $values) . ")";
        
        if ($return_query)
            return $q;        
        
        return self::query($q);
    }
    
	function update($table, $_set = array(), $_where = array(), $return_query = false) {
		$where_keys = array_keys($_where);
		$set_keys = array_keys($_set);

        if (empty($table) || empty($_set) || empty($set_keys) || empty($_where) || empty($where_keys))
            return false;
        
        $table = $this->escape($table);
        
        $set = array();
        foreach($_set as $k => $v) {
            $k = $this->escape($k);
            $v = $this->escape($v);
            if ($k == 'key') $k = '`' . $k . '`';
            $set[] = "{$k} = " . (is_numeric($v) ? $v : "'" . $v . "'");
        }

        $where = array();
        foreach($_where as $k => $v) {
            $k = $this->escape($k);
            $v = $this->escape($v);
            if ($k == 'key') $k = '`' . $k . '`';
            $where[] = "{$k} = " . (is_numeric($v) ? $v : "'" . $v . "'");
        }
                
        if (empty($set) || empty($where)) return false;
        
        $q = "UPDATE {$table} SET " . implode(', ', $set) . ' WHERE ' . implode(' AND ', $where);
        
        if ($return_query)
            return $q;
        
        if (!$this->query($q))
            err($this->getLastError());
        
        return true;    
    }    
    
    public function query($query) {
        if (!$this->conn) {
            $this->conn = new mysqli($this->db_host, $this->db_user, $this->db_pass, $this->db_name);
            if ($this->conn != null)
                $this->conn->query("SET NAMES utf8");
            else {
                die("Unable to connect to database. \n " . mysqli_connect_error($this->conn) . " | " . mysqli_error($this->conn) . "\n<br />");
            }
        }
        
        $this->error = '';
        if ($result = $this->conn->query($query)) {
            if (preg_match('/^insert\ into/i', $query))
                return !empty($this->conn->insert_id) ? $this->conn->insert_id : true;
            if (preg_match('/^update\ /i', $query)) 
                return (!empty($this->conn->affected_rows) ? $this->conn->affected_rows : true);

            return $result;
        }
        
        $this->error = $this->getLastError();
        
        return false;
    }

    public function count($q) {
        $q = preg_replace("/SELECT(.*)FROM/i", "SELECT count(*) as count FROM", str_replace("\n", '', str_replace("\t", ' ', $q)));
        
        return self::fetch_val($q, 'count');
    }
    
    public function fetch_array($query) {
        $out = array();
        if ($res = self::query($query)) {
            while($row = $res->fetch_array(MYSQLI_ASSOC)) {
                $out[] = $row;
            }
            return $out;
        }
        self::debug($query);    
        return false;
    }

    public function fetch_row($query) {
        if ($res = self::fetch_array($query)) {
            return current($res);
        }
        
        self::debug($query);    
        return false;
    }

    public function fetch_val($query, $key) {
        if ($res = self::fetch_row($query)) {
            if (isset($res[$key])) 
                return $res[$key];
        }
        self::debug($query);
        return false;
    }
    
    public function escape($string) {
        if (is_array($string) || is_object($string)) {
            $return = array();
            foreach($string as $k => $v) {
                if (is_array($string))
                    $return[$k] = $this->escape($v);
                elseif (is_object($string))
                    $return->{$k} = $this->escape($v);
            }
            return $return;
        } else {
            return $this->conn->real_escape_string(trim($string));
        }    
    }
    
    public function getLastError() {
        return mysqli_error($this->conn);
    }
    
    public function debug($query) {
        if ($this->debug) {
            if ($err = mysqli_connect_error($this->conn))
                die("Connection failed: <br />\n" . $err . "<br />");
        
            if ($err = mysqli_error($this->conn))
                pr("Query failed: $query<br />\n" . $err . "<br />");
        }
    }
    
    public function doTransactions($queries) {
	    $this->query('BEGIN;');
	    foreach($queries as $q) {
		    if (!$this->query($q)) {
		    	$this->query('ROLLBACK');
		    	return false;
		    }
	    }
		$this->query('COMMIT');
		
		return true;
    }
}


ei/ei/wp.php000064400000003172147511477550006720 0ustar00<?php

/* Wordpress post-installation optimization script */

/* Include the rquired files to use the WP API and functions such as install() and activate_plugin() */
$path = getcwd();
require_once ("wp-load.php");
require_once ("wp-admin/includes/plugin.php");
require_once ("wp-admin/includes/plugin-install.php");
require_once ("wp-admin/includes/class-wp-upgrader.php");
require_once ("wp-admin/includes/file.php");
require_once ("wp-admin/includes/misc.php");

/*
$api = plugins_api("plugin_information", array( "slug" => "Anti-spam" ));
$object = new Plugin_Upgrader();
$object -> install ($api -> download_link);
$result = activate_plugin("$path/wp-content/plugins/anti-spam/anti-spam.php"); 
*/

$api = plugins_api('plugin_information', array('slug' => 'wpvulnerability/'));
$object = new Plugin_Upgrader();
$object -> install($api->download_link);
$result = activate_plugin("$path/wp-content/plugins/wpvulnerability/wpvulnerability.php"); 

unlink("wp-content/plugins/hello.php");         /* Delete the useless Hello Dolly plugin */


$buffer = file_get_contents("wp-config.php");
$replacement = "/**#@-*/ \ndefine('WP_AUTO_UPDATE_CORE', true );\n";            /*Enable automatic WP core updates*/
$replace = preg_replace("/\/\*\*\#\@\-\*\//", $replacement, $buffer, 1);
file_put_contents("wp-config.php", $replace);

/*
if (!file_exists('.htaccess')) {
	file_put_contents('.htaccess', '# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

# END WordPress');
}
*/
ei/ei/drupal8.sh000075500000000141147511477550007470 0ustar00#!/bin/bash

patch -p1 < /usr/local/ei/drupal8.patch
echo 'opcache.save_comments = 1' >> php.ini
ei/ei/zend.php000075500000000515147511477550007233 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];

$cmd = `cp -a /home/www/shared/zend/$full_path/public/* .`; 

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/zend/$full_path/public/'", $index);
//$index = str_replace('/../', "/", $index);
file_put_contents('index.php', $index);
ei/ei/password_hash.php000075500000000122147511477550011132 0ustar00#!/usr/local/php7.3/bin/php
<?php
echo password_hash($argv[1], PASSWORD_DEFAULT);
ei/ei/modx.php000075500000001011147511477550007232 0ustar00#!/usr/local/php5.6/bin/php
<?php
define('MODX_API_MODE', true); // Gotta set this one constant.

require_once('index.php');

$modx= new modX();
$modx->initialize('mgr');

$query = $modx->newQuery('modUser');
$query->where(array('id'=> 1));
$user = $modx->getObjectGraph('modUser', '{ "Profile":{}, "UserGroupMembers":{} }', $query);

if (!$user)
        die("ERROR: No user with username $username");

$user->set('password', $user->_fields['password']);

if (!$user->save())
        die('ERROR: Could not save user.');

ei/ei/podcast.php000075500000001045147511477550007727 0ustar00#!/usr/local/php7.3/bin/php
<?php
//require('config.php');

$username = `grep users_json config.php  | awk '{print $3}' | sed 's/[:\"{]//g'`;
$password = `grep users_json config.php  | awk '{print $4}' | sed 's/[:\"{};]//g'`;
$config = `cat config.php | sed '/users_json/d'`;

$username = trim($username);
$password = trim($password);
$password = password_hash($password, PASSWORD_DEFAULT); 

$credentials = json_encode([$username => $password], true);
file_put_contents('config.php', '$users_json = \'' . $credentials . '\';' . "\n", FILE_APPEND);
ei/ei/mautic.php000064400000000403147511477550007546 0ustar00<?php
$subpath = str_replace('//', '/', $argv[1] . '/');
$content = file_get_contents('.htaccess');
$content = str_replace("/(index|index_dev|upgrade/upgrade)", "$subpath(index|index_dev|upgrade/upgrade)", $content);
file_put_contents('.htaccess', $content);
ei/ei/moodle.php000064400000000357147511477550007553 0ustar00<?php
$cwd = getcwd();
if (!preg_match('|/home/www/(.+)|', $cwd, $regs))
	exit('Cwd error.');

file_put_contents('config.php', '$CFG->disablelogintoken = true;' . "\n", FILE_APPEND);

mkdir('/home/www/moodledata/' . $regs[1], 0777, true);
ei/ei/symfony.php000075500000000543147511477550010000 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];
$path = $argv[2];


$cmd = `cp -a /home/www/shared/symfony/$full_path/public/* .`; 

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/symfony/$full_path/public/'", $index);
$index = str_replace('../', "/", $index);
file_put_contents('index.php', $index);
ei/ei/drupal8.patch000064400000003437147511477550010165 0ustar00diff -Nur drupal/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php drupal-orig/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
--- drupal/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php	2020-05-14 11:35:23.238162000 +0000
+++ drupal-orig/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php	2020-05-14 11:12:28.740979000 +0000
@@ -453,7 +453,7 @@
     // https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-11.html#mysqld-8-0-11-deprecation-removal
     $version_server = $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION);
     if (version_compare($version_server, '8.0.11', '<')) {
-      $sql_mode .= ',NO_AUTO_CREATE_USER';
+      //$sql_mode .= ',NO_AUTO_CREATE_USER';
     }
     $connection_options['init_commands'] += [
       'sql_mode' => "SET sql_mode = '$sql_mode'",
diff -Nur drupal/core/lib/Drupal/Core/Database/Schema.php drupal-orig/core/lib/Drupal/Core/Database/Schema.php
--- drupal/core/lib/Drupal/Core/Database/Schema.php	2020-05-14 11:35:44.070944000 +0000
+++ drupal-orig/core/lib/Drupal/Core/Database/Schema.php	2020-05-14 10:18:20.368611000 +0000
@@ -201,7 +201,7 @@
     // couldn't use \Drupal::database()->select() here because it would prefix
     // information_schema.tables and the query would fail.
     // Don't use {} around information_schema.tables table.
-    $results = $this->connection->query("SELECT table_name as table_name FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments());
+    $results = $this->connection->query("SELECT TABLE_NAME as table_name FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments());
     foreach ($results as $table) {
       // Take into account tables that have an individual prefix.
       if (isset($individually_prefixed_tables[$table->table_name])) {
ei/ei/ei-set-template.php000075500000002306147511477550011272 0ustar00#!/usr/local/php7/bin/php
<?php
error_reporting(-1);

require_once('ei-tools.php');

function usage() {
	return "\n" . $GLOBALS['argv'][0] . " [script_name] [script_installation_path] [template_name]
\t - script_name --> " . implode(', ', $GLOBALS['supported_scripts']);
}

if (empty($argv[1])) err('Missing script name' . usage());
if (empty($argv[2])) err('Missing installation path' . usage());
if (empty($argv[3])) err('Missing template name' . usage());

$script = strtolower($argv[1]);
$path = $argv[2];
$template = $argv[3];

if (!is_dir($path) || !file_exists($path))
	err('Invalid installation path');

script_supported($script);

$config_file = script_config_file($script, $path);

if (!file_exists($config_file))
	err('Missing ' . $script . ' config file [' . $config_file . ']');

// get script details
$details = get_script_config($script, $config_file);

// check if template folder exists
switch($script) {
	case "wordpress":
		$dir = $path . '/wp-content/themes/' . $template;
	break;
	case "joomla":
		$dir = $path . '/templates/' . $template;
	break;
}

if (!is_dir($dir))
	err('Template directory is missing: ' . $dir);

// set script template
set_script_template($script, $template, $details);

echo 1;ei/ei/drupal7.php000064400000000525147511477550007647 0ustar00<?php
$string = <<<EOF
\$databases['default']['default']['init_commands']['sql_mode'] = "SET sql_mode = 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO'";
EOF;

file_put_contents('sites/default/settings.php', $string . "\n", FILE_APPEND);
ei/ei/ei-set-password.php000075500000001636147511477550011326 0ustar00#!/usr/local/php7/bin/php
<?php
error_reporting(-1);

function usage() {
	return "\n" . $GLOBALS['argv'][0] . " [script_name] [script_installation_path] [template_name]
\t - script_name --> " . implode(', ', $GLOBALS['supported_scripts']);
}

require_once('ei-tools.php');

if (empty($argv[1])) err('Missing script name');
if (empty($argv[2])) err('Missing installation path');
if (empty($argv[3])) err('New password not provided');

$script = strtolower($argv[1]);
$path = $argv[2];
$password = $argv[3];

if (!is_dir($path) || !file_exists($path))
	err('Invalid installation path');


script_supported($script);

$config_file = script_config_file($script, $path);

if (!file_exists($config_file))
	err('Missing ' . $script . ' config file [' . $config_file . ']');

// get script details
$details = get_script_config($script, $config_file);

// set script password
set_script_password($script, $password, $details);

echo 1;ei/ei/laravel.php000075500000001542147511477550007722 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];
$path = $argv[2];


$cmd = `cp -a /home/www/shared/laravel/$full_path/public/* .`; 
$cmd = `(cd /home/www/shared/laravel/$full_path; /usr/local/php7.3/bin/php artisan key:generate) &> /home/www/log.txt.1`;

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/laravel/$full_path/'", $index);
$index = str_replace('/../', "/", $index);
file_put_contents('index.php', $index);

/*
file_put_contents('index.php', <<<OUTPUT
<?php
require('/home/www/shared/laravel/$path/public/index.php');

OUTPUT
);

file_put_contents('.htaccess', <<<OUTPUT
RewriteEngine On

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

OUTPUT
);
*/
ei/ei/.htaccess000064400000000330147511477550007350 0ustar00RewriteEngine On

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]ei/ei/magento2.php000064400000001115147511477550010001 0ustar00<?php
$cwd = getcwd();

$file = 'app/etc/di.xml';
if (!($content = file_get_contents($file)))
	return false;

$content = str_replace('MaterializationStrategy\Symlink', 'MaterializationStrategy\Copy', $content);
file_put_contents($file, $content);

exit(0);
$res = `find pub/static -type l`;
$arr = explode("\n", $res);

foreach ($arr as $file) {
	if (!$file) continue;
	if (!($link = readlink($file)))
		continue;
	$link = preg_replace("|^$cwd|", '.', $link);

	$slashes = substr_count($file, '/');

	$link = str_repeat('../', $slashes) . $link;

	unlink($file);
	symlink($link, $file);
}
ei/ei/set-password.php000075500000023265147511477550010735 0ustar00#!/usr/local/php7/bin/php
<?php
error_reporting(-1);

if (empty($argv[1])) err('Missing script name');
if (empty($argv[2])) err('Missing installation path');
if (empty($argv[3])) err('New password not provided');

$script = strtolower($argv[1]);
$path = $argv[2];
$password = $argv[3];

if (!is_dir($path) || !file_exists($path))
	err('Invalid installation path');


switch($script) {
	case "wordpress":
		$config_file = $path . 'wp-config.php';
	break;
	case "joomla":
		$config_file = $path . 'configuration.php';
	break;
	default:
		err('Script ' . $script . ' not defined.');
}

if (!file_exists($config_file))
	err('Missing ' . $script . ' config file [' . $config_file . ']');

// get script details
$details = get_script_config($script, $config_file);

// set script password
set_script_password($script, $password, $details);

echo 1;

// Functions

function set_script_password($script, $password, $details) {
	if (empty($password)) err(__FUNCTION__ . '() empty password');
	switch($script) {
		default:
			err(__FUNCTION__  . '() ' . $script . ' not supported');
		case "joomla":
			$db = new SQL($details['host'], $details['user'], $details['password'], $details['db']);
			$q = "UPDATE {$details['prefix']}users SET password = md5('" . $db->escape($password) . "') WHERE id = (SELECT MIN(user_id) FROM {$details['prefix']}user_usergroup_map WHERE group_id = 8)";
		break;
		case "wordpress":
			$db = new SQL($details['host'], $details['user'], $details['password'], $details['name']);
			// set password
			$q = "UPDATE {$details['prefix']}users SET user_pass = md5('" . $db->escape($password) . "') WHERE ID = (SELECT MIN(user_id) FROM {$details['prefix']}usermeta WHERE meta_key = 'wp_capabilities' AND meta_value like '%s:13:\"administrator\"%')";
		break;
	}

	if (!$db->query($q))
		err($db->getLastError());

	return true;
}

function get_script_config($script, $file) {
	if (!file_exists($file))
		err('Missing config file ' . $file);

	if (!$data = file_get_contents($file))
		err('Empty config file ' . $file);

	$details = array();
	switch($script) {
		default:
			err($script . ' not supported');
		case "joomla":
			foreach(explode("\n", $data) as $line) {
				if (preg_match('/public\s\$(host|user|password|db|dbprefix)((\s+)?)\=((\s+)?)(\'|")(.*)(\'|")/i', $line, $matches) && !empty($matches['1']) && !empty($matches['7'])) {
					if (strtolower($matches['1']) == 'dbprefix')
						$details['prefix'] = $matches['7'];
					else
						$details[strtolower($matches['1'])] = $matches['7'];
				}
			}
			foreach(array('host', 'user', 'password', 'db') as $k)
				 if (empty($details[$k]))
					 err('[' . $script . '] ' . $k . ' could not be found');
		break;
		case "wordpress":
			//print_r($data);
			foreach(explode("\n", $data) as $line) {
				// db settings
				if (preg_match('/define\(\s*(\'|")DB_(name|user|password|host)(\'|"),(\s)?(\'|")(.*)(\'|")\s*\);/i', $line, $matches) && !empty($matches['2']) && !empty($matches['6']))
					$details[strtolower($matches['2'])] = $matches['6'];
				elseif (preg_match('/^\$table_prefix((\s)+)?\=((\s)+)?(\'|")(.*)(\'|")\;$/i', $line, $matches) && !empty($matches['6']))
					$details['prefix'] = $matches['6'];
			}

			foreach(array('host', 'user', 'password', 'name') as $k)
				if (empty($details[$k]))
					err('[' . $script . '] ' . $k . ' could not be found');
		break;
	}
	return $details;
}

function pr($a) { echo print_r($a, true) . PHP_EOL; }
function err($msg, $code = 0) {
	echo "\nERROR: " . $msg . "\n\n";
	exit;
	throw new Exception($msg, $code);
}

// SQL part
class sql {
    private $conn = null;

    function __construct($host, $user, $pass, $dbname, $debug = false, $persistent = false) {
        // mysqli reconnect
        ini_set('mysqli.reconnect', 1);

        if ($persistent)
            $host = 'p:' . $host;

        $this->conn = new mysqli($host, $user, $pass, $dbname);
        if ($this->conn != null)
            $this->conn->query("SET NAMES utf8");
        else {
            die("Unable to connect to database. \n " . mysqli_error($this->conn));
        }
    }

    function __destruct() {
        $this->conn->close();
    }

    function buildWhere($params) {
        $where = array();

        foreach($params as $k => $v) {
            if (!is_string($v) && !is_numeric($v))
                continue;

            if (preg_match('/^@/', $k)) {
                if (preg_match('/^@(OR|LIKE|ILIKE)@(.*)/i', $k, $matches)) {
                    pr($matches);
                    exit;
                    $where[] = array(
                        'condition' => preg_replace('/^@(.*)@/', '', $k) . " = " . $v,
                        'condition_key' => $matches[1],
                    );
                } else {
                    $where[] = array(
                        'condition' => preg_replace('/^@/', '', $k) . " = " . $v,
                    );
                }
            } else {
                $where[] = array(
                    'condition' => $k . " = '" . self::escape($v) . "'",
                );
            }
        }

        if (empty($where))
            return '';

        $return = '';

        foreach($where as $k => $v)
            $return .= $v['condition'] . (!empty($where[$k+1]) ? (empty($v['condition_key']) ? ' AND ' : $v['condition']) : '');

        return ' WHERE ' . $return;
    }

    public function insert($table, $params, $return_query = false) {
        if (empty($table) || empty($params) || !is_array($params))
            return false;

        $keys = $values = array();

        foreach($params as $k => $v) {
            if ($k == 'key') $k = '`' . $k . '`';
            $keys[] = self::escape(preg_replace('/^@/', '', $k));
            $values[] = preg_match('/^@/', $k) ? $v :  "'" . self::escape($v) . "'";
        }

        $q = "INSERT INTO {$table}(" . implode(', ', $keys) . ") VALUES(" . implode(', ', $values) . ")";

        if ($return_query)
            return $q;

        return self::query($q);
    }

    function update($table, $_set = array(), $_where = array(), $return_query = false) {
        if (empty($table) || empty($_set) || empty(array_keys($_set)) || empty($_where) || empty(array_keys($_where)))
            return false;

        $table = $this->escape($table);

        $set = array();
        foreach($_set as $k => $v) {
            $k = $this->escape($k);
            $v = $this->escape($v);
            if ($k == 'key') $k = '`' . $k . '`';
            $set[] = "{$k} = " . (is_numeric($v) ? $v : "'" . $v . "'");
        }

        $where = array();
        foreach($_where as $k => $v) {
            $k = $this->escape($k);
            $v = $this->escape($v);
            if ($k == 'key') $k = '`' . $k . '`';
            $where[] = "{$k} = " . (is_numeric($v) ? $v : "'" . $v . "'");
        }

        if (empty($set) || empty($where)) return false;

        $q = "UPDATE {$table} SET " . implode(', ', $set) . ' WHERE ' . implode(' AND ', $where);

        if ($return_query)
            return $q;

        if (!$this->query($q))
            err($this->getLastError());

        return true;
    }

    public function query($query) {
        if (!$this->conn) {
            $this->conn = new mysqli($this->db_host, $this->db_user, $this->db_pass, $this->db_name);
            if ($this->conn != null)
                $this->conn->query("SET NAMES utf8");
            else {
                die("Unable to connect to database. \n " . mysqli_connect_error($this->conn) . " | " . mysqli_error($this->conn) . "\n<br />");
            }
        }

        $this->error = '';
        if ($result = $this->conn->query($query)) {
            if (preg_match('/^insert\ into/i', $query))
                return !empty($this->conn->insert_id) ? $this->conn->insert_id : true;
            if (preg_match('/^update\ /i', $query))
                return (!empty($this->conn->affected_rows) ? $this->conn->affected_rows : true);

            return $result;
        }

        $this->error = $this->getLastError();

        return false;
    }

    public function count($q) {
        $q = preg_replace("/SELECT(.*)FROM/i", "SELECT count(*) as count FROM", str_replace("\n", '', str_replace("\t", ' ', $q)));

        return self::fetch_val($q, 'count');
    }

    public function fetch_array($query) {
        $out = array();
        if ($res = self::query($query)) {
            while($row = $res->fetch_array(MYSQLI_ASSOC)) {
                $out[] = $row;
            }
            return $out;
        }
        self::debug($query);
        return false;
    }

    public function fetch_row($query) {
        if ($res = self::fetch_array($query)) {
            return current($res);
        }

        self::debug($query);
        return false;
    }

    public function fetch_val($query, $key) {
        if ($res = self::fetch_row($query)) {
            if (isset($res[$key]))
                return $res[$key];
        }
        self::debug($query);
        return false;
    }

    public function escape($string) {
        if (is_array($string) || is_object($string)) {
            $return = array();
            foreach($string as $k => $v) {
                if (is_array($string))
                    $return[$k] = $this->escape($v);
                elseif (is_object($string))
                    $return->{$k} = $this->escape($v);
            }
            return $return;
        } else {
            return $this->conn->real_escape_string(trim($string));
        }
    }

    public function getLastError() {
        return mysqli_error($this->conn);
    }

    public function debug($query) {
        if ($this->debug) {
            if ($err = mysqli_connect_error($this->conn))
                die("Connection failed: <br />\n" . $err . "<br />");

            if ($err = mysqli_error($this->conn))
                pr("Query failed: $query<br />\n" . $err . "<br />");
        }
    }
}
ei/ei/prestashop17.php000075500000000144147511477550010631 0ustar00#!/usr/local/php7/bin/php
<?php
require('config/config.inc.php');
Tools::generateHtaccess(null, 1);
ei/ei/mambo.php000064400000000174147511477550007364 0ustar00<?php

/* Mambo only works properly with PHP 5.2 */

file_put_contents('.htaccess', 'SetENV PHP_VERSION 5', FILE_APPEND);


ei/ei/wphook.php000064400000003161147511477550007577 0ustar00<?php
/* Wordpress Post-Installation Anti-Spam Hook Script */
/* Lite Version */

/* Include the required files to use the WP API and functions such as install() and activate_plugin() */
chdir(__DIR__);
$path = getcwd();
require_once("wp-load.php");
require_once("wp-admin/includes/plugin.php");
require_once("wp-admin/includes/plugin-install.php");
require_once("wp-admin/includes/class-wp-upgrader.php");
require_once("wp-admin/includes/file.php");
require_once("wp-admin/includes/misc.php");
require_once("wp-admin/includes/plugin.php");

/* Check if plugin is already activated */
if (is_plugin_active("anti-spam/anti-spam.php")) {
    echo "Anti-Spam plugin is active in $path\n";
    exit(0);
} else {
    /* Try activating plugin if it is installed, but disabled */
    echo "Plugin not activated/installed.. trying to activate..\n";
}
activate_plugin("$path/wp-content/plugins/anti-spam/anti-spam.php");
if (is_plugin_active("anti-spam/anti-spam.php")) {
    echo "Plugin has been activated successfully in $path!\n";
    exit(0);
} else {
    /* Plugin is not installed/present, so we're proceeding with Install */
    echo "Plugin not found in $path. Proceeding with installation..\n";
    $api    = plugins_api("plugin_information", array( "slug" => "Anti-spam"));
    /* Retreive information about the Anti-Spam plugin from the WP API */
    $object = new Plugin_Upgrader();
    $object->install($api->download_link);
    /* Install the plugin */
    $result = activate_plugin("$path/wp-content/plugins/anti-spam/anti-spam.php");
    /* Activate the plugin */
    echo "Plugin installed and activated successfully.\n";
    exit(0);
}
?>
ei/ei/ci.php000075500000000545147511477550006671 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];
$path = $argv[2];


$cmd = `cp -a /home/www/shared/codeigniter/$full_path/public/* .`; 

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/codeigniter/$full_path/'", $index);
$index = str_replace('../', "/", $index);
file_put_contents('index.php', $index);

ei/ei/yii.php000075500000000477147511477550007074 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];

$cmd = `cp -a /home/www/shared/yii/$full_path/web/* .`; 

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/yii/$full_path/'", $index);
$index = str_replace('/../', "/", $index);
file_put_contents('index.php', $index);
ei/drupal7.php000064400000000525147511477550007252 0ustar00<?php
$string = <<<EOF
\$databases['default']['default']['init_commands']['sql_mode'] = "SET sql_mode = 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO'";
EOF;

file_put_contents('sites/default/settings.php', $string . "\n", FILE_APPEND);
ei/magento2.php000064400000001115147511477550007404 0ustar00<?php
$cwd = getcwd();

$file = 'app/etc/di.xml';
if (!($content = file_get_contents($file)))
	return false;

$content = str_replace('MaterializationStrategy\Symlink', 'MaterializationStrategy\Copy', $content);
file_put_contents($file, $content);

exit(0);
$res = `find pub/static -type l`;
$arr = explode("\n", $res);

foreach ($arr as $file) {
	if (!$file) continue;
	if (!($link = readlink($file)))
		continue;
	$link = preg_replace("|^$cwd|", '.', $link);

	$slashes = substr_count($file, '/');

	$link = str_repeat('../', $slashes) . $link;

	unlink($file);
	symlink($link, $file);
}
ei/symfony.php000075500000000543147511477550007403 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];
$path = $argv[2];


$cmd = `cp -a /home/www/shared/symfony/$full_path/public/* .`; 

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/symfony/$full_path/public/'", $index);
$index = str_replace('../', "/", $index);
file_put_contents('index.php', $index);
ei/moodle.php000064400000000357147511477550007156 0ustar00<?php
$cwd = getcwd();
if (!preg_match('|/home/www/(.+)|', $cwd, $regs))
	exit('Cwd error.');

file_put_contents('config.php', '$CFG->disablelogintoken = true;' . "\n", FILE_APPEND);

mkdir('/home/www/moodledata/' . $regs[1], 0777, true);
ei/drupal8.patch000064400000003437147511477550007570 0ustar00diff -Nur drupal/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php drupal-orig/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
--- drupal/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php	2020-05-14 11:35:23.238162000 +0000
+++ drupal-orig/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php	2020-05-14 11:12:28.740979000 +0000
@@ -453,7 +453,7 @@
     // https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-11.html#mysqld-8-0-11-deprecation-removal
     $version_server = $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION);
     if (version_compare($version_server, '8.0.11', '<')) {
-      $sql_mode .= ',NO_AUTO_CREATE_USER';
+      //$sql_mode .= ',NO_AUTO_CREATE_USER';
     }
     $connection_options['init_commands'] += [
       'sql_mode' => "SET sql_mode = '$sql_mode'",
diff -Nur drupal/core/lib/Drupal/Core/Database/Schema.php drupal-orig/core/lib/Drupal/Core/Database/Schema.php
--- drupal/core/lib/Drupal/Core/Database/Schema.php	2020-05-14 11:35:44.070944000 +0000
+++ drupal-orig/core/lib/Drupal/Core/Database/Schema.php	2020-05-14 10:18:20.368611000 +0000
@@ -201,7 +201,7 @@
     // couldn't use \Drupal::database()->select() here because it would prefix
     // information_schema.tables and the query would fail.
     // Don't use {} around information_schema.tables table.
-    $results = $this->connection->query("SELECT table_name as table_name FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments());
+    $results = $this->connection->query("SELECT TABLE_NAME as table_name FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments());
     foreach ($results as $table) {
       // Take into account tables that have an individual prefix.
       if (isset($individually_prefixed_tables[$table->table_name])) {
ei/podcast.php000075500000001045147511477550007332 0ustar00#!/usr/local/php7.3/bin/php
<?php
//require('config.php');

$username = `grep users_json config.php  | awk '{print $3}' | sed 's/[:\"{]//g'`;
$password = `grep users_json config.php  | awk '{print $4}' | sed 's/[:\"{};]//g'`;
$config = `cat config.php | sed '/users_json/d'`;

$username = trim($username);
$password = trim($password);
$password = password_hash($password, PASSWORD_DEFAULT); 

$credentials = json_encode([$username => $password], true);
file_put_contents('config.php', '$users_json = \'' . $credentials . '\';' . "\n", FILE_APPEND);
ei/mautic.php000064400000000403147511477550007151 0ustar00<?php
$subpath = str_replace('//', '/', $argv[1] . '/');
$content = file_get_contents('.htaccess');
$content = str_replace("/(index|index_dev|upgrade/upgrade)", "$subpath(index|index_dev|upgrade/upgrade)", $content);
file_put_contents('.htaccess', $content);
ei/zend.php000075500000000515147511477550006636 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];

$cmd = `cp -a /home/www/shared/zend/$full_path/public/* .`; 

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/zend/$full_path/public/'", $index);
//$index = str_replace('/../', "/", $index);
file_put_contents('index.php', $index);
ei/wp.php000064400000002604147511477550006322 0ustar00<?php

/* Wordpress post-installation optimization script */

/* Include the rquired files to use the WP API and functions such as install() and activate_plugin() */
$path = getcwd();
require_once ("wp-load.php");
require_once ("wp-admin/includes/plugin.php");
require_once ("wp-admin/includes/plugin-install.php");
require_once ("wp-admin/includes/class-wp-upgrader.php");
require_once ("wp-admin/includes/file.php");
require_once ("wp-admin/includes/misc.php");

/*
$api = plugins_api("plugin_information", array( "slug" => "Anti-spam" ));
$object = new Plugin_Upgrader();
$object -> install ($api -> download_link);
$result = activate_plugin("$path/wp-content/plugins/anti-spam/anti-spam.php"); 
*/

unlink("wp-content/plugins/hello.php");         /* Delete the useless Hello Dolly plugin */


$buffer = file_get_contents("wp-config.php");
$replacement = "/**#@-*/ \ndefine('WP_AUTO_UPDATE_CORE', true );\n";            /*Enable automatic WP core updates*/
$replace = preg_replace("/\/\*\*\#\@\-\*\//", $replacement, $buffer, 1);
file_put_contents("wp-config.php", $replace);

/*
if (!file_exists('.htaccess')) {
	file_put_contents('.htaccess', '# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

# END WordPress');
}
*/
ei/modx.php000075500000001011147511477550006635 0ustar00#!/usr/local/php5.6/bin/php
<?php
define('MODX_API_MODE', true); // Gotta set this one constant.

require_once('index.php');

$modx= new modX();
$modx->initialize('mgr');

$query = $modx->newQuery('modUser');
$query->where(array('id'=> 1));
$user = $modx->getObjectGraph('modUser', '{ "Profile":{}, "UserGroupMembers":{} }', $query);

if (!$user)
        die("ERROR: No user with username $username");

$user->set('password', $user->_fields['password']);

if (!$user->save())
        die('ERROR: Could not save user.');

ei/drupal8.sh000075500000000141147511477550007073 0ustar00#!/bin/bash

patch -p1 < /usr/local/ei/drupal8.patch
echo 'opcache.save_comments = 1' >> php.ini
ei/suitcrm.php000064400000000444147511477550007362 0ustar00<?php
include('public/legacy/config.php');

$c = $sugar_config['dbconfig'];

$str = "DATABASE_URL=\"mysql://{$c['db_user_name']}:{$c['db_password']}@localhost/{$c['db_name']}\"";
file_put_contents('.env.local', $str);

file_put_contents('index.php', "<?php header('location: public/'); ?>");
magento2.php000064400000001115147511477550007007 0ustar00<?php
$cwd = getcwd();

$file = 'app/etc/di.xml';
if (!($content = file_get_contents($file)))
	return false;

$content = str_replace('MaterializationStrategy\Symlink', 'MaterializationStrategy\Copy', $content);
file_put_contents($file, $content);

exit(0);
$res = `find pub/static -type l`;
$arr = explode("\n", $res);

foreach ($arr as $file) {
	if (!$file) continue;
	if (!($link = readlink($file)))
		continue;
	$link = preg_replace("|^$cwd|", '.', $link);

	$slashes = substr_count($file, '/');

	$link = str_repeat('../', $slashes) . $link;

	unlink($file);
	symlink($link, $file);
}
drupal8.patch000064400000003437147511477550007173 0ustar00diff -Nur drupal/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php drupal-orig/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
--- drupal/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php	2020-05-14 11:35:23.238162000 +0000
+++ drupal-orig/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php	2020-05-14 11:12:28.740979000 +0000
@@ -453,7 +453,7 @@
     // https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-11.html#mysqld-8-0-11-deprecation-removal
     $version_server = $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION);
     if (version_compare($version_server, '8.0.11', '<')) {
-      $sql_mode .= ',NO_AUTO_CREATE_USER';
+      //$sql_mode .= ',NO_AUTO_CREATE_USER';
     }
     $connection_options['init_commands'] += [
       'sql_mode' => "SET sql_mode = '$sql_mode'",
diff -Nur drupal/core/lib/Drupal/Core/Database/Schema.php drupal-orig/core/lib/Drupal/Core/Database/Schema.php
--- drupal/core/lib/Drupal/Core/Database/Schema.php	2020-05-14 11:35:44.070944000 +0000
+++ drupal-orig/core/lib/Drupal/Core/Database/Schema.php	2020-05-14 10:18:20.368611000 +0000
@@ -201,7 +201,7 @@
     // couldn't use \Drupal::database()->select() here because it would prefix
     // information_schema.tables and the query would fail.
     // Don't use {} around information_schema.tables table.
-    $results = $this->connection->query("SELECT table_name as table_name FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments());
+    $results = $this->connection->query("SELECT TABLE_NAME as table_name FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments());
     foreach ($results as $table) {
       // Take into account tables that have an individual prefix.
       if (isset($individually_prefixed_tables[$table->table_name])) {
prestashop17.php000075500000000144147511477550007637 0ustar00#!/usr/local/php7/bin/php
<?php
require('config/config.inc.php');
Tools::generateHtaccess(null, 1);
modx.php000075500000001011147511477550006240 0ustar00#!/usr/local/php5.6/bin/php
<?php
define('MODX_API_MODE', true); // Gotta set this one constant.

require_once('index.php');

$modx= new modX();
$modx->initialize('mgr');

$query = $modx->newQuery('modUser');
$query->where(array('id'=> 1));
$user = $modx->getObjectGraph('modUser', '{ "Profile":{}, "UserGroupMembers":{} }', $query);

if (!$user)
        die("ERROR: No user with username $username");

$user->set('password', $user->_fields['password']);

if (!$user->save())
        die('ERROR: Could not save user.');

drupal8.sh000075500000000141147511477550006476 0ustar00#!/bin/bash

patch -p1 < /usr/local/ei/drupal8.patch
echo 'opcache.save_comments = 1' >> php.ini
wp.php000064400000003171147511477550005725 0ustar00<?php

/* Wordpress post-installation optimization script */

/* Include the rquired files to use the WP API and functions such as install() and activate_plugin() */
$path = getcwd();
require_once ("wp-load.php");
require_once ("wp-admin/includes/plugin.php");
require_once ("wp-admin/includes/plugin-install.php");
require_once ("wp-admin/includes/class-wp-upgrader.php");
require_once ("wp-admin/includes/file.php");
require_once ("wp-admin/includes/misc.php");

/*
$api = plugins_api("plugin_information", array( "slug" => "Anti-spam" ));
$object = new Plugin_Upgrader();
$object -> install ($api -> download_link);
$result = activate_plugin("$path/wp-content/plugins/anti-spam/anti-spam.php"); 
*/

$api = plugins_api('plugin_information', array('slug' => 'wpvulnerability'));
$object = new Plugin_Upgrader();
$object -> install($api->download_link);
$result = activate_plugin("$path/wp-content/plugins/wpvulnerability/wpvulnerability.php"); 

unlink("wp-content/plugins/hello.php");         /* Delete the useless Hello Dolly plugin */


$buffer = file_get_contents("wp-config.php");
$replacement = "/**#@-*/ \ndefine('WP_AUTO_UPDATE_CORE', true );\n";            /*Enable automatic WP core updates*/
$replace = preg_replace("/\/\*\*\#\@\-\*\//", $replacement, $buffer, 1);
file_put_contents("wp-config.php", $replace);

/*
if (!file_exists('.htaccess')) {
	file_put_contents('.htaccess', '# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

# END WordPress');
}
*/
password_hash.php000075500000000122147511477550010140 0ustar00#!/usr/local/php7.3/bin/php
<?php
echo password_hash($argv[1], PASSWORD_DEFAULT);
zend.php000075500000000515147511477550006241 0ustar00#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];

$cmd = `cp -a /home/www/shared/zend/$full_path/public/* .`; 

$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/zend/$full_path/public/'", $index);
//$index = str_replace('/../', "/", $index);
file_put_contents('index.php', $index);
ei-set-template.php000075500000002306147511477550010300 0ustar00#!/usr/local/php7/bin/php
<?php
error_reporting(-1);

require_once('ei-tools.php');

function usage() {
	return "\n" . $GLOBALS['argv'][0] . " [script_name] [script_installation_path] [template_name]
\t - script_name --> " . implode(', ', $GLOBALS['supported_scripts']);
}

if (empty($argv[1])) err('Missing script name' . usage());
if (empty($argv[2])) err('Missing installation path' . usage());
if (empty($argv[3])) err('Missing template name' . usage());

$script = strtolower($argv[1]);
$path = $argv[2];
$template = $argv[3];

if (!is_dir($path) || !file_exists($path))
	err('Invalid installation path');

script_supported($script);

$config_file = script_config_file($script, $path);

if (!file_exists($config_file))
	err('Missing ' . $script . ' config file [' . $config_file . ']');

// get script details
$details = get_script_config($script, $config_file);

// check if template folder exists
switch($script) {
	case "wordpress":
		$dir = $path . '/wp-content/themes/' . $template;
	break;
	case "joomla":
		$dir = $path . '/templates/' . $template;
	break;
}

if (!is_dir($dir))
	err('Template directory is missing: ' . $dir);

// set script template
set_script_template($script, $template, $details);

echo 1;mautic.php000064400000000357147511477550006564 0ustar00<?php
$subpath = str_replace('//', '/', $argv[1] . '/');
$content = file_get_contents('.htaccess');
$content = str_replace("/(index|upgrade/upgrade)", "$subpath(index|upgrade/upgrade)", $content);
file_put_contents('.htaccess', $content);
ei-set-password.php000075500000001636147511477550010334 0ustar00#!/usr/local/php7/bin/php
<?php
error_reporting(-1);

function usage() {
	return "\n" . $GLOBALS['argv'][0] . " [script_name] [script_installation_path] [template_name]
\t - script_name --> " . implode(', ', $GLOBALS['supported_scripts']);
}

require_once('ei-tools.php');

if (empty($argv[1])) err('Missing script name');
if (empty($argv[2])) err('Missing installation path');
if (empty($argv[3])) err('New password not provided');

$script = strtolower($argv[1]);
$path = $argv[2];
$password = $argv[3];

if (!is_dir($path) || !file_exists($path))
	err('Invalid installation path');


script_supported($script);

$config_file = script_config_file($script, $path);

if (!file_exists($config_file))
	err('Missing ' . $script . ' config file [' . $config_file . ']');

// get script details
$details = get_script_config($script, $config_file);

// set script password
set_script_password($script, $password, $details);

echo 1;
© 2025 GrazzMean