字段类型选择

@param	string	$name
@param	string	$length
@return  string
431234
public function field_type($name = NULL, $length = NULL, $fvalue = '')
	{
		if ($this->fieldtype === TRUE) {
			$select	= '<option value="">-</option>
				<option value="INT" '.($name == 'INT' ? 'selected' : '').'>INT</option>
				<option value="TINYINT" '.($name == 'TINYINT' ? 'selected' : '').'>TINYINT</option>
				<option value="SMALLINT" '.($name == 'SMALLINT' ? 'selected' : '').'>SMALLINT</option>
				<option value="MEDIUMINT" '.($name == 'MEDIUMINT' ? 'selected' : '').'>MEDIUMINT</option>
				<option value="">-</option>
				<option value="DECIMAL" '.($name == 'DECIMAL' ? 'selected' : '').'>DECIMAL</option>
				<option value="FLOAT" '.($name == 'FLOAT' ? 'selected' : '').'>FLOAT</option>
				<option value="">-</option>
				<option value="CHAR" '.($name == 'CHAR' ? 'selected' : '').'>CHAR</option>
				<option value="VARCHAR" '.($name == 'VARCHAR' ? 'selected' : '').'>VARCHAR</option>
				<option value="TEXT" '.($name == 'TEXT' ? 'selected' : '').'>TEXT</option>
				<option value="MEDIUMTEXT" '.($name == 'MEDIUMTEXT' ? 'selected' : '').'>MEDIUMTEXT</option>';
		} elseif (count($this->fieldtype) > 1) {
			$select	= '<option value="">-</option>';
			foreach ($this->fieldtype as $t) {
				$select	= "<option value=\"{$t}\" ".($name == $t ? "selected" : "").">{$t}</option>";
			}
		} else {
			return '
			<div class="hstui-form-group hstui-form-group-sm">
	          <label class="hstui-u-sm-2 hstui-form-label">'.hst_lang('hstcms::fields.default.value').'</label>
	          <div class="hstui-u-sm-10 hstui-form-input">
	              <input type="text" name="setting[option][fvalue]" value="'.$fvalue.'" class="hstui-input hstui-length-5">
	            <div class="hstui-form-input-tips" id="J_form_tips_name" data-tips="'.hst_lang('hstcms::fields.default.value.tips').'">'.hst_lang('hstcms::fields.default.value.tips').'</div>
	          </div>
	        </div>';
		}
		$str = '
			<div class="hstui-form-group hstui-form-group-sm">
	          <label class="hstui-u-sm-2 hstui-form-label">'.hst_lang('hstcms::manage.fields.fieldtype').'</label>
	          <div class="hstui-u-sm-10 hstui-form-input">
	             	<select class="hstui-input hstui-textarea" name="setting[option][fieldtype]" onChange="setlength()" id="type">
						'.$select.'
					</select>
	            <div class="hstui-form-input-tips" id="J_form_tips_name" data-tips="'.hst_lang('hstcms::manage.fields.fieldtype.tips').'">'.hst_lang('hstcms::manage.fields.fieldtype.tips').'</div>
	          </div>
	        </div>
			<div class="hstui-form-group hstui-form-group-sm">
	          <label class="hstui-u-sm-2 hstui-form-label">'.hst_lang('hstcms::manage.fields.length.value').'</label>
	          <div class="hstui-u-sm-10 hstui-form-input">
	              <input type="text" name="setting[option][fieldlength]" value="'.$length.'" class="hstui-input hstui-length-5">
	            <div class="hstui-form-input-tips" id="J_form_tips_name" data-tips="'.hst_lang('hstcms::manage.fields.length.value.tips').'">'.hst_lang('hstcms::manage.fields.length.value.tips').'</div>
	          </div>
	        </div>
			<div class="hstui-form-group hstui-form-group-sm">
	          <label class="hstui-u-sm-2 hstui-form-label">'.hst_lang('hstcms::fields.default.value').'</label>
	          <div class="hstui-u-sm-10 hstui-form-input">
	              <input type="text" name="setting[option][fvalue]" value="'.$fvalue.'" class="hstui-input hstui-length-5">
	            <div class="hstui-form-input-tips" id="J_form_tips_name" data-tips="'.hst_lang('hstcms::fields.default.value.tips').'">'.hst_lang('hstcms::fields.default.value.tips').'</div>
	          </div>
	        </div>';
		return $str; 
	}
199183
private function mkstr($name, $type = 'string', $options = array())
    {
        $result = "  define('$name', ";
        $quot = "'";
        $value = isset($_POST[$name]) ? $_POST[$name] : null;

        if (isset($options['nobr']) && $options['nobr'])
        {
            $value = str_replace(array("\n", "\r"), ' ', $value);
        }

        if (isset($options['savebr']) && $options['savebr'])
        {
            $value = addcslashes($value, "\n\r\"");
            $quot = '"';
        }

        switch ($type)
        {
            case 'string':
                $value = str_replace(
                    array('\\', $quot),
                    array('\\\\', '\\' . $quot),
                    $value
                );
                $value = $quot . $value . $quot;
                break;
            case 'bool':
                $value = $value ? 'true' : 'false';
                break;
            case 'int':
                $value = intval($value);
                break;
        }
        $result .= $value . ");\n";
        return $result;
    }
673061
private static function generateBytes($length)
    {
        $bytes = '';
        for ($i = 1; $i <= $length; $i++) {
            $bytes = \chr(\mt_rand(0, 255)) . $bytes;
        }

        return $bytes;
    }
859462
public static function randStr($type, $length = 6)
    {
        // TODO 生成随机长度的字符串
        if ($type == self::ALPHABET) {
            return self::randAlphabet($length);
        } elseif ($type == self::ALPHABET_AND_NUMBERS) {
            return self::randAlphabetAndNumbers($length);
        } elseif ($type == self::NUMBERS) {
            return self::randNumbers($length);
        }

        return "unknown type";
    }
12331
public static function genRandomChar($length = 8)
    {
        // 密码字符集，可任意添加你需要的字符
        //$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
        $chars = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789';
        $char = '';
        for ($i = 0; $i < $length; $i++) {
            $char .= $chars[mt_rand(0, strlen($chars) - 1)];
        }
        return $char;
    }
504351
public static function string(
        int $length = 32,
        string $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
    ) : string {
        $rand = static::bytes($length * 2);
        $lngt = iconv_strlen($characters, 'UTF-8');
        $rslt = '';
        for ($i = 0; $i < strlen($rand); ++$i) {
            $rslt .= iconv_substr($characters, ord($rand[$i]) % $lngt, 1, 'UTF-8');
        }
        return iconv_substr($rslt, 0, $length, 'UTF-8');
    }
449682
public function getAbstract($length = 100)
    {
        $content = $this->getContent();
        if (mb_strlen($content) > $length - 3) {
            return mb_substr($content, 0, $length - 3) . '...';
        } else {
            return $content;
        }
    }
279204
public static function truncate($str, $length, $postFix = '...')
    {
        if (strlen($str) <= $length) {
            return $str;
        }

        return substr($str, 0, ($length - strlen($postFix))) . $postFix;
    }
542469
public final function read($length): string
   {
       if (!$this->isReadable()) {
           throw new RuntimeException("Can't read: stream is not readable");
       }
       $read = (string) fread($this->stream, (int) $length);
       $this->meta["eof"] = !$read ? true : false;
       return $read;
   }
1017997
public static function getRandomString(int $length = 64) : string
    {
        $characters = "01234567890123456789";
        $characters .= "abcdefghijklmnopqrstuvwxyz";

        $string_generated = "";

        while ($length--) {
            $string_generated .= $characters[mt_rand(0, 45)];
        }

        return $string_generated;
    }
55013
private function Value($name)
    {
        $value = Request::PostData($this->prefix . $name);
        return Str::Trim($value);
    }
40063
public function string(int $length = 8)
    {
        $list = 'abcdefghijklmnopqrstuvwxyz';
        $return = '';
        for ($i = 0; $i < $length; $i++) {
            $return .= $list[rand(0, strlen($list) - 1)];
        }

        return $return;
    }
965534
public function length($length = null)
    {
        if (!is_null($length)) {
            $this->length = (int) $length;
        }

        return $this->length;
    }
1025613
public static function getNonce($length = 16)
    {
        
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $charactersLength = strlen($characters);
        $randomString = '';
        for ($i = 0; $i < $length; $i++) {
            $randomString .= $characters[rand(0, $charactersLength - 1)];
        }
        return $randomString;
    }
562569
private function readString($length)
    {
        $result = substr($this->buffer, $this->position, $length);
        $this->position += $length;

        return $result;
    }
604768
public function getRandomKey($length = self::TOKEN_LENGTH)
    {
        $chars = "A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6Q7R8S9T0U1V2W3X4Y5Z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6";
        $key = "";

        for ($i = 0; $i < $length; $i++) {
            $key .= $chars{mt_rand(0, strlen($chars) - 1)};
        }

        return $key;
    }
519732
public static function randomString($length)
    {
        $key = '';
        $keys = array_merge(range('a', 'z'));

        for ($i = 0; $i < $length; ++$i) {
            $key .= $keys[array_rand($keys)];
        }

        return $key;
    }