码迷,mamicode.com
首页 > Windows程序 > 详细

发现一个微博图床API和图片上传代码

时间:2019-01-31 13:12:03      阅读:429      评论:0      收藏:0      [点我收藏+]

标签:frame   res   ast   get   exit   dism   .exe   gif   row   

网上寻到一款微博图床的插件,然后顺藤摸瓜找到了原作者的API代码。

API文件:

  1 <?php
  2 /**
  3  * 上传图片到微博图床
  4  * @author Youngxj & mengkun & 阿珏
  5  * @param $file 图片文件/图片url
  6  * @param $multipart 是否采用multipart方式上传
  7  * @return 返回的json数据
  8  * @code  200:正常;201:错误;203:cookie获取失败;404:请勿直接访问
  9  * @ps    图片尺寸可供选择:square、thumb150、orj360、orj480、mw690、mw1024、mw2048、small、bmiddle、large 默认为:thumb150,请自行替换
 10  */
 11 header("Access-Control-Allow-Origin:*");
 12 header(‘Content-type: application/json‘);
 13 error_reporting(0);
 14 if (!is_file(‘sina_config.php‘)) {
 15   CookieSet(‘SUB;‘,‘0‘);
 16 }
 17 include ‘sina_config.php‘;
 18 //账号
 19 $sinauser = ‘admin‘;
 20 //密码
 21 $sinapwd = ‘password‘;
 22 if (time() - $config[‘time‘] >20*3600||$config[‘cookie‘]==‘SUB;‘) {
 23   $cookie = login($sinauser,$sinapwd);
 24   if($cookie&&$cookie!=‘SUB;‘){
 25     CookieSet($cookie,$time = time());
 26   }else{
 27     return error(‘203‘,‘获取cookie出现错误,请检查账号状态或者重新获取cookie‘);
 28   }
 29 }
 30 if ($_SERVER[‘REQUEST_METHOD‘] == ‘OPTIONS‘) {exit;}
 31 $type=$_GET[‘type‘];
 32 if($type==‘multipart‘){
 33   $multipart = true;
 34   $file = $_FILES["file"]["tmp_name"];
 35 }elseif(isset($_GET[‘img‘])){
 36   $multipart = false;
 37   $file = $_GET[‘img‘];
 38 }else{
 39   return error(‘404‘,‘请勿直接访问‘);
 40 }
 41 if (isset($file) && $file != "") {
 42   include ‘sina_config.php‘;
 43   $cookie = $config[‘cookie‘];
 44   echo upload($file, $multipart,$cookie);
 45 }else{
 46   return error(‘201‘,‘上传错误‘);
 47 }
 48 
 49 function CookieSet($cookie,$time){
 50   $newConfig = ‘<?php 
 51   $config = array(
 52     "cookie" => "‘.$cookie.‘",
 53     "time" => "‘.$time.‘",
 54   );‘;
 55   @file_put_contents(‘sina_config.php‘, $newConfig);
 56 }
 57 
 58 function error($code,$msg){
 59   $arr = array(‘code‘=>$code,‘msg‘=>$msg);
 60   echo json_encode($arr);
 61 }
 62 /**
 63      * 新浪微博登录(无加密接口版本)
 64      * @param  string $u 用户名
 65      * @param  string $p 密码
 66      * @return string    返回最有用最精简的cookie
 67      */
 68 function login($u,$p){
 69   $loginUrl = ‘https://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.4.15)&_=1403138799543‘;
 70   $loginData[‘entry‘] = ‘sso‘;
 71   $loginData[‘gateway‘] = ‘1‘;
 72   $loginData[‘from‘] = ‘null‘;
 73   $loginData[‘savestate‘] = ‘30‘;
 74   $loginData[‘useticket‘] = ‘0‘;
 75   $loginData[‘pagerefer‘] = ‘‘;
 76   $loginData[‘vsnf‘] = ‘1‘;
 77   $loginData[‘su‘] = base64_encode($u);
 78   $loginData[‘service‘] = ‘sso‘;
 79   $loginData[‘sp‘] = $p;
 80   $loginData[‘sr‘] = ‘1920*1080‘;
 81   $loginData[‘encoding‘] = ‘UTF-8‘;
 82   $loginData[‘cdult‘] = ‘3‘;
 83   $loginData[‘domain‘] = ‘sina.com.cn‘;
 84   $loginData[‘prelt‘] = ‘0‘;
 85   $loginData[‘returntype‘] = ‘TEXT‘;
 86   return loginPost($loginUrl,$loginData); 
 87 }
 88 
 89 /**
 90      * 发送微博登录请求
 91      * @param  string $url  接口地址
 92      * @param  array  $data 数据
 93      * @return json         算了,还是返回cookie吧//返回登录成功后的用户信息json
 94      */
 95 function loginPost($url,$data){
 96   $tmp = ‘‘;
 97   if(is_array($data)){
 98     foreach($data as $key =>$value){
 99       $tmp .= $key."=".$value."&";
100     }
101     $post = trim($tmp,"&");
102   }else{
103     $post = $data;
104   }
105   $ch = curl_init();
106   curl_setopt($ch,CURLOPT_URL,$url); 
107   curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
108   curl_setopt($ch,CURLOPT_HEADER,1);
109   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
110   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
111   curl_setopt($ch,CURLOPT_POST,1);
112   curl_setopt($ch,CURLOPT_POSTFIELDS,$post);
113   $return = curl_exec($ch);
114   curl_close($ch);
115   return ‘SUB‘ . getSubstr($return,"Set-Cookie: SUB",‘; ‘) . ‘;‘;
116 }
117 
118 /**
119  * 取本文中间
120  */
121 function getSubstr($str,$leftStr,$rightStr){
122   $left = strpos($str, $leftStr);
123   //echo ‘左边:‘.$left;
124   $right = strpos($str, $rightStr,$left);
125   //echo ‘<br>右边:‘.$right;
126   if($left <= 0 or $right < $left) return ‘‘;
127   return substr($str, $left + strlen($leftStr), $right-$left-strlen($leftStr));
128 }
129 
130 
131 function upload($file, $multipart = true,$cookie) {
132   $url = ‘http://picupload.service.weibo.com/interface/pic_upload.php‘.‘?mime=image%2Fjpeg&data=base64&url=0&markpos=1&logo=&nick=0&marks=1&app=miniblog‘;
133   if($multipart) {
134     $url .= ‘&cb=http://weibo.com/aj/static/upimgback.html?_wv=5&callback=STK_ijax_‘.time();
135     if (class_exists(‘CURLFile‘)) {     // php 5.5
136       $post[‘pic1‘] = new \CURLFile(realpath($file));
137     } else {
138       $post[‘pic1‘] = ‘@‘.realpath($file);
139     }
140   } else {
141     $post[‘b64_data‘] = base64_encode(file_get_contents($file));
142   }
143   // Curl提交
144   $ch = curl_init($url);
145   curl_setopt_array($ch, array(
146     CURLOPT_POST => true,
147     CURLOPT_VERBOSE => true,
148     CURLOPT_RETURNTRANSFER => true,
149     CURLOPT_HTTPHEADER => array("Cookie: $cookie"),
150     CURLOPT_POSTFIELDS => $post,
151   ));
152   $output = curl_exec($ch);
153   curl_close($ch);
154   // 正则表达式提取返回结果中的json数据
155   preg_match(‘/({.*)/i‘, $output, $match);
156   if(!isset($match[1])) return error(‘201‘,‘上传错误‘);
157   $a=json_decode($match[1],true);
158   $width = $a[‘data‘][‘pics‘][‘pic_1‘][‘width‘];
159   $size = $a[‘data‘][‘pics‘][‘pic_1‘][‘size‘];
160   $height = $a[‘data‘][‘pics‘][‘pic_1‘][‘height‘];
161   $pid = $a[‘data‘][‘pics‘][‘pic_1‘][‘pid‘];
162   if(!$pid){return error(‘201‘,‘上传错误‘);}
163   $arr = array(‘code‘=>‘200‘,‘width‘=>$width,"height"=>$height,"size"=>$size,"pid"=>$pid,"url"=>"http://ws3.sinaimg.cn/thumb150/".$pid.".jpg");
164   return json_encode($arr);
165 }

js代码:

/**
* @act      新浪图床上传
* @version  1.0
* @author   youngxj
* @date     <?php echo date("Y-m-d");?>
* @url      http://www.youngxj.cn
*/

$(document).ready(function() {
    $("input[type=‘file‘]").change(function(e) {
        images_upload(this.files)
    });
    var obj = $(‘body‘);
    obj.on(‘dragenter‘, function(e) {
        e.stopPropagation();
        e.preventDefault()
    });
    obj.on(‘dragover‘, function(e) {
        e.stopPropagation();
        e.preventDefault()
    });
    obj.on(‘drop‘, function(e) {
        e.preventDefault();
        images_upload(e.originalEvent.dataTransfer.files)
    })
});
//远程上传
var url_upload = function() { var urls = $("#urls").val(); var url_arr = urls.split("\n"); if (urls == "" || url_arr.length == 0) { layer.alert("请贴入需要上传的网络图片地址."); return; } $(‘#url_upload_model‘).modal(‘hide‘); $(‘.mselector > button‘)[1].innerHTML = ‘上传中‘; for (var i = 0; i < url_arr.length; i++) { $.ajax({ url: ‘https://api.yum6.cn/sinaimg.php‘, type: ‘GET‘, data: { img: url_arr[i] }, cache: false, dataType: ‘json‘, success: function(data) { layer.msg(‘上传中‘); if (typeof data.pid != ‘undefined‘) { $(‘#url-res-txt‘).append(‘https://ws3.sinaimg.cn/large/‘+data.pid + ‘.jpg\n‘); $(‘.mselector > button‘)[1].innerHTML = ‘成功 ‘ + (i + 1) + ‘/‘ + url_arr.length; var apc = "<img src=‘" + data.url + "‘ alt=‘" + data.url + "‘><p><a id=‘copy‘ data-clipboard-target=‘#copy‘ href=‘#‘ title=‘点击复制链接‘>https://ws3.sinaimg.cn/large/" + data.pid + ".jpg</a></p><br>"; $(‘.preview‘).css(‘display‘, ‘block‘); $(".preview>hr").after(apc) } else { $(‘.mselector > button‘)[1].innerHTML = ‘第‘ + (i + 1) + ‘张上传失败‘ } if (typeof data.pid != ‘undefined‘) { $(‘.mselector > button‘)[1].innerHTML = ‘上传成功‘ } else { $(‘.mselector > button‘)[1].innerHTML = ‘上传失败‘; $(‘#url-res-txt‘).append(data.code + ‘\n‘); layer.alert(data.code) } }, error: function(XMLResponse) { layer.alert("error:" + XMLResponse.responseText) } }) } };
//本地上传
var images_upload = function(files) { var flag = 0; $(‘textarea‘).empty(); $(files).each(function(key, value) { $(‘.mselector > button‘)[0].innerHTML = ‘上传中‘; image_form = new FormData(); image_form.append(‘file‘, value); $.ajax({ url: ‘https://api.yum6.cn/sinaimg.php?type=multipart‘, //此处填写API地址,这个地址是原作者提供调用,可以直接使用无问题 type: ‘POST‘, data: image_form, mimeType: ‘multipart/form-data‘, contentType: false, cache: false, processData: false, dataType: ‘json‘, success: function(data) { flag++; if (typeof data.url != ‘undefined‘) { $(‘#url-res-txt‘).append(‘https://ws3.sinaimg.cn/large/‘+data.pid + ‘.jpg\n‘); $(‘.mselector > button‘)[0].innerHTML = ‘成功 ‘ + flag + ‘/‘ + files.length; var apc = "<img src=‘" + data.url + "‘ alt=‘" + data.url + "‘><p><a id=‘copy"+ flag +"‘ data-clipboard-target=‘#copy"+ flag +"‘ href=‘#‘ title=‘点击复制链接‘ >https://ws3.sinaimg.cn/large/" + data.pid + ".jpg</a></p><br>"; $(‘.preview‘).css(‘display‘, ‘block‘); $(".preview>hr").after(apc) } else { $(‘.mselector > button‘)[0].innerHTML = ‘第‘ + flag + ‘张上传失败‘ } if (flag == $("input[type=‘file‘]")[0].files.length) { if (typeof data.url != ‘undefined‘) { $(‘.mselector > button‘)[0].innerHTML = ‘上传成功‘ } else { $(‘.mselector > button‘)[0].innerHTML = ‘上传失败‘; $(‘#url-res-txt‘).append(data.code + ‘\n‘); layer.alert(data.code) } } }, error: function(XMLResponse) { layer.alert("error:" + XMLResponse.responseText) } }) }) }; document.onpaste = function(e) { var data = e.clipboardData; for (var i = 0; i < data.items.length; i++) { var item = data.items[i]; if (item.kind == ‘file‘ && item.type.match(/^image\//i)) { var blob = item.getAsFile(); images_upload(blob) } } } //复制 var clipboard = new ClipboardJS(‘a‘); clipboard.on(‘success‘,function(e){ e.clearSelection(); layer.msg(‘复制成功!‘); }); clipboard.on(‘error‘,function(e){ e.clearSelection(); layer.msg(‘复制失败!‘); });

html代码:

 1 <div class="container clearfix">
 2     <div class="panel panel-default">
 3         <div class="panel-heading">新浪图床外链<small class="text-capitalize">-Sina Img</small></div>
 4         <div class="panel-body">
 5             <div class="text-center">
 6                 <div class="mselector">
 7                     <input type="file" accept="image/*" multiple="">
 8                     <button type="button" class="btn btn-primary">选择本地图片</button>
 9                     <button type="button" class="btn btn-success" data-toggle="modal" data-target="#url_upload_model">上传远程图片</button>
10                 </div>
11                 <hr/>
12                 
13                 <textarea id="url-res-txt" class="form-control" rows="5" placeholder="上传后的图片外链地址将显示在此处哦、下方会同时显示外链地址和预览图。" ></textarea>
14                 <div class="preview">
15                     <hr/>
16                 </div>
17                 <div id="url_upload_model" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
18                     <div class="modal-dialog">
19                         <div class="modal-content">
20                             <div class="modal-header">
21                                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
22                                 <h4 class="modal-title" id="myModalLabel">上传远程图片</h4>
23                             </div>
24                             <div class="modal-body">
25                                 <p class="lead">请在下方输入远程图片地址~每行一个~</p>
26                                 <textarea class="form-control" name="urls" rows="3" id="urls"></textarea>
27                                 <p id="urlUploadNotice"></p>
28                             </div>
29                             <div class="modal-footer">
30                                 <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
31                                 <button type="button" class="btn btn-primary" onclick="url_upload();">上传</button>
32                             </div>
33                         </div>
34                     </div>
35                 </div>
36             </div>
37         </div>
38     </div>
39 <script type="text/javascript" src="sinaimg.js"></script>

另外还有一个html网页,现成的,复制到本地打开就行:

  1 <!DOCTYPE html>
  2 <html lang=‘zh-cn‘>
  3 <head>
  4     <meta charset=‘UTF-8‘>
  5     <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
  6     <title>免费多图床</title>
  7 
  8     <link rel=‘stylesheet‘ href=‘https://cdn.bootcss.com/normalize/5.0.0/normalize.min.css‘>
  9     <script src="https://cdn.bootcss.com/jquery/3.3.0/jquery.min.js"></script>
 10     <style>
 11     html,body {height: 100%;margin: 0;padding: 0;}body {font-family: ‘lucida grande‘, ‘lucida sans unicode‘, lucida, helvetica, ‘Hiragino Sans GB‘, ‘Microsoft YaHei‘, ‘WenQuanYi Micro Hei‘, sans-serif;align-items: center;display: flex;}a{text-decoration:none;}#container {max-width: 400px;flex-basis: 100%;margin: 0 auto;background: #FFF;border-radius: 10px;box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);-webkit-box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);overflow: hidden;}#container #hero-img {width: 100%;height: 200px;background: #007bff;}#container #profile-img {width: 160px;height: 160px;margin: -80px auto 0 auto;}#container #profile-img img {width: 100%;background: #FFF;border-radius: 50%;}#container #content {text-align: center;width: 320px;margin: 0 auto;padding: 0 0 50px 0;}#container #content h1 {font-size: 29px;font-weight: 500;margin: 30px 0 0 0;}#container #content p {font-size: 18px;font-weight: 400;line-height: 1.4;color: #666;margin: 15px 0 40px 0;}#container #content a {color: #CCC;font-size: 14px;margin: 0 10px;transition: color .3s ease-in-out;-webkit-transition: color .3s ease-in-out;line-height: 40px;}#container #content a:hover {color: #007bff;}.btn{background: none repeat scroll 0 0 #1BA1E2; border: 0 none; border-radius: 2px; color: #FFFFFF !important; cursor: pointer; font-family: "Open Sans","Hiragino Sans GB","Microsoft YaHei","WenQuanYi Micro Hei",Arial,Verdana,Tahoma,sans-serif; font-size: 14px;  padding: 6px 10%;}.btn:hover,.yanshibtn:hover{background: none repeat scroll 0 0 #9B59B6; border: 0 none; border-radius: 2px; color: #FFFFFF!important; cursor: pointer; font-family: "Open Sans","Hiragino Sans GB","Microsoft YaHei","WenQuanYi Micro Hei",Arial,Verdana,Tahoma,sans-serif; font-size: 14px; padding: 8px 10%;}
 12     .imgType{display: none;}
 13     #images img{width: 100%}
 14     #imgurl input{width: 100%}
 15     #imgurl,#progress{display: none;}
 16 
 17     @-webkit-keyframes rotation{
 18         from {-webkit-transform: rotate(0deg);}
 19         to {-webkit-transform: rotate(360deg);}
 20     }
 21 
 22     .Rotation{
 23         -webkit-transform: rotate(360deg);
 24         animation: rotation 3s linear infinite;
 25         -moz-animation: rotation 3s linear infinite;
 26         -webkit-animation: rotation 3s linear infinite;
 27         -o-animation: rotation 3s linear infinite;
 28     }
 29 
 30     .img{border-radius: 250px;}
 31 </style>
 32 </head>
 33 <body>
 34     <div id=‘container‘>
 35         
 36         <div id=‘profile-img‘>
 37             <img src=‘‘ id="imgLoading" class="Rotation img" title=""/>
 38         </div>
 39         <div id=‘content‘>
 40             
 41             <div id="progress"><progress max="100" value="0" id="pg"></progress></div>
 42             <p class="imgType" id="imgType"></p>
 43             <form id="form1">
 44                 <a href=‘javascript:void(0)‘ id="baiduImg" onclick="update(‘baidu‘)" class="btn btn-default" rel=‘nofollow‘>百度图床(有效无https)</a><a href=‘javascript:void(0)‘ id="SinaImg" onclick="update(‘sina‘)" class="btn btn-default" rel=‘nofollow‘>新浪图床(正常https)</a>
 45                 <a href=‘javascript:void(0)‘ id="sougouImg" onclick="update(‘sougou‘)" class="btn btn-default" rel=‘nofollow‘>搜狗图床(失效)</a><a href=‘javascript:void(0)‘ id="soImg" onclick="update(‘so‘)" class="btn btn-default" rel=‘nofollow‘>360 图床(失效)</a>
 46                 <input type="file" id="file" name="file" onchange="sc($(‘#imgType‘).attr(‘imgType‘));" style="display:none" accept="image/*">
 47             </form>
 48             <div class="imgContent" id="imgContent">
 49                 <div id="images"></div>
 50                 <div id="imgurl">
 51                     <code>ImgUrl:</code>
 52                     <input onclick="oCopy(this)" value=""  id="Imgs_url">
 53                     <code>HtmlUrl:</code>
 54                     <input onclick="oCopy(this)" value=""  id="Imgs_html">
 55                     <code>Ubb:</code>
 56                     <input onclick="oCopy(this)" value=""  id="Imgs_Ubb">
 57                     <code>Markdown:</code>
 58                     <input onclick="oCopy(this)" value=""  id="Imgs_markdown">
 59                 </div>
 60             </div>
 61 
 62         </div>
 63     </div>
 64 </body>
 65 <script type="text/javascript">
 66 
 67 
 68  function update(type){
 69      $(#file).val(‘‘);
 70      $(#imgType).attr({
 71          imgType: type,
 72      });
 73      file.click();
 74 
 75  }
 76 
 77 
 78  function sc(type){
 79      if(!type){return false;}
 80      var animateimg = $("#file").val();
 81      $(#pg).val(0);
 82      var imgarr=animateimg.split(\\);
 83      var myimg=imgarr[imgarr.length-1];
 84      var houzui = myimg.lastIndexOf(.);
 85      var ext = myimg.substring(houzui, myimg.length).toUpperCase();  
 86      var file = $(#file).get(0).files[0];
 87      if(!file){return false;}
 88      var fileSize = file.size;
 89 
 90      switch(type){
 91          case sougou:
 92          var maxSize = 2097152;
 93          break;
 94          case baidu:
 95          var maxSize = 2097152;
 96          break; 
 97          case so:
 98          var maxSize = 2097152; 
 99          break;
100          case sina:
101          var maxSize = 10485760; 
102          break;
103          default:
104          var maxSize = 10485760; 
105      } 
106      if(ext !=.PNG && ext !=.GIF && ext !=.JPG && ext !=.JPEG && ext !=.BMP){  
107          parent.alert(文件类型错误,请上传图片类型);return false;  
108      }else if(parseInt(fileSize) >= parseInt(maxSize)){  
109          parent.alert(上传的文件不能超过+maxSize/1024/1024+MB);return false;  
110      }else{
111          $(#imgLoading).attr(src,‘‘);
112          var data = new FormData($(#form1)[0]);  
113          var YoungxjApisToken = f07b711396f9a05bc7129c4507fb65c5;
114          switch(type){
115              case sougou:
116              var apiUrl = https://apis.yum6.cn/api/5bd7f16aa33d7;
117              break;
118              case baidu:
119              var apiUrl = https://apis.yum6.cn/api/5bd828881f92b; 
120              break;
121              case so:
122              var apiUrl = https://apis.yum6.cn/api/5bd90750c3f77; 
123              break;
124              case sina:
125              var apiUrl = https://apis.yum6.cn/api/5bd44dc94bcfc; 
126              break;
127              default:
128              return false;
129          };
130          $(#progress).show();
131          $.ajax({
132              url: apiUrl+?token=+YoungxjApisToken,   
133              type: POST,    
134              data: data,    
135              dataType: JSON, 
136              processData: false,    
137              contentType: false,
138              xhr: function(){
139                  var xhr = $.ajaxSettings.xhr();
140                  if(onprogress && xhr.upload) {
141                      xhr.upload.addEventListener("progress" , onprogress, false);
142                      return xhr;
143                  }
144              }
145          }).done(function(ret){
146              if(ret[code]==1){
147 
148                  var img = ‘‘;var imgurl = ‘‘;
149                  if(type!=sina){var imgSrc = ret[data];}else{var imgSrc = ret[data][url];}
150                  img += <img src="+imgSrc+" name="sinaimg" id="sinaimg">;
151                  
152                  $(#Imgs_url).val(imgSrc);
153                  $(#Imgs_html).val(<img src="+imgSrc+"/>);
154                  $(#Imgs_Ubb).val([img]+imgSrc+[/img]);
155                  $(#Imgs_markdown).val(![](+imgSrc+));
156                  $(#images).html(img);$(#imgLoading).attr(src,‘‘);
157                  $(#imgurl).show();
158                  $(#progress).hide();  
159              }else{
160                  $(#progress).hide();
161                  $(#imgLoading).attr(src,‘‘);
162                  parent.alert(ret[msg]);
163              }  
164              
165          });
166          return false;  
167      }    
168  }
169 
170  function onprogress(evt){
171      var loaded = evt.loaded;
172      var tot = evt.total;
173      var per = Math.floor(100*loaded/tot);
174      $(#pg).val(per);
175 
176  }
177  function oCopy(obj){
178      obj.select();
179      document.execCommand("Copy");
180      if (browserRedirect()) {alert(设备类型为手机,有一定几率复制失败!请查看剪切板是否成功复制);}
181  }
182 
183  function browserRedirect(){
184      var sUserAgent = navigator.userAgent.toLowerCase();
185      var bIsIpad = sUserAgent.match(/ipad/i) == ipad;
186      var bIsIphone = sUserAgent.match(/iphone os/i) == iphone os;
187      var bIsMidp = sUserAgent.match(/midp/i) == midp;
188      var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == rv:1.2.3.4;
189      var bIsUc = sUserAgent.match(/ucweb/i) == web;
190      var bIsCE = sUserAgent.match(/windows ce/i) == windows ce;
191      var bIsWM = sUserAgent.match(/windows mobile/i) == windows mobile;
192      var bIsAndroid = sUserAgent.match(/android/i) == android;
193      if(bIsIpad || bIsIphone || bIsMidp || bIsUc7 || bIsUc || bIsCE || bIsWM || bIsAndroid ){
194          return 1;
195      }
196  };
197  $(document).ready(function(){
198      $(#imgLoading).click(function() {$("#imgContent").toggle();});
199  });
200 </script>
201 </html>

 

作者博客地址:https://www.youngxj.cn

文中JS链接地址:https://blog-static.cnblogs.com/files/vanwee/sinaimg.js

优秀免费资源,请敬畏待之

发现一个微博图床API和图片上传代码

标签:frame   res   ast   get   exit   dism   .exe   gif   row   

原文地址:https://www.cnblogs.com/vanwee/p/10341298.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!