private function canRunLynx() { $this->loadConfiguration(); $cmd = escapeshellcmd(Tools::confParam('path_to_lynx')) . ' --help'; exec($cmd, $output, $statusCode); return $statusCode == 0; }
public static function createSymbolicLink($rootDir = null) { IS_MULTI_MODULES || exit('please set is_multi_modules => true'); $deper = Request::isCli() ? PHP_EOL : '<br />'; echo "{$deper}**************************create link start!*********************{$deper}"; echo '|' . str_pad('', 64, ' ', STR_PAD_BOTH) . '|'; is_null($rootDir) && ($rootDir = ROOT_PATH . DIRECTORY_SEPARATOR . 'web'); is_dir($rootDir) || mkdir($rootDir, true, 0700); //modules_static_path_name // 递归遍历目录 $dirIterator = new \DirectoryIterator(APP_MODULES_PATH); foreach ($dirIterator as $file) { if (!$file->isDot() && $file->isDir()) { $resourceDir = $file->getPathName() . DIRECTORY_SEPARATOR . Config::get('modules_static_path_name'); if (is_dir($resourceDir)) { $distDir = ROOT_PATH . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . $file->getFilename(); $cmd = Request::operatingSystem() ? "mklink /d {$distDir} {$resourceDir}" : "ln -s {$resourceDir} {$distDir}"; exec($cmd, $result); $tip = "create link Application [{$file->getFilename()}] result : [" . (is_dir($distDir) ? 'true' : 'false') . "]"; $tip = str_pad($tip, 64, ' ', STR_PAD_BOTH); print_r($deper . '|' . $tip . '|'); } } } echo $deper . '|' . str_pad('', 64, ' ', STR_PAD_BOTH) . '|'; echo "{$deper}****************************create link end!**********************{$deper}"; }
public function shareBugglAction(Request $request) { $prevEmails = ''; $invalidMessage = ''; if ($request->isMethod('POST')) { $invalidEmails = array(); $validEmails = array(); $prevEmails = $request->request->get('emails', ''); $localReferenceService = $this->get('buggl_main.local_reference_service'); $validationData = $localReferenceService->validateEmails($prevEmails); $invalidMessage = $validationData['invalidMessage']; if (empty($invalidMessage)) { $shareService = $this->get('buggl_main.share'); $user = $this->get('security.context')->getToken()->getUser(); foreach ($validationData['validEmails'] as $key => $email) { $share = $shareService->saveShareInfo($email, $user); } $prevEmails = ''; exec('../app/console buggl:email_shares > /dev/null 2>&1 &'); $streetCreditService = $this->get('buggl_main.street_credit'); $streetCreditService->updateShareStatus($user); $this->get('session')->getFlashBag()->add('success', "Emails sent!"); } } $localAuthor = $this->get('security.context')->getToken()->getUser(); //$streetCredit = $this->getDoctrine()->getRepository("BugglMainBundle:StreetCredit")->findOneByLocalAuthor($localAuthor); $newEGuideRequestCount = $this->getDoctrine()->getEntityManager()->getRepository('BugglMainBundle:MessageToUser')->countRequestByStatus($localAuthor, array('0' => '0')); $data = array('invalidMessage' => $invalidMessage, 'prevEmails' => $prevEmails, 'newRequestCount' => $newEGuideRequestCount); return $this->render('BugglMainBundle:LocalAuthor\\EarnMore:shareBuggl.html.twig', $data); }
/** * Load metadata about an HTML document using Aperture. * * @param string $htmlFile File on disk containing HTML. * * @return array */ protected static function getApertureFields($htmlFile) { $xmlFile = tempnam('/tmp', 'apt'); $cmd = static::getApertureCommand($htmlFile, $xmlFile, 'filecrawler'); exec($cmd); // If we failed to process the file, give up now: if (!file_exists($xmlFile)) { throw new \Exception('Aperture failed.'); } // Extract and decode the full text from the XML: $xml = str_replace(chr(0), ' ', file_get_contents($xmlFile)); @unlink($xmlFile); preg_match('/<plainTextContent[^>]*>([^<]*)</ms', $xml, $matches); $final = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : ''; // Extract the title from the XML: preg_match('/<title[^>]*>([^<]*)</ms', $xml, $matches); $title = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : ''; // Extract the keywords from the XML: preg_match_all('/<keyword[^>]*>([^<]*)</ms', $xml, $matches); $keywords = []; if (isset($matches[1])) { foreach ($matches[1] as $current) { $keywords[] = trim(html_entity_decode($current, ENT_QUOTES, 'UTF-8')); } } // Extract the description from the XML: preg_match('/<description[^>]*>([^<]*)</ms', $xml, $matches); $description = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : ''; // Send back the extracted fields: return ['title' => $title, 'keywords' => $keywords, 'description' => $description, 'fulltext' => $final]; }
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]); }
public function guideShareAction(Request $request) { $slug = $request->get('slug'); $eguide = $this->getDoctrine()->getRepository('BugglMainBundle:EGuide')->findOneBySlug($slug); $localAuthor = $this->get('security.context')->getToken()->getUser(); if (is_null($eguide) || $eguide->getLocalAuthor()->getId() != $localAuthor->getId()) { $this->get('session')->setFlash('error', 'The guide does not exist or is not yours!'); return new RedirectResponse($this->generateUrl('local_author_dashboard')); } $socialMedia = $this->get('buggl_main.entity_repository')->getRepository('BugglMainBundle:SocialMedia')->findByLocalAuthor($localAuthor); $prevEmails = ''; $invalidMessage = ''; if ($request->isMethod('POST')) { $invalidEmails = array(); $validEmails = array(); $prevEmails = $request->request->get('emails', ''); // TODO: maybe refactor email validation in a separate service $localReferenceService = $this->get('buggl_main.local_reference_service'); $validationData = $localReferenceService->validateEmails($prevEmails); $invalidMessage = $validationData['invalidMessage']; if (empty($invalidMessage)) { $prevEmails = ''; exec('../app/console buggl:guide_share_email ' . implode(',', $validationData['validEmails']) . ' ' . $eguide->getId() . ' > /dev/null 2>&1 &'); $this->get('session')->getFlashBag()->add('success', "Guide has been shared!"); return new RedirectResponse($this->generateUrl('e_guide_share', array('slug' => $eguide->getSlug()))); } } $data = array('eguide' => $eguide, 'socialMedia' => $socialMedia, 'invalidMessage' => $invalidMessage, 'prevEmails' => $prevEmails); return $this->render('BugglMainBundle:LocalAuthor/EGuideShare:share.html.twig', $data); }
function execute($subpage) { global $wgOut, $wgRequest, $wgNotAValidWikia, $IP; $redirect = $wgNotAValidWikia; $wikia = $wgRequest->getText('wikia'); $art = $wgRequest->getText('article'); if (!empty($wikia)) { $iCityId = self::isWikiExists($wikia); if ($iCityId) { //wiki exists $redirect = self::getCityUrl($iCityId); if (empty($art)) { //no article set - redir to the main page $output = null; exec("'echo Title::newMainPage();' | SERVER_ID={$iCityId} php {$IP}/maintenance/eval.php --conf /usr/wikia/docroot/wiki.factory/LocalSettings.php", $output); if (count($output)) { $redirect .= '/index.php?title=' . $output[0]; } } else { //article provided $redirect .= '/index.php?title=' . $art; } } } // $wgOut->SetPageTitle(wfMsg('interwikidispatcher')); $wgOut->redirect($redirect, 301); }
public function plist($plist, $setting, $value = '') { if ($value == '') { return exec("defaults read '{$plist}' '{$setting}'"); } return exec("defaults write '{$plist}' '{$setting}' '{$value}'"); }
public function toWebM() { $options = " -i {$this->video->getTmpFolder()}{$this->video->getName()} -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis {$this->video->getTmpFolder()}{$this->video->getName()}.webm"; exec(__DIR__ . "/resources/{$this->sistema_operacional}{$options}"); $this->versions[] = ".webm"; return $this; }
private function execute2($command) { $output = array(); $ret = 0; exec($command, $output, $ret); return $output; }
/** * @depends GLPIInstallTest::installDatabase */ public function testInstall() { global $DB; $DB->connect(); $this->assertTrue($DB->connected, "Problem connecting to the Database"); // Delete if Table of FusionInventory or Tracker yet in DB $query = "SHOW FULL TABLES WHERE TABLE_TYPE LIKE 'VIEW'"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { if (strstr($data[0], "fusi")) { $DB->query("DROP VIEW " . $data[0]); } } $query = "SHOW TABLES"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { if (strstr($data[0], "tracker") or strstr($data[0], "fusi")) { $DB->query("DROP TABLE " . $data[0]); } } $output = array(); $returncode = 0; exec("php -f " . FUSINV_ROOT . "/scripts/cli_install.php -- --as-user 'glpi'", $output, $returncode); $this->assertEquals(0, $returncode, "Error when installing plugin in CLI mode\n" . implode("\n", $output)); $GLPIlog = new GLPIlogs(); $GLPIlog->testSQLlogs(); $GLPIlog->testPHPlogs(); $FusinvDBTest = new FusinvDB(); $FusinvDBTest->checkInstall("fusioninventory", "install new version"); PluginFusioninventoryConfig::loadCache(); }
public function run($path = '.') { chdir($path); $command = $this->phpspec . ' ' . $this->phpspec_options; exec($command, $return, $status); if ($status != 0) { $this->expiration_in_secs = 5; $this->notify("Error running test", $return[1], $this->fail_image); } else { $output = join("\n", $return); echo $output; foreach ($return as $line) { if (preg_match('/^([0-9]+) example/', $line, $matches)) { $examples = $matches[1]; preg_match('/([0-9]+) failure/', $line, $matches); $failures = $matches[1]; preg_match('/([0-9]+) pending/', $line, $matches); $pendings = $matches[1]; } } if ($failures > 0) { $this->notify("Tests Failed", $failures . "/" . $examples . ($failures == 1 ? " test failed" : " tests failed"), $this->fail_image); } elseif ($pendings > 0) { $this->notify("Tests Pending", $pendings . "/" . $examples . ($pendings == 1 ? " test is pending" : " tests are pending"), $this->pending_image); } else { $this->notify("Tests Passed", "All " . $examples . " tests passed", $this->success_image); } } }
function new_pic() { $inpId = $this->input->post('inpId'); $inpVal = $this->input->post('inpValue'); $cid = $this->session->userdata['profile_data'][0]['custID']; $filepath = $_SERVER['DOCUMENT_ROOT'] . "/uploads/"; $name = $this->session->userdata['profile_data'][0]['custID'] . '_' . $_FILES['profile_pic']['name']; $size = $_FILES['profile_pic']['size']; $photo_type = $_FILES['profile_pic']['type']; $tmp = $_FILES['profile_pic']['tmp_name']; $upload_image = $filepath . basename($_FILES['profile_pic']['name']); $thumbnail = $filepath . 'small_' . $name; $actual = $filepath . $name; $newwidth = "200"; $newheight = "200"; if (move_uploaded_file($_FILES['profile_pic']['tmp_name'], $upload_image)) { exec('convert ' . $upload_image . ' -resize ' . $newwidth . 'x' . $newheight . '^ ' . $thumbnail); rename($upload_image, $actual); /* unlink("uploads/".$this->session->userdata['profile_data'][0]['photo']); unlink("uploads/small_".$this->session->userdata['profile_data'][0]['photo']); $data=array( 'photo' => $name ); $this->session->set_userdata("profile_data[0]['photo']",$name); */ echo "uploaded" . $_SERVER['DOCUMENT_ROOT']; } else { echo "not_uploaded"; } $sql_11 = "UPDATE `personaldata` SET `PerdataProfPict`='{$name}' WHERE `custID`='{$cid}'"; $this->db->query($sql_11); $sql_22 = "UPDATE `personalphoto` SET `photo`='{$name}' WHERE `custID`='{$cid}'"; $this->db->query($sql_22); $this->update_joomla('avatar', $name); echo $this->db->affected_rows(); }
public function verifyError() { $path = $this->getBasePath() . $this->getParam(self::PATH, null); $allowedStatuses = $this->getParam(self::STATUS); if (!file_exists($path)) { return; } exec("tail -n {$this->getParam(self::COUNT)} {$path}", $tail); if (count($tail) == 0) { return; } $log = $buffer = array(); foreach (array_reverse($tail) as $str) { $buffer[] = $str; if (preg_match('#\\d{4}/\\d{2}/\\d{2}#', $str)) { $log[] = implode("\r\n", array_reverse($buffer)); $buffer = array(); } } $allowedTime = $this->getParam(self::TIME); foreach ($log as $l) { $status = $this->showStatus($l); $date = strtotime($this->showDate($l)); if (in_array($status, $allowedStatuses) && time() - $date < $allowedTime) { $error = $this->showError($l); $this->getHandler()->addErrorHandle($error, $this->showStack($l), $this->getStateType()); } } }
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; }
public function getHarFile(UriInterface $uri, $timeout = 1000) { $command = $this->phantomJSExec . ' ' . $this->netSniffTempFile . ' ' . (string) $uri . " " . $timeout; $timeoutCommand = ''; if (`which timeout`) { $timeoutCommand = "timeout " . $this->commandTimeoutInSeconds . " "; } else { if (`which gtimeout`) { $timeoutCommand = "gtimeout " . $this->commandTimeoutInSeconds . " "; } } exec($timeoutCommand . $command, $output, $exitCode); $rawOutput = implode($output, "\n"); if ($exitCode > 0) { $e = new PhantomJsRuntimeException('Phantom exits with exit code ' . $exitCode . PHP_EOL . $rawOutput); $e->setExitCode($exitCode); throw $e; } $harStart = strpos($rawOutput, '##HARFILE-BEGIN') + 16; $harEnd = strpos($rawOutput, '##HARFILE-END'); $harLength = $harEnd - $harStart; $harContent = substr($rawOutput, $harStart, $harLength); $htmlStart = strpos($rawOutput, '##CONTENT-BEGIN') + 15; $htmlEnd = strpos($rawOutput, '##CONTENT-END'); $htmlLength = $htmlEnd - $htmlStart; $htmlContent = substr($rawOutput, $htmlStart, $htmlLength); return array('harFile' => new HarArchive(json_decode($harContent)), 'html' => $htmlContent); }
/** * {@inheritdoc} */ public function run(JobInterface $job, $data) { // Data format: // i) array('patch_file' => '...', 'patch_dir' => '...') // or // iii) array(array(...), array(...)) // Normalize data to the third format, if necessary $data = count($data) == count($data, COUNT_RECURSIVE) ? [$data] : $data; $job->getOutput()->writeln("<info>Entering setup_patch().</info>"); foreach ($data as $key => $details) { if (empty($details['patch_file'])) { $job->errorOutput("Error", "No valid patch file provided for the patch command."); return; } $workingdir = realpath($job->getWorkingDir()); $patchfile = $details['patch_file']; $patchdir = !empty($details['patch_dir']) ? $details['patch_dir'] : $workingdir; // Validate target directory. if (!($directory = $this->validate_directory($job, $patchdir))) { // Invalid checkout directory $job->errorOutput("Error", "The patch directory <info>{$directory}</info> is invalid."); return; } $cmd = "patch -p1 -i {$patchfile} -d {$directory}"; exec($cmd, $cmdoutput, $result); if ($result !== 0) { // The command threw an error. $job->errorOutput("Patch failed", "The patch attempt returned an error."); $job->getOutput()->writeln($cmdoutput); // TODO: Pass on the actual return value for the patch attempt return; } $job->getOutput()->writeln("<comment>Patch <options=bold>{$patchfile}</options=bold> applied to directory <options=bold>{$directory}</options=bold></comment>"); } }
function planwatch_mark_all_unread() { if (user_is_valid($_SERVER['USERINFO_ARRAY']['username'], $_SERVER['USERINFO_ARRAY']['userpass']) && is_dir($_SERVER['USER_ROOT'])) { exec("rm -f {$_SERVER['USER_ROOT']}/lastread.dat"); } redirect("/"); }
public static function processemail($emailsrc, $pdfout, $coverfile = '') { $combfilelist = array(); # Process the email $emailparts = Mail_mimeDecode::decode(array('include_bodies' => true, 'decode_bodies' => true, 'decode_headers' => true, 'input' => file_get_contents($emailsrc), 'crlf' => "\r\n")); # Process the cover if it exists if ($coverfile !== '') { $combfilelist[] = self::processpart(file_get_contents($coverfile), mime_content_type($coverfile)); } # Process the parts $combfilelist = array_merge($combfilelist, self::processparts($emailparts)); # Create an intermediate file to build the pdf $tmppdffilename = sys_get_temp_dir() . '/e2p-' . (string) abs((int) (microtime(true) * 100000)) . '.pdf'; # Build the command to combine all of the intermediate files into one $conbcom = str_replace(array_merge(array('INTFILE', 'COMBLIST'), array_keys(self::$driver_paths)), array_merge(array($tmppdffilename, implode(' ', $combfilelist)), array_values(self::$driver_paths)), self::$mime_drivers['gs']); exec($conbcom); # Remove the intermediate files foreach ($combfilelist as $combfilename) { unlink($combfilename); } # Write the intermediate file to the final destination $intfileres = fopen($tmppdffilename, 'rb'); $outfileres = fopen($pdfout, 'ab'); while (!feof($intfileres)) { fwrite($outfileres, fread($intfileres, 8192)); } fclose($intfileres); fclose($outfileres); # Remove the intermediate file unlink($tmppdffilename); }
/** * Get last commit time of each file in the Git repository. */ private function getLastCommitTime() { // Execute command for get list with file name and mtime from GIT log $command = "git log --format='format:%ai' --name-only"; exec($command, $output, $return); if ($return != 0) { $this->logError("Can not execute command %s in exec", $command); } // Find latest mtime for each file from $output. // Note: Each line is either: // * an empty line // * a timestamp // * a filename. $commit_date = ''; foreach ($output as $line) { if (preg_match('/^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2} [+\\-]\\d{4}$/', $line)) { $commit_date = strtotime($line); } else { if ($line !== '') { $file_name = $line; if (!isset($this->myLastCommitTime[$file_name]) || $this->myLastCommitTime[$file_name] < $commit_date) { $this->myLastCommitTime[$file_name] = $commit_date; } } } } }
/** * Start the commandline to send a newsletter * This is offloaded because it could take a while and/or resources * * @param Newsletter $entity Newsletter entity to be processed * * @return void */ function newsletter_start_commandline_sending(Newsletter $entity) { if (!empty($entity) && elgg_instanceof($entity, "object", Newsletter::SUBTYPE)) { // prepare commandline settings $settings = array("entity_guid" => $entity->getGUID(), "host" => $_SERVER["HTTP_HOST"], "memory_limit" => ini_get("memory_limit"), "secret" => newsletter_generate_commanline_secret($entity->getGUID())); if (isset($_SERVER["HTTPS"])) { $settings["https"] = $_SERVER["HTTPS"]; } // ini settings $ini_param = ""; $ini_file = php_ini_loaded_file(); if (!empty($ini_file)) { $ini_param = "-c " . $ini_file . " "; } // which script to run $script_location = dirname(dirname(__FILE__)) . "/procedures/cli.php"; // convert settings to commandline params $query_string = http_build_query($settings, "", " "); // start the correct commandline if (PHP_OS === "WINNT") { pclose(popen("start /B php " . $ini_param . $script_location . " " . $query_string, "r")); } else { exec("php " . $ini_param . $script_location . " " . $query_string . " > /dev/null &"); } } }
public function execute($message) { global $api; global $t; $t->setPlugin("youtube"); switch (strtolower($message->getCommand())) { case "dlv": $api->sendVideo($message->chat->id, $data[0]); break; case "vid2mp3": $url = $message->getData(); $url = $url[0]; if (filter_var($url, FILTER_VALIDATE_URL)) { $url = $this->expand_url($url); if (strpos($url, "youtube") !== false) { $file = $this->download($url, $message); $data = file_get_contents($file); $tmpname = "plugins/youtube/downloads/" . str_replace(" ", "_", microtime()); file_put_contents($tmpname, $data); $batch = "avconv -i " . $tmpname . " -threads auto -vn -c:a libmp3lame -qscale:a 3 " . $tmpname . ".mp3"; exec($batch); $audio = file_get_contents($tmpname . ".mp3"); exec("rm " . $tmpname); $api->sendAudio($message->chat->id, $tmpname . ".mp3"); exec("rm " . $tmpname . ".mp3"); exit; } } $api->sendMessage($message->chat->id, $t->g("invalid_url")); break; } }
/** * The main entry point method. */ public function main() { $path = $this->path; // shortcut $result = exec("svn status {$path}"); $this->project->setProperty($this->result, $result); }
/** * Extract a frame from a movie file. Valid movie_options are start_time (in seconds), * input_args (extra ffmpeg input args) and output_args (extra ffmpeg output args). Extra args * are added at the end of the list, so they can override any prior args. * * @param string $input_file * @param string $output_file * @param array $movie_options (optional) */ static function extract_frame($input_file, $output_file, $movie_options = null) { $ffmpeg = movie::find_ffmpeg(); if (empty($ffmpeg)) { throw new Exception("@todo MISSING_FFMPEG"); } list($width, $height, $mime_type, $extension, $duration) = movie::get_file_metadata($input_file); if (isset($movie_options["start_time"]) && is_numeric($movie_options["start_time"])) { $start_time = max(0, $movie_options["start_time"]); // ensure it's non-negative } else { $start_time = module::get_var("gallery", "movie_extract_frame_time", 3); // use default } // extract frame at start_time, unless movie is too short $start_time_arg = $duration >= $start_time + 0.1 ? "-ss " . movie::seconds_to_hhmmssdd($start_time) : ""; $input_args = isset($movie_options["input_args"]) ? $movie_options["input_args"] : ""; $output_args = isset($movie_options["output_args"]) ? $movie_options["output_args"] : ""; $cmd = escapeshellcmd($ffmpeg) . " {$input_args} -i " . escapeshellarg($input_file) . " -an {$start_time_arg} -an -r 1 -vframes 1" . " -s {$width}x{$height}" . " -y -f mjpeg {$output_args} " . escapeshellarg($output_file) . " 2>&1"; exec($cmd, $exec_output, $exec_return); clearstatcache(); // use $filename parameter when PHP_version is 5.3+ if (filesize($output_file) == 0 || $exec_return) { // Maybe the movie needs the "-threads 1" argument added // (see http://sourceforge.net/apps/trac/gallery/ticket/1924) $cmd = escapeshellcmd($ffmpeg) . " -threads 1 {$input_args} -i " . escapeshellarg($input_file) . " -an {$start_time_arg} -an -r 1 -vframes 1" . " -s {$width}x{$height}" . " -y -f mjpeg {$output_args} " . escapeshellarg($output_file) . " 2>&1"; exec($cmd, $exec_output, $exec_return); clearstatcache(); if (filesize($output_file) == 0 || $exec_return) { throw new Exception("@todo FFMPEG_FAILED"); } } }
/** * Counting terminal char width * @return int */ private static function getMaxColumns() { if (preg_match_all("/columns.([0-9]+);/", strtolower(@exec('stty -a | grep columns')), $output) && 2 == sizeof($output)) { return $output[1][0]; } return 80; }
/** * Check if are any DNS records corresponding to a given Internet host name or IP address * @param string $hostname Host name or IP address * @return boolean TRUE if any records are found or FALSE if no records were found or if an error occurred */ function checkDNS_record($hostname = '') { $result = false; $hostname = strtolower(trim($hostname)); if ($hostname != '') { if (function_exists('checkdnsrr')) { // Non-Windows platform $result = checkdnsrr($hostname, 'ANY'); } else { // Windows platform $output = null; @exec('nslookup.exe -type=ANY ' . $hostname, $output); if (!empty($output)) { foreach ($output as $line) { if (0 === strpos(strtolower($line), $hostname)) { // DNS record found $result = true; break; } } } } } return $result; }
public function testAction(Application $app, Request $request, $id = null) { $basepath = realpath(__DIR__ . '/../../src/'); $cmd = __DIR__ . "/../../vendor/bin/phpcs --report=checkstyle --standard=PSR2 " . $basepath; exec($cmd, $output); $res = implode("\n", $output); //print_r($res); $start = strpos($res, '<?xml'); $data = substr($res, $start); $files = array(); $xml = simplexml_load_string($data); foreach ($xml->file as $filenode) { $file = new CheckstyleFile(); $relfilename = substr($filenode['name'], strlen($basepath)); $file->setFilename($filenode['name']); $file->setRelativeFilename($relfilename); foreach ($filenode->error as $errornode) { $error = new CheckstyleError(); $error->setLine($errornode['line']); $error->setMessage($errornode['message']); $file->addError($error); } $files[] = $file; } //print_r($files); //exit(); $html = $app['twig']->render('@Dashboard/test.html.twig', array('files' => $files)); return $html; }
public function donateAction() { $this->setAccess('frontend/dashboard/access'); // collect some data $data = []; exec('git-summary', $gitSummary); exec('git log -1 --format=%cd', $gitLastCommit); $key = 'git-time-extractor-file'; $timeStatsFilePath = ROOT_PATH . '/../data/git/stats.csv'; $this->getCache()->getItem($key, $success); if (!$success || !file_exists($timeStatsFilePath)) { exec('git_time_extractor > ' . $timeStatsFilePath); $this->getCache()->setItem($key, 'true'); } if (isset($gitSummary[2]) && isset($gitSummary[4]) && isset($gitSummary[5])) { // summary $data['project_age'] = trim(str_replace('repo age : ', '', $gitSummary[2])); $data['total_commits*'] = trim(str_replace('commits : ', '', $gitSummary[4])); $data['total_project_files'] = trim(str_replace('files : ', '', $gitSummary[5])); } else { $data['project_age'] = ''; $data['total_commits*'] = ''; $data['total_project_files'] = ''; } // changelog $data['last_commit'] = isset($gitLastCommit[0]) ? $gitLastCommit[0] : ''; $stats = fopen($timeStatsFilePath, 'r'); $x = 0; $changelog = []; $totalTime = 0; while (!feof($stats)) { $line = fgetcsv($stats, 1024, ',', '"'); if ($x++ == 0 || count($line) <= 1) { continue; } $changes = explode('---', $line[8]); unset($changes[0]); $changelog[] = ['date' => $line[0], 'changes' => $changes]; $totalTime += $line[3]; } $userRepo = $this->getEntityManager()->getRepository('Auth\\Entity\\Benutzer'); $squadRepo = $this->getEntityManager()->getRepository('Frontend\\Squads\\Entity\\Squad'); $memberRepo = $this->getEntityManager()->getRepository('Frontend\\Squads\\Entity\\Member'); // total user $data['registered_users'] = $userRepo->createQueryBuilder('c')->select('count(c.id)')->getQuery()->getSingleScalarResult(); // total squads $data['total_squads'] = $squadRepo->createQueryBuilder('c')->select('count(c.id)')->getQuery()->getSingleScalarResult(); // total squads $data['total_squad_members'] = $memberRepo->createQueryBuilder('c')->select('count(c.squad)')->getQuery()->getSingleScalarResult(); // total images $data['total_squad_logos'] = $squadRepo->createQueryBuilder('c')->select('count(c.logo)')->where('c.logo IS NOT NULL')->andWhere("c.logo != ''")->getQuery()->getSingleScalarResult(); // total image file size $data['total_squad_logos_size'] = $this->directoryFileSize(ROOT_PATH . '/uploads/logos/'); $viewModel = new ViewModel(); $viewModel->setTemplate('/dashboard/donate.phtml'); $viewModel->setVariable('data', $data); $viewModel->setVariable('changelog', array_reverse($changelog)); $viewModel->setVariable('total_time', $totalTime); return $viewModel; }
public function run() { // prepare Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); // verbose mode? $verbose = $this->getArg('verbose'); $mygassi = $this->getArg('mygassionly'); $limit = $this->getArg('limit'); $product = $this->getArg('product'); if ($limit === false) { $limit = 100; } // check what we're up to if ($this->getArg('import')) { /** @var $importer Codex_Productimport_Model_Import */ $importer = Mage::getModel('codex_productimport/import'); if ($product) { $importer->importSingleProduct($product, false); } else { $importer->importProducts($limit, $mygassi, $verbose); } // clean image cache exec("rm -Rf " . Mage::getBaseDir('media') . '/catalog/product/cache'); } else { if ($this->getArg('dump')) { /** @var $importer Codex_Productimport_Model_Import */ $importer = Mage::getModel('codex_productimport/import'); $importer->dumpProducts($limit, $mygassi, $verbose, $product); } else { $this->usageHelp(); } } }
function get_local_ip() { $preg = "/\\A((([0-9]?[0-9])|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\\.){3}(([0-9]?[0-9])|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\\Z/"; //获取操作系统为win2000/xp、win7的本机IP真实地址 exec("ipconfig", $out, $stats); var_dump($out); foreach ($out as $row) { if (strstr($row, "IP") && strstr($row, ":") && !strstr($row, "IPv6")) { $tmpIp = explode(":", $row); if (preg_match($preg, trim($tmpIp[1]))) { return trim($tmpIp[1]); } } } //获取操作系统为linux类型的本机IP真实地址 exec("ifconfig", $out, $stats); if (isset($out[1]) && strstr($out[1], 'addr:')) { $tmpArray = explode(":", $out[1]); $tmpIp = explode(" ", $tmpArray[1]); if (preg_match($preg, trim($tmpIp[0]))) { return trim($tmpIp[0]); } } return '127.0.0.1'; }