v6
Chaim 4 years ago
parent e4a55487a1
commit de8df76290

@ -87,7 +87,10 @@ class ApiController extends stdClass
public function error($msg = 'error', $code = 1, $data = [])
{
throw new HttpResponseException(json([
'code' => $code, 'msg' => $msg, 'timestamp' => time(), 'data' => $data,
'code' => $code,
'msg' => $msg,
'timestamp' => time(),
'data' => $data,
]));
}
@ -100,7 +103,10 @@ class ApiController extends stdClass
public function success($data = [], $msg = 'success', $code = 0)
{
throw new HttpResponseException(json([
'code' => $code, 'msg' => $msg, 'timestamp' => time(), 'data' => $data,
'code' => $code,
'msg' => $msg,
'timestamp' => time(),
'data' => $data,
]));
}
@ -137,7 +143,10 @@ class ApiController extends stdClass
{
$timestamp = time();
throw new HttpResponseException(json([
'code' => $code, 'msg' => $msg, 'timestamp' => $timestamp, 'data' => [
'code' => $code,
'msg' => $msg,
'timestamp' => $timestamp,
'data' => [
'aes' => $this->encrypt($data, $timestamp)
],
]));

@ -73,7 +73,9 @@ class Controller extends stdClass
*/
public function error($info, $data = '{-null-}', $code = 0)
{
if ($data === '{-null-}') $data = new stdClass();
if ($data === '{-null-}') {
$data = new stdClass();
}
throw new HttpResponseException(json([
'code' => $code, 'info' => $info, 'data' => $data,
]));
@ -87,7 +89,9 @@ class Controller extends stdClass
*/
public function success($info, $data = '{-null-}', $code = 1)
{
if ($data === '{-null-}') $data = new stdClass();
if ($data === '{-null-}') {
$data = new stdClass();
}
throw new HttpResponseException(json([
'code' => $code, 'info' => $info, 'data' => $data,
]));
@ -110,7 +114,9 @@ class Controller extends stdClass
*/
public function fetch($tpl = '', $vars = [])
{
foreach ($this as $name => $value) $vars[$name] = $value;
foreach ($this as $name => $value) {
$vars[$name] = $value;
}
throw new HttpResponseException(view($tpl, $vars));
}

@ -50,7 +50,9 @@ class UnIqIds
}
$string = $prefix . $chars[rand(1, strlen($chars) - 1)];
if (isset($chars)) {
while (strlen($string) < $size) $string .= $chars[rand(0, strlen($chars) - 1)];
while (strlen($string) < $size) {
$string .= $chars[rand(0, strlen($chars) - 1)];
}
}
return $string;
}
@ -67,7 +69,9 @@ class UnIqIds
$size = 14;
}
$string = $prefix . date('Ymd') . (date('H') + date('i')) . date('s');
while (strlen($string) < $size) $string .= rand(0, 9);
while (strlen($string) < $size) {
$string .= rand(0, 9);
}
return $string;
}
@ -84,7 +88,9 @@ class UnIqIds
$size = 10;
}
$string = $prefix . ($time[0] . $time[1]) . substr($time, 2) . rand(0, 9);
while (strlen($string) < $size) $string .= rand(0, 9);
while (strlen($string) < $size) {
$string .= rand(0, 9);
}
return $string;
}
}

Loading…
Cancel
Save