[更新]ComposerUpdate

This commit is contained in:
Anyon 2019-07-16 11:28:15 +08:00
parent 3547a0944b
commit 97dc0d68c6
26 changed files with 117 additions and 140 deletions

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php'; require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitcd810a1640b6294256452cfc7e3e3b69::getLoader(); return ComposerAutoloaderInit9f532fe51df20fe03503300614827aa4::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer // autoload_real.php @generated by Composer
class ComposerAutoloaderInitcd810a1640b6294256452cfc7e3e3b69 class ComposerAutoloaderInit9f532fe51df20fe03503300614827aa4
{ {
private static $loader; private static $loader;
@ -19,15 +19,15 @@ class ComposerAutoloaderInitcd810a1640b6294256452cfc7e3e3b69
return self::$loader; return self::$loader;
} }
spl_autoload_register(array('ComposerAutoloaderInitcd810a1640b6294256452cfc7e3e3b69', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInit9f532fe51df20fe03503300614827aa4', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(); self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitcd810a1640b6294256452cfc7e3e3b69', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInit9f532fe51df20fe03503300614827aa4', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) { if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php'; require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitcd810a1640b6294256452cfc7e3e3b69::getInitializer($loader)); call_user_func(\Composer\Autoload\ComposerStaticInit9f532fe51df20fe03503300614827aa4::getInitializer($loader));
} else { } else {
$map = require __DIR__ . '/autoload_namespaces.php'; $map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) { foreach ($map as $namespace => $path) {
@ -48,19 +48,19 @@ class ComposerAutoloaderInitcd810a1640b6294256452cfc7e3e3b69
$loader->register(true); $loader->register(true);
if ($useStaticLoader) { if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitcd810a1640b6294256452cfc7e3e3b69::$files; $includeFiles = Composer\Autoload\ComposerStaticInit9f532fe51df20fe03503300614827aa4::$files;
} else { } else {
$includeFiles = require __DIR__ . '/autoload_files.php'; $includeFiles = require __DIR__ . '/autoload_files.php';
} }
foreach ($includeFiles as $fileIdentifier => $file) { foreach ($includeFiles as $fileIdentifier => $file) {
composerRequirecd810a1640b6294256452cfc7e3e3b69($fileIdentifier, $file); composerRequire9f532fe51df20fe03503300614827aa4($fileIdentifier, $file);
} }
return $loader; return $loader;
} }
} }
function composerRequirecd810a1640b6294256452cfc7e3e3b69($fileIdentifier, $file) function composerRequire9f532fe51df20fe03503300614827aa4($fileIdentifier, $file)
{ {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file; require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload; namespace Composer\Autoload;
class ComposerStaticInitcd810a1640b6294256452cfc7e3e3b69 class ComposerStaticInit9f532fe51df20fe03503300614827aa4
{ {
public static $files = array ( public static $files = array (
'841780ea2e1d6545ea3a253239d59c05' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/functions.php', '841780ea2e1d6545ea3a253239d59c05' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/functions.php',
@ -347,9 +347,9 @@ class ComposerStaticInitcd810a1640b6294256452cfc7e3e3b69
public static function getInitializer(ClassLoader $loader) public static function getInitializer(ClassLoader $loader)
{ {
return \Closure::bind(function () use ($loader) { return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitcd810a1640b6294256452cfc7e3e3b69::$prefixLengthsPsr4; $loader->prefixLengthsPsr4 = ComposerStaticInit9f532fe51df20fe03503300614827aa4::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitcd810a1640b6294256452cfc7e3e3b69::$prefixDirsPsr4; $loader->prefixDirsPsr4 = ComposerStaticInit9f532fe51df20fe03503300614827aa4::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitcd810a1640b6294256452cfc7e3e3b69::$classMap; $loader->classMap = ComposerStaticInit9f532fe51df20fe03503300614827aa4::$classMap;
}, null, ClassLoader::class); }, null, ClassLoader::class);
} }

View File

@ -118,17 +118,17 @@
}, },
{ {
"name": "qiniu/php-sdk", "name": "qiniu/php-sdk",
"version": "v7.2.8", "version": "v7.2.9",
"version_normalized": "7.2.8.0", "version_normalized": "7.2.9.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/qiniu/php-sdk.git", "url": "https://github.com/qiniu/php-sdk.git",
"reference": "464f3eb3b0f51586d274733aee67f372fc6276ef" "reference": "afe7d8715d8a688b1d8d8cdf031240d2363dad90"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/qiniu/php-sdk/zipball/464f3eb3b0f51586d274733aee67f372fc6276ef", "url": "https://api.github.com/repos/qiniu/php-sdk/zipball/afe7d8715d8a688b1d8d8cdf031240d2363dad90",
"reference": "464f3eb3b0f51586d274733aee67f372fc6276ef", "reference": "afe7d8715d8a688b1d8d8cdf031240d2363dad90",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -141,10 +141,10 @@
"php": ">=5.3.3" "php": ">=5.3.3"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~8.0", "phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.3" "squizlabs/php_codesniffer": "~2.3"
}, },
"time": "2019-06-21T06:22:05+00:00", "time": "2019-07-09T07:55:07+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {
@ -502,12 +502,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "12cc9a956969fa6716cb7da75fe6e5fc5fa8985d" "reference": "861a56cda1b7a0b6ae9a781aa4bd834491d2d03b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/12cc9a956969fa6716cb7da75fe6e5fc5fa8985d", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/861a56cda1b7a0b6ae9a781aa4bd834491d2d03b",
"reference": "12cc9a956969fa6716cb7da75fe6e5fc5fa8985d", "reference": "861a56cda1b7a0b6ae9a781aa4bd834491d2d03b",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -526,7 +526,7 @@
"qiniu/php-sdk": "^7.2", "qiniu/php-sdk": "^7.2",
"topthink/framework": "5.1.*" "topthink/framework": "5.1.*"
}, },
"time": "2019-07-08T02:34:45+00:00", "time": "2019-07-15T06:16:28+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {

View File

@ -6,7 +6,6 @@ php:
- 5.5 - 5.5
- 5.6 - 5.6
- 7.0 - 7.0
- 7.2
before_script: before_script:
- export QINIU_TEST_ENV="travis" - export QINIU_TEST_ENV="travis"

View File

@ -16,7 +16,7 @@
"php": ">=5.3.3" "php": ">=5.3.3"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~8.0", "phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.3" "squizlabs/php_codesniffer": "~2.3"
}, },
"autoload": { "autoload": {

View File

@ -3,7 +3,7 @@ namespace Qiniu;
final class Config final class Config
{ {
const SDK_VER = '7.3.0'; const SDK_VER = '7.2.9';
const BLOCK_SIZE = 4194304; //4*1024*1024 分块上传块大小,该参数为接口规格,不能修改 const BLOCK_SIZE = 4194304; //4*1024*1024 分块上传块大小,该参数为接口规格,不能修改

View File

@ -31,8 +31,7 @@ final class FormUploader
$config, $config,
$params, $params,
$mime, $mime,
$fname, $fname
$checkCrc
) { ) {
$fields = array('token' => $upToken); $fields = array('token' => $upToken);
if ($key === null) { if ($key === null) {

View File

@ -46,8 +46,7 @@ final class UploadManager
$data, $data,
$params = null, $params = null,
$mime = 'application/octet-stream', $mime = 'application/octet-stream',
$fname = null, $fname = null
$checkCrc = false
) { ) {
$params = self::trimParams($params); $params = self::trimParams($params);
@ -58,8 +57,7 @@ final class UploadManager
$this->config, $this->config,
$params, $params,
$mime, $mime,
$fname, $fname
$checkCrc
); );
} }
@ -110,8 +108,7 @@ final class UploadManager
$this->config, $this->config,
$params, $params,
$mime, $mime,
basename($filePath), basename($filePath)
$checkCrc
); );
} }

View File

@ -5,18 +5,17 @@ namespace Qiniu {
function time() function time()
{ {
return isset($_SERVER['override_qiniu_auth_time']) return isset($_SERVER['override_qiniu_auth_time'])
? 2234567890 ? 1234567890
: \time(); : \time();
} }
} }
namespace Qiniu\Tests { namespace Qiniu\Tests {
use Qiniu\Auth; use Qiniu\Auth;
use PHPUnit\Framework\TestCase;
// @codingStandardsIgnoreEnd // @codingStandardsIgnoreEnd
class AuthTest extends TestCase class AuthTest extends \PHPUnit_Framework_TestCase
{ {
public function testSign() public function testSign()
@ -30,10 +29,7 @@ namespace Qiniu\Tests {
{ {
global $dummyAuth; global $dummyAuth;
$token = $dummyAuth->signWithData('test'); $token = $dummyAuth->signWithData('test');
$this->assertEquals( $this->assertEquals('abcdefghklmnopq:-jP8eEV9v48MkYiBGs81aDxl60E=:dGVzdA==', $token);
'abcdefghklmnopq:-jP8eEV9v48MkYiBGs81aDxl60E=:dGVzdA==',
$token
);
} }
public function testSignRequest() public function testSignRequest()
@ -43,10 +39,7 @@ namespace Qiniu\Tests {
$this->assertEquals('abcdefghklmnopq:cFyRVoWrE3IugPIMP5YJFTO-O-Y=', $token); $this->assertEquals('abcdefghklmnopq:cFyRVoWrE3IugPIMP5YJFTO-O-Y=', $token);
$ctype = 'application/x-www-form-urlencoded'; $ctype = 'application/x-www-form-urlencoded';
$token = $dummyAuth->signRequest('http://www.qiniu.com?go=1', 'test', $ctype); $token = $dummyAuth->signRequest('http://www.qiniu.com?go=1', 'test', $ctype);
$this->assertEquals( $this->assertEquals($token, 'abcdefghklmnopq:svWRNcacOE-YMsc70nuIYdaa1e4=');
$token,
'abcdefghklmnopq:svWRNcacOE-YMsc70nuIYdaa1e4='
);
} }
public function testPrivateDownloadUrl() public function testPrivateDownloadUrl()
@ -54,7 +47,7 @@ namespace Qiniu\Tests {
global $dummyAuth; global $dummyAuth;
$_SERVER['override_qiniu_auth_time'] = true; $_SERVER['override_qiniu_auth_time'] = true;
$url = $dummyAuth->privateDownloadUrl('http://www.qiniu.com?go=1'); $url = $dummyAuth->privateDownloadUrl('http://www.qiniu.com?go=1');
$expect = 'http://www.qiniu.com?go=1&e=2234571490&token=abcdefghklmnopq:Hvi3R79Sl6wZy1c331nv0iIFoJk='; $expect = 'http://www.qiniu.com?go=1&e=1234571490&token=abcdefghklmnopq:8vzBeLZ9W3E4kbBLFLW0Xe0u7v4=';
$this->assertEquals($expect, $url); $this->assertEquals($expect, $url);
unset($_SERVER['override_qiniu_auth_time']); unset($_SERVER['override_qiniu_auth_time']);
} }
@ -65,10 +58,14 @@ namespace Qiniu\Tests {
$_SERVER['override_qiniu_auth_time'] = true; $_SERVER['override_qiniu_auth_time'] = true;
$token = $dummyAuth->uploadToken('1', '2', 3600, array('endUser' => 'y')); $token = $dummyAuth->uploadToken('1', '2', 3600, array('endUser' => 'y'));
// @codingStandardsIgnoreStart // @codingStandardsIgnoreStart
$exp = 'abcdefghklmnopq:GracWhW1iGwVL6haVH5dr4gjqeo=:eyJlbmRVc2VyIjoieSIsInNjb3BlIjoiMToyIiwiZGVhZGxpbmUiOjIyMzQ1NzE0OTB9'; $exp = 'abcdefghklmnopq:yyeexeUkPOROoTGvwBjJ0F0VLEo=:eyJlbmRVc2VyIjoieSIsInNjb3BlIjoiMToyIiwiZGVhZGxpbmUiOjEyMzQ1NzE0OTB9';
// @codingStandardsIgnoreEnd // @codingStandardsIgnoreEnd
$this->assertEquals($exp, $token); $this->assertEquals($exp, $token);
unset($_SERVER['override_qiniu_auth_time']); unset($_SERVER['override_qiniu_auth_time']);
} }
public function testVerifyCallback()
{
}
} }
} }

View File

@ -2,9 +2,8 @@
namespace Qiniu\Tests; namespace Qiniu\Tests;
use Qiniu; use Qiniu;
use PHPUnit\Framework\TestCase;
class Base64Test extends TestCase class Base64Test extends \PHPUnit_Framework_TestCase
{ {
public function testUrlSafe() public function testUrlSafe()
{ {

View File

@ -2,9 +2,8 @@
namespace Qiniu\Tests; namespace Qiniu\Tests;
use Qiniu\Storage\BucketManager; use Qiniu\Storage\BucketManager;
use PHPUnit\Framework\TestCase;
class BucketTest extends TestCase class BucketTest extends \PHPUnit_Framework_TestCase
{ {
protected $bucketManager; protected $bucketManager;
protected $dummyBucketManager; protected $dummyBucketManager;
@ -12,7 +11,7 @@ class BucketTest extends TestCase
protected $key; protected $key;
protected $key2; protected $key2;
protected function setUp(): void protected function setUp()
{ {
global $bucketName; global $bucketName;
global $key; global $key;

View File

@ -10,15 +10,14 @@ namespace Qiniu\Tests;
use Qiniu\Cdn\CdnManager; use Qiniu\Cdn\CdnManager;
use Qiniu\Http\Client; use Qiniu\Http\Client;
use PHPUnit\Framework\TestCase;
class CdnManagerTest extends TestCase class CdnManagerTest extends \PHPUnit_Framework_TestCase
{ {
protected $cdnManager; protected $cdnManager;
protected $encryptKey; protected $encryptKey;
protected $imgUrl; protected $imgUrl;
protected function setUp(): void protected function setUp()
{ {
global $timestampAntiLeechEncryptKey; global $timestampAntiLeechEncryptKey;
global $customDomain; global $customDomain;
@ -35,17 +34,8 @@ class CdnManagerTest extends TestCase
$signUrl = $this->cdnManager->createTimestampAntiLeechUrl($this->imgUrl, $this->encryptKey, 3600); $signUrl = $this->cdnManager->createTimestampAntiLeechUrl($this->imgUrl, $this->encryptKey, 3600);
$response = Client::get($signUrl); $response = Client::get($signUrl);
$this->assertEquals($response->statusCode, 200);
$this->assertNull($response->error);
$url2 = $this->imgUrl . '?imageInfo';
$signUrl2 = $this->cdnManager->createTimestampAntiLeechUrl($url2, $this->encryptKey, 3600);
$response = Client::get($signUrl2);
$imgInfo = $response->json();
$this->assertEquals($response->statusCode, 200); $this->assertEquals($response->statusCode, 200);
$this->assertEquals($imgInfo['size'], 2196145);
$this->assertNull($response->error); $this->assertNull($response->error);
} }
} }

View File

@ -2,9 +2,8 @@
namespace Qiniu\Tests; namespace Qiniu\Tests;
use Qiniu; use Qiniu;
use PHPUnit\Framework\TestCase;
class Crc32Test extends TestCase class Crc32Test extends \PHPUnit_Framework_TestCase
{ {
public function testData() public function testData()
{ {

View File

@ -2,14 +2,13 @@
namespace Qiniu\Tests; namespace Qiniu\Tests;
use Qiniu\Http\Client; use Qiniu\Http\Client;
use PHPUnit\Framework\TestCase;
class DownloadTest extends TestCase class DownloadTest extends \PHPUnit_Framework_TestCase
{ {
public function test() public function test()
{ {
global $testAuth; global $testAuth;
$base_url = 'http://pojiwyou0.bkt.clouddn.com/demo.png'; $base_url = 'http://private-res.qiniudn.com/gogopher.jpg';
$private_url = $testAuth->privateDownloadUrl($base_url); $private_url = $testAuth->privateDownloadUrl($base_url);
$response = Client::get($private_url); $response = Client::get($private_url);
$this->assertEquals(200, $response->statusCode); $this->assertEquals(200, $response->statusCode);
@ -18,7 +17,7 @@ class DownloadTest extends TestCase
public function testFop() public function testFop()
{ {
global $testAuth; global $testAuth;
$base_url = 'http://pojiwyou0.bkt.clouddn.com/demo.png?imageInfo'; $base_url = 'http://private-res.qiniudn.com/gogopher.jpg?exif';
$private_url = $testAuth->privateDownloadUrl($base_url); $private_url = $testAuth->privateDownloadUrl($base_url);
$response = Client::get($private_url); $response = Client::get($private_url);
$this->assertEquals(200, $response->statusCode); $this->assertEquals(200, $response->statusCode);

View File

@ -2,9 +2,8 @@
namespace Qiniu\Tests; namespace Qiniu\Tests;
use Qiniu\Etag; use Qiniu\Etag;
use PHPUnit\Framework\TestCase;
class EtagTest extends TestCase class EtagTest extends \PHPUnit_Framework_TestCase
{ {
public function test0M() public function test0M()
{ {

View File

@ -3,14 +3,13 @@ namespace Qiniu\Tests;
use Qiniu\Processing\Operation; use Qiniu\Processing\Operation;
use Qiniu\Processing\PersistentFop; use Qiniu\Processing\PersistentFop;
use PHPUnit\Framework\TestCase;
class FopTest extends TestCase class FopTest extends \PHPUnit_Framework_TestCase
{ {
public function testExifPub() public function testExifPub()
{ {
$fop = new Operation('7xkv1q.com1.z0.glb.clouddn.com'); $fop = new Operation('testres.qiniudn.com');
list($exif, $error) = $fop->execute('grape.jpg', 'exif'); list($exif, $error) = $fop->execute('gogopher.jpg', 'exif');
$this->assertNull($error); $this->assertNull($error);
$this->assertNotNull($exif); $this->assertNotNull($exif);
} }
@ -27,12 +26,12 @@ class FopTest extends TestCase
public function testbuildUrl() public function testbuildUrl()
{ {
$fops = 'imageView2/2/h/200'; $fops = 'imageView2/2/h/200';
$fop = new Operation('7xkv1q.com1.z0.glb.clouddn.com'); $fop = new Operation('testres.qiniudn.com');
$url = $fop->buildUrl('grape.jpg', $fops); $url = $fop->buildUrl('gogopher.jpg', $fops);
$this->assertEquals($url, 'http://7xkv1q.com1.z0.glb.clouddn.com/grape.jpg?imageView2/2/h/200'); $this->assertEquals($url, 'http://testres.qiniudn.com/gogopher.jpg?imageView2/2/h/200');
$fops = array('imageView2/2/h/200', 'imageInfo'); $fops = array('imageView2/2/h/200', 'imageInfo');
$url = $fop->buildUrl('grape.jpg', $fops); $url = $fop->buildUrl('gogopher.jpg', $fops);
$this->assertEquals($url, 'http://7xkv1q.com1.z0.glb.clouddn.com/grape.jpg?imageView2/2/h/200|imageInfo'); $this->assertEquals($url, 'http://testres.qiniudn.com/gogopher.jpg?imageView2/2/h/200|imageInfo');
} }
} }

View File

@ -4,15 +4,14 @@ namespace Qiniu\Tests;
use Qiniu\Storage\FormUploader; use Qiniu\Storage\FormUploader;
use Qiniu\Storage\UploadManager; use Qiniu\Storage\UploadManager;
use Qiniu\Config; use Qiniu\Config;
use PHPUnit\Framework\TestCase;
class FormUpTest extends TestCase class FormUpTest extends \PHPUnit_Framework_TestCase
{ {
protected $bucketName; protected $bucketName;
protected $auth; protected $auth;
protected $cfg; protected $cfg;
protected function setUp(): void protected function setUp()
{ {
global $bucketName; global $bucketName;
$this->bucketName = $bucketName; $this->bucketName = $bucketName;
@ -25,16 +24,7 @@ class FormUpTest extends TestCase
public function testData() public function testData()
{ {
$token = $this->auth->uploadToken($this->bucketName); $token = $this->auth->uploadToken($this->bucketName);
list($ret, $error) = FormUploader::put( list($ret, $error) = FormUploader::put($token, 'formput', 'hello world', $this->cfg, null, 'text/plain', null);
$token,
'formput',
'hello world',
$this->cfg,
null,
'text/plain',
null,
false
);
$this->assertNull($error); $this->assertNull($error);
$this->assertNotNull($ret['hash']); $this->assertNotNull($ret['hash']);
} }
@ -43,7 +33,7 @@ class FormUpTest extends TestCase
{ {
$upManager = new UploadManager(); $upManager = new UploadManager();
$token = $this->auth->uploadToken($this->bucketName); $token = $this->auth->uploadToken($this->bucketName);
list($ret, $error) = $upManager->put($token, 'formput', 'hello world', null, 'text/plain', null, false); list($ret, $error) = $upManager->put($token, 'formput', 'hello world', null, 'text/plain', null);
$this->assertNull($error); $this->assertNull($error);
$this->assertNotNull($ret['hash']); $this->assertNotNull($ret['hash']);
} }
@ -52,7 +42,7 @@ class FormUpTest extends TestCase
{ {
$key = 'formPutFile'; $key = 'formPutFile';
$token = $this->auth->uploadToken($this->bucketName, $key); $token = $this->auth->uploadToken($this->bucketName, $key);
list($ret, $error) = FormUploader::putFile($token, $key, __file__, $this->cfg, null, 'text/plain', null, false); list($ret, $error) = FormUploader::putFile($token, $key, __file__, $this->cfg, null, 'text/plain', null);
$this->assertNull($error); $this->assertNull($error);
$this->assertNotNull($ret['hash']); $this->assertNotNull($ret['hash']);
} }
@ -62,7 +52,7 @@ class FormUpTest extends TestCase
$key = 'formPutFile'; $key = 'formPutFile';
$token = $this->auth->uploadToken($this->bucketName, $key); $token = $this->auth->uploadToken($this->bucketName, $key);
$upManager = new UploadManager(); $upManager = new UploadManager();
list($ret, $error) = $upManager->putFile($token, $key, __file__, null, 'text/plain', null, false); list($ret, $error) = $upManager->putFile($token, $key, __file__, null, 'text/plain', null);
$this->assertNull($error); $this->assertNull($error);
$this->assertNotNull($ret['hash']); $this->assertNotNull($ret['hash']);
} }

View File

@ -2,9 +2,8 @@
namespace Qiniu\Tests; namespace Qiniu\Tests;
use Qiniu\Http\Client; use Qiniu\Http\Client;
use PHPUnit\Framework\TestCase;
class HttpTest extends TestCase class HttpTest extends \PHPUnit_Framework_TestCase
{ {
public function testGet() public function testGet()
{ {

View File

@ -2,8 +2,6 @@
namespace Qiniu\Tests; namespace Qiniu\Tests;
use PHPUnit\Framework\TestCase;
/** /**
* imageprocess test * imageprocess test
* *
@ -11,7 +9,7 @@ use PHPUnit\Framework\TestCase;
* @subpackage test * @subpackage test
* @author Sherlock Ren <sherlock_ren@icloud.com> * @author Sherlock Ren <sherlock_ren@icloud.com>
*/ */
class ImageUrlBuilderTest extends TestCase class ImageUrlBuilderTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* 缩略图测试 * 缩略图测试

View File

@ -3,9 +3,8 @@ namespace Qiniu\Tests;
use Qiniu\Processing\Operation; use Qiniu\Processing\Operation;
use Qiniu\Processing\PersistentFop; use Qiniu\Processing\PersistentFop;
use PHPUnit\Framework\TestCase;
class PfopTest extends TestCase class PfopTest extends \PHPUnit_Framework_TestCase
{ {
public function testPfop() public function testPfop()
{ {

View File

@ -5,14 +5,13 @@ use Qiniu\Storage\ResumeUploader;
use Qiniu\Storage\UploadManager; use Qiniu\Storage\UploadManager;
use Qiniu\Config; use Qiniu\Config;
use Qiniu\Zone; use Qiniu\Zone;
use PHPUnit\Framework\TestCase;
class ResumeUpTest extends TestCase class ResumeUpTest extends \PHPUnit_Framework_TestCase
{ {
protected $bucketName; protected $bucketName;
protected $auth; protected $auth;
protected function setUp(): void protected function setUp()
{ {
global $bucketName; global $bucketName;
$this->bucketName = $bucketName; $this->bucketName = $bucketName;
@ -36,7 +35,7 @@ class ResumeUpTest extends TestCase
public function test4ML2() public function test4ML2()
{ {
$key = 'resumePutFile4ML'; $key = 'resumePutFile4ML';
$zone = new Zone(array('up.qiniup.com')); $zone = new Zone(array('up.fake.qiniu.com'), array('up.qiniup.com'));
$cfg = new Config($zone); $cfg = new Config($zone);
$upManager = new UploadManager($cfg); $upManager = new UploadManager($cfg);
$token = $this->auth->uploadToken($this->bucketName, $key); $token = $this->auth->uploadToken($this->bucketName, $key);

View File

@ -3,9 +3,8 @@ namespace Qiniu\Tests;
use Qiniu; use Qiniu;
use Qiniu\Zone; use Qiniu\Zone;
use PHPUnit\Framework\TestCase;
class ZoneTest extends TestCase class ZoneTest extends \PHPUnit_Framework_TestCase
{ {
protected $zone; protected $zone;
protected $zoneHttps; protected $zoneHttps;
@ -16,7 +15,7 @@ class ZoneTest extends TestCase
protected $bucketNameNA; protected $bucketNameNA;
protected function setUp(): void protected function setUp()
{ {
global $bucketName; global $bucketName;
$this->bucketName = $bucketName; $this->bucketName = $bucketName;

View File

@ -9,8 +9,8 @@ $secretKey = getenv('QINIU_SECRET_KEY');
$testAuth = new Auth($accessKey, $secretKey); $testAuth = new Auth($accessKey, $secretKey);
$bucketName = 'phpsdk'; $bucketName = 'phpsdk';
$key = '1503385451.png'; $key = 'php-logo.png';
$key2 = '1503385568.png'; $key2 = 'niu.jpg';
$bucketNameBC = 'phpsdk-bc'; $bucketNameBC = 'phpsdk-bc';
$bucketNameNA = 'phpsdk-na'; $bucketNameNA = 'phpsdk-na';
@ -21,7 +21,7 @@ $dummyAuth = new Auth($dummyAccessKey, $dummySecretKey);
//cdn //cdn
$timestampAntiLeechEncryptKey = getenv('QINIU_TIMESTAMP_ENCRPTKEY'); $timestampAntiLeechEncryptKey = getenv('QINIU_TIMESTAMP_ENCRPTKEY');
$customDomain = "http://phpsdk.support2technical.me"; $customDomain = "http://phpsdk.peterpy.cn";
$tid = getenv('TRAVIS_JOB_NUMBER'); $tid = getenv('TRAVIS_JOB_NUMBER');
if (!empty($tid)) { if (!empty($tid)) {

View File

@ -3,7 +3,7 @@
# ThinkLibrary for ThinkPHP5.1 # ThinkLibrary for ThinkPHP5.1
ThinkLibrary 是针对 ThinkPHP5.1 版本封装的一套工具类库,方便快速构建 WEB 应用。 ThinkLibrary 是针对 ThinkPHP5.1 版本封装的一套工具类库,方便快速构建 WEB 应用。
## 主要包含内容 ## 包含组件
* 数据列表展示(可带高级搜索器) * 数据列表展示(可带高级搜索器)
* FORM表单处理器表单展示及数据入库 * FORM表单处理器表单展示及数据入库
* 数据状态快速处理(数据指定字段更新,支持多字段同时) * 数据状态快速处理(数据指定字段更新,支持多字段同时)
@ -11,29 +11,36 @@ ThinkLibrary 是针对 ThinkPHP5.1 版本封装的一套工具类库,方便快
* 文件存储通用组件(本地服务存储 + 阿里云OSS存储 + 七牛云存储) * 文件存储通用组件(本地服务存储 + 阿里云OSS存储 + 七牛云存储)
* 通用数据保存更新(通过 key 值及 where 判定是否存在,存在则更新,不存在则新增) * 通用数据保存更新(通过 key 值及 where 判定是否存在,存在则更新,不存在则新增)
* 通用网络请求 (支持 get 及 post可配置请求证书等 * 通用网络请求 (支持 get 及 post可配置请求证书等
* emoji 表情转义处理(部分数据库不支持保存 Emoji 表情,可用这个方法哦) * Emoji 表情转义处理(部分数据库不支持保存 Emoji 表情,可用这个方法哦)
* 系统参数通用 k-v 配置(快速参数长久化配置) * 系统参数通用 k-v 配置(快速参数长久化配置)
* UTF8加密算法支持安全URL参数传参数 * UTF8加密算法支持安全URL参数传参数
* 接口 CORS 跨域默认支持(输出 JSON 标准化) * 接口 CORS 跨域默认支持(输出 JSON 标准化)
* 支持表单CSRF安全验证自动化form标签替换) * 支持表单CSRF安全验证自动化 FORM 标签替换)
* 更新功能等待您来发现哦.... * 更新功能等待您来发现哦....
## 参考项目 ## 参考项目
* Gitee 仓库https://gitee.com/zoujingli/framework
* Github 仓库https://github.com/zoujingli/framework
代码仓库 #### framework - V1.0 / V2.0
-- * Gitee 仓库 https://gitee.com/zoujingli/framework
* Github 仓库 https://github.com/zoujingli/framework
* 体验地址账号密码都是adminhttps://framework.thinkadmin.top
#### ThinkAdmin - V4.0 / V4.1
* Gitee 仓库 https://gitee.com/zoujingli/ThinkAdmin
* Github 仓库 https://github.com/zoujingli/ThinkAdmin
* 体验地址账号密码都是adminhttps://demo.thinkadmin.top
## 代码仓库
ThinkLibrary 为 MIT 协议开源项目,安装使用或二次开发不受约束,欢迎 fork 项目。 ThinkLibrary 为 MIT 协议开源项目,安装使用或二次开发不受约束,欢迎 fork 项目。
部分代码来自互联网,若有异议可以联系作者进行删除。 部分代码来自互联网,若有异议可以联系作者进行删除。
* 在线体验地址https://framework.thinkadmin.top (账号和密码都是 admin * 在线体验地址https://demo.thinkadmin.top (账号和密码都是 admin
* Gitee仓库地址https://gitee.com/zoujingli/ThinkLibrary * Gitee仓库地址https://gitee.com/zoujingli/ThinkLibrary
* GitHub仓库地址https://github.com/zoujingli/ThinkLibrary * GitHub仓库地址https://github.com/zoujingli/ThinkLibrary
## 使用说明 ## 使用说明
* ThinkLibrary 需要Composer支持 * ThinkLibrary 需要 Composer 支持
* 安装命令 ` composer require zoujingli/think-library 5.1.x-dev` * 安装命令 ` composer require zoujingli/think-library 5.1.x-dev`
* 案例代码: * 案例代码:
控制器需要继承 `library\Controller`,然后`$this`就可能使用全部功能 控制器需要继承 `library\Controller`,然后`$this`就可能使用全部功能
@ -69,7 +76,7 @@ CREATE TABLE `system_config` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='系统配置'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='系统配置';
``` ```
## 列表处理 #### 列表处理
```php ```php
// 列表展示 // 列表展示
$this->_page($dbQuery, $isPage, $isDisplay, $total); $this->_page($dbQuery, $isPage, $isDisplay, $total);
@ -83,19 +90,19 @@ $db = $query->db(); // @todo 这里可以对db进行操作
$this->_page($db); // 显示列表分页 $this->_page($db); // 显示列表分页
``` ```
## 表单处理 #### 表单处理
```php ```php
// 表单显示及数据更新 // 表单显示及数据更新
$this->_form($dbQuery, $tplFile, $pkField , $where, $data); $this->_form($dbQuery, $tplFile, $pkField , $where, $data);
``` ```
## 删除处理 #### 删除处理
```php ```php
// 数据删除处理 // 数据删除处理
$this->_deleted($dbQuery); $this->_deleted($dbQuery);
``` ```
## 禁用启用处理 #### 禁用启用处理
```php ```php
// 数据禁用处理 // 数据禁用处理
$this->_save($dbQuery,['status'=>'0']); $this->_save($dbQuery,['status'=>'0']);
@ -104,7 +111,7 @@ $this->_save($dbQuery,['status'=>'0']);
$this->_save($dbQuery,['status'=>'1']); $this->_save($dbQuery,['status'=>'1']);
``` ```
## 文件存储组件( oss 及 qiniu 需要配置参数) #### 文件存储组件( oss 及 qiniu 需要配置参数)
```php ```php
// 配置默认存储方式 // 配置默认存储方式
@ -160,13 +167,13 @@ $resutl = \library\File::instance('local')->info($filename);
$resutl = \library\File::instance('qiniu')->info($filename); $resutl = \library\File::instance('qiniu')->info($filename);
``` ```
## 通用数据保存 #### 通用数据保存
```php ```php
// 指定关键列更新($where 为扩展条件) // 指定关键列更新($where 为扩展条件)
boolean data_save($dbQuery,$data,'pkname',$where); boolean data_save($dbQuery,$data,'pkname',$where);
``` ```
## 通用网络请求 #### 通用网络请求
```php ```php
// 发起get请求 // 发起get请求
$result = http_get($url,$query,$options); $result = http_get($url,$query,$options);
@ -177,7 +184,7 @@ $result = http_post($url,$data,$options);
$result = \library\tools\Http::post($url,$data,$options); $result = \library\tools\Http::post($url,$data,$options);
``` ```
## emoji 表情转义(部分数据库不支持可以用这个) #### emoji 表情转义(部分数据库不支持可以用这个)
```php ```php
// 输入数据库前转义 // 输入数据库前转义
$content = emoji_encode($content); $content = emoji_encode($content);
@ -186,7 +193,7 @@ $content = emoji_encode($content);
$content = emoji_decode($content); $content = emoji_decode($content);
``` ```
## 系统参数配置(基于 system_config 数据表) #### 系统参数配置(基于 system_config 数据表)
```php ```php
// 设置参数 // 设置参数
sysconf($keyname,$keyvalue); sysconf($keyname,$keyvalue);
@ -195,7 +202,7 @@ sysconf($keyname,$keyvalue);
$keyvalue = sysconf($kename); $keyvalue = sysconf($kename);
``` ```
## UTF8加密算法 #### UTF8加密算法
```php ```php
// 字符串加密操作 // 字符串加密操作
$string = encode($content); $string = encode($content);
@ -203,3 +210,7 @@ $string = encode($content);
// 加密字符串解密 // 加密字符串解密
$content = decode($string); $content = decode($string);
``` ```
## 赞助打赏
![赞助](http://static.thinkadmin.top/pay.png)

View File

@ -43,7 +43,13 @@ class Controller extends \stdClass
* 表单CSRF验证状态 * 表单CSRF验证状态
* @var boolean * @var boolean
*/ */
private $csrf = false; private $csrf_state = false;
/**
* 表单CSRF验证失败提示消息
* @var string
*/
protected $csrf_message = '表单令牌验证失败,请刷新页面再试!';
/** /**
* Controller constructor. * Controller constructor.
@ -106,7 +112,7 @@ class Controller extends \stdClass
public function success($info, $data = [], $code = 1) public function success($info, $data = [], $code = 1)
{ {
$result = ['code' => $code, 'info' => $info, 'data' => $data]; $result = ['code' => $code, 'info' => $info, 'data' => $data];
if ($this->csrf) Csrf::clearFormToken(Csrf::getToken()); if ($this->csrf_state) Csrf::clearFormToken(Csrf::getToken());
throw new HttpResponseException(json($result)); throw new HttpResponseException(json($result));
} }
@ -130,7 +136,7 @@ class Controller extends \stdClass
public function fetch($tpl = '', $vars = [], $node = null) public function fetch($tpl = '', $vars = [], $node = null)
{ {
foreach ($this as $name => $value) $vars[$name] = $value; foreach ($this as $name => $value) $vars[$name] = $value;
if ($this->csrf) { if ($this->csrf_state) {
Csrf::fetchTemplate($tpl, $vars, $node); Csrf::fetchTemplate($tpl, $vars, $node);
} else { } else {
throw new HttpResponseException(view($tpl, $vars)); throw new HttpResponseException(view($tpl, $vars));
@ -182,10 +188,10 @@ class Controller extends \stdClass
*/ */
protected function applyCsrfToken($return = false) protected function applyCsrfToken($return = false)
{ {
$this->csrf = true; $this->csrf_state = true;
if ($this->request->isPost() && !Csrf::checkFormToken()) { if ($this->request->isPost() && !Csrf::checkFormToken()) {
if ($return) return false; if ($return) return false;
$this->error('表单令牌验证失败,请刷新页面再试!'); $this->error($this->csrf_message);
} else { } else {
return true; return true;
} }