/** * Prepare file to be converted * this will first get info of the file * and enter its info into database */ function prepare($file = NULL) { global $db; if ($file) { $this->input_file = $file; } if (file_exists($this->input_file)) { $this->input_file = $this->input_file; } else { $this->input_file = TEMP_DIR . '/' . $this->input_file; } //Checking File Exists if (!file_exists($this->input_file)) { $this->log('File Exists', 'No'); } else { $this->log('File Exists', 'Yes'); } //Get File info $this->input_details = $this->get_file_info(); //Loging File Details $this->log .= "\nPreparing file...\n"; $this->log_file_info(); //Insert Info into database //$this->insert_data(); //Gett FFMPEG version $result = shell_output(FFMPEG_BINARY . " -version"); $version = parse_version('ffmpeg', $result); $this->vconfigs['map_meta_data'] = 'map_meta_data'; if (strstr($version, 'Git')) { $this->vconfigs['map_meta_data'] = 'map_metadata'; } }
list($doc_id, $inv_p) = get_safe_param('doc_id', '/^[[:alnum:]\-\_\.\:]+$/'); $basicQuery = new SolrQuery(); $basicQuery->addSort("epoch desc"); $basicQuery->addSort("sort_version desc"); $basicQuery->addSort("infofilechanged desc"); $basicQuery->setRows(1); $basicQuery->addQuery("name_e:\"$package\"", true); $fullQuery = clone $basicQuery; if ($version) { list($epoch, $version, $revision) = parse_version($version); if ($epoch != null) $fullQuery->addQuery("epoch:$epoch", true); if ($version != null) $fullQuery->addQuery("version_e:\"$version\"", true); if ($revision != null) $fullQuery->addQuery("revision_e:\"$revision\"", true); } if ($doc_id) { $fullQuery->addQuery("doc_id:\"$doc_id\"", true); } elseif ($rel_id) { $fullQuery->addQuery("rel_id:\"$rel_id\"", true); } else { // no need to parse the other parameters if ($distribution) { $fullQuery->addQuery("dist_name:\"$distribution\"", true);
/** * Function used to cheack weather MODULE is INSTALLED or NOT */ function check_module_path($params) { $rPath = $path = $params['path']; if ($path['get_path']) { $path = get_binaries($path); } $array = array(); $result = shell_output($path . " -version"); if ($result) { if (strstr($result, 'error') || strstr($result, 'No such file or directory')) { $error['error'] = $result; if ($params['assign']) { assign($params['assign'], $error); } return false; } if ($params['assign']) { $array['status'] = 'ok'; $array['version'] = parse_version($params['path'], $result); assign($params['assign'], $array); } else { return $result; } } else { if ($params['assign']) { assign($params['assign']['error'], "error"); } else { return false; } } }
# PHP Link Directory Forum http://www.phplinkdirectory.com/forum/ # # @link http://www.phplinkdirectory.com/ # @copyright 2004-2006 NetCreated, Inc. (http://www.netcreated.com/) # @projectManager David DuVal <*****@*****.**> # @package PHPLinkDirectory # ###################################################################### */ require_once 'init.php'; //Clear the entire cache $tpl->clear_all_cache(); //Clear all compiled template files $tpl->clear_compiled_tpl(); $url = get_url('http://code.google.com/p/scriptmind-links/wiki/CurrentVersion?show=content', URL_CONTENT, $_SERVER['SERVER_NAME'] . request_uri()); $sv = parse_version($url['content']); $cv = parse_version(CURRENT_VERSION); //Version check if ($sv > $cv) { $version = _L('A new version (##VERSION##) is available.'); $version = str_replace('##VERSION##', format_version($sv), $version); $tpl->assign('update_available', 1); } else { $version = _L('Your installation is up to date, no updates are available for your version of ScriptMind::Links.'); $tpl->assign('update_available', 0); } //Security check $security_warnings = install_security_check(); if (!empty($security_warnings)) { $tpl->assign('security_warnings', $security_warnings); } unset($security_warnings);
/** * Compares two arbitrary version strings. * * @param mixed $ver The version to test. Can be a string or array created with parse_version(). * @param string $op The comparison operation to perform. * @param mixed $num The version number to test the comparison again. Can also be a string or array. * @return mixed True or false if comparison is performed, otherwise returns an array of the passed-in version. * * @see parse_version(string $str, bool $named) */ function test_version($ver, $op, $num) { $ver = is_string($ver) ? parse_version($ver) : $ver; $num = is_string($num) ? parse_version($num) : $num; // Be sure both arrays are the same size. if (count($ver) < count($num)) { $ver = array_pad($ver, count($num), 0); } else { if (count($num) < count($ver)) { $num = array_pad($num, count($ver), 0); } } // Based on $op, compare each element in turn. switch ($op) { case '>': case 'gt': for ($i = 0; $i < count($ver); $i++) { if ($ver[$i] > $num[$i]) { return true; } else { if ($ver[$i] === $num[$i]) { continue; } else { return false; } } } case '<': case 'lt': for ($i = 0; $i < count($ver); $i++) { if ($ver[$i] < $num[$i]) { return true; } else { if ($ver[$i] === $num[$i]) { continue; } else { return false; } } } case '=': case '==': case 'eq': for ($i = 0; $i < count($ver); $i++) { if ($ver[$i] === $num[$i]) { continue; } else { return false; } } // All are equal return true; case '>=': case 'gteq': for ($i = 0; $i < count($ver); $i++) { if ($ver[$i] >= $num[$i]) { continue; } else { return false; } } // All are greater than or equal to return true; case '<=': case 'lteq': for ($i = 0; $i < count($ver); $i++) { if ($ver[$i] <= $num[$i]) { continue; } else { return false; } } // All are less than or equal to return true; default: return $ver; } }
<?php /** * Created by Reza Salarmehr * Date: 30/09/2015 * Time: 16:24 */ use Salarmehr\Ary; if (!function_exists('ary') && phpversion()) { function parse_version($version) { $version = explode('.', $version); return $version[0] * 10000 + $version[1] * 100 + $version[2]; } if (!defined('ary') && parse_version(PHP_VERSION) > parse_version('5.6.0')) { /** * @param mixed $items,... * @return Ary */ function ary() { return new Ary(...func_get_args()); } } }
function process_app($app_name, $app_link, $app_group = "default") { global $scrape_options; if ($scrape_options["verbose"]) { echo "processing app {$app_name}\ngetting app page {$app_link}\n"; } //getting and parsing app page //there may be several versions of app //we store all versions meta (created date, publis date and current status) $res = getUrlContent2($app_link); if (!$res) { return error("failed to get app page\\s"); } //parsing primary meta $pat = '/<p><label>SKU<\\/label>(.*?)<\\/p>[\\s]*<p><label>Bundle ID<\\/label>(.*?)<\\/p>[\\s]*<p><label>Apple ID<\\/label>(.*?)<\\/p>[\\s]*<p><label>Type<\\/label>(.*?)<\\/p>[\\s]*<p><label style="white-space: nowrap">Default Language<\\/label>(.*?)<\\/p>/si'; $match = preg_match($pat, $res, $matches); if (!$match || !is_array($matches) || count($matches) == 0) { return error("Failed to parse app page: meta markers not found"); } $sku = trim(strip_tags($matches[1])); $bundle_id = trim(strip_tags($matches[2])); $apple_id = trim(strip_tags($matches[3])); $app_type = trim(strip_tags($matches[4])); $lang = trim(strip_tags($matches[5])); if ($scrape_options["verbose"]) { echo "parsed memo:\nsku: {$sku}\nbundle_id: {$bundle_id}\napple_id: {$apple_id}\napp_type: {$app_type}\ndefault language: {$lang}\n"; } $pat = '/<td class="value"><a target="_blank" href="(.*?)">View in App Store[\\s]*<\\/a><\\/td>/si'; $match = preg_match($pat, $res, $matches); if (!$match || !is_array($matches) || count($matches) == 0) { return error("Failed to parse app page: Appstore link not found"); } $applink = $matches[1]; if ($scrape_options["verbose"]) { echo "appstore link: {$applink}\n"; } $pat = '/id([0-9]*)\\?/si'; $match = preg_match($pat, $applink, $matches); if (!$match || !is_array($matches) || count($matches) == 0) { return error("Failed to parse app page: Appstore ID not found"); } $appid = $matches[1]; echo "appid: {$appid}\n"; $p = strpos($res, "version-container"); if ($p === false) { return error("version-container marker not found"); } $p2 = strpos($res, "version-container", $p + 10); if ($p2 === false) { if ($scrape_options["debug"]) { echo "second version-container marker not found. parsing only one\n"; } $str1 = substr($res, $p, strlen($res) - $p); $str2 = false; } else { if ($scrape_options["debug"]) { echo "both version-container markers found\n"; } $str1 = substr($res, $p, $p2 - $p); $str2 = substr($res, $p2, strlen($res) - $p2); } $ver1 = parse_version($str1); if (!$ver1) { return error("parse Current version failed"); } if ($str2) { $ver2 = parse_version($str2); // if (!$ver2) // return error("parse New version failed"); } else { $ver2 = false; } if (!is_dir(BASE_META_DIR . "/app_{$appid}") && !mkdir(BASE_META_DIR . "/app_{$appid}")) { return error("couldn't access to application directory [" . BASE_META_DIR . "/app_{$appid}]"); } $obj = array("app_name" => $app_name, "apple_id" => $apple_id, "app_group" => $app_group, "sku" => $sku, "bundle_id" => $bundle_id, "app_type" => $app_type, "lang" => $lang, "ituneslink" => $applink, "current_version" => $ver1, "new_version" => $ver2); $fn = BASE_META_DIR . "/app_{$appid}/appmeta.dat"; if (file_exists($fn)) { $cont = file_get_contents($fn); if ($cont) { $row = unserialize($cont); if ($row) { $obj["stat_max_report_date"] = $row["stat_max_report_date"]; $obj["stat_min_report_date"] = $row["stat_min_report_date"]; $obj["stat_last_day"] = $row["stat_last_day"]; $obj["stat_last_month"] = $row["stat_last_month"]; $obj["stat_whole_period"] = $row["stat_whole_period"]; } } } $res = file_put_contents($fn, serialize($obj)); $res = get_icons($appid, $ver1, $ver2); process_app_to_db($obj); if (!$res) { return error("some problems while writing appmeta.dat file"); } return true; }