@@ -7,13 +7,13 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // Argument parsing |
| 10 | -if(empty($_SERVER['argv'][1])) { |
|
| 10 | +if (empty($_SERVER['argv'][1])) { |
|
| 11 | 11 | echo "Usage: {$_SERVER['argv'][0]} (site-docroot)\n"; |
| 12 | 12 | exit(1); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | $basePath = $_SERVER['argv'][1]; |
| 16 | -if($basePath[0] != '/') $basePath = getcwd() . '/' . $basePath; |
|
| 16 | +if ($basePath[0] != '/') $basePath = getcwd().'/'.$basePath; |
|
| 17 | 17 | |
| 18 | 18 | // SilverStripe bootstrap |
| 19 | 19 | define('BASE_PATH', $basePath); |
@@ -23,24 +23,24 @@ discard block |
||
| 23 | 23 | $_SERVER['HTTP_HOST'] = 'localhost'; |
| 24 | 24 | chdir(BASE_PATH); |
| 25 | 25 | |
| 26 | -if(file_exists(BASE_PATH.'/sapphire/core/Core.php')) { |
|
| 26 | +if (file_exists(BASE_PATH.'/sapphire/core/Core.php')) { |
|
| 27 | 27 | //SS 2.x |
| 28 | - require_once(BASE_PATH . '/sapphire/core/Core.php'); |
|
| 29 | -} else if(file_exists(BASE_PATH.'/framework/core/Core.php')) { |
|
| 28 | + require_once(BASE_PATH.'/sapphire/core/Core.php'); |
|
| 29 | +} else if (file_exists(BASE_PATH.'/framework/core/Core.php')) { |
|
| 30 | 30 | //SS 3.x |
| 31 | - require_once(BASE_PATH. '/framework/core/Core.php'); |
|
| 32 | -} else if(file_exists(BASE_PATH.'/framework/src/Core/Core.php')) { |
|
| 31 | + require_once(BASE_PATH.'/framework/core/Core.php'); |
|
| 32 | +} else if (file_exists(BASE_PATH.'/framework/src/Core/Core.php')) { |
|
| 33 | 33 | //SS 4.x |
| 34 | - require_once(BASE_PATH. '/vendor/autoload.php'); |
|
| 35 | - require_once(BASE_PATH. '/framework/src/Core/Core.php'); |
|
| 34 | + require_once(BASE_PATH.'/vendor/autoload.php'); |
|
| 35 | + require_once(BASE_PATH.'/framework/src/Core/Core.php'); |
|
| 36 | 36 | } else { |
| 37 | - echo "Couldn't locate framework's Core.php. Perhaps " . BASE_PATH . " is not a SilverStripe project?\n"; |
|
| 37 | + echo "Couldn't locate framework's Core.php. Perhaps ".BASE_PATH." is not a SilverStripe project?\n"; |
|
| 38 | 38 | exit(2); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $output = array(); |
| 42 | -foreach($databaseConfig as $k => $v) { |
|
| 43 | - $output['db_' . $k] = $v; |
|
| 42 | +foreach ($databaseConfig as $k => $v) { |
|
| 43 | + $output['db_'.$k] = $v; |
|
| 44 | 44 | } |
| 45 | 45 | $output['assets_path'] = ASSETS_PATH; |
| 46 | 46 | |
@@ -88,16 +88,16 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | function help($args) { |
| 90 | 90 | echo "SSPak: manage SilverStripe .sspak archives.\n\nUsage:\n"; |
| 91 | - foreach($this->getActions() as $action => $info) { |
|
| 91 | + foreach ($this->getActions() as $action => $info) { |
|
| 92 | 92 | echo "sspak $action"; |
| 93 | - if(!empty($info['unnamedArgs'])) { |
|
| 94 | - foreach($info['unnamedArgs'] as $arg) echo " ($arg)"; |
|
| 93 | + if (!empty($info['unnamedArgs'])) { |
|
| 94 | + foreach ($info['unnamedArgs'] as $arg) echo " ($arg)"; |
|
| 95 | 95 | } |
| 96 | - if(!empty($info['namedFlags'])) { |
|
| 97 | - foreach($info['namedFlags'] as $arg) echo " (--$arg)"; |
|
| 96 | + if (!empty($info['namedFlags'])) { |
|
| 97 | + foreach ($info['namedFlags'] as $arg) echo " (--$arg)"; |
|
| 98 | 98 | } |
| 99 | - if(!empty($info['namedArgs'])) { |
|
| 100 | - foreach($info['namedArgs'] as $arg) echo " --$arg=\"$arg value\""; |
|
| 99 | + if (!empty($info['namedArgs'])) { |
|
| 100 | + foreach ($info['namedArgs'] as $arg) echo " --$arg=\"$arg value\""; |
|
| 101 | 101 | } |
| 102 | 102 | echo "\n {$info['description']}\n\n"; |
| 103 | 103 | } |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | $filesystem = new FilesystemEntity(null, $executor); |
| 123 | 123 | |
| 124 | - if($pakParts['db']) { |
|
| 124 | + if ($pakParts['db']) { |
|
| 125 | 125 | $dbPath = escapeshellarg($namedArgs['db']); |
| 126 | 126 | $process = $filesystem->createProcess("cat $dbPath | gzip -c"); |
| 127 | 127 | $sspak->writeFileFromProcess('database.sql.gz', $process); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if($pakParts['assets']) { |
|
| 130 | + if ($pakParts['assets']) { |
|
| 131 | 131 | $assetsParentArg = escapeshellarg(dirname($namedArgs['assets'])); |
| 132 | 132 | $assetsBaseArg = escapeshellarg(basename($namedArgs['assets'])); |
| 133 | 133 | $process = $filesystem->createProcess("cd $assetsParentArg && tar cfh - $assetsBaseArg | gzip -c"); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | // manually. |
| 155 | 155 | // There is no cross-platform way of checking the assets.tar.gz size without unpacking, so we assume the size |
| 156 | 156 | // of database is negligible which let's us approximate the size of assets. |
| 157 | - if (filesize($file) > 8*1024*1024*1024) { |
|
| 157 | + if (filesize($file) > 8 * 1024 * 1024 * 1024) { |
|
| 158 | 158 | $msg = <<<EOM |
| 159 | 159 | |
| 160 | 160 | ERROR: SSPak is unable to extract archives over 8 GB. |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | $sspak = new SSPakFile($file, $executor); |
| 176 | 176 | |
| 177 | 177 | // Validation |
| 178 | - if(!$sspak->exists()) throw new Exception("File '$file' doesn't exist."); |
|
| 178 | + if (!$sspak->exists()) throw new Exception("File '$file' doesn't exist."); |
|
| 179 | 179 | |
| 180 | 180 | $phar = $sspak->getPhar(); |
| 181 | 181 | $phar->extractTo($dest); |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | $db = new DatabaseConnector($webroot); |
| 208 | 208 | |
| 209 | - foreach($db->getTables() as $table) { |
|
| 210 | - $filename = $destPath . '/' . $table . '.csv'; |
|
| 211 | - echo $filename . "...\n"; |
|
| 209 | + foreach ($db->getTables() as $table) { |
|
| 210 | + $filename = $destPath.'/'.$table.'.csv'; |
|
| 211 | + echo $filename."...\n"; |
|
| 212 | 212 | touch($filename); |
| 213 | 213 | $writer = new CsvTableWriter($filename); |
| 214 | 214 | $db->saveTable($table, $writer); |
@@ -229,10 +229,10 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | $db = new DatabaseConnector($webroot); |
| 231 | 231 | |
| 232 | - foreach($db->getTables() as $table) { |
|
| 233 | - $filename = $srcPath . '/' . $table . '.csv'; |
|
| 234 | - if(file_exists($filename)) { |
|
| 235 | - echo $filename . "...\n"; |
|
| 232 | + foreach ($db->getTables() as $table) { |
|
| 233 | + $filename = $srcPath.'/'.$table.'.csv'; |
|
| 234 | + if (file_exists($filename)) { |
|
| 235 | + echo $filename."...\n"; |
|
| 236 | 236 | $reader = new CsvTableReader($filename); |
| 237 | 237 | $db->loadTable($table, $reader); |
| 238 | 238 | } else { |
@@ -254,16 +254,16 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | $webroot = new Webroot($unnamedArgs[0], $executor); |
| 256 | 256 | $file = $unnamedArgs[1]; |
| 257 | - if(file_exists($file)) throw new Exception( "File '$file' already exists."); |
|
| 257 | + if (file_exists($file)) throw new Exception("File '$file' already exists."); |
|
| 258 | 258 | |
| 259 | 259 | $sspak = new SSPakFile($file, $executor); |
| 260 | 260 | |
| 261 | - if(!empty($namedArgs['identity'])) { |
|
| 261 | + if (!empty($namedArgs['identity'])) { |
|
| 262 | 262 | // SSH private key |
| 263 | 263 | $webroot->setSSHItentityFile($namedArgs['identity']); |
| 264 | 264 | } |
| 265 | - if(!empty($namedArgs['from-sudo'])) $webroot->setSudo($namedArgs['from-sudo']); |
|
| 266 | - else if(!empty($namedArgs['sudo'])) $webroot->setSudo($namedArgs['sudo']); |
|
| 265 | + if (!empty($namedArgs['from-sudo'])) $webroot->setSudo($namedArgs['from-sudo']); |
|
| 266 | + else if (!empty($namedArgs['sudo'])) $webroot->setSudo($namedArgs['sudo']); |
|
| 267 | 267 | |
| 268 | 268 | // Look up which parts of the sspak are going to be saved |
| 269 | 269 | $pakParts = $args->pakParts(); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | $details = $webroot->sniff(); |
| 273 | 273 | |
| 274 | 274 | // Create a build folder for the sspak file |
| 275 | - $buildFolder = "/tmp/sspak-" . rand(100000,999999); |
|
| 275 | + $buildFolder = "/tmp/sspak-".rand(100000, 999999); |
|
| 276 | 276 | $webroot->exec(array('mkdir', $buildFolder)); |
| 277 | 277 | |
| 278 | 278 | $dbFile = "$buildFolder/database.sql.gz"; |
@@ -283,22 +283,22 @@ discard block |
||
| 283 | 283 | $fileList = array(); |
| 284 | 284 | |
| 285 | 285 | // Save DB |
| 286 | - if($pakParts['db']) { |
|
| 286 | + if ($pakParts['db']) { |
|
| 287 | 287 | // Check the database type |
| 288 | 288 | $dbFunction = 'getdb_'.$details['db_type']; |
| 289 | - if(!method_exists($this,$dbFunction)) { |
|
| 290 | - throw new Exception("Can't process database type '" . $details['db_type'] . "'"); |
|
| 289 | + if (!method_exists($this, $dbFunction)) { |
|
| 290 | + throw new Exception("Can't process database type '".$details['db_type']."'"); |
|
| 291 | 291 | } |
| 292 | 292 | $this->$dbFunction($webroot, $details, $sspak, basename($dbFile)); |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // Save Assets |
| 296 | - if($pakParts['assets']) { |
|
| 296 | + if ($pakParts['assets']) { |
|
| 297 | 297 | $this->getassets($webroot, $details['assets_path'], $sspak, basename($assetsFile)); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | // Save git-remote |
| 301 | - if($pakParts['git-remote']) { |
|
| 301 | + if ($pakParts['git-remote']) { |
|
| 302 | 302 | $this->getgitremote($webroot, $sspak, basename($gitRemoteFile)); |
| 303 | 303 | } |
| 304 | 304 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | $hostArg = ''; |
| 319 | 319 | $portArg = ''; |
| 320 | 320 | if (!empty($conf['db_server']) && $conf['db_server'] != 'localhost') { |
| 321 | - if (strpos($conf['db_server'], ':')!==false) { |
|
| 321 | + if (strpos($conf['db_server'], ':') !== false) { |
|
| 322 | 322 | // Handle "server:port" format. |
| 323 | 323 | $server = explode(':', $conf['db_server'], 2); |
| 324 | 324 | $hostArg = escapeshellarg("--host=".$server[0]); |
@@ -357,16 +357,16 @@ discard block |
||
| 357 | 357 | |
| 358 | 358 | function getgitremote($webroot, $sspak, $gitRemoteFile) { |
| 359 | 359 | // Only do anything if we're copying from a git checkout |
| 360 | - $gitRepo = $webroot->getPath() .'/.git'; |
|
| 361 | - if($webroot->exists($gitRepo)) { |
|
| 360 | + $gitRepo = $webroot->getPath().'/.git'; |
|
| 361 | + if ($webroot->exists($gitRepo)) { |
|
| 362 | 362 | // Identify current branch |
| 363 | 363 | $output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'branch')); |
| 364 | - if(preg_match("/\* ([^ \n]*)/", $output['output'], $matches) && strpos("(no branch)", $matches[1])===false) { |
|
| 364 | + if (preg_match("/\* ([^ \n]*)/", $output['output'], $matches) && strpos("(no branch)", $matches[1]) === false) { |
|
| 365 | 365 | // If there is a current branch, use that branch's remove |
| 366 | 366 | $currentBranch = trim($matches[1]); |
| 367 | - $output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'config','--get',"branch.$currentBranch.remote")); |
|
| 367 | + $output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'config', '--get', "branch.$currentBranch.remote")); |
|
| 368 | 368 | $remoteName = trim($output['output']); |
| 369 | - if(!$remoteName) $remoteName = 'origin'; |
|
| 369 | + if (!$remoteName) $remoteName = 'origin'; |
|
| 370 | 370 | |
| 371 | 371 | // Default to origin |
| 372 | 372 | } else { |
@@ -375,11 +375,11 @@ discard block |
||
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | // Determine the URL of that remote |
| 378 | - $output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'config','--get',"remote.$remoteName.url")); |
|
| 378 | + $output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'config', '--get', "remote.$remoteName.url")); |
|
| 379 | 379 | $remoteURL = trim($output['output']); |
| 380 | 380 | |
| 381 | 381 | // Determine the current SHA |
| 382 | - $output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'log','-1','--format=%H')); |
|
| 382 | + $output = $webroot->exec(array('git', '--git-dir='.$gitRepo, 'log', '-1', '--format=%H')); |
|
| 383 | 383 | $sha = trim($output['output']); |
| 384 | 384 | |
| 385 | 385 | $content = "remote = $remoteURL\nbranch = $currentBranch\nsha = $sha\n"; |
@@ -407,22 +407,22 @@ discard block |
||
| 407 | 407 | $pakParts = $args->pakParts(); |
| 408 | 408 | |
| 409 | 409 | $namedArgs = $args->getNamedArgs(); |
| 410 | - if(!empty($namedArgs['identity'])) { |
|
| 410 | + if (!empty($namedArgs['identity'])) { |
|
| 411 | 411 | // SSH private key |
| 412 | 412 | $webroot->setSSHItentityFile($namedArgs['identity']); |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | // Validation |
| 416 | - if(!$sspak->exists()) throw new Exception( "File '$file' doesn't exist."); |
|
| 416 | + if (!$sspak->exists()) throw new Exception("File '$file' doesn't exist."); |
|
| 417 | 417 | |
| 418 | 418 | // Push database, if necessary |
| 419 | 419 | $namedArgs = $args->getNamedArgs(); |
| 420 | - if($pakParts['db'] && $sspak->contains('database.sql.gz')) { |
|
| 420 | + if ($pakParts['db'] && $sspak->contains('database.sql.gz')) { |
|
| 421 | 421 | $webroot->putdb($sspak, isset($namedArgs['drop-db'])); |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | // Push assets, if neccessary |
| 425 | - if($pakParts['assets'] && $sspak->contains('assets.tar.gz')) { |
|
| 425 | + if ($pakParts['assets'] && $sspak->contains('assets.tar.gz')) { |
|
| 426 | 426 | $webroot->putassets($sspak); |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -444,13 +444,13 @@ discard block |
||
| 444 | 444 | $pakParts = $args->pakParts(); |
| 445 | 445 | |
| 446 | 446 | // Validation |
| 447 | - if($webroot->exists($webroot->getPath())) throw new Exception( "Webroot '$webrootDir' already exists."); |
|
| 448 | - if(!$sspak->exists()) throw new Exception( "File '$file' doesn't exist."); |
|
| 447 | + if ($webroot->exists($webroot->getPath())) throw new Exception("Webroot '$webrootDir' already exists."); |
|
| 448 | + if (!$sspak->exists()) throw new Exception("File '$file' doesn't exist."); |
|
| 449 | 449 | |
| 450 | 450 | // Create new dir |
| 451 | 451 | $webroot->exec(array('mkdir', $webroot->getPath())); |
| 452 | 452 | |
| 453 | - if($sspak->contains('git-remote')) { |
|
| 453 | + if ($sspak->contains('git-remote')) { |
|
| 454 | 454 | $details = $sspak->gitRemoteDetails(); |
| 455 | 455 | $webroot->putgit($details); |
| 456 | 456 | } |
@@ -459,12 +459,12 @@ discard block |
||
| 459 | 459 | |
| 460 | 460 | // Push database, if necessary |
| 461 | 461 | $namedArgs = $args->getNamedArgs(); |
| 462 | - if($pakParts['db'] && $sspak->contains('database.sql.gz')) { |
|
| 462 | + if ($pakParts['db'] && $sspak->contains('database.sql.gz')) { |
|
| 463 | 463 | $webroot->putdb($sspak, isset($namedArgs['drop-db'])); |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | // Push assets, if neccessary |
| 467 | - if($pakParts['assets'] && $sspak->contains('assets.tar.gz')) { |
|
| 467 | + if ($pakParts['assets'] && $sspak->contains('assets.tar.gz')) { |
|
| 468 | 468 | $webroot->putassets($sspak); |
| 469 | 469 | } |
| 470 | 470 | } |
@@ -491,10 +491,10 @@ discard block |
||
| 491 | 491 | $sspakScript = str_replace('$isSelfExtracting = false;', '$isSelfExtracting = true;', $sspakScript); |
| 492 | 492 | |
| 493 | 493 | // Load the sniffer file |
| 494 | - $snifferFile = dirname(__FILE__) . '/sspak-sniffer.php'; |
|
| 494 | + $snifferFile = dirname(__FILE__).'/sspak-sniffer.php'; |
|
| 495 | 495 | $sspakScript = str_replace("\$snifferFileContent = '';\n", |
| 496 | 496 | "\$snifferFileContent = '" |
| 497 | - . str_replace(array("\\","'"),array("\\\\", "\\'"), file_get_contents($snifferFile)) . "';\n", $sspakScript); |
|
| 497 | + . str_replace(array("\\", "'"), array("\\\\", "\\'"), file_get_contents($snifferFile))."';\n", $sspakScript); |
|
| 498 | 498 | |
| 499 | 499 | file_put_contents($destFile, $sspakScript); |
| 500 | 500 | chmod($destFile, 0775); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * Calls sniff once and then caches |
| 17 | 17 | */ |
| 18 | 18 | function details() { |
| 19 | - if(!$this->details) $this->details = $this->sniff(); |
|
| 19 | + if (!$this->details) $this->details = $this->sniff(); |
|
| 20 | 20 | return $this->details; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -26,16 +26,16 @@ discard block |
||
| 26 | 26 | function sniff() { |
| 27 | 27 | global $snifferFileContent; |
| 28 | 28 | |
| 29 | - if(!$snifferFileContent) $snifferFileContent = file_get_contents(PACKAGE_ROOT . 'src/sspak-sniffer.php'); |
|
| 29 | + if (!$snifferFileContent) $snifferFileContent = file_get_contents(PACKAGE_ROOT.'src/sspak-sniffer.php'); |
|
| 30 | 30 | |
| 31 | - $remoteSniffer = '/tmp/sspak-sniffer-' . rand(100000,999999) . '.php'; |
|
| 31 | + $remoteSniffer = '/tmp/sspak-sniffer-'.rand(100000, 999999).'.php'; |
|
| 32 | 32 | $this->uploadContent($snifferFileContent, $remoteSniffer); |
| 33 | 33 | |
| 34 | 34 | $result = $this->execSudo(array('/usr/bin/env', 'php', $remoteSniffer, $this->path)); |
| 35 | 35 | $this->unlink($remoteSniffer); |
| 36 | 36 | |
| 37 | 37 | $parsed = @unserialize($result['output']); |
| 38 | - if(!$parsed) throw new Exception("Could not parse sspak-sniffer content:\n{$result['output']}\n"); |
|
| 38 | + if (!$parsed) throw new Exception("Could not parse sspak-sniffer content:\n{$result['output']}\n"); |
|
| 39 | 39 | return $parsed; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -44,19 +44,19 @@ discard block |
||
| 44 | 44 | * @param string $command Shell command, either a fully escaped string or an array |
| 45 | 45 | */ |
| 46 | 46 | function execSudo($command) { |
| 47 | - if($this->sudo) { |
|
| 48 | - if(is_array($command)) $command = $this->executor->commandArrayToString($command); |
|
| 47 | + if ($this->sudo) { |
|
| 48 | + if (is_array($command)) $command = $this->executor->commandArrayToString($command); |
|
| 49 | 49 | // Try running sudo without asking for a password |
| 50 | 50 | try { |
| 51 | - return $this->exec("sudo -n -u " . escapeshellarg($this->sudo) . " " . $command); |
|
| 51 | + return $this->exec("sudo -n -u ".escapeshellarg($this->sudo)." ".$command); |
|
| 52 | 52 | |
| 53 | 53 | // Otherwise capture SUDO password ourselves and pass it in through STDIN |
| 54 | - } catch(Exception $e) { |
|
| 54 | + } catch (Exception $e) { |
|
| 55 | 55 | echo "[sspak sudo] Enter your password: "; |
| 56 | - $stdin = fopen( 'php://stdin', 'r'); |
|
| 56 | + $stdin = fopen('php://stdin', 'r'); |
|
| 57 | 57 | $password = fgets($stdin); |
| 58 | 58 | |
| 59 | - return $this->exec("sudo -S -p '' -u " . escapeshellarg($this->sudo) . " " . $command, array('inputContent' => $password)); |
|
| 59 | + return $this->exec("sudo -S -p '' -u ".escapeshellarg($this->sudo)." ".$command, array('inputContent' => $password)); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | } else { |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | // Check the database type |
| 77 | 77 | $dbFunction = 'putdb_'.$details['db_type']; |
| 78 | - if(!method_exists($this,$dbFunction)) { |
|
| 79 | - throw new Exception("Can't process database type '" . $details['db_type'] . "'"); |
|
| 78 | + if (!method_exists($this, $dbFunction)) { |
|
| 79 | + throw new Exception("Can't process database type '".$details['db_type']."'"); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // Extract DB direct from sspak file |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $hostArg = ''; |
| 96 | 96 | $portArg = ''; |
| 97 | 97 | if (!empty($conf['db_server']) && $conf['db_server'] != 'localhost') { |
| 98 | - if (strpos($conf['db_server'], ':')!==false) { |
|
| 98 | + if (strpos($conf['db_server'], ':') !== false) { |
|
| 99 | 99 | // Handle "server:port" format. |
| 100 | 100 | $server = explode(':', $conf['db_server'], 2); |
| 101 | 101 | $hostArg = escapeshellarg("--host=".$server[0]); |
@@ -104,9 +104,9 @@ discard block |
||
| 104 | 104 | $hostArg = escapeshellarg("--host=".$conf['db_server']); |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | - $dbCommand = "create database if not exists `" . addslashes($conf['db_database']) . "`"; |
|
| 108 | - if($dropdb) { |
|
| 109 | - $dbCommand = "drop database if exists `" . addslashes($conf['db_database']) . "`; " . $dbCommand; |
|
| 107 | + $dbCommand = "create database if not exists `".addslashes($conf['db_database'])."`"; |
|
| 108 | + if ($dropdb) { |
|
| 109 | + $dbCommand = "drop database if exists `".addslashes($conf['db_database'])."`; ".$dbCommand; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $this->exec("echo '$dbCommand' | mysql $usernameArg $passwordArg $hostArg $portArg"); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | // Create database if needed |
| 128 | 128 | $result = $this->exec("echo \"select count(*) from pg_catalog.pg_database where datname = $databaseArg\" | $passwordArg psql $usernameArg $hostArg $databaseArg -qt"); |
| 129 | - if(trim($result['output']) == '0') { |
|
| 129 | + if (trim($result['output']) == '0') { |
|
| 130 | 130 | $this->exec("$passwordArg createdb $usernameArg $hostArg $databaseArg"); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | function putassets($sspak) { |
| 139 | 139 | $details = $this->details(); |
| 140 | 140 | $assetsPath = $details['assets_path']; |
| 141 | - $assetsOldPath = $assetsPath . '.old'; |
|
| 141 | + $assetsOldPath = $assetsPath.'.old'; |
|
| 142 | 142 | |
| 143 | 143 | $assetsParentArg = escapeshellarg(dirname($assetsPath)); |
| 144 | 144 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | function putgit($details) { |
| 166 | 166 | $this->exec(array('git', 'clone', $details['remote'], $this->path)); |
| 167 | - $this->exec("cd $this->path && git checkout " . escapeshellarg($details['branch'])); |
|
| 167 | + $this->exec("cd $this->path && git checkout ".escapeshellarg($details['branch'])); |
|
| 168 | 168 | return true; |
| 169 | 169 | } |
| 170 | 170 | } |