private function sassProcessing()
 {
     global $IP, $wgSassExecutable, $wgDevelEnvironment;
     wfProfileIn(__METHOD__);
     $tempDir = sys_get_temp_dir();
     //replace \ to / is needed because escapeshellcmd() replace \ into spaces (?!!)
     $tempOutFile = str_replace('\\', '/', tempnam($tempDir, 'Sass'));
     $tempDir = str_replace('\\', '/', $tempDir);
     $params = urldecode(http_build_query($this->mParams, '', ' '));
     $cmd = "{$wgSassExecutable} {$IP}/{$this->mOid} {$tempOutFile} --cache-location {$tempDir}/sass -r {$IP}/extensions/wikia/SASS/wikia_sass.rb {$params}";
     $escapedCmd = escapeshellcmd($cmd) . " 2>&1";
     $sassResult = shell_exec($escapedCmd);
     if ($sassResult != '') {
         Wikia::log(__METHOD__, false, "commandline error: " . $sassResult . " -- Full commandline was: {$escapedCmd}", true);
         Wikia::log(__METHOD__, false, "Full commandline was: {$escapedCmd}", true);
         Wikia::log(__METHOD__, false, AssetsManager::getRequestDetails(), true);
         if (file_exists($tempOutFile)) {
             unlink($tempOutFile);
         }
         if (!empty($wgDevelEnvironment)) {
             $exceptionMsg = "Problem with SASS processing: {$sassResult}";
         } else {
             $exceptionMsg = 'Problem with SASS processing. Check the PHP error log for more info.';
         }
         throw new Exception("/* {$exceptionMsg} */");
     }
     $this->mContent = file_get_contents($tempOutFile);
     unlink($tempOutFile);
     wfProfileOut(__METHOD__);
 }
 function getSuggestion($word)
 {
     if ($fh = fopen($this->tmpfile, "w")) {
         fwrite($fh, "!\n");
         fwrite($fh, "^{$word}\n");
         fclose($fh);
     } else {
         die("Error opening tmp file.");
     }
     $data = shell_exec($this->cmd);
     $returnData = array();
     $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);
     foreach ($dataArr as $dstr) {
         $matches = array();
         // Skip this line.
         if (strpos($dstr, "@") === 0) {
             continue;
         }
         preg_match("/\\& .* .* .*: (.*)/i", $dstr, $matches);
         if (!empty($matches[1])) {
             // For some reason, the exec version seems to add commas?
             $returnData[] = str_replace(",", "", $matches[1]);
         }
     }
     return $returnData;
 }
Пример #3
0
 /**
  * Calculates Time for the repository this shell is run in and prints to screen
  *
  * @return void
  * @access public
  */
 function main()
 {
     $committerName = '';
     $committer = null;
     $totalTime = 0;
     if (isset($this->args[0])) {
         foreach ($this->args as $key => $anArg) {
             if ($key === count($this->args) - 1) {
                 $committerName .= $anArg;
             } else {
                 $committerName .= $anArg . " ";
             }
         }
         $committer = " --committer='{$committerName}'";
     }
     $this->out("Running: git --no-pager log --all-match --pretty=oneline --grep=[0-9].{$committer}");
     $this->out('');
     $output = shell_exec("git --no-pager log --all-match --pretty=oneline --grep=[0-9].{$committer}");
     $this->out('Commits with CodebaseHQ times:');
     $this->out($output);
     preg_match_all("{T[0-9]+}", $output, &$matches);
     foreach ($matches['0'] as $match) {
         preg_match_all("{[0-9]+}", $match, &$out);
         $totalTime += $out['0']['0'];
     }
     $hours = floor($totalTime / 60);
     $mins = $totalTime % 60;
     if (isset($this->args[0])) {
         $this->out("Committer {$committerName} took approximately {$hours} Hours {$mins} Minutes ");
     } else {
         $this->out("Current project has taken a total time of {$hours} Hours {$mins} Minutes ");
     }
 }
Пример #4
0
 public static function _shell_exec($cmd)
 {
     # string shell_exec ( string $cmd )
     # returns command output
     $back = shell_exec($cmd);
     return array(false, $back);
 }
Пример #5
0
 /**
  * Checks that the directories Piwik needs write access are actually writable
  * Displays a nice error page if permissions are missing on some directories
  *
  * @param array $directoriesToCheck Array of directory names to check
  */
 public static function dieIfDirectoriesNotWritable($directoriesToCheck = null)
 {
     $resultCheck = self::checkDirectoriesWritable($directoriesToCheck);
     if (array_search(false, $resultCheck) === false) {
         return;
     }
     $directoryList = '';
     foreach ($resultCheck as $dir => $bool) {
         $realpath = Filesystem::realpath($dir);
         if (!empty($realpath) && $bool === false) {
             $directoryList .= self::getMakeWritableCommand($realpath);
         }
     }
     // Also give the chown since the chmod is only 755
     if (!SettingsServer::isWindows()) {
         $realpath = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/');
         $directoryList = "<code>chown -R www-data:www-data " . $realpath . "</code><br />" . $directoryList;
     }
     if (function_exists('shell_exec')) {
         $currentUser = trim(shell_exec('whoami'));
         if (!empty($currentUser)) {
             $optionalUserInfo = " (running as user '" . $currentUser . "')";
         }
     }
     $directoryMessage = "<p><b>Piwik couldn't write to some directories {$optionalUserInfo}</b>.</p>";
     $directoryMessage .= "<p>Try to Execute the following commands on your server, to allow Write access on these directories" . ":</p>" . "<blockquote>{$directoryList}</blockquote>" . "<p>If this doesn't work, you can try to create the directories with your FTP software, and set the CHMOD to 0755 (or 0777 if 0755 is not enough). To do so with your FTP software, right click on the directories then click permissions.</p>" . "<p>After applying the modifications, you can <a href='index.php'>refresh the page</a>.</p>" . "<p>If you need more help, try <a href='?module=Proxy&action=redirect&url=http://piwik.org'>Piwik.org</a>.</p>";
     Piwik_ExitWithMessage($directoryMessage, false, true);
 }
 public static function read_osx_system_profiler($data_type, $object, $multiple_objects = false, $ignore_values = array())
 {
     $value = $multiple_objects ? array() : false;
     if (pts_client::executable_in_path('system_profiler')) {
         $info = trim(shell_exec('system_profiler ' . $data_type . ' 2>&1'));
         $lines = explode("\n", $info);
         for ($i = 0; $i < count($lines) && ($value == false || $multiple_objects); $i++) {
             $line = pts_strings::colon_explode($lines[$i]);
             if (isset($line[0]) == false) {
                 continue;
             }
             $line_object = str_replace(' ', null, $line[0]);
             if (($cut_point = strpos($line_object, '(')) > 0) {
                 $line_object = substr($line_object, 0, $cut_point);
             }
             if (strtolower($line_object) == strtolower($object) && isset($line[1])) {
                 $this_value = trim($line[1]);
                 if (!empty($this_value) && !in_array($this_value, $ignore_values)) {
                     if ($multiple_objects) {
                         array_push($value, $this_value);
                     } else {
                         $value = $this_value;
                     }
                 }
             }
         }
     }
     return $value;
 }
Пример #7
0
 public function index()
 {
     $filename = "s.pdf";
     $content = shell_exec('pdftotext -raw ' . $filename . ' -');
     $separator = "\r\n";
     $line = strtok($content, $separator);
     $i = 0;
     $j = 0;
     while ($line !== false) {
         $i++;
         if ($line == 'Issue') {
             $j++;
             $data = new stdClass();
             $data->muhasil = strtok($separator);
             $data->jumlah = strtok($separator);
             $data->no_m1 = strtok($separator);
             $data->periode = strtok($separator);
             $data->nama = strtok($separator);
             $data->aims = strtok($separator);
             list($data->tanggal, $data->metode) = explode(' ', strtok($separator));
             while (($line = strtok($separator)) != 'Issue' && ord($line[0]) != 12) {
                 $data->rincian[] = $line;
             }
             var_dump($data);
             echo '<br/>------------------------------------<br/>';
         } else {
             $line = strtok($separator);
         }
     }
 }
Пример #8
0
 function updateCodes($parameters, $arg1 = '', $arg2 = '', $arg3 = '')
 {
     $mode = "pull";
     $shellResult = "";
     if ($arg1 or $arg2 or $arg3) {
         $mode = $arg1 ? $arg1 : $mode;
     }
     if (is_array($parameters)) {
         $mode = array_key_exists("mode", $parameters) ? $parameters['mode'] : $mode;
     }
     switch ($mode) {
         case "push":
             break;
         default:
             set_time_limit(60);
             $shellResult .= shell_exec("svn up ../");
             $directories = zig("dbTableApplications", "getApplicationDirectories");
             foreach ($directories as $directory) {
                 switch (substr($directory, 0, 4) != "zig-") {
                     case true:
                         set_time_limit(60);
                         $shellResult .= shell_exec("cd ../{$directory}");
                         $shellResult .= shell_exec("git {$mode}");
                 }
             }
     }
     $zigReturn['value'] = $shellResult;
     return $zigReturn;
 }
Пример #9
0
 /**
  * 
  */
 public static function installCentreon()
 {
     if (Migrate::checkForMigration()) {
         Migrate::migrateCentreon();
     } else {
         // Initialize configuration
         $di = Di::getDefault();
         $config = $di->get('config');
         $centreonPath = $config->get('global', 'centreon_path');
         $dbName = $config->get('db_centreon', 'dbname');
         // Check Php Dependencies
         $phpDependencies = json_decode(file_get_contents(rtrim($centreonPath, '/') . '/install/dependencies.json'));
         PhpDependencies::checkDependencies($phpDependencies);
         echo Colorize::colorizeMessage("Starting to install Centreon 3.0", "info") . "\n";
         echo "Creating " . Colorize::colorizeText('centreon', 'blue', 'black', true) . " database... ";
         // Install DB
         $migrationManager = new Manager('core', 'production');
         $migrationManager->generateConfiguration();
         $cmd = self::getPhinxCallLine() . 'migrate ';
         $cmd .= '-c ' . $migrationManager->getPhinxConfigurationFile();
         $cmd .= ' -e core';
         shell_exec($cmd);
         //Db::update('core');
         echo Colorize::colorizeText('Done', 'green', 'black', true) . "\n";
         $modulesToInstall = self::getCoreModules();
         $dependencyResolver = new Dependency($modulesToInstall['modules']);
         $installOrder = $dependencyResolver->resolve();
         foreach ($installOrder as $moduleName) {
             $currentModule = $modulesToInstall['modules'][$moduleName];
             $moduleInstaller = new $currentModule['classCall']($currentModule['directory'], $currentModule['infos'], 'console');
             $moduleInstaller->install();
         }
         echo Colorize::colorizeMessage("Centreon 3.0 has been successfully installed", "success") . "\n";
     }
 }
Пример #10
0
/**
* Automatically update from the git master (if configured)
* 
*/
function GitUpdate()
{
    if (GetSetting('gitUpdate')) {
        echo "Updating from GitHub...\n";
        echo shell_exec('git pull origin master');
    }
}
function genSchoolCertificates($schoolID)
{
    shell_exec("rm -rf " . CERTIGEN_EXPORTDIR . "/" . $schoolID);
    mkdir(CERTIGEN_EXPORTDIR . "/" . $schoolID, $code = 0777, $recursive = true);
    list($aGroups, $aContestants) = getGroupsAndContestants($schoolID);
    $nbStudents = count($aContestants);
    if ($nbStudents == 0) {
        return 0;
    }
    foreach ($aContestants as $contestant) {
        $contestant->Group->certificates .= getHtmlCertificate($contestant);
        $contestant->Group->contestants[] = $contestant;
    }
    $groupsHtml = "";
    foreach ($aGroups as $groupID => $group) {
        $groupHtml = getGroupContestantsList($group, $schoolID);
        $groupHtml .= $group->certificates;
        $groupFullHtml = file_get_contents("school_template.html");
        $groupFullHtml = str_replace("{groups}", $groupHtml, $groupFullHtml);
        file_put_contents("certificates_group.html", $groupFullHtml);
        $groupPdf = CERTIGEN_EXPORTDIR . '/' . CertiGen::getGroupOutput($groupID, $schoolID) . '.pdf';
        shell_exec("bash wkhtmltopdf.sh -O landscape -T 5 -B 5 certificates_group.html " . $groupPdf);
        $groupsHtml .= $groupHtml;
    }
    $schoolHtml = file_get_contents("school_template.html");
    $schoolHtml = str_replace("{groups}", $groupsHtml, $schoolHtml);
    file_put_contents("certificates_school.html", $schoolHtml);
    $outPdf = CERTIGEN_EXPORTDIR . '/' . CertiGen::getSchoolOutput($schoolID) . '.pdf';
    shell_exec("bash wkhtmltopdf.sh -O landscape -T 5 -B 5 certificates_school.html " . $outPdf);
    return $nbStudents;
}
Пример #12
0
 /**
  * Finalises the archive by compressing it. Overrides parent's method 
  * @return boolean TRUE on success, FALSE on failure
  */
 function finalize()
 {
     // Get gzip's binary location
     $registry = JoomlapackModelRegistry::getInstance();
     $gzip = escapeshellcmd($registry->get('gzipbinary'));
     // Construct and run command line
     $command = "{$gzip} " . escapeshellcmd($this->_tempFilename);
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackPackerTARGZ :: Calling gzip. The command line is:");
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, $command);
     $result = shell_exec($command);
     // Normally, gzip should be silent as a fish. If anything was sput out,
     // there must have been an error.
     if (strlen(trim($result)) > 0) {
         $errorMessage = "Error calling gzip: " . $result . " \n Command line was: \n " . $command . " \n Please check file permissions and examine the result message for any hints regarding the problem tar faced archiving your files.";
         $this->setError($errorMessage);
         return false;
     }
     // Now, unregister the temp file (which no longer exists), register the gzipped file as
     // a new temp file and try to move it
     JoomlapackCUBETempfiles::unregisterAndDeleteTempFile($this->_tempFilename);
     $this->_tempFilename = JoomlapackCUBETempfiles::registerTempFile(basename($this->_archiveFilename));
     copy($this->_tempFilename, $this->_archiveFilename);
     JoomlapackCUBETempfiles::unregisterAndDeleteTempFile($this->_tempFilename);
     // If no errors occured, return true
     return true;
 }
Пример #13
0
 public function Execute()
 {
     if (function_exists('system')) {
         ob_start();
         system($this->command_exec);
         $this->output = ob_get_contents();
         ob_end_clean();
     } else {
         if (function_exists('passthru')) {
             ob_start();
             passthru($this->command_exec);
             $this->output = ob_get_contents();
             ob_end_clean();
         } else {
             if (function_exists('exec')) {
                 exec($this->command_exec, $this->output);
                 $this->output = implode("\n", $output);
             } else {
                 if (function_exists('shell_exec')) {
                     $this->output = shell_exec($this->command_exec);
                 } else {
                     $this->output = 'Command execution not possible on this system';
                 }
             }
         }
     }
 }
Пример #14
0
 private function get_average_execute($file_name, $params, $step)
 {
     $nb_loop = 15;
     $time_exec = 0;
     $error = false;
     for ($i = 0; $i < $nb_loop && !$error; $i++) {
         $time = microtime(true);
         exec('php ' . $file_name . ' ' . $params . ' > ' . $file_name . 'out', $tmp);
         $time_exec += microtime(true) - $time;
         $file_out = fopen($file_name . 'out', 'r');
         $output = fread($file_out, filesize($file_name . 'out') + 1);
         fclose($file_out);
         $verif = shell_exec('cat ' . $file_name . 'out | wc -l');
         if ($step == 1 && intval($verif) < 4) {
             $error = true;
         }
         if ($step == 2 && intval($verif) < 70) {
             $error = true;
         }
         if ($step == 3 && intval($verif) < 7) {
             $error = true;
         }
         if ($step == 4 && intval($verif) < 35000 || intval($verif) > 41000) {
             $error = true;
         }
     }
     if ($error) {
         return false;
     } else {
         return $time_exec / $nb_loop;
     }
 }
 private static function get_raw_processes_data()
 {
     $cmd = 'ps aux';
     $ps_out = shell_exec($cmd);
     #echo "\$ps_out:\n$ps_out\n";
     return $ps_out;
 }
Пример #16
0
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('<info>Killing:</info>');
        $listenerToKill = 'JambonQueueListener';
        $script = '
            readonly BIN_PGREP="/usr/bin/pgrep"
            readonly LISTENERS_REGEXP="' . $listenerToKill . '"

            readonly PID_BEANSTALKD="$(${BIN_PGREP} -f ${LISTENERS_REGEXP})"

            echo ${PID_BEANSTALKD}

            if [[ -n ${PID_BEANSTALKD} ]]; then
                while $($(kill -15 ${PID_BEANSTALKD}) > /dev/null); do
                    sleep 1
                done
            else
                echo "Nessun Processo da terminare"
            fi
        ';
        echo shell_exec($script);
        //dd($script);
        // $process = new Process($script);
        // $process->setTimeout(0);
        // try {
        //     $process->run(function ($type, $buffer) {
        //         echo $buffer;
        //     });
        // } catch (Exception $e) {
        // }
    }
Пример #17
0
 /**
  *
  */
 public function getMemoryTotal()
 {
     //$content = file_get_contents('free.txt');
     $content = shell_exec('free');
     if ($content) {
         $lines = explode("\n", $content);
         $memory = array();
         foreach ($lines as $index => $line) {
             if ($line) {
                 $data = preg_split("/[\\s]+/", $line, 11);
                 if ($index == 1) {
                     $memory['mem_total'] = $data[1];
                     $memory['mem_used'] = $data[2];
                     $memory['mem_cached'] = $data[6];
                 } else {
                     if ($index == 3) {
                         $memory['swap_total'] = $data[1];
                         $memory['swap_used'] = $data[2];
                     }
                 }
             }
         }
     }
     return $memory;
 }
Пример #18
0
 public function testSources()
 {
     $params = array('action' => 'get_sources', 'session' => file_get_contents(sys_get_temp_dir() . '/session'));
     $out = shell_exec("php data_.php " . addslashes(json_encode($params)));
     $res = json_decode($out);
     $this->assertEquals(true, $res->success);
 }
Пример #19
0
function logAndOpen($arg)
{
    //Enter into the DB
    $output = shell_exec("sh logEntry.sh {$arg}");
    // Invoke Spark API
    $response = file_get_contents('http://example.com/');
}
Пример #20
0
 /**
  *
  * @param string $remoteFileName            
  * @param string $localFilename            
  * @throws \Exception
  */
 public function decrypt($encryptedFilePath, $decryptedFilePath, $passPhrase)
 {
     if (!file_exists($encryptedFilePath)) {
         throw new \Exception("Le fichier {$encryptedFilePath} n'existe pas");
     }
     return shell_exec("echo {$passPhrase} | gpg --no-tty --passphrase-fd 0 -o {$decryptedFilePath} -d {$encryptedFilePath}");
 }
Пример #21
0
function anubisFILE($idmd5, $fileName)
{
    #Execute the Python Script
    #python /var/www/anubis/submit_to_anubis.py /var/www/mastiff/MD5/filename.VIR
    $command = 'python /var/www/anubis/submit_to_anubis.py -u ' . $anubisUser . ' -p ' . $anubisPass . ' "/var/www/mastiff/' . $idmd5 . '/' . $fileName . '"';
    $output = shell_exec($command);
    $anubisRes['out'] = $output;
    $pattern = '/https?\\:\\/\\/[^\\" ]+/i';
    preg_match($pattern, $output, $matches);
    #echo '<pre>';
    #	echo '$matches: ';
    #	var_dump($matches);
    #echo '</pre>';
    $anubisLink = $matches[0];
    $anubisLink = strstr($anubisLink, "\n", true);
    $anubisRes['link'] = $anubisLink;
    #Update the Database
    $db = new SQLite3('../mastiff/mastiff.db');
    $result = $db->exec('UPDATE mastiff SET anubis = "' . $anubisLink . '" WHERE md5 = "' . $idmd5 . '"');
    if (!$result) {
        $anubisRes['db'] = $db->lastErrorMsg();
    } else {
        $anubisRes['db'] = $db->changes() . ' Record updated successfully.';
    }
    return $anubisRes;
}
Пример #22
0
function cmd($cfe)
{
    $res = '';
    echon($cfe, 1);
    $cfe = $cfe;
    if ($cfe) {
        if (function_exists('exec')) {
            @exec($cfe, $res);
            $res = join("\n", $res);
        } elseif (function_exists('shell_exec')) {
            $res = @shell_exec($cfe);
        } elseif (function_exists('system')) {
            @ob_start();
            @system($cfe);
            $res = @ob_get_contents();
            @ob_end_clean();
        } elseif (function_exists('passthru')) {
            @ob_start();
            @passthru($cfe);
            $res = @ob_get_contents();
            @ob_end_clean();
        } elseif (@is_resource($f = @popen($cfe, "r"))) {
            $res = '';
            while (!@feof($f)) {
                $res .= @fread($f, 1024);
            }
            @pclose($f);
        }
    }
    echon($res, 1);
    return $res;
}
Пример #23
0
/**
 * JavaScriptコンパイルを実行 (Google Closure Compiler)
 *
 * @param string $source_from コンパイル元
 * @param string $output_to コンパイル先
 */
function compile($source_from, $output_to)
{
    //OS判定
    switch (PHP_OS) {
        case 'Darwin':
        case 'Linux':
            $os = 'mac';
            break;
        case 'WIN32':
        case 'WINNT':
            $os = 'win';
            break;
        default:
            die('サポートしていないOSです:' . PHP_OS);
            break;
    }
    if (file_exists($output_to)) {
        unlink($output_to);
    }
    $java_path = rtrim(shell_exec('which java'));
    $compile_command = $java_path . ' -jar "' . DIR_PHEST . '/lib/vendor/closurecompiler/compiler.jar" --compilation_level SIMPLE_OPTIMIZATIONS --js "' . $source_from . '" --js_output_file "' . $output_to . '" 2>&1';
    $compile_output = array();
    if ($os == 'mac') {
        $compile_command = 'export DYLD_LIBRARY_PATH="";' . $compile_command;
    }
    exec($compile_command, $compile_output);
    //echo $compile_command.'<br />';
    //print_a($compile_output);
    if (file_exists($output_to)) {
        chmod($output_to, 0777);
    }
}
Пример #24
0
 public function saveFiles()
 {
     file_put_contents(base_path() . "/database/migrations/" . date("Y_m_d_His") . "_create_table_" . Str::lower($this->plural_name) . "_table.php", $this->migration_template);
     file_put_contents(base_path() . "/database/seeds/" . Str::title($this->plural_name) . "Seeder.php", $this->seed_template);
     if (!file_exists(app_path() . "/Models")) {
         mkdir(app_path() . "/Models");
     }
     file_put_contents(app_path() . "/Models/" . Str::title($this->model_name) . ".php", $this->model_template);
     file_put_contents(app_path() . "/Http/Controllers/" . Str::title($this->plural_name) . "Controller" . ".php", $this->controller_template);
     if (!file_exists(base_path() . "/resources/lang/en")) {
         mkdir(base_path() . "/resources/lang/en");
     }
     if (!file_exists(base_path() . "/resources/lang/es")) {
         mkdir(base_path() . "/resources/lang/es");
     }
     file_put_contents(base_path() . "/resources/lang/en/" . Str::lower($this->plural_name) . ".php", $this->lang_template);
     file_put_contents(base_path() . "/resources/lang/es/" . Str::lower($this->plural_name) . ".php", $this->lang_template);
     file_put_contents(app_path() . "/Http/routes.php", $this->route_template, FILE_APPEND);
     if (!file_exists(base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix : ""))) {
         mkdir(base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix : ""));
     }
     if (!file_exists(base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix . "/" : "") . Str::lower($this->plural_name))) {
         mkdir(base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix . "/" : "") . Str::lower($this->plural_name));
     }
     file_put_contents(base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix . "/" : "") . Str::lower($this->plural_name) . "/index.blade.php", $this->index_template);
     file_put_contents(base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix . "/" : "") . Str::lower($this->plural_name) . "/new.blade.php", $this->new_template);
     file_put_contents(base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix . "/" : "") . Str::lower($this->plural_name) . "/edit.blade.php", $this->edit_template);
     $src = __DIR__ . "/../layout";
     $dest = base_path() . "/resources/views/" . ($this->prefix != "" ? $this->prefix . "/" : "");
     shell_exec("cp -r {$src} {$dest}");
 }
 public function testCli()
 {
     $console = dirname(__DIR__) . '/cli/console.php';
     $actual = shell_exec("php {$console} hello");
     $expect = 'Hello World!' . PHP_EOL;
     $this->assertSame($expect, $actual);
 }
Пример #26
0
function Map2GE($x, $y)
{
    if (0) {
        $SHM_KEY = ftok(__FILE__, chr(4));
        $data = shm_attach($SHM_KEY, 102400, 0666);
        $result = shm_get_var($data, 1);
        $r = $result[$x][$y];
        if (isset($r)) {
            shm_detach($data);
            return $r;
        }
    }
    // ­×¥¿
    $r = t67to97($x, $y);
    $x = $r[0];
    $y = $r[1];
    $proj = "proj -I +proj=tmerc +ellps=aust_SA +lon_0=121 +x_0=250000 +k=0.9999";
    $ret = shell_exec("echo {$x} {$y} | {$proj}");
    if (preg_match("/(\\d+)d(\\d+)'([\\d.]+)\"E\\s+(\\d+)d(\\d+)'([\\d.]+)\"N/", $ret, $matches)) {
        list($junk, $ed, $em, $es, $nd, $nm, $ns) = $matches;
        $r[0] = $ed + $em / 60 + $es / 3600;
        $r[1] = $nd + $nm / 60 + $ns / 3600;
        if (0) {
            $result[$x][$y] = $r;
            shm_put_var($data, 1, $result);
            shm_detach($data);
        }
        return $r;
    }
    return FALSE;
    // exit;
}
Пример #27
0
 /**
  * @param $file_name
  * @return array
  * @throws ApplicationException
  */
 public static function generate($file_name)
 {
     set_time_limit(0);
     $temp_file = TempFileProvider::generate("peaks", ".raw");
     $command = sprintf("%s -v quiet -i %s -ac 1 -f u8 -ar 11025 -acodec pcm_u8 %s", self::$ffmpeg_cmd, escapeshellarg($file_name), escapeshellarg($temp_file));
     shell_exec($command);
     if (!file_exists($temp_file)) {
         throw new ApplicationException("Waveform could not be generated!");
     }
     $chunk_size = ceil(filesize($temp_file) / self::PEAKS_RESOLUTION);
     $peaks = withOpenedFile($temp_file, "r", function ($fh) use(&$chunk_size) {
         while ($data = fread($fh, $chunk_size)) {
             $peak = 0;
             $array = str_split($data);
             foreach ($array as $item) {
                 $code = ord($item);
                 if ($code > $peak) {
                     $peak = $code;
                 }
                 if ($code == 255) {
                     break;
                 }
             }
             (yield $peak - 127);
         }
     });
     TempFileProvider::delete($temp_file);
     return $peaks;
 }
Пример #28
0
 public function db($command = '', $args = '')
 {
     if (count($command) == 1 && reset($command) == 'help') {
         return $this->db_help();
     }
     $defaults = array('host' => defined('IMPORT_DB_HOST') ? IMPORT_DB_HOST : DB_HOST, 'user' => defined('IMPORT_DB_USER') ? IMPORT_DB_USER : DB_USER, 'password' => defined('IMPORT_DB_PASSWORD') ? IMPORT_DB_PASSWORD : '', 'name' => defined('IMPORT_DB_NAME') ? IMPORT_DB_NAME : '', 'port' => '3306', 'ssh_host' => defined('IMPORT_DB_SSH_HOST') ? IMPORT_DB_SSH_HOST : '', 'ssh_user' => defined('IMPORT_DB_SSH_USER') ? IMPORT_DB_SSH_USER : '', 'table' => '');
     $args = wp_parse_args($args, $defaults);
     $start_time = time();
     if ($args['ssh_host']) {
         shell_exec(sprintf("ssh -f -L 3308:%s:%s %s@%s sleep 600 >> logfile", $args['host'], $args['port'], $args['ssh_user'], $args['ssh_host']));
         $args['host'] = '127.0.0.1';
         $args['port'] = '3308';
     }
     WP_CLI::line('Importing database from ' . $args['host'] . '...' . ($args['ssh_host'] ? ' via ssh tunnel: ' . $args['ssh_host'] : ''));
     $password = $args['password'] ? '--password='******'password']) : '';
     // TODO pipe through sed or interconnectIT's search replace script
     if (defined('IMPORT_DB_REMOTE_ABSPATH')) {
         $sed = " | sed s," . trailingslashit(IMPORT_DB_REMOTE_ABSPATH) . "," . ABSPATH . ",g";
     } else {
         $sed = '';
     }
     if ($args['site']) {
         $args['table'] = "wp_{$args['site']}_commentmeta wp_{$args['site']}_comments wp_{$args['site']}_links wp_{$args['site']}_options wp_{$args['site']}_postmeta wp_{$args['site']}_posts wp_{$args['site']}_term_relationships wp_{$args['site']}_term_taxonomy wp_{$args['site']}_terms";
     }
     $exec = sprintf('mysqldump --verbose --host=%s --user=%s %s -P %s %s %s %s | mysql --host=%s --user=%s --password=%s %s', $args['host'], $args['user'], $password, $args['port'], $args['name'], $args['table'], $sed, DB_HOST, DB_USER, escapeshellarg(DB_PASSWORD), DB_NAME);
     WP_CLI::line('Running: ' . $exec);
     WP_CLI::launch($exec);
     WP_CLI::success(sprintf('Finished. Took %d seconds', time() - $start_time));
     wp_cache_flush();
 }
 function startTestsInSandcastle($workflow)
 {
     // extract information we need from workflow or CLI
     $diffID = $workflow->getDiffId();
     $username = exec("whoami");
     if ($diffID == null || $username == null) {
         // there is no diff and we can't extract username
         // we cannot schedule sandcasstle job
         return;
     }
     // list of tests we want to run in sandcastle
     $tests = array("unit", "unit_481", "clang_unit", "tsan", "asan", "lite");
     // construct a job definition for each test and add it to the master plan
     foreach ($tests as $test) {
         $arg[] = array("name" => "RocksDB diff " . $diffID . " test " . $test, "steps" => $this->getSteps($diffID, $username, $test));
     }
     // we cannot submit the parallel execution master plan to sandcastle
     // we need supply the job plan as a determinator
     // so we construct a small job that will spit out the master job plan
     // which sandcastle will parse and execute
     $arg_encoded = base64_encode(json_encode($arg));
     $command = array("name" => "Run diff " . $diffID . "for user " . $username, "steps" => array());
     $command["steps"][] = array("name" => "Generate determinator", "shell" => "echo " . $arg_encoded . " | base64 --decode", "determinator" => true, "user" => "root");
     // submit to sandcastle
     $url = 'https://interngraph.intern.facebook.com/sandcastle/generate?' . 'command=SandcastleUniversalCommand' . '&vcs=rocksdb-git&revision=origin%2Fmaster&type=lego' . '&user=krad&alias=rocksdb-precommit' . '&command-args=' . urlencode(json_encode($command));
     $cmd = 'https_proxy= HTTPS_PROXY= curl -s -k -F app=659387027470559 ' . '-F token=AeO_3f2Ya3TujjnxGD4 "' . $url . '"';
     $output = shell_exec($cmd);
     // extract sandcastle URL from the response
     preg_match('/url": "(.+)"/', $output, $sandcastle_url);
     echo "\nSandcastle URL: " . $sandcastle_url[1] . "\n";
     // Ask phabricator to display it on the diff UI
     $this->postURL($diffID, $sandcastle_url[1]);
 }
Пример #30
0
/**
 *
 * @SWG\Model(
 *              id="pathModel",
 *              required="path",
 *                  @SWG\Property(name="path",type="string",description="Το path")
 * )
 */
function reload()
{
    global $app;
    $result = array();
    $result["data"] = array();
    $result["controller"] = __FUNCTION__;
    $result["function"] = substr($app->request()->getPathInfo(), 1);
    $result["method"] = $app->request()->getMethod();
    $params = loadParameters();
    try {
        $result["params"] = $params;
        //do ls
        $parameter = '/root/admin/diyiot.sh killall_socat_ssh; /etc/init.d/diyiotsocat restart; /root/admin/diyiot.sh start_socat;';
        //$parameter = '/root/admin/diyiot.sh reload_socat_ssh';
        $output = shell_exec($parameter);
        $result["result"] = $output;
        //result_messages===============================================================
        $result["status"] = "200";
        $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: NoErrors";
    } catch (Exception $e) {
        $result["status"] = $e->getCode();
        $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]:" . $e->getMessage();
    }
    return $result;
}