public function actionFind() { if (isset($_POST['flightNumber'])) { $current = date('Y-m-d'); $flightNumber = $_POST['flightNumber']; $criteria = new CDbCriteria(); $criteria->join = 'LEFT JOIN tbl_mry_user ON tbl_mry_plan.userId=tbl_mry_user.userId'; $criteria->addCondition('flightNumber=:flightNumber'); $criteria->params = array(':flightNumber' => $flightNumber); $criteria->order = 'startDate DESC'; $UserModel = User::model(); $total = $UserModel->count($criteria); $pager = new CPagination($total); $pager->pageSize = 10; $pager->applyLimit($criteria); $UserList = $UserModel->findAll($criteria); //删除PASSWORD相关的信息 $dataFormat = new DataFormat(); $format = $dataFormat->format($userList, null, null); $clientFlash = new ClientFlash(); if ($total > 0) { $clientFlash->pushMobile(0, $format); } else { _echo(3, 数据为空); } } }
/** * Parses the page * * @author Art <*****@*****.**> * @return Apache */ protected function parsePage() { $d = new DOMDocument(); @$d->loadhtml($this->raw_html); $xpath = new DOMXPath($d); $versions = $xpath->query('//a[starts-with(@href, "/download/VC14/binaries/")]'); /** @var DOMNode $v */ foreach ($versions as $v) { $c14 = $v->C14N(); if (stripos($c14, '.zip"') !== false && stripos($c14, '-win32-') !== false) { $matches = []; preg_match('~"[/a-z0-9\\-.]+"~i', $c14, $matches); if (!empty($matches)) { $matches = $matches[0]; $link = explode('-win32-', explode('httpd-', $matches)[1])[0]; $this->download_links[$link] = self::HOST . trim($matches, ' "'); } } } if (empty($this->download_links)) { _echo('No download links found.'); } else { _echo(count($this->download_links) . ' Apache HTTPD versions found for download.'); } return $this; }
/** * Downloads a version * * @author Art <*****@*****.**> * @return AbstractBinSetup */ protected function download() { $this->downloader = new Downloader($this->links[$this->version], $this->dest); if ($this->downloader->download()) { _echo('Download successful. Setting up version ' . $this->version); sleep(1); } else { die('Download failed. Aborting setup.'); } return $this; }
/** * Attempts to route a request * * @author Art <*****@*****.**> */ function route() { if (!defined('PHPUNIT_RUNNING')) { $route = trim(strtolower(get(IO::$argv[0]))); $file = DIR_CORE . 'routes' . DIRECTORY_SEPARATOR . $route . '.php'; if (file_exists($file)) { include $file; } else { _echo('The route ' . $route . ' is invalid.'); } } }
/** * Downloads the page * * @author Art <*****@*****.**> * @return PHP */ protected function downloadPage() { _echo('Loading PHP download page'); $this->curl = new cURL(self::HOST . '/download/'); $this->curl->exec(); if ($this->curl->errno() != CURLE_OK) { die('Failed to load PHP download page'); } else { _echo('PHP download page loaded'); $this->raw_html = $this->curl->get(); } return $this; }
/** * Prompts to download a different version * * @author Art <*****@*****.**> * @return BinDownloaderTrait */ protected function promptDownload() { $this->getInstalledVers()->filterLinks(); if (!empty($this->links)) { $version_numbers = array_keys($this->links); _echo('The following versions were found for download (versions already installed are not included): ' . PHP_EOL . "\t" . implode(PHP_EOL . "\t", $version_numbers)); $io = trim(IO::readline('Which version would you like to download? Input N to abort')); if (!$io) { $this->promptDownload(); } elseif ($io == 'n') { die('Aborting.'); } elseif (!isset($this->links[$io])) { _echo('The version you selected is not available for download.'); $this->promptDownload(); } else { $this->version = $io; $this->download(); return $this; } } else { die('There are no versions available to download that aren\'t installed already.'); } return $this; }
function _info($text, $prefix = true) { _echo($text, '[info]: '); }
/** * Copies unzipped contents * * @author Art <*****@*****.**> * @return MySQL */ protected function copy() { $scan = scandir($this->dest_unzip); Format::formatScandir($scan); $dir = null; foreach ($scan as $s) { if (is_dir($this->dest_unzip . $s)) { $dir = $this->dest_unzip . $s; break; } } if (!$dir) { die('Could not find the MySQL source directory in the unzipped files. Aborting.'); } else { _echo('Copying downloaded contents. It\'s usually over 1GB so this might take a while...'); $source = $dir; $this->unzipped_destination = DIR_MYSQL . $this->version; if (!file_exists($this->unzipped_destination . DIRECTORY_SEPARATOR)) { mkdir($this->unzipped_destination . DIRECTORY_SEPARATOR, 777, true); } shell_exec('xcopy /s /e "' . $source . '" "' . $this->unzipped_destination . '"'); $this->unzipped_destination .= DIRECTORY_SEPARATOR; if (file_exists($this->unzipped_destination . 'bin')) { _echo('Copy successful!'); $this->cleanup(); $this->updateSettings(); } else { die('Failed to copy. Terminating setup.'); } } return $this; }
/** * Starts the download * * @author Art <*****@*****.**> * @return bool Whther the download was successful (on the cURL side) */ function download() { if (file_exists($this->dest)) { unlink($this->dest); } $this->fp = fopen($this->dest, 'w'); $this->curl->setopt(CURLOPT_FILE, $this->fp); $this->curl->exec(); fclose($this->fp); $errno = $this->curl->errno(); if ($errno === CURLE_OK) { return true; } else { _echo($this->curl->error()); return false; } }
$hs = "," . $str . ","; $n = "," . $val . ","; $pos = strpos($hs, $n); $_wallet_prev = null; $_wallet_next = null; if ($pos !== false) { $_wallet_prev = wallet_prev($hs, $n); $_wallet_next = wallet_next($hs, $n); } return array("wallet_prev" => $_wallet_prev, "wallet_next" => $_wallet_next); } function _echo($str, $val) { echo "needle: " . $val . "\n"; $res = pagination($str, $val); echo "prev: " . $res["wallet_prev"] . "\n"; echo "next: " . $res["wallet_next"] . "\n"; echo "------------------------------------\n"; } echo "* ******************************** *\n"; echo "* STRING EXPLOSION without explode *\n"; echo "* ******************************** *\n"; echo "\n"; echo "Given Input " . $str . "\n"; echo "____________________________________\n\n"; foreach ($seed["arr"] as $val) { _echo($seed["str"], (string) $val); } $endTime = time(); echo "\n\n"; echo "The calculations took " . (string) ($endTime - $startTime) . "ms!\n\n";
/** * Checks and creates the memcache directory * * @author Art <*****@*****.**> * @return Setup */ function checkMemcache() { if (file_exists(DIR_MEMCACHE)) { _echo('Memcache OK'); } else { $rl = \IO::readline('Memcache not found. Would you like to download it? It\'s an optional module. [Y/N]'); switch ($rl) { case 'y': _echo('Contacting download server...'); new \Setup\Memcache(); break; case 'n': _echo('Memcache skipped'); break; default: return $this->checkMemcache(); } } return $this; }
/** * Generates the actual download links (MySQL has a two-page thing for this) * * @author Art <*****@*****.**> * @return MySQL */ protected function getAcutalLinks() { foreach ($this->download_links as $version => &$download_page) { $html = file_get_contents($download_page); if ($html) { $domdoc = new DOMDocument(); @$domdoc->loadHTML($html); $xpath = new DOMXPath($domdoc); $link = $xpath->query('//a[contains(.,"No thanks, just start my download.")]')->item(0); if ($link) { $matches = []; preg_match('~"[a-z0-9\\-\\?\\./=]+"~i', $link->C14N(), $matches); if (!empty($matches)) { $download_page = self::HOST . trim($matches[0], ' "'); continue; } } } unset($this->download_links[$version]); } if (empty($this->download_links)) { _echo('No download links found.'); } else { _echo(count($this->download_links) . ' MySQL versions found for download.'); } return $this; }
function cli_processPlaylist($folder, $info) { $nextPageToken = null; $items = array(); do { $data = tubeAPI::getInstance()->playlistItems($info['id'], $nextPageToken); if (!empty($data->nextPageToken)) { $nextPageToken = $data->nextPageToken; } $items = array_merge($items, $data->items); } while (!empty($data->nextPageToken)); if (!empty($info['filter'])) { _echo(' Using title filter: `' . $info['filter'] . '`'); foreach ($items as $i => $item) { if (false === strstr($item->snippet->title, $info['filter'])) { unset($items[$i]); } } } $items = array_values($items); _echo(' ' . count($items) . ' items found'); $itemsInFolder = 0; $itemsDownloaded = 0; foreach ($items as $item) { if (!empty($info['inRegex']) && !empty($info['outRegex'])) { $fileName = preg_replace(chr(1) . $info['inRegex'] . chr(1), $info['outRegex'], $item->snippet->title) . '.mp4'; } else { $fileName = $item->snippet->title . '.mp4'; } $fileName = preg_replace('"\\s+"', ' ', $fileName); if (file_exists($folder . '/' . $fileName)) { // _echo( ' File `' . $fileName . '` exists' ); $itemsInFolder++; continue; } else { ini_set('set_time_limit', '0'); $vUrl = 'http://www.youtube.com/watch?v=' . $item->snippet->resourceId->videoId; _echo(' Downloading file `' . $fileName . '` from `' . $vUrl . '`...'); _echo(' > youtube-dl -f 22 -o "%(title)s.%(ext)s" "' . $item->snippet->resourceId->videoId . '"'); $downFileName = exec('youtube-dl -f 22 --get-filename -o "%(title)s.%(ext)s" "' . $item->snippet->resourceId->videoId . '"', $null, $ret); exec('youtube-dl -f 22 -o "' . $folder . '/%(title)s.%(ext)s" ' . $item->snippet->resourceId->videoId, $null, $ret); if (!empty($info['inRegex']) && !empty($info['outRegex']) && $downFileName != $fileName) { if (!rename($folder . '/' . $downFileName, $folder . '/' . $fileName)) { _error('Unable to rename file'); _error(' >"' . $folder . '/' . $downFileName . '"' . (file_exists($folder . '/' . $downFileName) ? ' [exists]' : ' [NOT exists]'), false); _error(' <"' . $folder . '/' . $fileName . '"' . (file_exists($folder . '/' . $fileName) ? ' [EXISTS]' : ' [not exists]'), true); } } _echo(' Done'); $itemsDownloaded++; } } if ($itemsInFolder == count($items)) { _echo(' Playlist is up to date. Nothing to download.'); } else { if (!empty($itemsDownloaded)) { _echo(' ' . $itemsDownloaded . ' files downloaded.'); } } }
<?php // echo or print function _echo($string) { $out = fopen('php://output', 'w'); fwrite($out, $string); fclose($out); } _echo('Hello php://output!');
echo wordwrap($string, 79) . "\n"; } if (!$cmd_line) { _echo('<pre>'); } if ($version === 'master') { _echo('You are using a development version, I cannot check how up to date it is.'); _echo('You can download the latest stable release from ' . urlify($DOWNLOAD_URL)); } else { _echo('Checking version...'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $URL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Luminous ' . LUMINOUS_VERSION . ' version check'); $json = curl_exec($ch); curl_close($ch); if (!$json) { _echo('Remote request failed. Try again later or visit ' . urlify($DOWNLOAD_URL) . ' to see what the latest version is'); } else { $data = json_decode($json, true); if ($data['release_number'] === $version || 'v' . $data['release_number'] === $version) { _echo('You are up to date!'); } else { $output = "You are not up to date: your version is " . $version . " and the most recent release is " . $data['release_number'] . ", released " . $data['release_date'] . '. ' . ' Visit ' . urlify($DOWNLOAD_URL) . ' to upgrade'; _echo($output); } } } if (!$cmd_line) { _echo('</pre>'); }
<?php _echo('Checking remote version...'); $remote_version = trim(file_get_contents('https://raw.githubusercontent.com/Alorel/AloWAMP/master/src/VERSION')); $local_version = trim(file_get_contents(DIR_INDEX . 'VERSION')); _echo('Local version: ' . $local_version); _echo('Remote version: ' . $remote_version); if (version_compare($local_version, $remote_version, '<')) { $loop = true; do { $io = trim(IO::readline('Would you like to download the update? [Y\\N]')); switch ($io) { case '': continue; case 'y': shell_exec('start ' . HOMEPAGE); $loop = false; break; default: $loop = false; } } while ($loop); } else { _echo('You have the newest version'); }
/** * URL manager * * @param string/array/null $param A parameter to set, or an array like `param => value` to set in URL * @param string/null $value The value of the `$param` argument (if it is a string) * @param string/null $url The URL to work on (`self::getRequestUrl()` by default) * @param bool $return Return/Echo flag (default is to echo result) * @return mixed The result of the `_echo` function (string or bool) * @see Library\Helper\Url::url() * @see _echo() */ function _url($param = null, $value = null, $url = null, $return = false) { return _echo(Helper\Url::url($param, $value, $url), $return); }
<?php if (\IO::readline('Are you sure you want to reset your installation? You will lose all configuration, but not your website data. [Y/N]') == 'y') { $items = [DIR_BIN, DIR_LOGS, DIR_TMP, DIR_CORE . 'settings.ini']; foreach ($items as $i) { if (file_exists($i)) { if (is_dir($i)) { shell_exec('rd /s /q "' . rtrim($i, '\\/') . '"'); } else { unlink($i); } } } _echo('Reset completed.'); } else { _echo('Reset aborted'); }
function the_author_rss($echo = true) { return _echo(wp_convert_rss_charset(the_author('', false)), $echo); }
function the_meta($echo = true) { $the_meta = ''; if ($keys = get_post_custom_keys()) { $the_meta .= "<ul class='post-meta'>\n"; foreach ($keys as $key) { $values = array_map('trim', $GLOBALS['post_meta_cache'][wp_id()][$GLOBALS['wp_post_id']][$key]); $value = implode($values, ', '); $the_meta .= "<li><span class='post-meta-key'>{$key}:</span> {$value}</li>\n"; } $the_meta .= "</ul>\n"; } return _echo($the_meta, $echo); }
/** * Updates apache settings * * @author Art <*****@*****.**> * * @param string $version Which version to update */ protected function updateApache($version) { _echo('Updating Apache ' . $version); $file = DIR_APACHE . $version . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR . 'httpd.conf'; if (!file_exists($file)) { _echo('Failed to update ' . $version . ': httpd.conf not found'); } else { $contents = file_get_contents($file); $contents = str_ireplace('bin' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . $this->old_version, 'bin' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . $this->new_version, $contents); if (file_put_contents($file, $contents) !== false) { _echo($version . ' updated'); } else { _echo('Failed to edit ' . $version . '\'s httpd.conf'); } } }
<?php require DIR_CORE . 'services.php'; /** @var array $launch */ foreach ($launch as $s) { /** @var array $services */ if (isset($services[$s])) { _echo('Stopping ' . $services[$s]); _echo(Service::stop($s)); } else { _echo('Service ' . $s . ' not installed'); } }
function trackback_rdf($timezone = 0, $echo = true) { $trackback_rdf = ''; if (!stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) { $trackback_rdf .= '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> <rdf:Description rdf:about="' . get_permalink() . '"' . "\n"; $trackback_rdf .= ' dc:identifier="' . get_permalink() . '"' . "\n"; $trackback_rdf .= ' dc:title="' . str_replace('--', '--', wptexturize(strip_tags(get_the_title()))) . '"' . "\n"; $trackback_rdf .= ' trackback:ping="' . trackback_url(0) . '"' . " />\n"; $trackback_rdf .= '</rdf:RDF>'; } return _echo($trackback_rdf, $echo); }
echo $_template->getTemplateObject('MetaTag')->write("\n\t\t %s "), $_template->getTemplateObject('TitleTag')->write("\n\t\t %s "), $_template->getTemplateObject('LinkTag')->write("\n\t\t %s "); if (true === $minify_css) { echo $_template->getTemplateObject('CssFile')->minify()->writeMinified("\n\t\t %s "); } elseif (true === $merge_css) { echo $_template->getTemplateObject('CssFile')->merge()->writeMerged("\n\t\t %s "); } else { echo $_template->getTemplateObject('CssFile')->write("\n\t\t %s "); } if (true === $minify_js) { echo $_template->getTemplateObject('JavascriptFile', 'jsfiles_header')->minify()->writeMinified("\n\t\t %s "); } elseif (true === $merge_js) { echo $_template->getTemplateObject('JavascriptFile', 'jsfiles_header')->merge()->writeMerged("\n\t\t %s "); } else { echo $_template->getTemplateObject('JavascriptFile', 'jsfiles_header')->write("\n\t\t %s "); } _echo("\n"); ?> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <a id="top"></a> <a href="#content" class="sr-only">Skip to main content</a> <?php foreach ($_template->getPageStructure() as $item) { ?>
function edit_comment_link($link = _WP_TPL_EDIT_THIS, $before = '', $after = '', $echo = true) { get_currentuserinfo(); if (!user_can_edit($GLOBALS['post']->post_author)) { return ""; } $location = wp_siteurl() . "/wp-admin/post.php?action=editcomment&comment={$GLOBALS['comment']->comment_ID}"; return _echo("{$before} <a href='{$location}'>{$link}</a> {$after}", $echo); }
<?php $setup = new Setup(); _echo('Hi! I will guide you through the setup.' . PHP_EOL . 'First, let\'s check if you have some of the core directories present.'); IO::echo_lines(2); $setup->checkDateTimezone()->checkDir(DIR_TMP, 'tmp folder')->checkDir(DIR_BIN, 'binaries folder')->checkDir(DIR_LOGS . 'php' . DIRECTORY_SEPARATOR, 'PHP log folder')->checkDir(DIR_LOGS . 'apache' . DIRECTORY_SEPARATOR, 'Apache log folder')->checkDir(DIR_LOGS . 'mysql' . DIRECTORY_SEPARATOR, 'MySQL log folder')->checkDir(DIR_LOGS . 'redis' . DIRECTORY_SEPARATOR, 'Redis log folder')->checkWWW()->checkPHP()->checkApache()->checkMySQL()->checkRedis()->checkMemcache();
function the_category_unicode($echo = true) { $category = get_the_category(); $category = apply_filters('the_category_unicode', $category); return _echo(convert_chars($category, 'unicode'), $echo); }
function the_weekday_date($before = '', $after = '', $echo = true) { $the_weekday_date = ''; if (empty($GLOBALS['previousweekday']) || $GLOBALS['day'] != $GLOBALS['previousweekday']) { $the_weekday_date .= $before . $GLOBALS['weekday'][mysql2date('w', $GLOBALS['post']->post_date)] . $after; $GLOBALS['previousweekday'] = $GLOBALS['day']; } $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date); return _echo($the_weekday_date, $echo); }
/** * Copies unzipped contents * * @author Art <*****@*****.**> * @return Redis */ protected function copy() { _echo('Copying unzipped contents..'); $source = rtrim($this->dest_unzip, DIRECTORY_SEPARATOR); $this->unzipped_destination = DIR_REDIS . $this->version; if (!file_exists($this->unzipped_destination)) { mkdir($this->unzipped_destination . DIRECTORY_SEPARATOR, 777, true); } shell_exec('xcopy /s /e "' . $source . '" "' . $this->unzipped_destination . '"'); $this->unzipped_destination .= DIRECTORY_SEPARATOR; if (file_exists($this->unzipped_destination . 'redis-server.exe')) { _echo('Copy successful!'); $this->updateSettings(); $this->cleanup(); } else { die('Failed to copy. Terminating setup.'); } return $this; }
/** * Downloads memcache * * @author Art <*****@*****.**> * @return Memcache */ protected function download() { $this->downloader = new \Downloader(self::MEMCACHE_DOWNLOAD_SOURCE, $this->dest); if ($this->downloader->download()) { _echo('Download successful. Setting up Memcache...'); } else { die('Download failed. Aborting setup.'); } return $this; }