Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

update Route and add Rsa,Encryption #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
blankqwq merged 2 commits into master from dev
Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 47 additions & 4 deletions README.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,17 +1,60 @@
<h1 align="center">blankphp/framework </h1>
<h1 align="center">blankqwq/framework </h1>

<p align="center"> a mvc framework.</p>


## Installing

```shell
$ composer require blankphp/framework -vvv
$ composer require blankqwq/framework -vvv
```

## Usage

TODO
- [ ] 文档
- [x] 容器
- [x] 依赖注入
- [x] 容器清理与重新注册
- [x] 管道
- [x] 中间件
- [ ] Pipeline扩展与异常
- [x] 门面
- [x] 基本完成
- [ ] 清理门面中的对象
- [x] 服务提供者
- [x] register
- [x] boot
- [ ] publish
- [x] Session
- [x] RedisSessionHandler
- [ ] FileSessionHandler
- [ ] DatabaseSessionHandler
- [x] Database
- [x] Builder
- [x] Grammar
- [ ] Secure
- [x] Cookie
- [x] View
- [x] Builder
- [ ] make
- [ ] Diy
- [ ] 国际化
- [ ] 国际化支持
- [ ] 安全
- [ ] 验证码
- [ ] 加密
- [ ] xss
- [x] 防注入
- [ ] Swoole
- [ ] Websocket
- [ ] Process
- [ ] Job
- [ ] RPC
- [ ] ...
- [ ] FormValidate
- [ ] Console
- [x] ConsoleKernel



## Contributing

Expand Down
2 changes: 1 addition & 1 deletion composer.json
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "blankphp/framework",
"name": "blankqwq/framework",
"description": "a mvc framework",
"license": "MIT",
"authors": [
Expand Down
10 changes: 5 additions & 5 deletions src/blankphp/Container.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function build($concrete)
* @return array
* 解决依赖注入问题
*/
public function resolveDepends($params = []):array
public function resolveDepends($params = []):array
{
// 判断参数类型
foreach ($params as $key => $param) {
Expand Down Expand Up @@ -252,7 +252,7 @@ public function call($instance, $method = null, $construct = null, array $param
}


public function flush():void
public function flush():void
{
$this->classes = [];
$this->alice = [];
Expand Down Expand Up @@ -286,20 +286,20 @@ public function offsetGet($offset)
* * @param offset
* * @param value
* */
public function offsetSet($offset, $value):void
public function offsetSet($offset, $value):void
{
$this->classes[$offset] = $value;
}

/**
* @param mixed $offset
*/
public function offsetUnset($offset):void
public function offsetUnset($offset):void
{
unset($this->binds[$offset], $this->instances[$offset]);
}

public function alice($name, $class):bool
public function alice($name, $class):bool
{
return class_alias($class, $name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/blankphp/Facade/Driver.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Driver extends Facade
{
protected static function getFacadeAccessor():string
{
return "driver.factory";
return 'driver.factory';
}

}
12 changes: 6 additions & 6 deletions src/blankphp/Route/Route.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function func($config, \Closure $closure): void
//开始设置
if (in_array($key, $key_set, true)) {
$temp[$key] = $this->{'get' . ucfirst($key)}();
$this->{'set' . ucfirst($key)}($value);
$this->{'set' . ucfirst($key)}($value, $temp[$key]);
}
}
$closure($this);
Expand All @@ -105,7 +105,7 @@ public function addRoute($methods, $uri, $action)
{
$uri = empty($this->prefix[0]) ? '/' . trim($uri, '/') : '/' . trim($this->prefix[0], '/') . '/' . trim($uri, '/');
$this->currentRoute = new RouteRule();
$this->currentRoute->set($methods, count($uri) === 1 ? $uri : rtrim($uri, '/'), trim($this->controllerNamespace, '\\') . '\\' . $action, '', $this->group[0], $this->prefix[0]);
$this->currentRoute->set($methods, strlen($uri) === 1 ? $uri : rtrim($uri, '/'), trim($this->controllerNamespace, '\\') . '\\' . $action, '', $this->group[0], $this->prefix[0]);
$this->routes->add($this->currentRoute, $this->currentRoute->getRule(), $methods);
return $this->currentRoute;
}
Expand Down Expand Up @@ -147,9 +147,9 @@ public function group($group)
}


public function setNamespace($namespace)
public function setNamespace($namespace, $parent = '')
{
$this->controllerNamespace = $namespace;
$this->controllerNamespace = empty($namespace) ? $namespace : $parent . '\\' . $namespace;
return $this;
}

Expand Down Expand Up @@ -283,9 +283,9 @@ public function getNamespace(): string
return $this->controllerNamespace;
}

public function setPrefix($prefix): void
public function setPrefix($prefix, $parent = ''): void
{
array_unshift($this->prefix, $prefix);
array_unshift($this->prefix, (empty($parent) ? '/' : '/' . trim($parent, '/') . '/') . $prefix);
}

public function getPrefix(): string
Expand Down
2 changes: 1 addition & 1 deletion src/blankphp/View/View.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function existsFile()
public function getValue($result)
{
if (is_array($result)) {
var_dump($result);
dump($result);
} else {
echo $result;
}
Expand Down
58 changes: 58 additions & 0 deletions src/helpers/Encryption.php
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php


namespace BlankQwq\Helpers;


class Encryption
{
public const IV = '';//16位
public static $key = 'sadklnxvnzlxjdawsen2l32194093j';



/**
* 解密字符串
* @param string $data 字符串
* @param string $key 加密key
* @param string $iv
* @return string
*/
public static function decryp($data, $key = null, $iv = self::IV): string
{
return openssl_decrypt(base64_decode($data), 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $iv);
}

/**
* 加密字符串
* @param string $data 字符串
* @param string $key 加密key
* @param string $iv
* @return string
*/
public
static function encrypt($data, $key = null, $iv = self::IV): string
{
return base64_encode(openssl_encrypt($data, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $iv));
}

/**
* @param $password
* @return string
*/
public static function bcrypt($password): string
{
return password_hash($password, PASSWORD_DEFAULT);
}

/**
* @param $password
* @param $hash
* @return string
*/
public function check($password, $hash): string
{
return password_verify($password, $hash);
}

}
14 changes: 14 additions & 0 deletions src/helpers/Rsa.php
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php


namespace BlankQwq\Helpers;

/**
* Class Rsa
* @package BlankQwq\Helpers
* RSA加密
*/
class Rsa
{

}
27 changes: 20 additions & 7 deletions src/helpers/helper.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ function app($abstract)
}

if (!function_exists('config')) {
function config($name="", $default = null)
function config($name = "", $default = null)
{
if (empty($name)){
if (empty($name)){
return app('config')->all();
}
$descNames = explode('.', $name);
Expand Down Expand Up @@ -70,10 +70,23 @@ function now()
}
}

if (!function_exists('dump')){
function dump($value){
echo '<pre>';
print_r($value);
echo '</pre>';
if (!function_exists('dump')) {
function dump($vars, $label = 'array', $return = false)
{
if (ini_get('html_errors')) {
$content = "<div ><pre>\n";
if ($label !== '') {
$content .= "<strong>{$label} :</strong>\n";
}
$content .= htmlspecialchars(print_r($vars, true));
$content .= "\n</pre>\n</div>";
} else {
$content = $label . " :\n" . print_r($vars, true);
}
if ($return) {
return $content;
}
echo $content;
return null;
}
}

AltStyle によって変換されたページ (->オリジナル) /