Files
itooldog/handler/index.php
T
2023-04-12 17:12:41 +08:00

283 lines
13 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
$act = $_GET['act'] ?? 'index';
$data = [];
switch ($act) {
case 'uuid':
$data['uuid_number'] = input('uuid_number', 1);
$data['uuid_letter'] = input('uuid_letter', 2);
$data['uuid'] = uuid($data['uuid_number'], $data['uuid_letter']);
break;
case 'guid':
$data['guid_number'] = input('guid_number', 1);
$data['guid_letter'] = input('guid_letter', 1);
$array = array();
for ($i = 0; $data['guid_number'] > $i; $i++) {
$guid = create_guid();
if (!in_array($guid, $array)) {
$array[] = ($data['guid_letter'] == 1) ? strtoupper($guid) : strtolower($guid);
} else {
$i--;
}
}
$data['guid'] = $array;
break;
case 'md5':
$data['txt_md5'] = input('txt_md5', '');
$md532 = md5($data['txt_md5']);
$md516 = substr($md532, 8, 16);
$data['md532_d'] = strtoupper($md532);
$data['md532_x'] = strtolower($md532);
$data['md516_d'] = strtoupper($md516);
$data['md516_x'] = strtolower($md516);
break;
case 'caiji':
$data['url'] = input('url', '');
$data['content'] = $data['url'] ? Fcurl($data['url']) : '';
break;
case 'ip':
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$ip = input('ip');
header('Location: ' . '/ip/' . $ip, true, 302);
}
$ips = new utils\Net\Ips(BASE_PATH . '/qqwry.dat');
$ip = input('ip');
if ($ip) {
$data['ym']['ip'] = $ip;
$data['ym']['domain'] = gethostbyname($ip);
$domain = preg_replace('/(\d+)..*/', '\\1', $data['ym']['domain']);
if ('1' <= $domain && $domain <= '126') {
$data['ym']['fw'] = '1.0.0.1 - 126.155.255.254';
} elseif ('128' <= $domain && $domain <= '191') {
$data['ym']['fw'] = '128.0.0.1 - 191.255.255.254';
} elseif ('192' <= $domain && $domain <= '223') {
$data['ym']['fw'] = '192.0.0.1 - 223.255.255.254';
}
$fwq = $ips->Getlocation($data['ym']['domain']);
$data['ym']['city'] = strToUTF8($fwq['country'] . ' ' . $fwq['area']);
}
$data['getip'] = getip(0, true);
$data['getBrowserOs'] = getBrowserOs();
$city = $ips->Getlocation($data['getip']);
$data['city'] = strToUTF8($city['country'] . ' ' . $city['area']);
break;
case 'favicon':
$data['upmsg'] = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$upimage = $_FILES['upimage'];
$getInfo = $upimage;
if (isset($getInfo['tmp_name']) && $getInfo['tmp_name'] && is_uploaded_file($getInfo['tmp_name'])) {
if ($getInfo['size'] > 210000) {
$data['upmsg'] = "<font color=\"red\">你上传的文件体积超过了限制 最大不能超过200K</font>";
} else {
$fileext = array("image/pjpeg", "image/gif", "image/x-png", "image/png", "image/jpeg", "image/jpg");
if (!in_array($getInfo['type'], $fileext)) {
$data['upmsg'] = "<font color=\"red\">你上传的文件格式不正确 仅支持 jpggifpng</font>";
} else {
$type = substr(strrchr($getInfo['name'], '.'), 1);
switch ($type) {
case 'pjpeg':
case 'jpeg':
case 'jpg':
$im = imagecreatefromjpeg($getInfo['tmp_name']);
break;
case 'x-png':
case 'png':
$im = imagecreatefrompng($getInfo['tmp_name']);
break;
case 'gif':
$im = imagecreatefromgif($getInfo['tmp_name']);
break;
default:
$im = null;
}
if ($im) {
$imginfo = getimagesize($getInfo['tmp_name']);
if (!is_array($imginfo)) {
$data['upmsg'] = "<font color=\"red\">图形格式错误!</font>";
} else {
switch (input('favicon_size')) {
case 1;
$resize_im = imagecreatetruecolor(16, 16);
$size = 16;
break;
case 2;
$resize_im = imagecreatetruecolor(32, 32);
$size = 32;
break;
case 3;
$resize_im = imagecreatetruecolor(48, 48);
$size = 48;
break;
case 4;
$resize_im = imagecreatetruecolor(64, 64);
$size = 64;
break;
case 5;
$resize_im = imagecreatetruecolor(128, 128);
$size = 128;
break;
default;
$resize_im = imagecreatetruecolor(32, 32);
$size = 32;
break;
}
imagecopyresampled($resize_im, $im, 0, 0, 0, 0, $size, $size, $imginfo[0], $imginfo[1]);
$icon = new utils\Net\Ico();
$gd_image_array = array($resize_im);
$icon_data = $icon->GD2ICOstring($gd_image_array);
header("Accept-Ranges: bytes");
header("Accept-Length: " . strlen($icon_data));
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . 'favicon.ico');
return $icon_data;
}
} else {
$data['upmsg'] = "<font color=\"red\">生成错误请重试!</font>";
}
}
}
}
}
break;
case 'gzip':
$data['q'] = input('q');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$data['q'] = str_replace(array('http://', 'https://'), '', $data['q']);
return $this->redirect('/gzip/?q=' . $data['q'], 302);
}
if ($data['q']) {
$data['url'] = preg_replace("/([\w.]+)[\w\/]*[\w.]*\??[\w=&\+\%]*/is", '\\1', $data['q']);
$data['gzip'] = is_url('http://' . $data['q']) ? urlheader($data['q']) : '';
}
break;
case 'refresh':
$url = input('url');
if ($url) {
$content = Fcurl($url);
return $content;
}
break;
case 'checkkeyword':
$data['url'] = input('txt_url');
$data['keyword'] = input('txt_keyword');
if ($data['url'] && $data['keyword']) {
$str = Fcurl($data['url']);
$str = htmlTotext($str);
$data['html_strlen'] = mb_strlen($str, 'utf-8');
$data['html_gjccd'] = mb_strlen($data['keyword'], 'utf-8');
$data['html_gjcsl'] = substr_count($str, $data['keyword']);
$data['html_gjczcd'] = $data['html_gjccd'] * $data['html_gjcsl'];
$data['html_mdjgjs'] = @round(($data['html_gjczcd'] / $data['html_strlen'] * 100), 1);
}
break;
case 'chameta':
$data['url'] = input('txt_url');
$data['title'] = '';
$data['title_len'] = 0;
$data['keywords'] = '';
$data['keywords_len'] = 0;
$data['description'] = '';
$data['description_len'] = 0;
if ($data['url']) {
$str = Fcurl($data['url']);
preg_match("/<title>([\w\W]*?)<\/title>/is", $str, $match);
$data['title'] = isset($match['1']) ? $match['1'] : null;
$data['title_len'] = mb_strlen($data['title'], 'utf-8');
preg_match("/<meta\s+name=\"keywords\"\s+content=\"([\w\W]*?)\"\s+\/>/is", $str, $match);
$data['keywords'] = isset($match['1']) ? $match['1'] : null;
$data['keywords_len'] = mb_strlen($data['keywords'], 'utf-8');
preg_match("/<meta\s+name=\"description\"\s+content=\"([\w\W]*?)\"\s+\/>/is", $str, $match);
$data['description'] = isset($match['1']) ? $match['1'] : null;
$data['description_len'] = mb_strlen($data['description'], 'utf-8');
}
break;
case 'webstatus':
$data['url'] = input('url');
$data['ip'] = '';
if ($data['url']) {
$web = webstatus($data['url']);
$data['ip'] = $web['ip'];
$data['code'] = $web['code'];
$data['head'] = $web['head'];
}
break;
case 'whois':
$data['url'] = input('whois');
$data['whois'] = '';
$data['domain'] = array();
if ($data['url']) {
if (preg_match('/(http:\/\/|https:\/\/|)([\w.\x{4e00}-\x{9fa5}]*?)/iUu', $data['url'], $domain)) {
$data['url'] = $domain['2'];
}
$whois = whois_query($data['url']);
if (preg_match('/Registrar:\s+(.*)/', $whois, $domain)) {
$data['domain']['注册商'] = $domain['1'];
}
if (preg_match('/Registrant[:]?\s+(.*)/', $whois, $domain)) {
$data['domain']['联系人'] = $domain['1'];
}
if (preg_match('/(Registrar\s+Abuse|Registrant)\s+Contact\s+Email[:]?\s+(.*)/', $whois, $domain)) {
$data['domain']['联系邮箱'] = $domain['2'];
}
if (preg_match('/(Registrar\s+Abuse|Registrant)\s+Contact\s+Phone[:]?\s+(.*)/', $whois, $domain)) {
$data['domain']['联系电话'] = $domain['2'];
}
if (preg_match('/Updated\s+Date[:]?\s+(.*)/', $whois, $domain)) {
$data['domain']['更新时间'] = $domain['1'];
}
if (preg_match('/(Registration\s+Time|Creation\s+Date)[:]?\s+(.*)/', $whois, $domain)) {
$data['domain']['创建时间'] = $domain['2'];
}
if (preg_match('/(Expiration\s+Time|Registry\s+Expiry\s+Date)[:]?\s+(.*)/', $whois, $domain)) {
$data['domain']['过期时间'] = $domain['2'];
}
if (preg_match('/Registrar\s+WHOIS\s+Server[:]?\s+(.*)/', $whois, $domain)) {
$data['domain']['域名服务器'] = $domain['1'];
}
if (preg_match_all('/Name\s+Server?[:]\s+(.*)/', $whois, $domain)) {
$data['domain']['DNS'] = $domain['1'];
}
if (preg_match('/Domain\s+Status[:]?\s+(.*)/', $whois, $domain)) {
$data['domain']['状态'] = $domain['1'];
}
unset($domain);
$whois = "'" . str_replace(["\r", '\'', "\n"], ['', "\'", "'+\"\\n\"+\r'"], $whois) . '\'';
$data['whois'] = $whois;
}
break;
case 'chaicp':
$data['url'] = input('icp');
$data['icp'] = array();
if ($data['url']) {
if (preg_match('/(http:\/\/|https:\/\/|)([\w.\x{4e00}-\x{9fa5}]*?)/iUu', $data['url'], $domain)) {
$data['url'] = $domain['2'];
}
$json = Fcurl('https://api.oick.cn/icp/api.php?url=' . $data['url']);
$data['icp'] = json_decode($json, true);
$data['code'] = $data['icp']['code'];
unset($data['icp']['code']);
}
break;
case 'lishishangdejintian':
$lsjt = Fcurl('https://api.oick.cn/lishi/api.php');
$data['list'] = array();
if ($lsjt) {
$lsjt = str_replace('""', '"', $lsjt);
$lsjt = json_decode($lsjt, true);
$data['list'] = ($lsjt['code'] == 1) ? $lsjt['result'] : array();
}
break;
}
$data["my"]["Think"]["config"]["web"] = getWebConfig();
//var_dump($data);die;
view("index/" . $act, $data);