/** * 字符串长度过滤截取 * @param string $string 字符串 * @param integer $start 起始长度 * @param int $end 结束位置 * @return mixed */ public static function lengthCute($string, $start = 0, $end = null) { if (!is_string($string)) { return ''; } // $length = Helper::strlen($string); return StrHelper::substr($string, $start, $end); }
/** * 根据服务器设置得到文件上传大小的最大值 * * @param int $max_size optional max file size * @return int max file size in bytes */ public static function getMaxUploadSize($max_size = 0) { $post_max_size = StrHelper::convertBytes(ini_get('post_max_size')); $upload_max_filesize = StrHelper::convertBytes(ini_get('upload_max_filesize')); if ($max_size > 0) { $result = min($post_max_size, $upload_max_filesize, $max_size); } else { $result = min($post_max_size, $upload_max_filesize); } return $result; }
function insertMainCharacter($pilotName, $pilotCharID, $corporationName, $corporationId, $allianceName, $allianceId, $pilotKeyID, $pilotVcode, $pilotRealName, $pilotGender, $pilotBirthDay, $pilotBirthMonth, $pilotBirthYear, $pilotCountry, $pilotTimeZone, $pilotEmail, $pilotFacebookID) { $today = date("Y-m-d H:m:s"); $pilotStatus = "Pending"; $pilotRank = "Candidate"; $pilotLevel = 7; $pilotPrimary = "Yes"; $pilotAltAccount = ""; $pilotQuestionaire = ""; $qqXml = new simpleXMLElement('resources/application/questionaire.xml', NULL, TRUE); foreach ($qqXml->question as $qq) { $qqid = $qq["id"]; $pilotQuestionaire .= $_POST['form_q' . $qqid] . "||"; } $pilotQuestionaire = StrHelper::sanitizeInput($pilotQuestionaire); upsert($today, $pilotName, $pilotRank, $pilotLevel, $pilotKeyID, $pilotVcode, $pilotCharID, $corporationName, $corporationId, $allianceName, $allianceId, $pilotRealName, $pilotGender, $pilotBirthDay, $pilotBirthMonth, $pilotBirthYear, $pilotCountry, $pilotTimeZone, $pilotEmail, $pilotFacebookID, $pilotStatus, $pilotQuestionaire, $pilotPrimary, $pilotAltAccount); }
/** * @param string $attr * @return string */ public function getAttrTran($attr) { $trans = $this->getAttrTrans(); return isset($trans[$attr]) ? $trans[$attr] : StrHelper::toUnderscoreCase($attr, ' '); }
private static function getStandingsXml() { self::$standingsXml = API::getApiXmlByUrl(self::$url); //todo remove and fix //CURL error: Unknown SSL protocol error in connection to standings.goonfleet.com:443 //sent update request to provider echo self::$standingsXml . "<br/>"; if (!self::$standingsXml) { self::$errorInfo = "Unknown error."; } if (StrHelper::startsWith(self::$standingsXml, "CURL")) { self::$errorInfo = self::$standingsXml; } if (isset(self::$standingsXml->error['code'])) { self::$errorInfo = self::$standingsXml->error['code'] . " " . self::$standingsXml->error; } }
/** * 字符串/数组长度检查 * @param string|array $var 字符串/数组 * @param integer $minLength 最小长度 * @param int $maxLength 最大长度 * @return mixed */ public static function length($var, $minLength = 0, $maxLength = null) { if (is_string($var)) { $length = StrHelper::strlen($var); } elseif (is_array($var)) { $length = count($var); } else { return false; } return self::size($length, $minLength, $maxLength); }
static function saveCharactersToSession() { for ($i = 0; $i < 100; $i++) { $index = StrHelper::getIndexString($i); $keyAccess = "form_keyid" . $index; $vCodeAccess = "form_vcode" . $index; $keyID = self::getKeyID($keyAccess); $vCode = self::getVCode($vCodeAccess); if (!$keyID or !$vCode) { continue; } //Store some info about the main if ($i == 0) { $_SESSION['eve_keyID'] = $keyID; $_SESSION['eve_vCode'] = $vCode; $apiXML = API::getApiXml($keyID, $vCode); for ($j = 0; $j < 3; $j++) { $_SESSION['eve_charname' . $j] = (string) $apiXML->result->key->rowset->row[$j]['characterName']; $_SESSION['eve_charid' . $j] = (string) $apiXML->result->key->rowset->row[$j]['characterID']; } } $characters = API::getCharactersFromApi($keyID, $vCode); if ($characters and is_a($characters, 'CharacterTriple')) { for ($k = 0; $k < 3; $k++) { $character = $characters->getCharacterAt($k); if ($character) { $apiId = "api" . $index . $k; $_SESSION[$apiId . '_character'] = serialize($character); } } } else { return $characters; //error info inside; } } return null; }