• 关于

    $_GET

    的搜索结果

回答

Re如何开启filegetcontents 转的: file_get_contents函数的使用示例: < ?php $file_contents = file_get_contents('http://www.ccvita.com/'); echo $file_contents; ?> 换成curl函数的使用示例: < ?php $ch = curl_init(); $timeout = 5; curl_setopt ($ch, CURLOPT_URL, 'http://www.ccvita.com'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); echo $file_contents; ?> 利用function_exists函数来判断php是否支持一个函数可以轻松写出下面函数 < ?php function vita_get_url_content($url) { if(function_exists('file_get_contents')) { $file_contents = file_get_contents($url); } else { $ch = curl_init(); $timeout = 5; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); } return $file_contents; } ?> 其实上面的这个函数还有待商榷,如果你的主机服务商把file_get_contents和curl都关闭了,上面的函数就会出现错误。
shanw 2019-12-02 02:05:25 0 浏览量 回答数 0

问题

PHP,MySQL错误:列数与第1行的值数不匹配

我收到此错误: Column count doesn't match value count at row 1 从以下代码: $name = $_GET['name']; $...
保持可爱mmm 2020-05-11 11:11:39 1 浏览量 回答数 1

回答

代码中添加if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map(’stripslashes_deep’, $value) : stripslashes($value); return $value; } $_POST = array_map(’stripslashes_deep’, $_POST); $_GET = array_map(’stripslashes_deep’, $_GET); $_COOKIE = array_map(’stripslashes_deep’, $_COOKIE); }
落地花开啦 2019-12-02 02:45:30 0 浏览量 回答数 0

回答

几乎没有200k随机记录的基准。与预期的一样,fetchAll方法更快,但需要更多的内存。 Result : fetchAll : 0.35965991020203s, 100249408b fetch : 0.39197015762329s, 440b 使用的基准代码: setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = 'SELECT * FROM test_table WHERE 1'; $stmt = $dbh->query($sql); $data = array(); $start_all = microtime(true); $data = $stmt->fetchAll(); $end_all = microtime(true); $stmt = $dbh->query($sql); $data = array(); $start_one = microtime(true); while($data = $stmt->fetch()){} $end_one = microtime(true); // Second benchmark : memory usage $stmt = $dbh->query($sql); $data = array(); $memory_start_all = memory_get_usage(); $data = $stmt->fetchAll(); $memory_end_all = memory_get_usage(); $stmt = $dbh->query($sql); $data = array(); $memory_end_one = 0; $memory_start_one = memory_get_usage(); while($data = $stmt->fetch()){ $memory_end_one = max($memory_end_one, memory_get_usage()); } echo 'Result : fetchAll : ' . ($end_all - $start_all) . 's, ' . ($memory_end_all - $memory_start_all) . 'b fetch : ' . ($end_one - $start_one) . 's, ' . ($memory_end_one - $memory_start_one) . 'b '; 分享来源:stack overflow
保持可爱mmm 2020-05-11 16:40:38 0 浏览量 回答数 0

问题

PHP中,如何把一字符串转换为$_GET数组?

$_SERVER['QUERY_STRING']的字符串类似: a=1&amp;b=2&amp;c=3&amp;vardate=2012-11-12 希望能转换成$_GET数组,内容类似于:`$_GET['a']=1;$_GET['b']=...
落地花开啦 2019-12-01 19:54:22 1058 浏览量 回答数 1

问题

Fatal error: Uncaught Error: Class '\m\index\index' not found

本地可以找到,所有的源码都上传了,但是阿里云提示找不到。public function route(){ $M = @$_GET['m']?$_GET['m']:$this-&gt;config['M']; $C = @$_...
岑子哥 2019-12-01 20:19:18 1330 浏览量 回答数 1

回答

$coon=mysqli_connct($host,$useranme,$password,$db); mysqli_query($conn,"set names utf8"); foreach ($_POST as $key => $value) { $_POST[$key] = mysqli_real_escape_string($conn,str_replace("\","\\",$value)); } foreach ($_GET as $key => $value) { $_GET[$key] = mysqli_real_escape_string($conn,htmlspecialchars ($value,ENT_QUOTES,'UTF-8')); } 下面的同上
蛮大人123 2019-12-02 01:43:15 0 浏览量 回答数 0

回答

" <a href=""https://github.com/sjclijie/php-des"" rel=""nofollow noreferrer"">https://github.com/sjclijie/p... 用这个试试吧,这和他用的什么java代码关系不大,你实现他的加密逻辑就可以了。 先 base64 decode 然后用des算法解密###### 已解决 class DES { protected $cipher; //密码 protected $mode; //模式 private $_secret_key; //密钥 public function __construct($key, $cipher=MCRYPT_TRIPLEDES, $mode=MCRYPT_MODE_ECB) { $this->_secret_key = $key; $this->cipher = $cipher; $this->mode = $mode; } public function encrypt($str, $padding = true) { if ($padding) { $size = mcrypt_get_block_size($this->cipher, $this->mode); $pad = $size - (strlen($str) % $size); $str .= str_repeat(chr($pad), $pad); } $td = mcrypt_module_open($this->cipher, '', $this->mode, ''); $iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); mcrypt_generic_init($td, $this->_secret_key, $iv); $data = mcrypt_generic($td, $str); mcrypt_generic_deinit($td); mcrypt_module_close($td); return base64_encode($data); } public function decrypt($str, $padding = true) { $td = mcrypt_module_open($this->cipher, '', $this->mode, ''); $iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); mcrypt_generic_init($td, $this->_secret_key, $iv); $data = mdecrypt_generic($td, base64_decode($str)); mcrypt_generic_deinit($td); mcrypt_module_close($td); if ($padding) { $pad = ord($data{strlen($data) - 1}); return substr($data, 0, -1 * $pad); } return $data; } }" ![image.png](https://ucc.alicdn.com/pic/developer-ecology/0332f43c26714d129f3999425907b9c0.png)
因为相信,所以看见。 2020-05-27 10:06:23 0 浏览量 回答数 0

问题

防止xss+sql注入的问题?报错

刚看了一个放xss和sql注入的文章: 框架类型或者有公共文件的,建议在公共文件中统一做一次XSS和SQL注入的过滤。写个过滤函数,可由如下所示: $_REQUEST = filter_xs...
爱吃鱼的程序员 2020-06-09 13:41:23 0 浏览量 回答数 1

回答

详细解答可以参考官方帮助文档使用签名URL进行临时授权您可以将生成的签名URL提供给访客进行临时访问。生成签名URL时,您可以指定URL的过期时间,来限制访客的访问时长。授权访问的完整代码请参见GitHub。 生成下载的签名URL以下代码用于生成下载的签名URL: <?phpif (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php';}if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php';}use OSS\OssClient;use OSS\Core\OssException;use OSS\Http\RequestCore;use OSS\Http\ResponseCore;// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。$accessKeyId = "<yourAccessKeyId>";$accessKeySecret = "<yourAccessKeySecret>";// Endpoint以杭州为例,其它Region请按实际情况填写。$endpoint = "http://oss-cn-hangzhou.aliyuncs.com";$bucket= "<yourBucketName>";$object = "<yourObjectName>";$securityToken = "<yourSecurityToken>";// 设置URL的有效期为3600秒。$timeout = 3600;try { $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, $securityToken); // 生成GetObject的签名URL。 $signedUrl = $ossClient->signUrl($bucket, $object, $timeout);} catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return;}print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n");// 可以使用代码来访问签名的URL,也可以输入到浏览器中进行访问。$request = new RequestCore($signedUrl);// 生成的URL默认以GET方式访问。$request->set_method('GET');$request->add_header('Content-Type', '');$request->send_request();$res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());if ($res->isOK()) { print(__FUNCTION__ . ": OK" . "\n");} else { print(__FUNCTION__ . ": FAILED" . "\n");}; 生成上传的签名URL以下代码用于生成上传的签名URL: <?phpif (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php';}if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php';}use OSS\OssClient;use OSS\Core\OssException;use OSS\Http\RequestCore;use OSS\Http\ResponseCore;// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。$accessKeyId = "<yourAccessKeyId>";$accessKeySecret = "<yourAccessKeySecret>";// Endpoint以杭州为例,其它Region请按实际情况填写。$endpoint = "http://oss-cn-hangzhou.aliyuncs.com";$bucket= "<yourBucketName>";$object = "<yourObjectName>";$securityToken = "<yourSecurityToken>";$timeout = 3600;try { $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, $securityToken); // 生成PutObject的签名URL。 $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT");} catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return;}print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n");$content = "Hello OSS.";$request = new RequestCore($signedUrl);// 生成的URL以PUT方式访问。$request->set_method('PUT');$request->add_header('Content-Type', '');$request->add_header('Content-Length', strlen($content));$request->set_body($content);$request->send_request();$res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());if ($res->isOK()) { print(__FUNCTION__ . ": OK" . "\n");} else { print(__FUNCTION__ . ": FAILED" . "\n");}; 使用STS进行临时授权您可以通过STS(Security Token Service)进行临时授权访问。更多有关STS的内容请参见访问控制API参考(STS)中的简介。关于账号及授权的详细信息请参见最佳实践中的STS临时授权访问。 以下代码用于使用STS临时授权上传文件: <?phpif (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php';}if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php';}use OSS\OssClient;use OSS\Core\OssException;// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。$accessKeyId = "<yourAccessKeyId>";$accessKeySecret = "<yourAccessKeySecret>";// Endpoint以杭州为例,其它Region请按实际情况填写。$endpoint = "http://oss-cn-hangzhou.aliyuncs.com";$bucket= "<yourBucketName>";$object = "<yourObjectName>";$securityToken = "<yourSecurityToken>";$content = "Hi, OSS.";try { $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, $securityToken); $ossClient->putObject($bucket, $object, $content);} catch (OssException $e) { print $e->getMessage();}
2019-12-01 23:14:30 0 浏览量 回答数 0

回答

详细解答可以参考官方帮助文档使用签名URL进行临时授权您可以将生成的签名URL提供给访客进行临时访问。生成签名URL时,您可以指定URL的过期时间,来限制访客的访问时长。授权访问的完整代码请参见GitHub。 生成下载的签名URL以下代码用于生成下载的签名URL: <?phpif (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php';}if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php';}use OSS\OssClient;use OSS\Core\OssException;use OSS\Http\RequestCore;use OSS\Http\ResponseCore;// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。$accessKeyId = "<yourAccessKeyId>";$accessKeySecret = "<yourAccessKeySecret>";// Endpoint以杭州为例,其它Region请按实际情况填写。$endpoint = "http://oss-cn-hangzhou.aliyuncs.com";$bucket= "<yourBucketName>";$object = "<yourObjectName>";$securityToken = "<yourSecurityToken>";// 设置URL的有效期为3600秒。$timeout = 3600;try { $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, $securityToken); // 生成GetObject的签名URL。 $signedUrl = $ossClient->signUrl($bucket, $object, $timeout);} catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return;}print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n");// 可以使用代码来访问签名的URL,也可以输入到浏览器中进行访问。$request = new RequestCore($signedUrl);// 生成的URL默认以GET方式访问。$request->set_method('GET');$request->add_header('Content-Type', '');$request->send_request();$res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());if ($res->isOK()) { print(__FUNCTION__ . ": OK" . "\n");} else { print(__FUNCTION__ . ": FAILED" . "\n");}; 生成上传的签名URL以下代码用于生成上传的签名URL: <?phpif (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php';}if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php';}use OSS\OssClient;use OSS\Core\OssException;use OSS\Http\RequestCore;use OSS\Http\ResponseCore;// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。$accessKeyId = "<yourAccessKeyId>";$accessKeySecret = "<yourAccessKeySecret>";// Endpoint以杭州为例,其它Region请按实际情况填写。$endpoint = "http://oss-cn-hangzhou.aliyuncs.com";$bucket= "<yourBucketName>";$object = "<yourObjectName>";$securityToken = "<yourSecurityToken>";$timeout = 3600;try { $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, $securityToken); // 生成PutObject的签名URL。 $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT");} catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return;}print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n");$content = "Hello OSS.";$request = new RequestCore($signedUrl);// 生成的URL以PUT方式访问。$request->set_method('PUT');$request->add_header('Content-Type', '');$request->add_header('Content-Length', strlen($content));$request->set_body($content);$request->send_request();$res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());if ($res->isOK()) { print(__FUNCTION__ . ": OK" . "\n");} else { print(__FUNCTION__ . ": FAILED" . "\n");}; 使用STS进行临时授权您可以通过STS(Security Token Service)进行临时授权访问。更多有关STS的内容请参见访问控制API参考(STS)中的简介。关于账号及授权的详细信息请参见最佳实践中的STS临时授权访问。 以下代码用于使用STS临时授权上传文件: <?phpif (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php';}if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php';}use OSS\OssClient;use OSS\Core\OssException;// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。$accessKeyId = "<yourAccessKeyId>";$accessKeySecret = "<yourAccessKeySecret>";// Endpoint以杭州为例,其它Region请按实际情况填写。$endpoint = "http://oss-cn-hangzhou.aliyuncs.com";$bucket= "<yourBucketName>";$object = "<yourObjectName>";$securityToken = "<yourSecurityToken>";$content = "Hi, OSS.";try { $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, $securityToken); $ossClient->putObject($bucket, $object, $content);} catch (OssException $e) { print $e->getMessage();}
2019-12-01 23:14:30 0 浏览量 回答数 0

回答

详细解答可以参考官方帮助文档使用签名URL进行临时授权您可以将生成的签名URL提供给访客进行临时访问。生成签名URL时,您可以指定URL的过期时间,来限制访客的访问时长。授权访问的完整代码请参见GitHub。 生成下载的签名URL以下代码用于生成下载的签名URL: <?phpif (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php';}if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php';}use OSS\OssClient;use OSS\Core\OssException;use OSS\Http\RequestCore;use OSS\Http\ResponseCore;// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。$accessKeyId = "<yourAccessKeyId>";$accessKeySecret = "<yourAccessKeySecret>";// Endpoint以杭州为例,其它Region请按实际情况填写。$endpoint = "http://oss-cn-hangzhou.aliyuncs.com";$bucket= "<yourBucketName>";$object = "<yourObjectName>";$securityToken = "<yourSecurityToken>";// 设置URL的有效期为3600秒。$timeout = 3600;try { $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, $securityToken); // 生成GetObject的签名URL。 $signedUrl = $ossClient->signUrl($bucket, $object, $timeout);} catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return;}print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n");// 可以使用代码来访问签名的URL,也可以输入到浏览器中进行访问。$request = new RequestCore($signedUrl);// 生成的URL默认以GET方式访问。$request->set_method('GET');$request->add_header('Content-Type', '');$request->send_request();$res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());if ($res->isOK()) { print(__FUNCTION__ . ": OK" . "\n");} else { print(__FUNCTION__ . ": FAILED" . "\n");}; 生成上传的签名URL以下代码用于生成上传的签名URL: <?phpif (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php';}if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php';}use OSS\OssClient;use OSS\Core\OssException;use OSS\Http\RequestCore;use OSS\Http\ResponseCore;// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。$accessKeyId = "<yourAccessKeyId>";$accessKeySecret = "<yourAccessKeySecret>";// Endpoint以杭州为例,其它Region请按实际情况填写。$endpoint = "http://oss-cn-hangzhou.aliyuncs.com";$bucket= "<yourBucketName>";$object = "<yourObjectName>";$securityToken = "<yourSecurityToken>";$timeout = 3600;try { $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, $securityToken); // 生成PutObject的签名URL。 $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT");} catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return;}print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n");$content = "Hello OSS.";$request = new RequestCore($signedUrl);// 生成的URL以PUT方式访问。$request->set_method('PUT');$request->add_header('Content-Type', '');$request->add_header('Content-Length', strlen($content));$request->set_body($content);$request->send_request();$res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());if ($res->isOK()) { print(__FUNCTION__ . ": OK" . "\n");} else { print(__FUNCTION__ . ": FAILED" . "\n");}; 使用STS进行临时授权您可以通过STS(Security Token Service)进行临时授权访问。更多有关STS的内容请参见访问控制API参考(STS)中的简介。关于账号及授权的详细信息请参见最佳实践中的STS临时授权访问。 以下代码用于使用STS临时授权上传文件: <?phpif (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php';}if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php';}use OSS\OssClient;use OSS\Core\OssException;// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。$accessKeyId = "<yourAccessKeyId>";$accessKeySecret = "<yourAccessKeySecret>";// Endpoint以杭州为例,其它Region请按实际情况填写。$endpoint = "http://oss-cn-hangzhou.aliyuncs.com";$bucket= "<yourBucketName>";$object = "<yourObjectName>";$securityToken = "<yourSecurityToken>";$content = "Hi, OSS.";try { $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, $securityToken); $ossClient->putObject($bucket, $object, $content);} catch (OssException $e) { print $e->getMessage();}
2019-12-01 23:14:30 0 浏览量 回答数 0

回答

拿去用,不谢 if (! is_writable(__DIR__)) { exit('目录不可写,exit'); } $cookie_file = 'cookies.txt'; $username = 'ty0716'; $password = 'test12345'; $post = array( 'username' => $username, 'password' => $password, 'expire' => '', 'url' => '', 'time' => time(), 'act' => 'do_login' ); // username=ty0716&password=qaz&expire=&url=&time=1456104638534&act=do_login $login_url = 'http://www.lazpw.cn/plus/ajax_user.php'; $login = post($login_url, http_build_query($post), $cookie_file); if ($login == 'err') { exit('用户名或密码错误'); } $login_log_page = get('http://www.lazpw.cn/user/personal/personal_user.php?act=login_log', $cookie_file); echo iconv("UTF-8", "GB2312//IGNORE", $login_log_page); unlink($cookie_file); function post($url, $data, $cookie_file) { // 初始化 $curl = curl_init($url); // 不输出header头信息 curl_setopt($curl, CURLOPT_HEADER, 0); // 保存到字符串而不是输出 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($curl, CURLOPT_POST, 1); // 请求数据 curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // 是否抓取跳转后的页面 curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); $req = curl_exec($curl); curl_close($curl); return $req; } function get($url, $cookie_file) { // 初始化 $curl = curl_init($url); // 不输出header头信息 curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file); // 保存到字符串而不是输出 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 是否抓取跳转后的页面 curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); $req = curl_exec($curl); curl_close($curl); return $req; }
杨冬芳 2019-12-02 02:55:26 0 浏览量 回答数 0

回答

基于 PHP/CURL 编写的类库, 使用方法见注释.直接使用, 不用处理Cookie(程序自动会处理, Cookie信息保存于调用类时传递的参数所指定的文件里).<?php /** * Author: dds_feng * Email: dds_feng@qq.com * * Example: * $http = new HttpClient(__DIR__.'/cookie.ck'); * $http->SetReferer('http://foo.com');//set request referer * echo $http->Get('http://foo.com/');//get * $http->SetProxy('http://127.0.0.1:8888');//set http proxy * echo $http->Post('http://bar.com/xxx', array('a'=>'123', 'b'=>'456'));//post **/ class HttpClient{ private $ch; function __construct($cookieJar){ $this->ch = curl_init(); curl_setopt($this->ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36');//UA curl_setopt($this->ch, CURLOPT_TIMEOUT, 60);//timeout curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, TRUE);//follow redirection curl_setopt($this->ch, CURLOPT_AUTOREFERER, true); curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, FALSE);//ssl curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($this->ch, CURLOPT_COOKIEJAR, $cookieJar);//cookie jar curl_setopt($this->ch, CURLOPT_COOKIEFILE, $cookieJar); } function __destruct(){ curl_close($this->ch); } final public function SetProxy($proxy='http://127.0.0.1:8888'){ //curl_setopt($this->ch, CURLOPT_HTTPPROXYTUNNEL, TRUE); curl_setopt($this->ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);//HTTP proxy //curl_setopt($this->ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);//Socks5 proxy curl_setopt($this->ch, CURLOPT_PROXY, $proxy); } final public function SetReferer($ref=''){ if($ref != ''){ curl_setopt($this->ch, CURLOPT_REFERER, $ref);//Referrer } } final public function SetCookie($ck=''){ if($ck != ''){ curl_setopt($this->ch, CURLOPT_COOKIE, $ck);//Cookie } } final public function Get($url, $header=false, $nobody=false){ curl_setopt($this->ch, CURLOPT_POST, false);//GET curl_setopt($this->ch, CURLOPT_URL, $url); curl_setopt($this->ch, CURLOPT_HEADER, $header);//Response Header curl_setopt($this->ch, CURLOPT_NOBODY, $nobody);//Response Body return curl_exec($this->ch); } final public function Post($url, $data=array(), $header=false, $nobody=false){ curl_setopt($this->ch, CURLOPT_URL, $url); curl_setopt($this->ch, CURLOPT_HEADER, $header);//Response Header curl_setopt($this->ch, CURLOPT_NOBODY, $nobody);//Response Body curl_setopt($this->ch, CURLOPT_POST, true);//POST curl_setopt($this->ch, CURLOPT_POSTFIELDS, http_build_query($data));//data return curl_exec($this->ch); } final public function getError(){ return curl_error($this->ch); } } // vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4:
蛮大人123 2019-12-02 01:53:32 0 浏览量 回答数 0

回答

/** * 获取客户端IP地址 * @return string */ function get_client_ip() { if(getenv('HTTP_CLIENT_IP')){ $client_ip = getenv('HTTP_CLIENT_IP'); } elseif(getenv('HTTP_X_FORWARDED_FOR')) { $client_ip = getenv('HTTP_X_FORWARDED_FOR'); } elseif(getenv('REMOTE_ADDR')) { $client_ip = getenv('REMOTE_ADDR'); } else { $client_ip = $_SERVER['REMOTE_ADDR']; } return $client_ip; } /** 获取服务器端IP地址 * @return string */ function get_server_ip() { if (isset($_SERVER)) { if($_SERVER['SERVER_ADDR']) { $server_ip = $_SERVER['SERVER_ADDR']; } else { $server_ip = $_SERVER['LOCAL_ADDR']; } } else { $server_ip = getenv('SERVER_ADDR'); } return $server_ip; }
小旋风柴进 2019-12-02 02:01:48 0 浏览量 回答数 0

回答

<?php $path = "."; $ext = ".css"; function get_filetree($path, $ext) { $tree = array(); $temp = glob($path . "/*" . $ext); if($temp) $tree = array_merge($tree, $temp); foreach (glob($path . "/*", GLOB_ONLYDIR) as $dir) { $temp = get_filetree($dir, $ext); if($temp) $tree = array_merge($tree, $temp); } return $tree; } //print_r(get_filetree($path, $ext)); $list = get_filetree($path, $ext); foreach($list as $item) { echo "".$file = basename($item)." "; }
小旋风柴进 2019-12-02 01:59:19 0 浏览量 回答数 0

问题

PHP API 上传图片提示 401Unauthorized ,如何解决?

下面是代码 &lt;?php require_once('../upyun.class.php'); $upyun = new UpYun('*', '*', '*'); try { echo "直接上传文件\r\n"; ...
落地花开啦 2019-12-01 19:58:03 2071 浏览量 回答数 2

回答

该方法get_results具有第二个参数: wpdb :: get_results(字符串$ query = null,字符串$ output = OBJECT) 利用它并传递ARRAY_A,然后get_results将返回一个数组而不是对象: $pre = $wpdb->get_results("SELECT * FROM prematch WHERE sport_id =1 ORDER BY timer", ARRAY_A); 然后处理数组: $ligues_events = array(); foreach ($pre as $key => $item) { $ligues_events[$item['league_name']][$key] = $item['event_name']; } 并输出: foreach ($ligues_events as $ligue_name => $events) { echo $ligue_name; foreach ($events as $event) { echo $event; } }
保持可爱mmm 2019-12-02 03:15:24 0 浏览量 回答数 0

问题

想问下这段代码是什么含义呀?

<?php/** NotORM - simple reading data from the database @link http://www.notorm.com/ @author Jakub Vrana, http://ww...
幸福量子 2019-12-01 20:03:45 1125 浏览量 回答数 0

回答

RePHP获取用户真实IP解决方案 function get_real_ip() { $ip=false; if(!empty($_SERVER["HTTP_CLIENT_IP"])) { $ip = $_SERVER["HTTP_CLIENT_IP"]; } if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ips = explode (“, ”, $_SERVER['HTTP_X_FORWARDED_FOR']); if ($ip) { array_unshift($ips, $ip); $ip = FALSE; } for ($i = 0; $i < count($ips); $i++) { if (!eregi (“^(10|172.16|192.168).”, $ips[$i])) { $ip = $ips[$i]; break; } } } return ($ip ? $ip : $_SERVER['REMOTE_ADDR']); } $onlineip = get_real_ip(); 我这样修改,但是访问不了RDS数据库了
0o0o 2019-12-02 02:57:16 0 浏览量 回答数 0

回答

对于你的情况,如果你可以接受定期从redis导入到mysql,那基本上表示你的业务就不需要mysql,因为redis不仅仅是缓存,塞给它的数据是持久化到硬盘的,你下次直接从redis读出来就行了。至于缓存,一般都是读缓存(写缓存实现起来很罗嗦,而且也不那么靠谱),与数据库的同步策略需要添加到自己的代码逻辑里。假设你原先的代码逻辑是这样:$data = get_from_db($condition);现在需要将get_from_db改成这样function get_from_db($condition) { $data = get_from_cache($condition); if (!$data) { $data = get_from_db_directly($condition); set_to_cache($condition, $data); } return $data; }
落地花开啦 2019-12-02 01:53:46 0 浏览量 回答数 0

回答

对于你的情况,如果你可以接受定期从redis导入到mysql,那基本上表示你的业务就不需要mysql,因为redis不仅仅是缓存,塞给它的数据是持久化到硬盘的,你下次直接从redis读出来就行了。至于缓存,一般都是读缓存(写缓存实现起来很罗嗦,而且也不那么靠谱),与数据库的同步策略需要添加到自己的代码逻辑里。假设你原先的代码逻辑是这样:$data = get_from_db($condition);现在需要将get_from_db改成这样function get_from_db($condition) { $data = get_from_cache($condition); if (!$data) { $data = get_from_db_directly($condition); set_to_cache($condition, $data); } return $data; }
爵霸 2019-12-02 02:01:45 0 浏览量 回答数 0

问题

SQL语句如何优化,这样的搜索请求, 给个思路。指点一二 400 请求报错 

/*获取筛选属性*/ $attr_para = $_GET['para']; //形状 $attr_cut = $_GET['cut']; //切工 $attr_color =...
kun坤 2020-05-30 22:59:01 2 浏览量 回答数 1

回答

[php] view plain copy print?在CODE上查看代码片派生到我的代码片 <?php $ch = curl_init(); $timeout = 5; curl_setopt ($ch, CURLOPT_URL, 'http://www.domain.com/'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_POST, 1 );//设置post请求 curl_setopt($ch, CURLOPT_HEADER, 0 ) ; curl_setopt($ch,CURLOPT_POSTFIELDS, "param=".$param);//param为请求的参数 $file_contents = curl_exec($ch); curl_close($ch); echo $file_contents; ?> /** * * @Description 批量请求获得内容 * @param @param array $urls * @param @param String $param * @return String */ public function remoteByRolling($urls, $param) { if (! is_array ( $urls ) || count ( $urls ) == 0) return false; $queue = curl_multi_init (); $map = array (); foreach ( $urls as $url ) { $this->remoteByPost ( $url, $param ); curl_multi_add_handle ( $queue, $this->ch ); $map [$url] = $this->$ch; } $active = null; // 执行批处理句柄 do { $mrc = curl_multi_exec ( $queue, $active ); } while ( $mrc == CURLM_CALL_MULTI_PERFORM ); while ( $active > 0 && $mrc == CURLM_OK ) { //curl_multi_select:等待所有cURL批处理中的活动连接 if (curl_multi_select ( $queue, 0.5 ) != - 1) { do { $mrc = curl_multi_exec ( $queue, $active ); } while ( $mrc == CURLM_CALL_MULTI_PERFORM ); } } /* get data */ $responses = array (); foreach ( $map as $url => $ch ) { if (curl_error ( $ch ) == '') { $responses [$url] = curl_multi_getcontent ( $ch ) ; }else{ error_log("curl error"); } curl_multi_remove_handle ( $queue, $ch ); curl_close ( $ch ); } }
小旋风柴进 2019-12-02 02:03:12 0 浏览量 回答数 0

问题

"Allowed memory size of 536870912 bytes exhausted "问题

Allowed memory size of 536870912 bytes exhausted (tried to allocate 130968 bytes)什么原因导致的,求大神解惑。public function test() { ...
落地花开啦 2019-12-01 20:00:49 1359 浏览量 回答数 1

回答

$url = 'http://www.baidu.com'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 20); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $ret = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch);
小旋风柴进 2019-12-02 02:01:17 0 浏览量 回答数 0

问题

可以转成java吗?

<?php////////////////////////////////////////////////////////////////////////// MG Software Corporation Sdn Bhd.// ...
你好世界123 2019-12-01 20:02:19 1139 浏览量 回答数 3

问题

php使用Curl调用接口 速度非常慢, 把 域名换成Ip速度就正常啦.

function requestCurl($url,$type = 'get',$data=NULL) { $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER...
a123456678 2019-12-01 20:12:32 1469 浏览量 回答数 1

问题

MySQL大圆距离(Haversine公式)

我有一个工作的PHP脚本,该脚本获取经度和纬度值,然后将它们输入到MySQL查询中。我只想将其制作成MySQL。这是我当前的PHP代码: if ($distance != "Any...
保持可爱mmm 2020-05-08 11:09:04 0 浏览量 回答数 1

问题

如何在wordpress主题里输出插件的内容?

//show contribute meta data function contribute_metadata( $content ){ if( is_single() ){ ...
小旋风柴进 2019-12-01 20:08:59 1026 浏览量 回答数 1

云产品推荐

上海奇点人才服务相关的云产品 小程序定制 上海微企信息技术相关的云产品 国内短信套餐包 ECS云服务器安全配置相关的云产品 开发者问答 阿里云建站 自然场景识别相关的云产品 万网 小程序开发制作 视频内容分析 视频集锦 代理记账服务