function main($args) { //input sanity check if (!is_array($args) || is_array($args) && !array_key_exists('name', $args)) { print_help(true); } $migration_name = $args['name']; //clear any filesystem stats cache clearstatcache(); //check to make sure our migration directory exists if (!is_dir(MIGRATION_DIR)) { die_with_error("ERROR: migration directory '" . MIGRATION_DIR . "' does not exist. Specify MIGRATION_DIR in config/config.inc.php and try again."); } //generate a complete complete $highest_version = VersionUtil::get_highest_migration(MIGRATION_DIR); $next_version = VersionUtil::to_migration_number($highest_version + 1); $klass = NamingUtil::camelcase($migration_name); $file_name = $next_version . '_' . $klass . '.php'; $full_path = realpath(MIGRATION_DIR) . '/' . $file_name; $template_str = get_template($klass); //check to make sure our destination directory is writable if (!is_writable(MIGRATION_DIR . '/')) { die_with_error("ERROR: migration directory '" . MIGRATION_DIR . "' is not writable by the current user. Check permissions and try again."); } //write it out! $file_result = file_put_contents($full_path, $template_str); if ($file_result === FALSE) { die_with_error("Error writing to migrations directory/file. Do you have sufficient privileges?"); } else { echo "\nCreated migration: {$file_name}\n\n"; } }
function exec_command($command, $returnAsString = FALSE, $dieIfEmpty = TRUE, $echoCommand = FALSE) { if ($echoCommand) { log_message($command); } $output = array(); exec($command, $output); if ($dieIfEmpty && empty($output)) { die_with_error('"' . $command . '" output is empty'); } if ($returnAsString) { $output = implode('', $output); } return $output; }
<?php require 'db-con.php'; $id = isset($_GET['id']) ? $_GET['id'] : ''; if ($id != '') { $query = "SELECT store_name,store_pic,operation_hours,concat(address,', ',city,', ',region) as address, city, region,status, postalcode, address as staddress,country\n FROM `data_mcdonalds2`\n WHERE id='{$id}' LIMIT 1 "; $result = mysqli_query($mysqli, $query); if (!$result) { die_with_error(mysqli_error($result)); } $result_array = ''; while ($row = mysqli_fetch_assoc($result)) { $result_array = $row; } $ret = array("status" => "OK", "data" => $result_array); die(json_encode($ret)); }
define("WP_MEMORY_LIMIT", "512M"); require_once(ABSPATH . 'wp-settings.php'); require_once('{$dir}/lib/load_whippet.php'); ////Whippet END EOT; // Get the config if (WPS_LOCATION == 'root') { if (file_exists($options['wp-root'] . "/wp-config.php")) { $options['wp-config'] = $options['wp-root'] . "/wp-config.php"; } else { if (file_exists($options['wp-root'] . "/../wp-config.php")) { $options['wp-config'] = $options['wp-root'] . "/../wp-config.php"; } else { die_with_error("Unable to find wp-config.php at {$options['wp-root']} or " . dirname($options['wp-root']), "This shouldn't happen. Please report this bug!"); } } $wp_config = file_get_contents($options['wp-config']); // Modify it $new_wp_config = preg_replace('/^.*wp-settings\\.php.*$/m', $inject, $wp_config); // Save it file_put_contents($options['wp-config'], $new_wp_config); // Save the original one so we can restore it later file_put_contents(dirname($options['wp-config']) . "/wp-config-original.whippet.bak", $wp_config); } else { if (WPS_LOCATION == 'wp-content') { $new_wp_config = <<<EOF <?php require_once("{$options['wp-content']}/whippet-wp-config.php");
printf("\n\tMigrations directory (%s doesn't exist, attempting to create.", $migrations_dir); if (mkdir($migrations_dir) === FALSE) { printf("\n\tUnable to create migrations directory at %s, check permissions?", $migrations_dir); } else { printf("\n\tCreated OK"); } } //check to make sure our destination directory is writable if (!is_writable($migrations_dir)) { die_with_error("ERROR: migration directory '" . $migrations_dir . "' is not writable by the current user. Check permissions and try again."); } //write it out! $full_path = $migrations_dir . '/' . $file_name; $file_result = file_put_contents($full_path, $template_str); if ($file_result === FALSE) { die_with_error("Error writing to migrations directory/file. Do you have sufficient privileges?"); } else { echo "\n\tCreated migration: {$file_name}\n\n"; } /* Parse command line arguments. */ function parse_args($argv) { $num_args = count($argv); if ($num_args < 2) { print_help(true); } $migration_name = $argv[1]; return array('name' => $migration_name); }