public static function path2array_paquet($_path, $lg1, $lg2, $mesure) { $array_lg = array($lg1, $lg2); sort($array_lg); $data = Tool_files::file_load($_path); $f = Tool_files::csv2array_line($data, "\n"); $array_paquet = array(); $tmp = array(); $flag_vu = false; foreach ($f as $line) { if (mb_eregi("[:alnum:]", $line)) { $tmp[] = trim($line); } elseif (len($tmp) > 0) { list($dist, $rep) = mb_split(" : ", $tmp[0]); list($score, $l1, $l2) = mb_split(" ", $rep); $score = trim($score); $dist = trim($dist); $l1 = trim($l1); $l2 = trim($l2); if ($dist == $mesure) { if ($l1 == $lg2 and $l2 == $lg1 or $lg1 == $l1 and $lg2 == $l2) { $flag_vu = true; list($str1, $rep1) = self::line2str_rep($tmp[1]); list($str2, $rep2) = self::line2str_rep($tmp[2]); $array_paquet[] = array('score' => $score, $l1 => $rep1, $l2 => $rep2, "str_{$l1}" => $str1, "str_{$l2}" => $str2); } } elseif ($flag_vu) { break; } $tmp = array(); } } return $array_paquet; }
/** * UTF-8 aware alternative to str_pad. * * $pad_str may contain multi-byte characters. * * @author Oliver Saunders <*****@*****.**> * @package php-utf-8 * @subpackage functions * @see http://www.php.net/str_pad * @uses utf8_substr * * @param string $input * @param int $length * @param string $pad_str * @param int $type (same constants as str_pad) * * @return string */ function pad($input, $length, $pad_str = ' ', $type = STR_PAD_RIGHT) { $input_len = len($input); if ($length <= $input_len) { return $input; } $pad_str_len = len($pad_str); $pad_len = $length - $input_len; if ($type == STR_PAD_RIGHT) { $repeat_times = ceil($pad_len / $pad_str_len); return sub($input . str_repeat($pad_str, $repeat_times), 0, $length); } if ($type == STR_PAD_LEFT) { $repeat_times = ceil($pad_len / $pad_str_len); return sub(str_repeat($pad_str, $repeat_times), 0, floor($pad_len)) . $input; } if ($type == STR_PAD_BOTH) { $pad_len /= 2; $pad_amount_left = floor($pad_len); $pad_amount_right = ceil($pad_len); $repeat_times_left = ceil($pad_amount_left / $pad_str_len); $repeat_times_right = ceil($pad_amount_right / $pad_str_len); $padding_left = sub(str_repeat($pad_str, $repeat_times_left), 0, $pad_amount_left); $padding_right = sub(str_repeat($pad_str, $repeat_times_right), 0, $pad_amount_right); return $padding_left . $input . $padding_right; } trigger_error('utf8_str_pad: Unknown padding type (' . $type . ')', E_USER_ERROR); }
/** * UTF-8 aware substr_replace. * * @package php-utf-8 * @subpackage functions * @see http://www.php.net/substr_replace * @uses utf8_strlen * @uses utf8_substr * * @param string $str * @param string $repl * @param int $start * @param int $length * * @return string */ function sub_replace($str, $repl, $start, $length = null) { preg_match_all('/./us', $str, $ar); preg_match_all('/./us', $repl, $rar); $length = is_int($length) ? $length : len($str); array_splice($ar[0], $start, $length, $rar[0]); return implode($ar[0]); }
function add_row($hook, $attributes) { $table .= "<tr><td><input type=\"button\" value=\"{$hook}\" onclick=\"pick({$hook})\"></td>"; for ($i = 0; $i < len($attributes); $i++) { $table += "<td>" . $attributes[$i] . "</td>"; } $table .= "</tr>"; }
/** * UTF-8 aware alternative to str_split. * * Convert a string to an array * * @package php-utf-8 * @subpackage functions * @see http://www.php.net/str_split * @uses utf8_strlen * * @param string $str A UTF-8 encoded string * @param int $split_len A number of characters to split string by * * @return string characters in string reverses */ function split($str, $split_len = 1) { if (!preg_match('/^[0-9]+$/', $split_len) || $split_len < 1) { return false; } $len = len($str); if ($len <= $split_len) { return array($str); } preg_match_all('/.{' . $split_len . '}|[^\\x00]{1,' . $split_len . '}$/us', $str, $ar); return $ar[0]; }
function istxt($str) { $i = 0; $str1 = ""; while ($i < 4) { $str1 .= $str[len($str) - $i]; } if ($str1 != "txt.") { return 0; } else { return 1; } }
/** * UTF-8 aware alternative to strcspn. * * Find length of initial segment not matching mask. * * @package php-utf-8 * @subpackage functions * @see http://www.php.net/strcspn * @uses utf8_strlen * @uses utf8_substr * * @param string $str * @param string $mask * @param integer $start * @param integer $length * * @return integer|null */ function cspn($str, $mask, $start = null, $length = null) { if (empty($mask) || strlen($mask) == 0) { return null; } $mask = preg_replace('!([\\\\\\-\\]\\[/^])!', '\\\\${1}', $mask); if ($start !== null || $length !== null) { $str = sub($str, $start, $length); } preg_match('/^[^' . $mask . ']+/u', $str, $matches); if (isset($matches[0])) { return len($matches[0]); } return 0; }
/** * UTF-8 aware alternative to wordwrap. * * Wraps a string to a given number of characters * https://github.com/nicolas-grekas/Patchwork-UTF8 * * @see http://www.php.net/manual/en/function.wordwrap.php * * @param string $str the input string * @param int $width the column width * @param string $break the line is broken using the optional break parameter * @param boolean $cut * * @return string the given string wrapped at the specified column * * @package php-utf-8 * @subpackage functions */ function wordwrap($str, $width = 75, $break = "\n", $cut = false) { $width = (int) $width; $str = explode($break, $str); $i_len = count($str); $result = array(); $line = ''; $line_len = 0; for ($i = 0; $i < $i_len; ++$i) { $words = explode(' ', $str[$i]); $line && ($result[] = $line); $line_len = len($line); $jLen = count($words); for ($j = 0; $j < $jLen; ++$j) { $w = $words[$j]; $wLen = len($w); if ($line_len + $wLen < $width) { if ($j) { $line .= ' '; } $line .= $w; $line_len += $wLen + 1; } else { if ($j || $i) { $result[] = $line; } $line = ''; $line_len = 0; if ($cut && $wLen > $width) { $w = split($w); do { $result[] = implode('', array_slice($w, 0, $width)); $line = implode('', $w = array_slice($w, $width)); $line_len = $wLen -= $width; } while ($wLen > $width); $w = implode('', $w); } $line = $w; $line_len = $wLen; } } } $line && ($result[] = $line); return implode($break, $result); }
function func_redir($line) { $tabtest = array(); preg_match("/([^>]*) >+ (.*)/", $line, $tabtest); if (count($tabtest) != 3) { echo "Syntax is wrong\n"; } else { if (is_dir($tabtest[2]) || $tabtest[2][len($tabtest[2]) - 1] == '/') { echo "content.php: {$tabtest[2]}: Is a directory\n"; } else { if (file_exists($tabtest[2]) && !is_writable($tabtest[2])) { echo "content.php: {$tabtest[2]}: Permission denied\n"; } else { redirection($tabtest); } } } }
/** * Global vars * * @param NCModule $module * @param Theme $view * @param Translate $lang * @return array|\System\Engine\NCBlock[] */ static function globalize(NCModule $module, Theme $view, Translate $lang) { $view->twig->addFilter(new \Twig_SimpleFilter('ord', function ($order) { $cur = Env::$request->get('order'); if (strpos($cur, $order) > -1) { return $cur[0] == '-' ? 'fa-chevron-down' : 'fa-chevron-up'; } return strpos($cur, $order); })); /** * Substr */ $view->twig->addFilter(new \Twig_SimpleFilter('sub', function ($str, $len = 24) { if (\len($str) > $len) { $str = \cut($str, 0, $len - 3) . '...'; } return $str; })); /** * Long to ip */ $view->twig->addFilter(new \Twig_SimpleFilter('longip', function ($str) { return long2ip($str); })); /** * IP to long */ $view->twig->addFilter(new \Twig_SimpleFilter('iplong', function ($str) { return ip2long($str); })); return ['title_prefix' => NCService::load('Application.Settings')->conf->get('title_prefix'), 'lang_code' => $lang->pack, 'ga' => lazy_arr('ga', ['$code' => function () { /** @var GA $manager */ $manager = NCService::load('SocialMedia.GA'); return $manager->code(); }])]; }
function getRParam($content, $lableStr) { $contentLCase = ''; $endS = ''; $i = ''; $s = ''; $c = ''; $isStart = ''; $startStr = ''; $isValue = ''; $content = ' ' . $content . ' '; //避免更精准获得值 $contentLCase = lCase($content); $lableStr = lCase($lableStr); $endS = mid($content, inStr($contentLCase, $lableStr) + len($lableStr), -1); //call echo("ends",ends) $isStart = false; //是否有开始类型值 $isValue = false; //是否有值 for ($i = 1; $i <= len($endS); $i++) { $s = mid($endS, $i, 1); if ($isStart == true) { if ($s != '') { if ($startStr == '') { $startStr = $s; } else { if ($startStr == '"' || $startStr == '\'') { if ($s == $startStr) { $isValue = true; break; } } else { if ($s == ' ' && $c == '') { } else { if ($s == ' ' || $s == '/' || $s == '>') { $isValue = true; break; } } } if ($s != ' ') { $c = $c . $s; } } } } if ($s == '=') { $isStart = true; } } if ($isValue == false) { $c = ''; } $getRParam = $c; //call echo("c",c) return @$getRParam; }
function JsEncode__($s) { if (isNul($s)) { $JsEncode__ = ''; return @$JsEncode__; } $arr1 = ''; $arr2 = ''; $i = ''; $j = ''; $c = ''; $p = ''; $t = ''; $arr1 = array(chr(34), chr(92), chr(47), chr(8), chr(12), chr(10), chr(13), chr(9)); //34|",92|\,47|/,8|,12|,10| ,13| ,9| , $arr2 = array(chr(34), chr(92), chr(47), chr(98), chr(102), chr(110), chr(114)); //34|",92|\,47|/,98|b,102|f,110|n,114|r,1865|, for ($i = 1; $i <= len($s); $i++) { $p = true; $c = mid($s, $i, 1); for ($j = 0; $j <= uBound($arr1); $j++) { if ($c == $arr1[$j]) { $t = $t . '\\' . $arr2[$j]; $p = false; break; } } if ($p) { $t = $t . $c; } } $JsEncode__ = $t; return @$JsEncode__; }
function count_attributes($dir, $single_file = FALSE) { $no_activity_dates = array(); $activities_with_at_least_one = array(); $no_activities = array(); $found_hierarchies = array(); $activities_with_attribute = array(); $activity_by = array(); $document_links = array(); $result_element = array(); $conditions = array(); $participating_org_accountable = array(); $participating_org_implementing = array(); $budget = array(); $identifiers = array(); $transaction_type_commitment = array(); $transaction_type_disbursement = array(); $transaction_type_expenditure = array(); $no_disbursements = $no_incoming_funds = $no_tracable_transactions = array(); $activities_with_sector = array(); $most_recent = array(); $activities_with_location = array(); $activities_with_coordinates = array(); $activities_with_adminstrative = array(); $activities_sector_assumed_dac = array(); $activities_sector_declared_dac = array(); $activies_in_country_lang = array(); $i = 0; //used to count bad id's if ($handle = opendir($dir)) { //echo "Directory handle: $handle\n"; //echo "Files:\n"; /* This is the correct way to loop over the directory. */ while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { //ignore these system files //echo $file . PHP_EOL; if ($single_file && $file != $single_file) { //skip all files except the one we want if set/requested.Handy to test just one file in a directory continue; } //load the xml SAFELY /* Some safety against XML Injection attack * see: http://phpsecurity.readthedocs.org/en/latest/Injection-Attacks.html * * Attempt a quickie detection of DOCTYPE - discard if it is present (cos it shouldn't be!) */ $xml = file_get_contents($dir . $file); $collapsedXML = preg_replace("/[[:space:]]/", '', $xml); //echo $collapsedXML; if (preg_match("/<!DOCTYPE/i", $collapsedXML)) { //throw new InvalidArgumentException( // 'Invalid XML: Detected use of illegal DOCTYPE' // ); //echo "fail"; return FALSE; } $loadEntities = libxml_disable_entity_loader(true); $dom = new DOMDocument(); $dom->loadXML($xml); foreach ($dom->childNodes as $child) { if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) { throw new Exception\ValueException('Invalid XML: Detected use of illegal DOCTYPE'); libxml_disable_entity_loader($loadEntities); return FALSE; } } libxml_disable_entity_loader($loadEntities); if ($xml = simplexml_import_dom($dom)) { //print_r($xml); if (!xml_child_exists($xml, "//iati-organisation")) { //exclude organisation files $activities = $xml->{"iati-activity"}; //print_r($attributes); die; foreach ($activities as $activity) { $hierarchy = (string) $activity->attributes()->hierarchy; if ($hierarchy && $hierarchy != NULL) { $hierarchy = (string) $activity->attributes()->hierarchy; } else { $hierarchy = 0; } $found_hierarchies[] = $hierarchy; if (!isset($no_activities[$hierarchy])) { $no_activities[$hierarchy] = 0; } $no_activities[$hierarchy]++; //Set up some more counters: if (!isset($no_disbursements[$hierarchy])) { $no_disbursements[$hierarchy] = 0; } if (!isset($no_incoming_funds[$hierarchy])) { $no_incoming_funds[$hierarchy] = 0; } if (!isset($no_tracable_transactions[$hierarchy])) { $no_tracable_transactions[$hierarchy] = 0; } //Elements check //is <document-link>,<conditions>,<result> present if (count($activity->{"document-link"}) > 0) { $document_links[$hierarchy][] = (string) $activity->{'iati-identifier'}; } if (count($activity->conditions) > 0) { $conditions[$hierarchy][] = (string) $activity->{'iati-identifier'}; } if (count($activity->result) > 0) { $result_element[$hierarchy][] = (string) $activity->{'iati-identifier'}; } //More elements //Participating Organisation (Implementing) $participating_orgs = $activity->{"participating-org"}; foreach ($participating_orgs as $participating_org) { //echo (string)$activity->{"participating-org"}->attributes()->role; if ((string) $participating_org->attributes()->role == "Implementing") { //echo "yes"; $participating_org_implementing[$hierarchy][] = (string) $activity->{'iati-identifier'}; } //Participating Organisation (Accountable) if ((string) $participating_org->attributes()->role == "Accountable") { $participating_org_accountable[$hierarchy][] = (string) $activity->{'iati-identifier'}; } } //Budget/Planned Disbursement if (count($activity->budget) > 0 || count($activity->{"planned-disbursement"}) > 0) { $budget[$hierarchy][] = (string) $activity->{'iati-identifier'}; } //Unique Identifier check //Suck up all activity identifiers - check they start with the reporting org string //We count by storing the activity id in an array //if there is no identifier then set a dummy one to dump it into the 'bad' pile if (!isset($activity->{'iati-identifier'})) { $iati_identifier = "noIdentifierGiven" . $i; $i++; } else { $iati_identifier = (string) $activity->{'iati-identifier'}; } if (isset($activity->{'reporting-org'}->attributes()->ref)) { $reporting_org_ref = (string) $activity->{'reporting-org'}->attributes()->ref; //echo $reporting_org_ref . PHP_EOL; //echo $iati_identifier . PHP_EOL; if (strpos($reporting_org_ref, $iati_identifier) == 0) { //echo "yes"; $identifiers[$hierarchy]["good"][] = $iati_identifier; } else { //echo "no"; $identifiers[$hierarchy]["bad"][] = $iati_identifier; } } else { $identifiers[$hierarchy]["bad"][] = $iati_identifier; } //Financial transaction (Commitment) $transactions = $activity->transaction; //if (count($transactions) == 0) { // echo $id; //die; //} if (isset($transactions) && count($transactions) > 0) { //something not quite right here //Loop through each of the elements foreach ($transactions as $transaction) { //print_r($transaction); //Counts number of elements of this type in this activity //$no_transactions[$hierarchy]++; //$transaction_date = (string)$transaction->{'transaction-date'}->attributes()->{'iso-date'}; if (isset($transaction->{'transaction-type'})) { $transaction_type = (string) $transaction->{'transaction-type'}->attributes()->{'code'}; if ($transaction_type == "C") { $transaction_type_commitment[$hierarchy][] = (string) $activity->{'iati-identifier'}; } if ($transaction_type == "D") { $transaction_type_disbursement[$hierarchy][] = (string) $activity->{'iati-identifier'}; //Count the number of disbursements at this level $no_disbursements[$hierarchy]++; //now test it and count the passes if (isset($transaction->{"receiver-org"})) { //We have a provider-org = pass! $no_tracable_transactions[$hierarchy]++; } //$no_disbursements = $no_incoming_funds = $no_tracable_transactions = array(); } if ($transaction_type == "IF") { //Count the number of IFs at this level $no_incoming_funds[$hierarchy]++; if (isset($transaction->{"provider-org"})) { //We have a provider-org = pass! $no_tracable_transactions[$hierarchy]++; } } if ($transaction_type == "E") { $transaction_type_expenditure[$hierarchy][] = (string) $activity->{'iati-identifier'}; } } //if code attribute exists } } //Going to need a count of disbursements and of IF transactions //Then need to test each against a set of criteria /*if ($transaction_type == NULL) { $transaction_type = "Missing"; echo "missing"; } if ($transaction_type !="D") { echo $id; //die; }*/ //Locations //We can have more than one location, but they should add up to 100% $locations = $activity->location; //if (!isset($activities_with_location[$hierarchy])) { // $activities_with_location[$hierarchy] = 0; //} if (isset($locations) && count($locations) > 0) { $activities_with_location[$hierarchy][] = (string) $activity->{'iati-identifier'}; foreach ($locations as $location) { if (isset($location->coordinates)) { $activities_with_coordinates[$hierarchy][] = (string) $activity->{'iati-identifier'}; } if (isset($location->administrative)) { if (isset($location->administrative->attributes()->adm1)) { $adm1 = string($location->administrative->attributes()->adm1); } if (isset($location->administrative->attributes()->adm2)) { $adm2 = string($location->administrative->attributes()->adm2); } if (isset($adm1) && len($adm1) > 0 || isset($adm2) && len($adm2) > 0) { $activities_with_adminstrative[$hierarchy][] = (string) $activity->{'iati-identifier'}; } } } } //Sector $sectors = $activity->sector; if (isset($sectors) && count($sectors) > 0) { //$activities_with_sector[$hierarchy][] = (string)$activity->{'iati-identifier'}; foreach ($sectors as $sector) { if (!isset($sector->attributes()->vocabulary)) { $activities_sector_assumed_dac[$hierarchy][] = (string) $activity->{'iati-identifier'}; } elseif ((string) $sector->attributes()->vocabulary == "DAC") { //echo "DAC"; $activities_sector_declared_dac[$hierarchy][] = (string) $activity->{'iati-identifier'}; } } } //Last-updated-datetime $last_updated = $activity->attributes()->{'last-updated-datetime'}; $last_updated = strtotime($last_updated); if (!isset($most_recent[$hierarchy])) { $most_recent[$hierarchy] = 0; } if ($last_updated > $most_recent[$hierarchy]) { $most_recent[$hierarchy] = $last_updated; } //Activity dates $activity_dates = $activity->{"activity-date"}; //if (count($activity_dates) > 0) { //if ($activity_dates !=NULL) { // $activities_with_at_least_one[$hierarchy]++; //} foreach ($activity_dates as $activity_date) { //$attributes = array("end-actual","end-planned","start-actual","start-planned"); // $no_activity_dates[$hierarchy]++; //foreach($attributes as $attribute) { $type = (string) $activity_date->attributes()->type; if ($type == "start-actual" || $type == "start-planned") { $type = "start"; } if ($type == "end-actual" || $type == "end-planned") { $type = "end"; } //$date = (string)$activity_date->attributes()->{'iso-date'}; //Special Case for DFID //$date = (string)$activity_date; //echo $date; die; // $unix_time = strtotime($date); //if ($unix_time) { // $year = date("Y",strtotime($date)); //} else { // $year = 0; //we could not parse the date, so store the year as 0 //// } //$activity_by[$year][$hierarchy][$type]++; $activities_with_attribute[$hierarchy][$type][] = (string) $activity->{'iati-identifier'}; //Languages // if($hierarchy == 2) { $title_langs = $country_langs = $description_langs = $all_langs = array(); //Reset each of these each run through //Find default language of the activity $default_lang = (string) $activity->attributes('http://www.w3.org/XML/1998/namespace')->{'lang'}; //echo $default_lang; //Find recipient countries for this activity: $recipient_countries = $activity->{"recipient-country"}; foreach ($recipient_countries as $country) { $code = (string) $country->attributes()->code; //Look up default language for this code: $country_langs[] = look_up_lang($code); } //print_r($country_langs); //Find all the different languages used on the title element $titles = $activity->title; foreach ($titles as $title) { //create an array of all declared languages on titles $title_lang = (string) $title->attributes('http://www.w3.org/XML/1998/namespace')->{'lang'}; if ($title_lang == NULL) { $title_langs[] = $default_lang; } else { $title_langs[] = $title_lang; } $title_lang = ""; } //Find all the different languages used on the description element $descriptions = $activity->description; foreach ($descriptions as $description) { //create an array of all declared languages on titles $description_lang = (string) $description->attributes('http://www.w3.org/XML/1998/namespace')->{'lang'}; if ($description_lang == NULL) { $description_langs[] = $default_lang; } else { $description_langs[] = $description_lang; } $description_lang = ""; } //print_r($title_langs); //die; //Merge these arrays $all_langs = array_merge($description_langs, $title_langs); $all_langs = array_unique($all_langs); //Loop through the country languiages and see if they are found on either the title or description foreach ($country_langs as $lang) { if (in_array($lang, $all_langs)) { $activies_in_country_lang[$hierarchy][] = (string) $activity->{'iati-identifier'}; } } //$description_lang = (string)$activity->description->attributes('http://www.w3.org/XML/1998/namespace')->{'lang'}; // } } } //end foreach } //end if not organisation file } //end if xml is created } // end if file is not a system file } //end while closedir($handle); } //if (isset($types)) { //echo "no_activities" . PHP_EOL; //print_r($no_activities); //echo "activities_with_at_least_one" . PHP_EOL; //print_r($activities_with_at_least_one); //echo "no_activity_dates" . PHP_EOL; //print_r($no_activity_dates); //echo "activity_by_year" . PHP_EOL; ksort($activity_by); //print_r($activity_by); //echo "activities_with_attribute" . PHP_EOL; //print_r($activities_with_attribute); //foreach($types as $attribute_name=>$attribute) { /// echo $attribute_name; //foreach($attribute as $hierarchy=>$values) { // echo $hierarchy; // print_r(array_count_values($values)); // } // } //echo count($participating_org_implementing[0]); die; $found_hierarchies = array_unique($found_hierarchies); sort($found_hierarchies); //die; return array("no-activities" => $no_activities, "activities_with_at_least_one" => $activities_with_at_least_one, "no_activity_dates" => $no_activity_dates, "activity_by_year" => $activity_by, "hierarchies" => array_unique($found_hierarchies), "activities_with_attribute" => $activities_with_attribute, "document_links" => $document_links, "result_element" => $result_element, "conditions" => $conditions, "participating_org_accountable" => $participating_org_accountable, "participating_org_implementing" => $participating_org_implementing, "budget" => $budget, "identifiers" => $identifiers, "transaction_type_commitment" => $transaction_type_commitment, "transaction_type_disbursement" => $transaction_type_disbursement, "transaction_type_expenditure" => $transaction_type_expenditure, "no_disbursements" => $no_disbursements, "no_tracable_transactions" => $no_tracable_transactions, "no_incoming_funds" => $no_incoming_funds, "activities_with_location" => $activities_with_location, "activities_with_coordinates" => $activities_with_coordinates, "activities_with_adminstrative" => $activities_with_adminstrative, "activities_sector_assumed_dac" => $activities_sector_assumed_dac, "activities_sector_declared_dac" => $activities_sector_declared_dac, "most_recent" => $most_recent, "activies_in_country_lang" => $activies_in_country_lang); //} else { // return FALSE; //} }
function formatting($content, $action) { $i = ''; $endStr = ''; $s = ''; $c = ''; $labelName = ''; $startLabel = ''; $endLabel = ''; $endLabelStr = ''; $nLevel = ''; $isYes = ''; $parentLableName = ''; $nextLableName = ''; //下一个标题名称 $isA = ''; //是否为A链接 $isTextarea = ''; //是否为多行输入文本框 $isScript = ''; //脚本语言 $isStyle = ''; //Css层叠样式表 $isPre = ''; //是否为pre $startLabel = '<'; $endLabel = '>'; $nLevel = 0; $action = '|' . $action . '|'; //层级 $isA = false; $isTextarea = false; $isScript = false; $isStyle = false; $isPre = false; $content = replace(replace($content, vbCrlf(), chr(10)), vbTab(), ' '); for ($i = 1; $i <= len($content); $i++) { $s = mid($content, $i, 1); $endStr = mid($content, $i, -1); if ($s == '<') { if (inStr($endStr, '>') > 0) { $s = mid($endStr, 1, inStr($endStr, '>')); $i = $i + len($s) - 1; $s = mid($s, 2, len($s) - 2); if (right($s, 1) == '/') { $s = PHPTrim(left($s, len($s) - 1)); } $endStr = right($endStr, len($endStr) - len($s) - 2); //最后字符减去当前标签 -2是因为它有<>二个字符 //注意之前放在labelName下面 $labelName = mid($s, 1, inStr($s . ' ', ' ') - 1); $labelName = lCase($labelName); //call echo("labelName",labelName) if ($labelName == 'a') { $isA = true; } else { if ($labelName == '/a') { $isA = false; } else { if ($labelName == 'textarea') { $isTextarea = true; } else { if ($labelName == '/textarea') { $isTextarea = false; } else { if ($labelName == 'script') { $isScript = true; } else { if ($labelName == '/script') { $isScript = false; } else { if ($labelName == 'style') { $isStyle = true; } else { if ($labelName == '/style') { $isStyle = false; } else { if ($labelName == 'pre') { $isPre = true; } else { if ($labelName == '/pre') { $isPre = false; } } } } } } } } } } $endLabelStr = $endLabel; $nextLableName = getHtmlLableName($endStr, 0); //不为压缩HTML if (inStr($action, '|ziphtml|') == false && $isPre == false) { if ($isA == false) { if (inStr('|a|strong|u|i|s|script|', '|' . $labelName . '|') == false && '/' . $labelName != $nextLableName && inStr('|/a|/strong|/u|/i|/s|/script|', '|' . $nextLableName . '|') == false) { $endLabelStr = $endLabelStr . chr(10); } } } //单标签最后加个 / 20160615 if (inStr('|br|hr|img|input|param|meta|link|', '|' . $labelName . '|') > 0) { $s = $s . ' /'; } $s = $startLabel . $s . $endLabelStr; //不为压缩HTML if (inStr($action, '|ziphtml|') == false && $isPre == false) { //处理这个 aaaaa</span> if ($isA == false && $isYes == false && left($labelName, 1) == '/' && $labelName != '/script' && $labelName != '/a') { //排除这种 <span>天天发团</span> 并且判断上一个字段不等于vbcrlf换行 if ('/' . $parentLableName != $labelName && right(aspTrim($c), 1) != chr(10)) { $s = chr(10) . $s; } } } $parentLableName = $labelName; $isYes = true; } } else { if ($s != '') { $isYes = false; //call echo("isPre",isPre) if ($isPre == false) { if ($s == chr(10)) { if ($isTextarea == false && $isScript == false && $isStyle == false) { $s = ''; } else { if ($isScript == true) { if (inStr($action, '|zipscripthtml|') > 0) { $s = ' '; } } else { if ($isStyle == true) { if (inStr($action, '|zipstylehtml|') > 0) { $s = ''; } } else { if ($isTextarea == true) { if (inStr($action, '|ziptextareahtml|') > 0) { $s = ''; } } else { $s = chr(10); } } } } // Right(Trim(c), 1) = ">") 为在压缩时用到 } else { if ((right(aspTrim($c), 1) == chr(10) || right(aspTrim($c), 1) == '>') && PHPTrim($s) == '' && $isTextarea == false && $isScript == false) { $s = ''; } } } } } $c = $c . $s; } $c = replace($c, chr(10), vbCrlf()); $formatting = $c; return @$formatting; }
function webStat($folderPath) { $dateTime = ''; $content = ''; $splStr = ''; $thisUrl = ''; $goToUrl = ''; $caiShu = ''; $c = ''; $fileName = ''; $co = ''; $ie = ''; $xp = ''; $goToUrl = serverVariables('HTTP_REFERER'); $thisUrl = 'http://' . serverVariables('HTTP_HOST') . serverVariables('SCRIPT_NAME'); $caiShu = serverVariables('QUERY_STRING'); if ($caiShu != '') { $thisUrl = $thisUrl . '?' . $caiShu; } $goToUrl = @$_REQUEST['GoToUrl']; $thisUrl = @$_REQUEST['ThisUrl']; $co = @$_GET['co']; $dateTime = now(); $content = serverVariables('HTTP_USER_AGENT'); $content = replace($content, 'MSIE', 'Internet Explorer'); $content = replace($content, 'NT 5.0', '2000'); $content = replace($content, 'NT 5.1', 'XP'); $content = replace($content, 'NT 5.2', '2003'); $splStr = aspSplit($content . ';;;;', ';'); $ie = $splStr[1]; $xp = aspTrim($splStr[2]); if (right($xp, 1) == ')') { $xp = mid($xp, 1, len($xp) - 1); } $c = '来访' . $goToUrl . vbCrlf(); $c = $c . '当前:' . $thisUrl . vbCrlf(); $c = $c . '时间:' . $dateTime . vbCrlf(); $c = $c . 'IP:' . getIP() . vbCrlf(); $c = $c . 'IE:' . getBrType('') . vbCrlf(); $c = $c . 'Cookies=' . $co . vbCrlf(); $c = $c . 'XP=' . $xp . vbCrlf(); $c = $c . 'Screen=' . @$_REQUEST['screen'] . vbCrlf(); //屏幕分辨率 $c = $c . '用户信息=' . serverVariables('HTTP_USER_AGENT') . vbCrlf(); //用户信息 $c = $c . '-------------------------------------------------' . vbCrlf(); //c=c & "CaiShu=" & CaiShu & vbcrlf $fileName = $folderPath . Format_Time(now(), 2) . '.txt'; CreateAddFile($fileName, $c); $c = $c . vbCrlf() . $fileName; $c = replace($c, vbCrlf(), '\\n'); $c = replace($c, '"', '\\"'); //Response.Write("eval(""var MyWebStat=\""" & C & "\"""")") $splxx = ''; $nIP = ''; $nPV = ''; $ipList = ''; $s = ''; $ip = ''; //判断是否显示回显记录 if (@$_REQUEST['stype'] == 'display') { $content = getFText($fileName); $splxx = aspSplit($content, vbCrlf() . '-------------------------------------------------' . vbCrlf()); $nIP = 0; $nPV = 0; $ipList = ''; foreach ($splxx as $key => $s) { if (inStr($s, '当前:') > 0) { $s = vbCrlf() . $s . vbCrlf(); $ip = ADSql(getStrCut($s, vbCrlf() . 'IP:', vbCrlf(), 0)); $nPV = $nPV + 1; if (inStr(vbCrlf() . $ipList . vbCrlf(), vbCrlf() . $ip . vbCrlf()) == false) { $ipList = $ipList . $ip . vbCrlf(); $nIP = $nIP + 1; } } } Rw('document.write(\'网长统计 | 今日IP[' . $nIP . '] | 今日PV[' . $nPV . '] \')'); } $webStat = $c; return @$webStat; }
function getInChain($httpUrl, $urlList) { $splStr = ''; $url = ''; $c = ''; $urlLCase = ''; $isHandle = ''; $splStr = aspSplit($urlList, vbCrlf()); $urlList = ''; foreach ($splStr as $key => $url) { if ($url != '') { $urlLCase = lCase($url); if (left($urlLCase, 1) != '#' && left($urlLCase, 11) != 'javascript:') { if (inStr(vbCrlf() . $urlList . vbCrlf(), vbCrlf() . $url . vbCrlf()) == false) { $url = fullHttpUrl($httpUrl, $url); $isHandle = isSonWebSite($url, $httpUrl); if ($isHandle == true) { $urlList = $urlList . $url . vbCrlf(); } } } } } if ($urlList != '') { $urlList = left($urlList, len($urlList) - 2); } $getInChain = $urlList; return @$getInChain; }
function getHandleWebHtmlLink($RootPath, $content) { $startStr = ''; $endStr = ''; $ImgList = ''; $splStr = ''; $c = ''; $CssUrl = ''; $NewCssUrl = ''; $CssStr = ''; $startStr = '<link '; $CssStr = ''; $endStr = '>'; $ImgList = GetArray($content, $startStr, $endStr, false, false); //Call RwEnd(ImgList) $splStr = aspSplit($ImgList, '$Array$'); foreach ($splStr as $key => $CssUrl) { if ($CssUrl != '' && inStr(lCase($CssUrl), 'stylesheet') > 0) { //获得Css加强版,改于20141125 $CssUrl = lCase(replace(replace(replace($CssUrl, '"', ''), '\'', ''), '>', ' ')) . ' '; $startStr = 'href='; $endStr = ' '; if (inStr($CssUrl, $startStr) > 0 && inStr($CssUrl, $endStr) > 0) { $CssUrl = StrCut($CssUrl, $startStr, $endStr, 2); } $NewCssUrl = handleHttpUrl($CssUrl); if (inStr($NewCssUrl, '/') > 0) { $NewCssUrl = mid($NewCssUrl, inStrRev($NewCssUrl, '/') + 1, -1); } if (lCase($NewCssUrl) != 'common.css' && lCase($NewCssUrl) != 'public.css') { $NewCssUrl = $RootPath . $NewCssUrl; $CssStr = $CssStr . '<link href="' . $NewCssUrl . '" rel="stylesheet" type="text/css" />' . vbCrlf(); } } } if ($CssStr != '') { $CssStr = left($CssStr, len($CssStr) - 2); } $getHandleWebHtmlLink = $CssStr; return @$getHandleWebHtmlLink; }
function handleSplitArray($content, $SplOneType, $SplTowType) { $SplA = ''; $SplB = ''; $splStr = ''; $splxx = ''; $i = ''; $s = ''; $c = ''; $j = ''; $t = ''; $SplType = ''; $SplType = '[|Array|]'; $splStr = aspSplit($content, $SplOneType); for ($i = 0; $i <= uBound($splStr); $i++) { if ($splStr[$i] != '') { $splxx = aspSplit($splStr[$i], $SplTowType); $SplA = $SplA . $splxx[0] . $SplType; $SplB = $SplB . $splxx[1] . $SplType; } } if ($SplA != '') { $SplA = left($SplA, len($SplA) - len($SplType)); } if ($SplB != '') { $SplB = left($SplB, len($SplB) - len($SplType)); } $SplA = aspSplit($SplA, $SplType); $SplB = aspSplit($SplB, $SplType); $splStr[uBound($SplA)][uBound($SplB)]; for ($i = 0; $i <= uBound($SplA); $i++) { $splStr[$i][0] = $SplA[$i]; $splStr[$i][1] = $SplB[$i]; } $handleSplitArray = $splStr; return @$handleSplitArray; }
</td><td class="blank"> [smallfont]<a href="showtopic.php?threadid=' . $a_thread['thread_id'] . '&boardid=' . $a_thread['board_id'] . '">' . len($a_thread['thread_topic']) . '</a>[smallfontend] ' . ($a_thread['deleted'] == 1 && P_SHOWDELETED ? ' <img src="templates/' . $style['styletemplate'] . '/images/saved_no.gif" width="10" height="10" border="0" />' : '') . '</td> <td class="blank" style="text-align:right">[smallfont]' . $a_thread['thread_views'] . '[smallfontend]</td> </tr>'; $i++; } mysql_free_result($r_thread); unset($a_thread); // Letzte 10 Posts $r_post = db_query("SELECT\n thread_topic, thread_id, last_post_id, last_act_time, board_id\n FROM " . $pref . "thread WHERE board_id IN (" . $show_boards . ") " . (P_SHOWDELETED ? "" : "AND deleted='0'") . " ORDER BY last_act_time DESC LIMIT 0, 10"); $i = 1; $data['last10posts'] = ''; while ($a_post = db_result($r_post)) { $data['last10posts'] .= '<tr bgcolor="' . ($i % 2 == 0 ? '[CellA]' : '[CellB]') . '"><td class="blank" width="10" style="text-align:right"> [smallfont]' . $i . '[smallfontend] </td><td class="blank"> [smallfont]<a href="showtopic.php?threadid=' . $a_post['thread_id'] . '&boardid=' . $a_post['board_id'] . '#p' . $a_post['last_post_id'] . '">' . len($a_post['thread_topic']) . '</a>[smallfontend]</td> <td class="blank" style="text-align:right">[smallfont]' . datum($a_post['last_act_time']) . '[smallfontend]</td> </tr>'; $i++; } mysql_free_result($r_post); unset($a_post); // letze 12 Monate $month = date("m", $board_time); $year = date("Y", $board_time); $monatsname = array(" ", "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"); $monate = array(); $monate[] = array($monatsname[intval($month)] . ' ' . $year, mktime(0, 0, 0, intval($month), 1, $year), mktime(0, 0, -1, intval($month) + 1, 1, $year)); for ($i = 0; $i < 12; $i++) { $month--; if ($month == 0) {
function add_if_not_exists3($what, $where, $group) { # digerinden farkı: istenilen my.cnf grubu altına ekler. # especially for config files with [groups], such as my.cnf $filearr = @file($where, FILE_IGNORE_NEW_LINES); # do not include \n character in strings if (!$filearr) { echo "cannot open file, trying to setup: ({$where})\n"; $fp = fopen($where, 'w'); fclose($fp); $filearr = file($where); } # once group bulunacak: $keys = array_keys($filearr, $group); if (len($keys) == 0) { #echo "#group not found, add group&item \n"; $filearr[] = $group; $filearr[] = $what; } else { $group_pos = $keys[0]; #echo "# group found.. at $group_pos \n"; $i = $group_pos + 1; # start searching token from next line, until next group name $found = False; while ($i < len($filearr) and $filearr[$i][0] != '[' and $filearr[$i] != $what) { $i++; } if ($i >= len($filearr)) { #echo "#dosya sonu geldi, sonuna ekle..\n"; $filearr[] = $what; } elseif ($filearr[$i] == $what) { #echo "# found, just return \n"; return; } else { array_splice($filearr, $i, 0, $what); #echo "# insert item here: $i \n"; } } arraytofile($where, $filearr, "\n"); }
function map_mit_phone($number) { $number = str_replace('/', '-', $number); // add the local area code if missing if(preg_match('/^\d{3}-\d{4}/', $number)) { return '617-' . $number; } // check if the number is short number such as x4-2323, 4-2323, 42323 if(preg_match('/^\d{5}/', $number)) { $number = substr($number, 0, 1) . '-' . substr($number, 1); } elseif(preg_match('/^x\d/', $number)) { $number = substr($number, 1, 1) . '-' . substr($number, len($number) - 4); } elseif(!preg_match('/^\d-\d{4}/', $number)) { return $number; } // if short number add the appropriate prefix and area code global $phonemap; foreach ($phonemap as $range) { if ($phone >= $range[0] && $phone >= $range[1]) { $phone = $range[2] . $phone; } } return $number; }
function validate($str, $maxLen) { return len($str) <= $maxLen; }
function copyHtmlToWeb() { $webDir = ''; $toWebDir = ''; $toFilePath = ''; $filePath = ''; $fileName = ''; $fileList = ''; $splStr = ''; $content = ''; $s = ''; $s1 = ''; $c = ''; $webImages = ''; $webCss = ''; $webJs = ''; $splJs = ''; $webFolderName = ''; $jsFileList = ''; $setFileCode = ''; $nErrLevel = ''; $jsFilePath = ''; $url = ''; $setFileCode = @$_REQUEST['setcode']; //设置文件保存编码 handlePower('复制生成HTML页面'); //管理权限处理 writeSystemLog('', '复制生成HTML页面'); //系统日志 $webFolderName = $GLOBALS['cfg_webTemplate']; if (left($webFolderName, 1) == '/') { $webFolderName = mid($webFolderName, 2, -1); } if (right($webFolderName, 1) == '/') { $webFolderName = mid($webFolderName, 1, len($webFolderName) - 1); } if (inStr($webFolderName, '/') > 0) { $webFolderName = mid($webFolderName, inStr($webFolderName, '/') + 1, -1); } $webDir = '/htmladmin/' . $webFolderName . '/'; $toWebDir = '/htmlw' . 'eb/viewweb/'; CreateDirFolder($toWebDir); $toWebDir = $toWebDir . pinYin2($webFolderName) . '/'; deleteFolder($toWebDir); //删除 CreateFolder('/htmlweb/web'); //创建文件夹 防止web文件夹不存在20160504 deleteFolder($webDir); CreateDirFolder($webDir); $webImages = $webDir . 'Images/'; $webCss = $webDir . 'Css/'; $webJs = $webDir . 'Js/'; copyFolder($GLOBALS['cfg_webImages'], $webImages); copyFolder($GLOBALS['cfg_webCss'], $webCss); CreateFolder($webJs); //创建Js文件夹 //处理Js文件夹 $splJs = aspSplit(getDirJsList($webJs), vbCrlf()); foreach ($splJs as $key => $filePath) { if ($filePath != '') { $toFilePath = $webJs . getFileName($filePath); aspEcho('js', $filePath); moveFile($filePath, $toFilePath); } } //处理Css文件夹 $splStr = aspSplit(getDirCssList($webCss), vbCrlf()); foreach ($splStr as $key => $filePath) { if ($filePath != '') { $content = getFText($filePath); $content = replace($content, $GLOBALS['cfg_webImages'], '../images/'); $content = deleteCssNote($content); $content = PHPTrim($content); //设置为utf-8编码 20160527 if (lCase($setFileCode) == 'utf-8') { $content = replace($content, 'gb2312', 'utf-8'); } WriteToFile($filePath, $content, $setFileCode); aspEcho('css', $GLOBALS['cfg_webImages']); } } //复制栏目HTML $GLOBALS['isMakeHtml'] = true; $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'webcolumn where isonhtml=true'); while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) { $GLOBALS['glb_filePath'] = replace(getColumnUrl($rss['columnname'], 'name'), $GLOBALS['cfg_webSiteUrl'] . '/', ''); if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') { $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html'; } if (right($GLOBALS['glb_filePath'], 5) == '.html') { if (right($GLOBALS['glb_filePath'], 11) == '/index.html') { $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf(); } else { $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList; } $fileName = replace($GLOBALS['glb_filePath'], '/', '_'); $toFilePath = $webDir . $fileName; copyFile($GLOBALS['glb_filePath'], $toFilePath); aspEcho('导航', $GLOBALS['glb_filePath']); } } //复制文章HTML $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'articledetail where isonhtml=true'); while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) { $GLOBALS['glb_url'] = getHandleRsUrl($rss['filename'], $rss['customaurl'], '/detail/detail' . $rss['id']); $GLOBALS['glb_filePath'] = replace($GLOBALS['glb_url'], $GLOBALS['cfg_webSiteUrl'] . '/', ''); if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') { $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html'; } if (right($GLOBALS['glb_filePath'], 5) == '.html') { if (right($GLOBALS['glb_filePath'], 11) == '/index.html') { $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf(); } else { $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList; } $fileName = replace($GLOBALS['glb_filePath'], '/', '_'); $toFilePath = $webDir . $fileName; copyFile($GLOBALS['glb_filePath'], $toFilePath); aspEcho('文章' . $rss['title'], $GLOBALS['glb_filePath']); } } //复制单面HTML $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'onepage where isonhtml=true'); while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) { $GLOBALS['glb_url'] = getHandleRsUrl($rss['filename'], $rss['customaurl'], '/page/page' . $rss['id']); $GLOBALS['glb_filePath'] = replace($GLOBALS['glb_url'], $GLOBALS['cfg_webSiteUrl'] . '/', ''); if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') { $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html'; } if (right($GLOBALS['glb_filePath'], 5) == '.html') { if (right($GLOBALS['glb_filePath'], 11) == '/index.html') { $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf(); } else { $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList; } $fileName = replace($GLOBALS['glb_filePath'], '/', '_'); $toFilePath = $webDir . $fileName; copyFile($GLOBALS['glb_filePath'], $toFilePath); aspEcho('单页' . $rss['title'], $GLOBALS['glb_filePath']); } } //批量处理html文件列表 //call echo(cfg_webSiteUrl,cfg_webTemplate) //call rwend(fileList) $sourceUrl = ''; $replaceUrl = ''; $splStr = aspSplit($fileList, vbCrlf()); foreach ($splStr as $key => $filePath) { if ($filePath != '') { $filePath = $webDir . replace($filePath, '/', '_'); aspEcho('filePath', $filePath); $content = getFText($filePath); foreach ($splStr as $key => $s) { $s1 = $s; if (right($s1, 11) == '/index.html') { $s1 = left($s1, len($s1) - 11) . '/'; } $sourceUrl = $GLOBALS['cfg_webSiteUrl'] . $s1; $replaceUrl = $GLOBALS['cfg_webSiteUrl'] . replace($s, '/', '_'); //Call echo(sourceUrl, replaceUrl) '屏蔽 否则大量显示20160613 $content = replace($content, $sourceUrl, $replaceUrl); } $content = replace($content, $GLOBALS['cfg_webSiteUrl'], ''); //删除网址 $content = replace($content, $GLOBALS['cfg_webTemplate'] . '/', ''); //删除模板路径 记 //content=nullLinkAddDefaultName(content) foreach ($splJs as $key => $s) { if ($s != '') { $fileName = getFileName($s); $content = replace($content, 'Images/' . $fileName, 'js/' . $fileName); } } if (inStr($content, '/Jquery/Jquery.Min.js') > 0) { $content = replace($content, '/Jquery/Jquery.Min.js', 'js/Jquery.Min.js'); copyFile('/Jquery/Jquery.Min.js', $webJs . '/Jquery.Min.js'); } $content = replace($content, '<a href="" ', '<a href="index.html" '); //让首页加index.html createFileGBK($filePath, $content); } } //把复制网站夹下的images/文件夹下的js移到js/文件夹下 20160315 $htmlFileList = ''; $splHtmlFile = ''; $splJsFile = ''; $htmlFilePath = ''; $jsFileName = ''; $jsFileList = getDirJsNameList($webImages); $htmlFileList = getDirHtmlList($webDir); $splHtmlFile = aspSplit($htmlFileList, vbCrlf()); $splJsFile = aspSplit($jsFileList, vbCrlf()); foreach ($splHtmlFile as $key => $htmlFilePath) { $content = getFText($htmlFilePath); foreach ($splJsFile as $key => $jsFileName) { $content = regExp_Replace($content, 'Images/' . $jsFileName, 'js/' . $jsFileName); } $nErrLevel = 0; $content = handleHtmlFormatting($content, false, $nErrLevel, '|删除空行|'); //|删除空行| $content = handleCloseHtml($content, true, ''); //闭合标签 $nErrLevel = checkHtmlFormatting($content); if (checkHtmlFormatting($content) == false) { echoRed($htmlFilePath . '(格式化错误)', $nErrLevel); //注意 } //设置为utf-8编码 if (lCase($setFileCode) == 'utf-8') { $content = replace($content, '<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />', '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'); } $content = PHPTrim($content); WriteToFile($htmlFilePath, $content, $setFileCode); } //images下js移动到js下 foreach ($splJsFile as $key => $jsFileName) { $jsFilePath = $webImages . $jsFileName; $content = getFText($jsFilePath); $content = PHPTrim($content); WriteToFile($webJs . $jsFileName, $content, $setFileCode); DeleteFile($jsFilePath); } copyFolder($webDir, $toWebDir); //使htmlWeb文件夹用php压缩 if (@$_REQUEST['isMakeZip'] == '1') { makeHtmlWebToZip($webDir); } //使网站用xml打包20160612 if (@$_REQUEST['isMakeXml'] == '1') { makeHtmlWebToXmlZip('/htmladmin/', $webFolderName); } //浏览地址 $url = 'http://10.10.10.57/' . $toWebDir; aspEcho('浏览', '<a href=\'' . $url . '\' target=\'_blank\'>' . $url . '</a>'); }
function haveChina($content) { $i = ''; $j = ''; $haveChina = false; for ($i = 1; $i <= len($content); $i++) { $j = asc(mid($content, $i, 1)); //是汉字累加 if ($j < 0) { if (($j <= -22033 && $j >= -24158) == false) { $haveChina = true; return @$haveChina; } } } return @$haveChina; }
function getHtmlValue($content, $sType) { $i = ''; $endStr = ''; $s = ''; $labelName = ''; $startLabel = ''; $endLabel = ''; $LCaseEndStr = ''; $paramName = ''; $startLabel = '<'; $endLabel = '>'; for ($i = 1; $i <= len($content); $i++) { $s = mid($content, $i, 1); $endStr = mid($content, $i, -1); if ($s == '<') { if (inStr($endStr, '>') > 0) { $s = mid($endStr, 1, inStr($endStr, '>')); $i = $i + len($s) - 1; $s = mid($s, 2, len($s) - 2); $s = PHPTrim($s); if (right($s, 1) == '/') { $s = PHPTrim(left($s, len($s) - 1)); } $endStr = right($endStr, len($endStr) - len($s) - 2); //最后字符减去当前标签 -2是因为它有<>二个字符 //注意之前放在labelName下面 $labelName = mid($s, 1, inStr($s . ' ', ' ') - 1); $labelName = lCase($labelName); if ($labelName == 'title' && $sType == 'webtitle') { $LCaseEndStr = lCase($endStr); if (inStr($LCaseEndStr, '</title>') > 0) { $s = mid($endStr, 1, inStr($LCaseEndStr, '</title>') - 1); } else { $s = ''; } $getHtmlValue = $s; return @$getHtmlValue; } else { if ($labelName == 'meta' && ($sType == 'webkeywords' || $sType == 'webdescription')) { $LCaseEndStr = lCase($endStr); $paramName = PHPTrim(lCase(getParamValue($s, 'name'))); if ('web' . $paramName == $sType) { $getHtmlValue = getParamValue($s, 'content'); return @$getHtmlValue; } } } } } } $getHtmlValue = ''; return @$getHtmlValue; }
function XY_handleGetTableBody($action, $tableName, $fieldParamName, $defaultFileName, $adminUrl) { $url = ''; $content = ''; $id = ''; $sql = ''; $addSql = ''; $fieldName = ''; $fieldParamValue = ''; $fieldNameList = ''; $nLen = ''; $delHtmlYes = ''; $trimYes = ''; $defaultStr = ''; $noisonhtml = ''; $intoFieldStr = ''; $valuesStr = ''; $nonull = ''; $fieldName = RParam($action, 'fieldname'); //字段名称 $noisonhtml = RParam($action, 'noisonhtml'); //不生成html $nonull = RParam($action, 'noisonhtml'); //内容不能为空20160716 home if ($noisonhtml == 'true') { $intoFieldStr = ',isonhtml'; $valuesStr = ',0'; } $fieldNameList = getHandleFieldList($GLOBALS['db_PREFIX'] . $tableName, '字段列表'); //字段名称不为空,并且要在表字段里 if ($fieldName == '' || inStr($fieldNameList, ',' . $fieldName . ',') == false) { $fieldName = $defaultFileName; } $fieldName = lCase($fieldName); //转为小写,因为在PHP里是全小写的 $fieldParamValue = RParam($action, $fieldParamName); //截取字段内容 $id = handleNumber(RParam($action, 'id')); //获得ID $addSql = ' where ' . $fieldParamName . '=\'' . $fieldParamValue . '\''; if ($id != '') { $addSql = ' where id=' . $id; } $content = getDefaultValue($action); $defaultStr = $content; //获得默认内容 $sql = 'select * from ' . $GLOBALS['db_PREFIX'] . $tableName . $addSql; $rsObj = $GLOBALS['conn']->query($sql); if (@mysql_num_rows($rsObj) == 0) { $rs = mysql_fetch_array($rsObj); //自动添加 20160113 if (RParam($action, 'autoadd') == 'true') { connexecute('insert into ' . $GLOBALS['db_PREFIX'] . $tableName . ' (' . $fieldParamName . ',' . $fieldName . $intoFieldStr . ') values(\'' . $fieldParamValue . '\',\'' . ADSql($content) . '\'' . $valuesStr . ')'); } } else { $id = $rs['id']; $content = $rs[$fieldName]; if (len($content) <= 0) { $content = $defaultStr; connexecute('update ' . $GLOBALS['db_PREFIX'] . $tableName . ' set ' . $fieldName . '=\'' . $content . '\' where id=' . $rs['id']); } } //删除Html $delHtmlYes = RParam($action, 'delHtml'); //是否删除Html if ($delHtmlYes == 'true') { $content = replace(delHtml($content), '<', '<'); } //HTML处理 //删除两边空格 $trimYes = RParam($action, 'trim'); //是否删除两边空格 if ($trimYes == 'true') { $content = TrimVbCrlf($content); } //截取字符处理 $nLen = RParam($action, 'len'); //字符长度值 $nLen = handleNumber($nLen); //If nLen<>"" Then ReplaceStr = CutStr(ReplaceStr,nLen,"null")' Left(ReplaceStr,nLen) if ($nLen != '') { $content = CutStr($content, $nLen, '...'); } //Left(ReplaceStr,nLen) if ($id == '') { $id = XY_AP_GetFieldValue('', $sql, 'id'); } $url = $adminUrl . '&id=' . $id . '&n=' . getRnd(11); if (@$_REQUEST['gl'] == 'edit') { $content = '<span>' . $content . '</span>'; } //call echo(sql,url) $content = handleDisplayOnlineEditDialog($url, $content, '', 'span'); $XY_handleGetTableBody = $content; return @$XY_handleGetTableBody; }
function cutFunctionvValue($content, $startStr, $endStr) { $ku1 = ''; $ku2 = ''; $i = ''; $s = ''; $c = ''; $ku1 = 1; $ku2 = 0; for ($i = 1; $i <= len($content); $i++) { $s = mid($content, $i, 1); $c = $c . $s; if ($s == $startStr) { $ku1 = $ku1 + 1; } else { if ($s == $endStr) { $ku2 = $ku2 + 1; if ($ku1 == $ku2) { break; } } } } $cutFunctionvValue = $c; return @$cutFunctionvValue; }
function handleTransferChinese_temp($content, $sType) { $zd = ''; $i = ''; $s = ''; $c = ''; $zd = '�I�����}���@���K���۰��a���\\�W�Ӊΰ��T�ڔ[�ܔ����C���k��O��Ͱ��^���r��������������U��݅��ؐ���^���N���䱹�v�����ʹP�Ϯ��Д��Ҏű��]��߅�ྎ���H��׃���q���p��˱��M���e��T���l���I���e���P����ܲ������K���g���a��ؔ�΅����Q�К��ёM�ґK�ӠN���n��œ�ւ}�ל�ގ����Ȳ�Բ�y��Ӳ�Ԍ��v�������s�������p���P���a���U��������L���L�������c���S�������n��܇���س��m��ꐳ��r�œγƷQ�͑ͳ��\\���G�հV���t���Y�ܐu���X����_���x�茙�뮠���P��I��I�������N���z���r���A�������|��̎�����������J�������N�����¾b���o���~���n�����[�ч�ӏĴԅ��՜����f�ܸZ���e���_�������J���ε������۵�đ�������Q���������������h��ʎ���n���v���u���\\�������I�Ɵ������Д��Ӝ���f������c��|��늵�឵��{��ՙ���B��ᔶ�픶��V��ӆ���G���|���Ӷ����������ٶ������x��ـ��僶�呶ϔ�о��҃���꠶Ԍ��և����D���g��Z�鉙���Z���~��Ӟ���I�����������D���E���l���y���m���\\���C����������L�ļ����w���u�ϏU���M���؉��܊^�ߑ���S���S������h���L�诂���T��p���S���P���w��ݗ���Ḩ�o���x����ؓ��Ӈ���D���`��ԓ���}���w�˗U���s�Ѷ����M�Ԍ��Մ���䓸پV�ڍ���怸�R�������w���t�������o�������m��얹�ؕ���^���Ϲ�ƈ������ُ������M��Є��Ғ���P���^���^�ߑT��؞��V��Ҏ��w�������|��܉��Ԏ���F��݁���L��偹������^���n���h��̖���u���Q���R��M���Z������t���ػ��o�����������W���A����������Ԓ���ѻ��Ļ��g���h��߀�������Q���������������o���S���e�ӓ]���x�ٚ����V��x�����Z��R���M���d���L��ȝ�뜆��@��؛�����������C���e�������E���I���u�����������O���������D�����E�����Ý���Ӌ��ӛ���H���^�ͼo�ЊA���v���a���Z��⛼ۃr���{�ߚ���O��Լ�{���g���D��}���O��z��A���|��������p���]�������b���`���v��Ҋ���I��Ş�������T���u���R�����������{���Y�����������v���u���z�������ɽ������q�óC�ăe���_����U�ʽg���I���^���A�ڹ�������Y���]��ý��o���\\���H��֔���M���x���a���M���ž��G���o���L���@�������i���o���R�������d�����������m�ǎ����f���x���e�ݓ���䏾�־無���N����X���Q���E���^���x��܊���E���_���P���w�ǚ����n�щ��ґ��ٓ�����ѝ��K��~�팒��V������r��̝���h���Q�����������U�����Ϟ���D���R������ه���{�������r���@���@���m�������������[�������|�à��ĞE�Ŭ��̓��̈́��ԝ��֘����D�݉������I��h�����x������Y���������������[���v���r���`���z����ɏ���B������z���i����������Ę������������������Z�����������v��Տ�Ư����|����ԫC���R�������[�݄C���U���g������`��X���I���s�����������@�������\\¢��¤�]¥��¦��§��¨�t«�J¬�R�B®�]¯�t°��±�u²̔³��¸�T»��¼�½�¿�H�������X�H�Ō��ƿ|�Ǒ]�˞V�̾G�͎n�Δ��ό\\�О��ҁy�Ւ���݆�ׂ����ٜS�ھ]��Փ���}���_��߉�����j��������j�苌�ꬔ��a��Λ���R���R�������I�������u���~���}���m���z���U���Má֙è؈ê�^í�Tó�Qû�]þ�V���T�Ɛ��ǂ����i�Ή��в[���i�֏���Ғ�݃���d�徒��R����������}���Q�����ևı�\\Ķ���Ņ����c�ɼ{���y�ӓ����X�Ր����[���H�ڃ���M��ā��f������B������������������������š�QŢ��ť�oŦ�~ŧēŨ��ũ�rű��ŵ�Zŷ�WŸ�tŹ��Ż�IŽ�a�̱P�����ג����r�燊���iƭ�_Ʈ�hƵ�lƶؚƻ�Oƾ�{���u�Ý����H�˓�����Ә����V�ܗ���Ě���R���T���M������������әǣ��ǥ�FǦ�UǨ�wǩ��ǫ�tǮ�Xǯ�QDZ��dz�\\Ǵ�lǵ�qǹ��Ǻ��ǽ��Ǿ�Nǿ���������@�Ř��dž��ȃS���N�ϸ[�Ը`�՚J���H�ތ����p�����A�����Ո��c����F��څ���^���|���ȣ�xȧ�EȨ��Ȱ��ȴ�sȵ�oȷ�_�������Ŕ_���@�ȟ����g���J�Ҽx�٘s�q��ܛ���J���c���������_���w��ِɡ��ɥ��ɧ�}ɨ��ɬ��ɱ��ɲ�xɴ��ɸ�Yɹ��ɾ�h���W�����٠�ɿ��ʉ��˂����p�՟��ܽB���d��z������O����������I���B�����Kʤ��ʦ��ʨ�{ʪ��ʫԊʱ�rʴ�gʵ��ʶ�Rʻ��Ƅ����m��������ҕ��ԇ�ى��ޫF������ݔ������H������g�������Q����˧��˫�p˭�l˰��˳�˵�f˶�T˸�q˿�z������ˑZ������A���b�Ӕ\\���K���V���C���m���S�罗��q��O��p��S���s�������i̡�H̢��̨�_̬�B̯��̰؝̱�c̲��̳��̷�T̸Մ̾�@�����̠C�Ν��н{��ӑ���v���`���R���}���w������l���N���F���d�� ���Nͭ�~ͳ�yͷ�^ͺ�dͼ�D�ňF���j��͑��Ó���r���W����֙E���m�䏝�垳���B���f���WΤ�fΥ�`Χ��Ϊ��Ϋ�Hά�SέȔΰ��α��γ��ν�^���l�����Ƽy�ȷ��ʆ��ͮY�Γ����Мu�ѸC���P�؆����u�ڞ����_�ޟo��ʏ�����]���F������`���a����Ϯ�uϰ��ϳ�Ϸ��ϸ��Ϻ�rϽݠϿ�{���b���M�ÏB�Ň����r���w���t������e���@���U�֬F�I�ؿh���W���w�ܑ��߾����������l��Ԕ��������ʒ�������N����Х�[Э�fЮ��Я�yв�{г�Cд��к�aл�xп�\\������d�׃��ڛ����P���C��̓��u������S�����w���m������ѡ�xѢ�_Ѥ�kѧ�Wѫ��ѯԃѰ��ѱ�ZѵӖѶӍѷ�dѹ��ѻ�fѼ���Ɔ��ǁ���Ӡ����̟����}�χ��Ҏr���������G�ᅒ�Ⳏ�叩���V������������P��������W���B��������ҡ�uҢ��ң�bҤ�Gҥ�{ҩˎү��ҳ�ҵ�IҶ�~ҽ�tҿ����U���z�ǃx��ρ��ˇ�ڃ|�䑛���x��Ԅ���h���x���g�쮐���[���a������y������[ӣ��Ӥ��ӥ��Ӧ��ӧ�tӨ��өΞӪ�Iӫ��ӬωӮ�Aӱ�fӴ��ӵ��Ӷ��Ӹ�bӻ�xӽԁ�Ń��Ǒn���]����̪q���T��ݛ���~��O������c��Z���Z���z���uԤ�AԦ�Sԧ�xԨ�Yԯ�@�@Ա�TԲ�AԵ��Զ�hԼ�sԾ�SԿ������Ð�������y�Ȅ����E���\\���N���j�Ε�������s�֞����d�ܔ��ݕ���ٝ���E���K����旗��؟�����t������\\��ٛ��܈ա�բ�lդ��թ�pի�Sծ��ձ��յ�Kն��շݚո��ջ��ս�����`�ŏ��ǝq�ʎ����~��Û���w���U���H���N���@��ؑ���������\\�����������������b����֡��֢�Y֣��֤�C֯��ְִ��ֽ��ֿ�����S�Ď����|�͜�����սK�ַN���[�ڱ����a���S�尙�畃���E���i���T���D��T�����������A���Tפ�vר��ש�uת�Dٍ��ׯ�fװ�bױ�y׳��״���F٘���YՁ�������ǝ���Ɲ���Y�՝n��ۙ�۾C�ܿ��ݿv���u���{��M���@ب��غ�G���d�Ć��Dž��Ʌ��ˏP���v���I�ЅQ�хT��ّ�لq�ۄ��܄�������t��������٭��ٯ�zٱ��ٲ��ٳ��ٶ�R�ǃf�̂��̓E���σ��Ѓ��݃L��e���Z������D������Ж���C���L���AڦӓڧӏڨӘک֎ڪ�nګ�Gڬ�bڭ�Xڮ�gگ�tڰ�xڱ�rڲ�Eڳ�CڴԟڵԑڶԜڷԖڸԍڹԏںՊڻ՟ڼԂڽ�Vھ�aڿ�N���O��Ռ��Վ��Ն����Ք���~���r���R���G���o���]���@���I���X���O���B���J��՛��փ��ו���q���u���k��ֆ���P���S���H��ח���d���ᎄ�������������w����ۣ�Pۦ��۩�i۪�Bۻ�cۼ�J۽���ώ��ш��ۉ��މ�����눺��N���s���P�������_ܳ�Hܼ�Gܿ�|��˞���{���O��ɐ���S���r���d���\\��L�䟦��ʁ��ɜ���w���C���j��������ݡ�nݣ�|ݥ�pݦȇݪ�Pݫ�nݰ�Wݲ�Wݵ�~ݺ�L�ӿM���r��ʉ���V������y���v��ʚ���`���Aޭ�I˒�\\���Y�ƊY�ό��ђ��ғ��ؓ��ⓝ�蓥�����d���tߢ�Xߣ�]ߥ�xߦ�{߱�sߴ�\\�`߽��߿���h�ÆJ�̇��Շ}�؇^�ن��܇������⇝�懁��O��Z������K����ඇD�࿇��ȇ����\\�Ӈ�������������������������ᫍ�sᰍ�ᴍ�ỎFὍ�῍����������ɎV���Ѝ��ێp�����E�������s����⤫M⨫J��h����q��������������A���G���Q���t���x���}���~�����ЏT���s�ޏ[����䑓��Y����ꐝ����������Q������������㢐�㥑a㫐�㳑C㴑|���V���Z������b���h���`���Y���������b������������]������������������H���D���I���R�㞖�휿��{��o���T����䤛�䥜�䫝�䯞g䰝G䱝�䵜Z䶝��^�ŝ��ɞc�˜O�ܞ��ޞ]�䝧��u��t�����|尞���q��߃��ޟ��ߊ��������������橊�櫋I欋�殌D洋z测�濋������ȋ��ɋ��͋������z���������|���A���w���~������������P���U���S���K������s���\\������t���~������������K���J���u���q���v���w���k硼�碼�磼�礽C祼�禼�秿U稽E穽I窽H笽W筽{箽�篽�簽�籾c精_糾p絾i綾E緾R績^繾J纾U绾l缾~罾|羾�翾����D�����¾��þ��ĿP�ž��ƿN�ǿb�ȿd�ɿc�ʿr�˿O�̿V���_�ο~�Ͽz�пw�ѿ��ҿ����i�Կ��տ����\\���`���R���Q���y��^��|��k�筇������t���q���I設a謭�趭���t��y��w还q�����Ǘ��Ș��ɗn�Ι��Й��ә��ٗd�ݙ��ߙf�◿�����E�瘁�����u���������������顙�餘�魙�鴙�鵙�鷙��ę��ƙ��ə{�֙��ڙ��ݙ_��{�䚑�暌�皚�隗�뚛��ܐ��ܗ���V���_���T���W���F���]���U���Y���e���b���`���m��݂���y��z��w�ݏ��A��O꧑�ꨑ�ꯑ�걮T꼕��ʕ��͕��ӕ����S���B���L���O��ٗ���D���W���B���c���l���g���y��َ��җ���J��Ҡ���]���D���M���P���U맚�몚�벚�뵚�빠��ʖV���F��Ä��Ē���T���t���e��Ĝ죚e��R��S��Z��`��j�ݞ��W쵔�쾟�쿟����������ǟ��ˠF��c��[�������U�������������X���µZ�õa�̳��ʹ��Ӵ��״~�������{���A������Ï���`��b������������������Q���A������{���O���S���������k���j���[������^������Z������`���������������X���f���g������p������C���B���G���������I���D������s���B������e���t���K������z������b���A���f������x��|����P��C��|��|��@������n����H������~��S��s��Z��u��|��H����Q����K���d������U���O������|���J���������}���D���U���I���������k������y���������\\���S���M���N������O���������C������h������|������j������Z���C���O���s���R�w��F��S��d��c��������R��z��|��������v��������[��P��Z���]���O�������Y���^���g���l���������������\\���F���_���Y���W���p���w�����������������������X�ܰX�ݰO�尒��A��B���D���������`�a�]�d�]���M���d��ў���c���@���h�䰗���e�������������@��R��M�}��W��h������D��������A��l�ϊ�͘�ϖ��Ϡ���|��͐���u��·��ϓ���X��ϔ���N����ƺV�ȹa�ֻe�ٺ`�ݹ~��j��D��X�캄�ﺍ�����f���[��Ŝ���A���U���u�̶i�ϼc�мg�ּR��{������ڎ���������z���O��ۄ���V���E��ۋ���]���Q���W���U���b��ۘ���X���k���g���x���z���n���Z���V���\\���Z���e���_���f���b���l���r���p���}���w���x�������h��ׇ������Y�����������|�շd���V���c���T���q���^���n���b���q���o���\\�������~�������������������������������a�������N���O���E���H���K���F���T�����������l���{���q���v���m���������������������������B���L�������Z���X���V���k���^���d���X���t���y���x���|���u����������W���N���t���o���B'; for ($i = 1; $i <= len($content); $i++) { $s = mid($content, $i, 1); if (inStr($zd, $s) > 0) { if ($sType == 1) { $s = mid($zd, inStr($zd, $s) - 1, 1); } else { $s = mid($zd, inStr($zd, $s) + 1, 1); } } $c = $c . $s; } $handleTransferChinese_temp = $c; return @$handleTransferChinese_temp; }
private static function _filterForRichMsg($articles) { $i = 0; $ii = len($articles); $list = array('title', 'desc', 'url', 'thumb_url'); $result = array(); while ($i < $ii) { $currentArticle = $articles[$i++]; try { array_push($result, array('title' => $currentArticle['title'], 'description' => $currentArticle['desc'], 'url' => $currentArticle['url'], 'picurl' => $currentArticle['thumb_url'])); } catch (Exception $e) { } } return $result; }
public function xDate($DateValue = null, $DateFormat = "date") { $oDate = new Date($DateValue); switch (lcase($DateFormat)) { case "fulldatestring": return $oDate->format("%d-%b-%Y %H:%M:%S"); break; case "fulldate": return $oDate->format("%d-%m-%Y %H:%M:%S"); break; case "datetime": return $oDate->format("%d-%m-%Y %H:%M"); break; case "datestring": return $oDate->format("%d %b %Y"); break; case "date": return $oDate->format("%d-%m-%y"); break; case "entrystring": return $oDate->format("%y %b %d"); break; case "entry": return $oDate->format("%d/%m/%y"); break; case "monthyear": return $oDate->format("%B %Y"); break; case "monyear": return $oDate->format("%b %Y"); break; case "time": if (len($DateValue) > 0) { return $oDate->format("%H:%M"); } break; case "timesec": return $oDate->format("%H:%M:%S"); break; case "sql": if (lcase(DB_TYPE) == "mysql") { //return $oDate->format("%Y-%m-%d"); return $oDate->format("%d-%m-%y"); } elseif (lcase(DB_TYPE == "mssql")) { return $oDate->format("%m/%y/%d"); } break; case "periode": // Full Version // return date("Ym"); // Demo Version Only return "200506"; break; case "periode_string": return $oDate->format("% %b %d"); break; case "periode_post": return $oDate->format("%d%m"); break; case "periodestring": // Full Version // return date("Ym"); // Demo Version Only return "Mei 2005"; break; case "file": return $oDate->format("%Y/%m/%d"); break; } }