function inverseHex($color) { $color = TRIM($color); $prependHash = FALSE; if (STRPOS($color, '#') !== FALSE) { $prependHash = TRUE; $color = STR_REPLACE('#', NULL, $color); } switch ($len = STRLEN($color)) { case 3: $color = PREG_REPLACE("/(.)(.)(.)/", "\\1\\1\\2\\2\\3\\3", $color); case 6: break; default: TRIGGER_ERROR("Invalid hex length ({$len}). Must be (3) or (6)", E_USER_ERROR); } if (!PREG_MATCH('/[a-f0-9]{6}/i', $color)) { $color = HTMLENTITIES($color); TRIGGER_ERROR("Invalid hex string #{$color}", E_USER_ERROR); } $r = DECHEX(255 - HEXDEC(SUBSTR($color, 0, 2))); $r = STRLEN($r) > 1 ? $r : '0' . $r; $g = DECHEX(255 - HEXDEC(SUBSTR($color, 2, 2))); $g = STRLEN($g) > 1 ? $g : '0' . $g; $b = DECHEX(255 - HEXDEC(SUBSTR($color, 4, 2))); $b = STRLEN($b) > 1 ? $b : '0' . $b; return ($prependHash ? '#' : NULL) . $r . $g . $b; }
function STR_FILTER($TOKEN) { $TOKEN = LUMINOUSUTILS::ESCAPE_TOKEN($TOKEN); $STR =& $TOKEN[1]; $STR = PREG_REPLACE('/: (?: (?:[\\)o":]|>) |\\([a-fA-F0-9]*\\) |\\[[A-Z ]*\\] |\\{\\w*\\} )/x', '<VARIABLE>$0</VARIABLE>', $STR); return $TOKEN; }
public static function PHONE($N) { $N = PREG_REPLACE("/[^0-9]/", "", $N); if (STRLEN($N) == 7) { return PREG_REPLACE("/([0-9]{3})([0-9]{4})/", "\$1-\$2", $N); } else { if (STRLEN($N) == 10) { return PREG_REPLACE("/([0-9]{3})([0-9]{3})([0-9]{4})/", "(\$1) \$2-\$3", $N); } else { return $N; } } }
public function strFilter($TOKEN) { $TOKEN = Utils::ESCAPETOKEN($TOKEN); $STR =& $TOKEN[1]; $STR = PREG_REPLACE('/: (?: (?:[\\)o":]|>) |\\([a-fA-F0-9]*\\) |\\[[A-Z ]*\\] |\\{\\w*\\} ) /x', '<VARIABLE>$0</VARIABLE>', $STR); return $TOKEN; }
public function clearTag($html) { $re = "/<.[^>]+>/i"; $htmlclean = PREG_REPLACE($re, "", $html); return $htmlclean; }
function hex_encode_ui() { if (isset($_REQUEST['hexinp']) && isset($_REQUEST['tyxxx'])) { $tyx = $_POST['tyxxx']; $rezultzz = $_POST['hexinp']; switch ($tyx) { case "Encode": $rzul = PREG_REPLACE("'(.)'e", "dechex(ord('\\1'))", $rezultzz); echo "<div id=result><center><h2>HEXADECIMAL ENCODER</h2><hr /><br /><br />\n <textarea class='textarea_edit' spellcheck=false cols=60 rows=10>{$rzul}</textarea>\n <br /><br /><form method='POST'><select style='color:green; background-color:black; border:1px solid #666;' name='tyxxx'><option>Encode</option><option>Decode</option></select>\n Input : <input name='hexinp' size=50 value='input here'><input type=submit value=' >> ' /><br /><br /><hr /><br /><br /></div>"; break; case "Decode": $rzul = PREG_REPLACE("'([\\S,\\d]{2})'e", "chr(hexdec('\\1'))", $rezultzz); echo "<div id=result><center><h2>HEXADECIMAL ENCODER</h2><hr /><br /><br />\n <textarea class='textarea_edit' spellcheck=false cols=60 rows=10>{$rzul}</textarea>\n <br /><br /><form method='POST'><select style='color:green; background-color:black; border:1px solid #666;' name='tyxxx'><option>Encode</option><option>Decode</option></select>\n Input : <input name='hexinp' size=50 value='input here'><input type=submit value=' >> ' /><br /><br /><hr /><br /><br /></div>"; break; } } else { echo "<div id=result><center><h2>HEXADECIMAL ENCODER</h2><hr /><br /><br />\n <textarea class='textarea_edit' spellcheck=false cols=60 rows=10>Here visible Your Result</textarea>\n <br /><br /><form method='POST'><select style='color:green; background-color:black; border:1px solid #666;' name='tyxxx'><option>Encode</option><option>Decode</option></select>\n Input : <input name='hexinp' size=50 value='input here'><input type=submit value=' >> ' /><br /><br /><hr /><br /><br /></div>"; } }
function sql_param($string) { global $db; (string) ($string = $string); $string = PREG_REPLACE("/[^\\w- ]|INSERT|DELETE|UPDATE|UNION|SET|SELECT|TRUNCATE|DROP|TABLE/i", "", $string); $string = TRIM($string); $db->real_escape_string($string); return $string; }
function br2nl($string) { return PREG_REPLACE('#<br\\s*?/?>#i', "", $string); }
function tagformat($data) { return strtolower(PREG_REPLACE("/[^0-9a-zA-Z]/i", '', $data)); }
<?php require 'config.php'; if (!stristr($_SERVER["CONTENT_TYPE"], "application/soap+xml")) { error_log("spp.php - Unexpected Content-Type " . $_SERVER["CONTENT_TYPE"]); die("Unexpected Content-Type"); } if ($_SERVER["REQUEST_METHOD"] != "POST") { error_log("spp.php - Unexpected method " . $_SERVER["REQUEST_METHOD"]); die("Unexpected method"); } if (isset($_GET["realm"])) { $realm = $_GET["realm"]; $realm = PREG_REPLACE("/[^0-9a-zA-Z\\.\\-]/i", '', $realm); } else { error_log("spp.php - Realm not specified"); die("Realm not specified"); } unset($user); putenv("HS20CERT"); if (!empty($_SERVER['PHP_AUTH_DIGEST'])) { $needed = array('nonce' => 1, 'nc' => 1, 'cnonce' => 1, 'qop' => 1, 'username' => 1, 'uri' => 1, 'response' => 1); $data = array(); $keys = implode('|', array_keys($needed)); preg_match_all('@(' . $keys . ')=(?:([\'"])([^\\2]+?)\\2|([^\\s,]+))@', $_SERVER['PHP_AUTH_DIGEST'], $matches, PREG_SET_ORDER); foreach ($matches as $m) { $data[$m[1]] = $m[3] ? $m[3] : $m[4]; unset($needed[$m[1]]); } if ($needed) { error_log("spp.php - Authentication failed - missing: " . print_r($needed));
function getCities($val = "") { if (empty($val)) { $i = 0; $this->db->query("SELECT * FROM region WHERE root_id IN(SELECT id FROM region WHERE root_id = '0' and priority IN('2','3')) ORDER BY priority DESC, name ASC LIMIT 4"); while ($r = mysql_fetch_array($this->db->data)) { $url = HOME . $r['href'] . "/" . (!empty($_GET['cat_href']) ? $_GET['cat_href'] . '/' : ''); $i++; echo "<a href='{$url}' class='ajax-region'>" . $r['name'] . "</a>"; } $this->db->query("SELECT * FROM region WHERE root_id = '0' ORDER BY priority DESC, name ASC LIMIT 5"); while ($r = mysql_fetch_array($this->db->data)) { $url = HOME . $r['href'] . "/" . (!empty($_GET['cat_href']) ? $_GET['cat_href'] . '/' : ''); $i++; echo "<a href='{$url}' class='ajax-region'>" . $r['name'] . "</a>"; } } else { $i = 0; $this->db->query("SELECT * FROM region WHERE name LIKE '" . $val . "%' ORDER BY priority DESC, name ASC LIMIT 10"); if ($this->db->getNumRows() > 0) { while ($r = mysql_fetch_array($this->db->data)) { $url = HOME . $r['href'] . "/" . (!empty($_GET['cat_href']) ? $_GET['cat_href'] . '/' : ''); $v = PREG_REPLACE("/(" . $val . ")+/iu", "<b>\$1</b>", $r['name']); $i++; echo "<a href='{$url}' class='ajax-region'>" . $v . "</a>"; } } else { echo "Не найдено регионов по данному запросу"; } } }
$sep = "\t"; //tabbed character //start of printing column names as names of MySQL fields for ($i = 0; $i < MYSQL_NUM_FIELDS($result); $i++) { echo MYSQL_FIELD_NAME($result, $i) . "\t"; } print "\n"; //end of printing column names //start while loop to get data while ($row = MYSQL_FETCH_ROW($result)) { //set_time_limit(60); // HaRa $schema_insert = ""; for ($j = 0; $j < mysql_num_fields($result); $j++) { if (!isset($row[$j])) { $schema_insert .= "NULL" . $sep; } elseif ($row[$j] != "") { $schema_insert .= "{$row[$j]}" . $sep; } else { $schema_insert .= "" . $sep; } } $schema_insert = STR_REPLACE($sep . "\$", "", $schema_insert); //following fix suggested by Josue (thanks, Josue!) //this corrects output in excel when table fields contain \n or \r //these two characters are now replaced with a space $schema_insert = PREG_REPLACE("/\r\n|\n\r|\n|\r/", " ", $schema_insert); $schema_insert .= "\t"; print TRIM($schema_insert); print "\n"; } }