public function run() { $rewrites = Args::get('rewrites', Args::argv); if ($rewrites && $rewrites == "nginx") { self::set_rules($rules); echo "== Start Nginx Rewrites" . PHP_EOL; $nginx_filename = Args::get('filename', Args::argv); $nginx_folder = Args::get('folder', Args::argv); if (!$nginx_filename || !$nginx_folder) { echo "Missing arguments"; exit(0); } self::save_nginx_rewrites($nginx_filename); if (!self::check_nginx_config($nginx_filename, $nginx_folder)) { echo "Nginx config is outdated, please run the following commands:" . PHP_EOL; echo "cp " . $nginx_filename . " " . $nginx_folder . $nginx_filename . PHP_EOL; echo "/etc/init.d/nginx restart" . PHP_EOL; } echo "== End Nginx Rewrites" . PHP_EOL; exit(0); } $generate_default_rules = Args::get('generate-default-rules', Args::argv); if ($generate_default_rules) { global $dirs; global $current_hostname; self::set_userland($dirs[$current_hostname]['userland']); echo "== Updating Default Rules..." . PHP_EOL; RocketPath::generate_default_rules(); RocketPath::write_default_rules_to_file('rules.default.php'); echo '== Default Rules Updated !' . PHP_EOL; exit(0); } }
<?php /** * dbname * plusql_one * plusql_two */ Murphy\Fixture::add(function ($row) { if (!($mysql_root = Args::get('mysql_root', Args::argv))) { die('You need to pass in mysql_root'); } mysql_connect('localhost', 'root', $mysql_root) or die(mysql_error()); $dbname = $row['dbname']; $dbuser = $dbname; mysql_query('DROP DATABASE IF EXISTS `' . mysql_real_escape_string($dbname) . '`'); mysql_query('CREATE DATABASE `' . mysql_real_escape_string($dbname) . '`') or die(mysql_error()); mysql_query('GRANT ALL ON `' . mysql_real_escape_string($dbname) . '`.* TO \'' . mysql_real_escape_string($dbuser) . '\'@\'localhost\' IDENTIFIED BY \'' . mysql_real_escape_string($dbuser) . '\'') or die(mysql_error()); mysql_select_db($dbname); mysql_query(' CREATE TABLE `strong_guy` ( `strong_guy_id` int(10) NOT NULL AUTO_INCREMENT, `strong_name` varchar(20) DEFAULT NULL, PRIMARY KEY(strong_guy_id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1') or die(mysql_error()); });
public function run() { if (!($include = Args::get('include', Args::argv))) { $include = array(); } else { $include = explode(',', $include); } if (!($exclude = Args::get('exclude', Args::argv))) { $exclude = array(); } else { $exclude = explode(',', $exclude); } if (!($dbconfig_path = Args::get('dbconfig', Args::argv)) || !($dbconfig = (include $dbconfig_path))) { echo "You need to include 'dbconfig' in the command line arguments." . PHP_EOL; echo "The file should have the following format: " . PHP_EOL; echo "<?php" . PHP_EOL; echo "return array('db_host' => 'localhost'," . PHP_EOL; echo " 'db_user' => 'root'," . PHP_EOL; echo " 'db_pass' => 'root'," . PHP_EOL; echo " 'db_name' => 'killerapp'," . PHP_EOL; echo " 'db_port' => 3309" . PHP_EOL; echo "?>" . PHP_EOL; echo PHP_EOL; echo "Usage: php index.php Murphy dbconfig=/path/to/dbconfig.php" . PHP_EOL; exit(1); } $tests = RocketSled::filteredPackages(function ($arg) { $ret = FALSE; if (RocketSled::endsWith($arg, '.run.php')) { $ret = $arg; } return $ret; }); foreach ($tests as $path) { if (count($include)) { $use = FALSE; } else { $use = TRUE; } foreach ($exclude as $exc) { if (strpos(realpath($path), realpath($exc)) === 0) { $use = FALSE; } } foreach ($include as $inc) { if (strpos(realpath($path), realpath($inc)) === 0) { $use = TRUE; } } if (strpos($path, '.murphy/') === FALSE) { $use = FALSE; } if ($use) { $output = ''; exec('php index.php "Murphy\\Test" path=' . escapeshellarg($path) . ' dbconfig=' . escapeshellarg(Args::get('dbconfig', Args::argv)), $output, $exit_code); if ($exit_code) { echo 'FATAL ERROR: ' . $path . ' terminated abnormally' . PHP_EOL; } echo PHP_EOL . '====Output from ' . $path . '===========' . PHP_EOL; foreach ($output as $opline) { echo $opline . PHP_EOL; } echo PHP_EOL . '=====================================' . PHP_EOL; } } }