Skip to content

Commit

Permalink
list
Browse files Browse the repository at this point in the history
  • Loading branch information
IoTcat committed Jan 1, 2021
1 parent 61bed92 commit 2064dca
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ function getImgsInfo($type, $isFast = false){

preg_match_all('/img_(\S*?)_(\d{2,4})x(\d{2,4})_(\S*?)_(\S*?)_(\S*?).(jpe?g|png|gif|svg)\b/', $str, $arr);

//echo var_dump($str);
//echo var_dump($arr);

return $arr;

Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
$redis->set($__num, $_num+1);
$redis->set($__ip, $_ip+1);

if((!in_array($__from, $whiteList) && $_num > 50) || $_ip > 100) {
if(!in_array($__from, $whiteList) && ($_num > 50 || $_ip > 100)) {
header("Location: https://api.vvhan.com/api/acgimg");
yimian__log("log_api", array("api" => "img", "timestamp" => date('Y-m-d H:i:s', time()), "ip" => ip2long(getIp()), "_from" => get_from(), "content" => 'https://api.vvhan.com/api/acgimg'));
die();
Expand Down
31 changes: 31 additions & 0 deletions list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

include 'functions.php';

$type = $_GET['type'];
$limit = $_GET['limit'];
$sort = $_GET['sort'];

if(!isset($type) || !($type == 'moe' || $type == 'wallpaper' || $type == 'head' || $type == 'koino' || $type == 'imgbed')) $type = 'moe';
if(!isset($limit)) $limit = 30;
if(!isset($sort)) $sort = 'random';



$data = getImgsInfo($type);

if($sort == 'random') shuffle($data[0]);
if($sort == 'reverse') $data[0] = array_reverse($data[0]);
if($limit >= 0) $data[0] = array_slice($data[0], 0, $limit);

$o = array();

foreach($data[0] as $val){
$o[] = array(
"name" => $val,
"url" => 'https://api.yimian.xyz/img/?path='.$type.'/'.$val
);
}


echo json_encode($o);

0 comments on commit 2064dca

Please sign in to comment.