function Bytes_Trim($String) { /****************************************************************************/ $__args_types = array('string'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ return DecHex(HexDec($String)); }
function couleur_inverse($c_orig) { $a = substr($c_orig, 0, 1); $b = substr($c_orig, 1, 1); $c = substr($c_orig, 2, 1); $d = substr($c_orig, 3, 1); $e = substr($c_orig, 4, 1); $f = substr($c_orig, 5, 1); $ai = DecHex(15 - HexDec($a)); $bi = DecHex(15 - HexDec($b)); $ci = DecHex(15 - HexDec($c)); $di = DecHex(15 - HexDec($d)); $ei = DecHex(15 - HexDec($e)); $fi = DecHex(15 - HexDec($f)); $c_inv = $ai . $bi . $ci . $di . $ei . $fi; return $c_inv; }
function BuildItemDesc($file) { print " * Loading multis config file...\n"; $cfg_file = ReadConfigFile($file); if ($cfg_file == FALSE) { print "Cant open {$file} ({$php_errormsg}). Blame Stephen Donald.\n"; exit; } print " * Purging itemdesc.cfg for new write...\n"; $handle = FOpen("itemdesc.cfg", "w"); FClose($handle); $handle = FOpen("itemdesc.cfg", "a"); print " * Finding elem names..."; $elem_names = GetConfigStringKeys($cfg_file, CLASS_LABELS_ON); print "(" . Count($elem_names) . ")\n"; foreach ($elem_names as $elem_name) { if (!Preg_Match("/^House\\s+/i", $elem_name)) { continue; } $multi_id = Preg_Replace("/^House\\s+/i", "", $elem_name); $objtype = HexDec($multi_id); $objtype += 16384; // 0x4000 $objtype = "0x" . DecHex($objtype); FWrite($handle, "House {$objtype}\n"); FWrite($handle, "{\n"); FWrite($handle, "\t// Main Stuff\n"); FWrite($handle, "\tName\t\tHouse{$objtype}\n"); FWrite($handle, "\tGraphic\t\t{$objtype}\n"); FWrite($handle, "\n"); FWrite($handle, "\t// Multi Info\n"); FWrite($handle, "\tMultiID\t\t{$multi_id}\n"); FWrite($handle, "}\n\n"); } FClose($handle); return 1; }
/** * [Describe function...] * * @param [type] $http_post_vars: ... * @param array (not used anymore) * @param [type] $theConstants: ... * @param [type] $tplRow: ... * @return [type] ... * @todo Define visibility */ public function ext_procesInput($http_post_vars, $http_post_files, $theConstants, $tplRow) { $data = $http_post_vars['data']; $check = $http_post_vars['check']; $Wdata = $http_post_vars['Wdata']; $W2data = $http_post_vars['W2data']; $W3data = $http_post_vars['W3data']; $W4data = $http_post_vars['W4data']; $W5data = $http_post_vars['W5data']; if (is_array($data)) { foreach ($data as $key => $var) { if (isset($theConstants[$key])) { // If checkbox is set, update the value if ($this->ext_dontCheckIssetValues || isset($check[$key])) { // Exploding with linebreak, just to make sure that no multiline input is given! list($var) = explode(LF, $var); $typeDat = $this->ext_getTypeData($theConstants[$key]['type']); switch ($typeDat['type']) { case 'int': if ($typeDat['paramstr']) { $var = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($var, $typeDat['params'][0], $typeDat['params'][1]); } else { $var = (int) $var; } break; case 'int+': $var = max(0, (int) $var); break; case 'color': $col = array(); if ($var && !GeneralUtility::inList($this->HTMLcolorList, strtolower($var))) { $var = preg_replace('/[^A-Fa-f0-9]*/', '', $var); $useFulHex = strlen($var) > 3; $col[] = HexDec($var[0]); $col[] = HexDec($var[1]); $col[] = HexDec($var[2]); if ($useFulHex) { $col[] = HexDec($var[3]); $col[] = HexDec($var[4]); $col[] = HexDec($var[5]); } $var = substr('0' . DecHex($col[0]), -1) . substr('0' . DecHex($col[1]), -1) . substr('0' . DecHex($col[2]), -1); if ($useFulHex) { $var .= substr('0' . DecHex($col[3]), -1) . substr('0' . DecHex($col[4]), -1) . substr('0' . DecHex($col[5]), -1); } $var = '#' . strtoupper($var); } break; case 'comment': if ($var) { $var = '#'; } else { $var = ''; } break; case 'wrap': if (isset($Wdata[$key])) { $var .= '|' . $Wdata[$key]; } break; case 'offset': if (isset($Wdata[$key])) { $var = (int) $var . ',' . (int) $Wdata[$key]; if (isset($W2data[$key])) { $var .= ',' . (int) $W2data[$key]; if (isset($W3data[$key])) { $var .= ',' . (int) $W3data[$key]; if (isset($W4data[$key])) { $var .= ',' . (int) $W4data[$key]; if (isset($W5data[$key])) { $var .= ',' . (int) $W5data[$key]; } } } } } break; case 'boolean': if ($var) { $var = $typeDat['paramstr'] ? $typeDat['paramstr'] : 1; } break; } if ($this->ext_printAll || (string) $theConstants[$key]['value'] !== (string) $var) { // Put value in, if changed. $this->ext_putValueInConf($key, $var); } // Remove the entry because it has been "used" unset($check[$key]); } else { $this->ext_removeValueInConf($key); } } } } // Remaining keys in $check indicates fields that are just clicked "on" to be edited. Therefore we get the default value and puts that in the template as a start... if (!$this->ext_dontCheckIssetValues && is_array($check)) { foreach ($check as $key => $var) { if (isset($theConstants[$key])) { $dValue = $theConstants[$key]['default_value']; $this->ext_putValueInConf($key, $dValue); } } } }
public function Read($Length = 1400) { $this->Buffer->Set(FRead($this->Socket, $Length)); if ($this->Buffer->Remaining() === 0) { // TODO: Should we throw an exception here? return; } $Header = $this->Buffer->GetLong(); if ($Header === -1) { // We don't have to do anything } else { if ($Header === -2) { $Packets = array(); $IsCompressed = false; $ReadMore = false; do { $RequestID = $this->Buffer->GetLong(); switch ($this->Engine) { case SourceQuery::GOLDSOURCE: $PacketCountAndNumber = $this->Buffer->GetByte(); $PacketCount = $PacketCountAndNumber & 0xf; $PacketNumber = $PacketCountAndNumber >> 4; break; case SourceQuery::SOURCE: $IsCompressed = ($RequestID & 0x80000000) !== 0; $PacketCount = $this->Buffer->GetByte(); $PacketNumber = $this->Buffer->GetByte() + 1; if ($IsCompressed) { $this->Buffer->GetLong(); // Split size $PacketChecksum = $this->Buffer->GetUnsignedLong(); } else { $this->Buffer->GetShort(); // Split size } break; } $Packets[$PacketNumber] = $this->Buffer->Get(); $ReadMore = $PacketCount > sizeof($Packets); } while ($ReadMore && $this->Sherlock($Length)); $Buffer = Implode($Packets); // TODO: Test this if ($IsCompressed) { // Let's make sure this function exists, it's not included in PHP by default if (!Function_Exists('bzdecompress')) { throw new RuntimeException('Received compressed packet, PHP doesn\'t have Bzip2 library installed, can\'t decompress.'); } $Buffer = bzdecompress($Buffer); if (CRC32($Buffer) !== $PacketChecksum) { throw new InvalidPacketException('CRC32 checksum mismatch of uncompressed packet data.', InvalidPacketException::CHECKSUM_MISMATCH); } } $this->Buffer->Set(SubStr($Buffer, 4)); } else { throw new InvalidPacketException('Socket read: Raw packet header mismatch. (0x' . DecHex($Header) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH); } } }
if (!isset($_POST['overridetime'])) { if ($hc_cfg[31] == 12) { $startTimeHour = $startTimeAMPM == 'PM' ? $startTimeHour < 12 ? $startTimeHour + 12 : $startTimeHour : ($startTimeHour == 12 ? 0 : $startTimeHour); if (!isset($_POST['ignoreendtime'])) { $endTimeHour = $endTimeAMPM == 'PM' ? $endTimeHour < 12 ? $endTimeHour + 12 : $endTimeHour : ($endTimeHour == 12 ? 0 : $endTimeHour); } } $tbd = 0; $startTime = "'" . $startTimeHour . ":" . $startTimeMins . ":00'"; $endTime = !isset($_POST['ignoreendtime']) ? "'" . $endTimeHour . ":" . $endTimeMins . ":00'" : 'NULL'; } else { $startTime = $endTime = 'NULL'; $tbd = $_POST['specialtime'] == 'allday' ? 1 : 2; } if (isset($_POST['recurCheck'])) { $seriesID = "'" . DecHex(microtime() * 9999999) . DecHex(microtime() * 5555555) . DecHex(microtime() * 1111111) . "'"; $stopDate = isset($_POST['recurEndDate']) ? dateToMySQL(cIn($_POST['recurEndDate']), $hc_cfg[24]) : ''; $curDate = $eventDate; switch ($_POST['recurType']) { case 'daily': $days = isset($_POST['dailyDays']) ? cIn($_POST['dailyDays']) : 1; if ($_POST['dailyOptions'] == 'EveryXDays') { while (strtotime($curDate) <= strtotime($stopDate)) { $dates[] = $curDate; $dateParts = explode("-", $curDate); $curDate = date("Y-m-d", mktime(0, 0, 0, $dateParts[1], $dateParts[2] + $days, $dateParts[0])); } } else { while (strtotime($curDate) <= strtotime($stopDate)) { $dateParts = explode("-", $curDate); $curDayOfWeek = date("w", mktime(0, 0, 0, $dateParts[1], $dateParts[2], $dateParts[0]));
/** * Get challenge (used for players/rules packets) * * @return bool True if all went well, false if server uses old GoldSource protocol, and it already contains answer */ private function GetChallenge($Header, $ExpectedResult) { if ($this->Challenge) { return self::GETCHALLENGE_ALL_CLEAR; } $this->Socket->Write($Header, 0xffffffff); $this->Socket->Read(); $Type = $this->Buffer->GetByte(); switch ($Type) { case self::S2A_CHALLENGE: $this->Challenge = $this->Buffer->Get(4); return self::GETCHALLENGE_ALL_CLEAR; case $ExpectedResult: // Goldsource (HLTV) return self::GETCHALLENGE_CONTAINS_ANSWER; case 0: return self::GETCHALLENGE_FAILED; default: throw new SourceQueryException('GetChallenge: Packet header mismatch. (0x' . DecHex($Type) . ')'); } }
protected function _crc($data) { $x = 0; for ($i = 0; $i < strlen($data); $i++) { $x += ord($data[$i]); } return str_pad(strtoupper(DecHex($x)), 4, '0', STR_PAD_LEFT); }
if ($endDate != '') { if (strtotime($startDate) > strtotime($endDate)) { $flipDate = $startDate; $startDate = $endDate; $endDate = $flipDate; } if (strtotime($startDate) < strtotime($endDate)) { $isLoop = true; } } $tbd = $startTime == '' ? 1 : 0; if ($tbd > 0) { $startTime = $endTime = '00:00:00'; } if ($isLoop == true) { $seriesID = DecHex(microtime() * 1000000) . DecHex(microtime() * 9999999) . DecHex(microtime() * 8888888); $curDate = $startDate; while (strtotime($curDate) <= strtotime($endDate)) { $dates[] = $curDate; $dateParts = explode("-", $curDate); $curDate = date("Y-m-d", mktime(0, 0, 0, $dateParts[1], $dateParts[2] + 1, $dateParts[0])); } } else { $seriesID = ""; $dates[] = $startDate; } foreach ($dates as $valAdd) { $eventDate = $valAdd; $query = "\tINSERT INTO " . HC_TblPrefix . "events(Title, LocationName, Description,\r\n\t\t\t\t\t\t\t\t\t\t\tStartDate, StartTime, TBD, EndTime, IsActive, IsApproved,\r\n\t\t\t\t\t\t\t\t\t\t\tSeriesID, PublishDate, ContactURL, LastMod)\r\n\t\t\t\t\t\t\t\tVALUES('" . substr(cIn($title), 0, 150) . "', '" . substr(cIn($location), 0, 50) . "', '" . cIn($description) . "',\r\n\t\t\t\t\t\t\t\t\t\t'" . cIn($eventDate) . "', '" . cIn($startTime) . "', '" . cIn($tbd) . "', '" . cIn($endTime) . "',\r\n\t\t\t\t\t\t\t\t\t\t'1', '1', '" . cIn($seriesID) . "', '" . cIn($publishDate) . "', '" . cIn($url) . "', '" . cIn($publishDate) . "');"; doQuery($query); $result = doQuery("SELECT LAST_INSERT_ID() FROM " . HC_TblPrefix . "events");
/** * [Describe function...] * * @param [type] $http_post_vars: ... * @param [type] $http_post_files: ... * @param [type] $theConstants: ... * @param [type] $tplRow: ... * @return [type] ... */ function ext_procesInput($http_post_vars, $http_post_files, $theConstants, $tplRow) { $data = $http_post_vars['data']; $check = $http_post_vars['check']; $copyResource = $http_post_vars['_copyResource']; $Wdata = $http_post_vars['Wdata']; $W2data = $http_post_vars['W2data']; $W3data = $http_post_vars['W3data']; $W4data = $http_post_vars['W4data']; $W5data = $http_post_vars['W5data']; if (is_array($data)) { foreach ($data as $key => $var) { if (isset($theConstants[$key])) { if ($this->ext_dontCheckIssetValues || isset($check[$key])) { // If checkbox is set, update the value list($var) = explode(LF, $var); // exploding with linebreak, just to make sure that no multiline input is given! $typeDat = $this->ext_getTypeData($theConstants[$key]['type']); switch ($typeDat['type']) { case 'int': if ($typeDat['paramstr']) { $var = t3lib_div::intInRange($var, $typeDat['params'][0], $typeDat['params'][1]); } else { $var = intval($var); } break; case 'int+': $var = max(0, intval($var)); break; case 'color': $col = array(); if ($var && !t3lib_div::inList($this->HTMLcolorList, strtolower($var))) { $var = preg_replace('/[^A-Fa-f0-9]*/', '', $var); $useFullHex = strlen($var) > 3; $col[] = HexDec(substr($var, 0, 1)); $col[] = HexDec(substr($var, 1, 1)); $col[] = HexDec(substr($var, 2, 1)); if ($useFullHex) { $col[] = HexDec(substr($var, 3, 1)); $col[] = HexDec(substr($var, 4, 1)); $col[] = HexDec(substr($var, 5, 1)); } $var = substr('0' . DecHex($col[0]), -1) . substr('0' . DecHex($col[1]), -1) . substr('0' . DecHex($col[2]), -1); if ($useFullHex) { $var .= substr('0' . DecHex($col[3]), -1) . substr('0' . DecHex($col[4]), -1) . substr('0' . DecHex($col[5]), -1); } $var = '#' . strtoupper($var); } break; case 'comment': if ($var) { $var = '#'; } else { $var = ''; } break; case 'wrap': if (isset($Wdata[$key])) { $var .= '|' . $Wdata[$key]; } break; case 'offset': if (isset($Wdata[$key])) { $var = intval($var) . ',' . intval($Wdata[$key]); if (isset($W2data[$key])) { $var .= ',' . intval($W2data[$key]); if (isset($W3data[$key])) { $var .= ',' . intval($W3data[$key]); if (isset($W4data[$key])) { $var .= ',' . intval($W4data[$key]); if (isset($W5data[$key])) { $var .= ',' . intval($W5data[$key]); } } } } } break; case 'boolean': if ($var) { $var = $typeDat['paramstr'] ? $typeDat['paramstr'] : 1; } break; case 'file': if (!$this->ext_noCEUploadAndCopying) { if ($http_post_files['upload_data']['name'][$key] && $http_post_files['upload_data']['tmp_name'][$key] != 'none') { $var = $this->upload_copy_file($typeDat, $tplRow, trim($http_post_files['upload_data']['name'][$key]), $http_post_files['upload_data']['tmp_name'][$key]); } if ($copyResource[$key]) { $var = $this->upload_copy_file($typeDat, $tplRow, basename($copyResource[$key]), $copyResource[$key]); } } break; } if ($this->ext_printAll || strcmp($theConstants[$key]['value'], $var)) { $this->ext_putValueInConf($key, $var); // Put value in, if changed. } unset($check[$key]); // Remove the entry because it has been "used" } else { $this->ext_removeValueInConf($key); } } } } // Remaining keys in $check indicates fields that are just clicked "on" to be edited. Therefore we get the default value and puts that in the template as a start... if (!$this->ext_dontCheckIssetValues && is_array($check)) { foreach ($check as $key => $var) { if (isset($theConstants[$key])) { $dValue = $theConstants[$key]['default_value']; $this->ext_putValueInConf($key, $dValue); } } } }
/** * Get challenge (used for players/rules packets) * * @param $Header * @param $ExpectedResult * @throws InvalidPacketException * @return bool True if all went well, false if server uses old GoldSource protocol, and it already contains answer */ private function GetChallenge($Header, $ExpectedResult) { if ($this->Challenge) { return self::GETCHALLENGE_ALL_CLEAR; } if ($this->UseOldGetChallengeMethod) { $Header = self::A2S_SERVERQUERY_GETCHALLENGE; } $this->Socket->Write($Header, 0xffffffff); $this->Socket->Read(); $Type = $this->Buffer->GetByte(); switch ($Type) { case self::S2A_CHALLENGE: $this->Challenge = $this->Buffer->Get(4); return self::GETCHALLENGE_ALL_CLEAR; case $ExpectedResult: // Goldsource (HLTV) return self::GETCHALLENGE_CONTAINS_ANSWER; case 0: return self::GETCHALLENGE_FAILED; default: throw new InvalidPacketException('GetChallenge: Packet header mismatch. (0x' . DecHex($Type) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH); } }
function EncodeJavascriptString($s) { $l = strlen($s = strval($s)); if ($l == 0) { return "''"; } $n = !strcmp(strtolower($this->encoding), "iso-8859-1"); $e = array("\n" => "\\n", "\r" => "\\r", "\t" => "\\t"); for ($d = 0, $j = "", $c = 0; $c < $l; $c++) { $t = $s[$c]; $a = Ord($t); if ($a < 32 || $t == '<' || $a > 126 && $n) { if (isset($e[$t])) { if ($c == 0 || $d) { if ($c != 0) { $j .= '+'; } $j .= "'" . $e[$t]; $d = 0; } else { $j .= $e[$t]; } } else { if ($c != 0) { if (!$d) { $j .= "'"; } $j .= "+"; } $j .= "unescape('"; for (; $c < $l; $c++) { $t = $s[$c]; $a = Ord($t); if ($a < 32 || $t == '<' || $t == '%' || $a > 126 && $n) { if (isset($e[$t])) { $j .= $e[$t]; } else { $j .= "%" . DecHex($a); } } else { if ($t == "'" || $t == "\\") { $j .= "\\"; } $j .= $t; } } $j .= "')"; $d = 1; } } else { if ($d) { $j .= "+'"; } else { if ($c == 0) { $j .= "'"; } } if ($t == "'" || $t == "\\") { $j .= "\\"; } $j .= $t; $d = 0; } } if (!$d) { $j .= "'"; } return $j; }
FUNCTION EncodeStr($user, $password, $key) { $str = $user.Chr(30).$password; FOR($i = 0; $i < StrLen($str); $i++) { $hex .= DecHex(Ord($str[$i])); } $hex = EregI_Replace("([a-f0-9]{".$key[9]."})([a-f0-9]{".$key[7]."})([a-f0-9]*)([a-f0-9]{".$key[6]."})([a-f0-9]{".$key[8]."})", "\\5\\4\\3\\2\\1", $hex); RETURN $hex; }
function mkstatus($a = 0, $b = 0, $gtor = 0) { if (!$b) { return 0; } $percent = $a / $b * 100; if (!@is_file("images/voting.gif")) { $percent = 100 - $percent; $return .= "<table cellpadding=0 cellspacing=0><tr height=10>"; if ($gtor) { $colorr = hexdec("20"); $colorg = hexdec("FF"); while ($colorr < hexdec("FF") && $colorg > hexdec("00") && $percent <= 100) { $r = DecHex($colorr += 2); $g = DecHex($colorg -= 2); $return .= "<td bgcolor=\"" . $r . $g . "00\" width=2></td>"; $percent++; } } else { $colorr = hexdec("FF"); $colorg = hexdec("20"); while ($colorr > hexdec("00") && $colorg < hexdec("FF") && $percent <= 100) { $r = DecHex($colorr -= 2); $g = DecHex($colorg += 2); $return .= "<td bgcolor=\"" . $r . $g . "00\" width=2></td>"; $percent++; } } $return .= "</tr></table>"; return $return; } else { return "<img src=\"./images/voting.gif\" height=7 width={$percent}% alt='Votes: {$percent}%'>"; } }