Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexchent committed Dec 5, 2019
1 parent abd0ccb commit 748fb75
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 35 deletions.
17 changes: 17 additions & 0 deletions Helper/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,21 @@ public static function isNotJson($str)
return is_null(json_decode($str, true));
}

/**
* 获取当前客户端的IP地址
* @return array|false|string
*/
public static function getIp()
{
if($ip = $_SERVER['REMOTE_ADDR']) return $ip;
if($ip = getenv('HTTP_CLIENT_IP')) return $ip;
if($ip = getenv('HTTP_X_FORWARDED_FOR')) return $ip;
}

public static function getServerIp()
{
return $_SERVER['SERVER_ADDR'];
}


}
2 changes: 1 addition & 1 deletion Useredis.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
class Useredis{
class Useredis{
const HOST="127.0.0.1";
const PORT="6379";
public $redis;
Expand Down
23 changes: 14 additions & 9 deletions array_foreach.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,37 @@
*/

#array_filter
#利用自定义函数筛选符合规则的元素,符合的放进结果数组中
function rule($var){
if($var%2 == 0) return true;
return false;
}

$arr=array('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>6);
$newarr = array_filter($arr,'rule', ARRAY_FILTER_USE_BOTH);
var_dump($newarr);
//var_dump($newarr);



#array_walk 传引用,第三个参数传给回调函数
/*
* array_walk
函数对数组中的每个元素应用用户自定义函数。在函数中,数组的键名和键值是参数。
注释:您可以通过把用户自定义函数中的第一个参数指定为引用:&$value,来改变数组元素的值(参见实例 2)。此时作用与array_map相同
*/
$arr = [1,2,3,4,5,6];
$a = 2;
function test(&$v, $key, $a) {
$v = $v + $a;
}
array_walk($arr, 'test', $a);

array_walk($arr, function(&$v, $k, $a){
$v = $v + $a;
}, $a);
//var_dump($arr);



#array_map 传值
$brr = [1,2,3,4,5,6];
#array_map 将自定义函数作用于数组的每一个元素
$brr = [1,2,3,'a'=>4,5,6];
$test1 = function ($v) use ($a) {
// echo $v.'——'.$a."\n";
echo $v.'——'.$a."\n";
return $v + $a;
};

Expand Down
1 change: 1 addition & 0 deletions cli/pachong.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php/** * Created by PhpStorm. * User: chentao * Date: 2019/10/29 * Time: 5:20 PM *///const URL = "http://www.punimaitv.com";const URL = "http://www.jzw110.com";//const URL = "http://www.jinyizhen.cc";getSource(URL);function getSource($url){ $file_content = file_get_contents($url);// 获取资源地址 preg_match_all('/href=([\"\'])([^\"|\'])+(html)/', $file_content, $content);//$content = preg_replace("/[\t\n\r]+/", "", $content);//echo "当前url地址: $url <br>";//var_dump($content[0]);die; $saveLink=[]; $findLink = array_unique($content[0]);//var_dump($findLink);die; foreach ($findLink as $link) { if(strpos($link,'http')) { $saveLink[] = $newLink = str_replace('href="','', $link); } else { $saveLink[] = $newLink = URL.str_replace('href="','', $link); } }//var_dump($saveLink);die; $key = "punimai"; $key_linked = "punimai_end"; $redis = new Redis(); $redis->connect('127.0.0.1', 6379); //获取并保存视频地址 preg_match_all('/http(s)?:\/\/(.)+\.mp4/', $file_content, $source); if(count($source[0])) { $redis->sAddArray('video_'.URL, $source[0]); } //保存连接 $res = $redis->sAddArray($key,$saveLink); echo $res."\t"; if ($res) { foreach ($saveLink as $item) {// echo $item."<br>"; if($redis->sAdd($key_linked, $item)) getSource($item);//爬取未扫描连接 } }}
Expand Down
26 changes: 26 additions & 0 deletions getVideoTxt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* Created by PhpStorm.
* User: chentao
* Date: 2019/1/26
* Time: 4:31 PM
*/


include 'Helper/Client.php';
include 'Helper/Tools.php';
include 'cli/pachong.php';


$redis = new Redis();
$redis->pconnect('127.0.0.1','6379');


//$res = $redis->sMembers('video_'.URL);
$res = $redis->sDiff('video_'.URL, 'video');//获取差集,key1为主体
//var_dump($res);die;
foreach ($res as $i){
file_put_contents("video1.txt", $i."\n",FILE_APPEND);
}

//var_dump($res);die;
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title></head><body></body><script> function f1(){ var n=999; function f2(){ return n; } return f2(); } var res = f1(); console.log(res);</script></html>
Expand Down
25 changes: 0 additions & 25 deletions phpinfo.php

This file was deleted.

1 change: 1 addition & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function f1(){ n=999;}f1();alert(n); // 999
Expand Down
1 change: 1 addition & 0 deletions test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php/** * Created by PhpStorm. * User: chentao * Date: 2019/12/5 * Time: 11:02 AM */include "Helper/Tools.php";//echo \Helper\Tools::getServerIp();die;//echo $ip = $_SERVER['REMOTE_ADDR'];die;//echo $ip = getenv('HTTP_X_FORWARDED_FOR');die;$a = [1,2,3,4,5,6];//echo current($a);//echo next($a);//echo prev($a);//echo end($a);class A { private $x = 1;}// PHP 7 之前版本定义闭包函数代码$getXCB = function() { return $this->x;};// 闭包函数绑定到类 A 上//$getX = $getXCB->bindTo(new A, 'A');//echo $getX();//print(PHP_EOL);echo $getXCB->call(new A, 'A');
Expand Down

0 comments on commit 748fb75

Please sign in to comment.