DefaultController.php 0000644 00000000411 15024757353 0010714 0 ustar 00 meow3;
$id = null;
if (empty(Auth::user()->id)) {
$id = session_id();
} else {
$id = Auth::user()->id;
}
echo $id;
}
}
QRController.php 0000644 00000003652 15024757353 0007664 0 ustar 00 json(array("status" => 0, "message" => "data parameter is required."));
}
$label = input('label') ? input('label') : '';
$image = input('logo') ? config('qr')->logo : config('qr')->no_logo;
$result = Builder::create()
->writer(new PngWriter())
->writerOptions([])
->data(input('data'))
->encoding(new Encoding('UTF-8'))
->errorCorrectionLevel(new ErrorCorrectionLevelHigh())
->size(300)
->margin(10)
->roundBlockSizeMode(new RoundBlockSizeModeMargin())
->logoPath($image)
->labelText($label)
->labelFont(new NotoSans(20))
->labelAlignment(new LabelAlignmentCenter())
->build();
// Directly output the QR code
header('Content-Type: ' . $result->getMimeType());
if (!empty(input('filename'))) {
header("Content-Disposition: inline;filename=" . input('filename') . ".png");
}
echo $result->getString();
// Save it to a file
// $result->saveToFile(__DIR__ . '/qrcode.png');
// Generate a data URI to include image data inline (i.e. inside an
tag)
$dataUri = $result->getDataUri();
}
}
PlaceController.php 0000644 00000013443 15024757353 0010365 0 ustar 00 new ExtJsonDecoder(true)]);
// $countries_new = Items::fromFile('../resources/json/place/countries+states+cities.json', ['decoder' => new ExtJsonDecoder(true)]);
// foreach ($countries_new as $row) {
// $nationality = "";
// $flag = "";
// foreach ($countries_old as $row1) {
// if ($row['iso2'] == $row1['iso2']) {
// $nationality = $row1['nationality'];
// $flag = $row1['flag'];
// }
// }
// $row['flag'] = $flag;
// $row['nationality'] = $nationality;
// $generated_json = array_merge($generated_json, array($row));
// }
// $myfile = fopen("newfile.json", "w") or die("Unable to open file!");
// fwrite($myfile, json_encode($generated_json));
// fclose($myfile);
// response()->json($generated_json);
// $countries = Items::fromFile('../resources/json/place/countries+states+cities.json', ['pointer' => '/-/states']);
// foreach ($countries as $name => $data) {
// print_r($data);
// }
// exit;
$countries = Items::fromFile('../resources/json/place/countries+states+cities.json', ['decoder' => new ExtJsonDecoder(true)]);
if (!empty(input('country')) && !empty(input('state')) && !empty(input('city'))) {
// $countries = Items::fromFile('../resources/json/place/countries+states+cities.json', ['decoder' => new ExtJsonDecoder(true)]);
$result = array();
foreach ($countries as $name => $data) {
$country_key = null;
if (is_numeric(input('country'))) {
$country_key = 'id';
} else {
$country_key = 'iso2';
}
if ($data[$country_key] == input('country')) {
foreach ($data['states'] as $stateK => $stateV) {
$state_key = null;
if (is_numeric(input('state'))) {
$state_key = 'id';
} else {
$state_key = 'state_code';
}
if ($stateV[$state_key] == input('state')) {
// response()->json($stateV['cities']);
$result = $stateV['cities'];
break;
}
}
}
}
if (count($result)) {
$result['status'] = 1;
response()->json($result);
} else {
response()->json(array("status" => 0, "message" => "Country or state not found."));
}
} else if (!empty(input('country')) && !empty(input('state'))) {
// $countries = Items::fromFile('../resources/json/place/countries+states+cities.json', ['decoder' => new ExtJsonDecoder(true)]);
$result = array();
foreach ($countries as $name => $data) {
$country_key = null;
if (is_numeric(input('country'))) {
$country_key = 'id';
} else {
$country_key = 'iso2';
}
if ($data[$country_key] == input('country')) {
foreach ($data['states'] as $stateK => $stateV) {
unset($data['states'][$stateK]['cities']);
}
$result = $data['states'];
break;
// response()->json($data['states']);
}
}
if (count($result)) {
$result['status'] = 1;
response()->json($result);
} else {
response()->json(array("status" => 0, "message" => "Country not found."));
}
} else if (!empty(input('country'))) {
// $countries = Items::fromFile('../resources/json/place/countries+states+cities.json', ['decoder' => new ExtJsonDecoder(true)]);
$result = array();
foreach ($countries as $name => $data) {
$country_key = null;
if (is_numeric(input('country'))) {
$country_key = 'id';
} else {
$country_key = 'iso2';
}
if ($data[$country_key] == input('country')) {
// $data = array_diff_key($data, array_flip(["states"]));
unset($data['states']);
$result = $data;
break;
}
}
if (count($result)) {
$result['status'] = 1;
response()->json($result);
} else {
response()->json(array("status" => 0, "message" => "Country not found."));
}
} else {
// $countries = Items::fromFile('../resources/json/place/countries+states+cities.json', ['decoder' => new ExtJsonDecoder(true)]);
$country_arr = array();
foreach ($countries as $key => $value) {
unset($value['states']);
$country_arr = array_merge($country_arr, array($value));
}
response()->json($country_arr);
}
}
}
BarCodeController.php 0000644 00000001661 15024757353 0010637 0 ustar 00 json(array("status" => 0, "message" => "data parameter is required."));
}
$color = [0, 0, 0];
$generator = new \Picqer\Barcode\BarcodeGeneratorPNG();
// file_put_contents('barcode.jpg', $generator->getBarcode(input('data'), $generator::TYPE_CODE_128, 3, 50, $color));
header('Content-Type: image/png');
if (!empty(input('filename'))) {
header("Content-Disposition: inline;filename=" . input('filename') . ".png");
}
echo $generator->getBarcode(input('data'), $generator::TYPE_CODE_128, 3, 50, $color);
// echo '
';
}
}
ApiController.php 0000644 00000003172 15024757353 0010050 0 ustar 00 json([
'authenticated' => request()->authenticated
]);
}
/**
* @return string|null
*/
public function index(): ?string
{
return response()->json([
'method' => 'index'
]);
}
/**
* @return string|null
*/
public function store(): ?string
{
return response()->json([
'method' => 'store'
]);
}
/**
* @return string|null
*/
public function create(): ?string
{
return response()->json([
'method' => 'create'
]);
}
/**
* View
* @param mixed $id
* @return string|null
*/
public function edit($id): ?string
{
return response()->json([
'method' => sprintf('edit: %s', $id),
]);
}
/**
* @param mixed $id
* @return string|null
*/
public function update($id): ?string
{
return response()->json([
'method' => sprintf('update: %s', $id),
]);
}
/**
* @param mixed $id
* @return string|null
*/
public function destroy($id): ?string
{
return response()->json([
'method' => sprintf('destroy: %s', $id),
]);
}
}
AuthController.php 0000644 00000005447 15024757353 0010247 0 ustar 00 redirect('/');
response()->redirect(url('login'));
}
public static function login()
{
}
public static function loginIndex()
{
// $http_referer = escape(input('ref'));
View::render('login', get_defined_vars());
}
public function loginData()
{
$email = input('email');
$username = input('username');
$password = input('password');
$remember = input('remember');
$user = new \App\Models\User;
$user_data = $user->getUserByEmail(array($email));
$response['status'] = 0;
if (!$user_data) {
$response['message'] = "User is not registered.";
response()->json($response);
}
if (!Hash::verify($password, $user_data['password'])) {
$response['message'] = "Incorrect password.";
response()->json($response);
}
if (!$user_data['status']) {
$response['message'] = "Account is disabled.";
response()->json($response);
}
if (!$user_data['active']) {
$response['message'] = "Account is not yet verified.";
response()->json($response);
}
if (!$user_data['is_admin']) {
$response['message'] = "You do not have admin privileges.";
response()->json($response);
}
//save user session
Session::set(['uid' => $user_data['id'], 'agent' => $_SERVER['HTTP_USER_AGENT']]);
//save remember cookie
$token = Token::generate();
$user->createLoginToken(array($user_data['id'], $token));
if ($remember) {
// Cookie::put("uid", $token, (86400 * 30), '/', 'None', env('APP_URL'), false, false);
// Cookie::put("uid", $token, (86400 * 30), '/');
Cookie::put("uid", $token, (86400 * 30), '/', 'Strict', false, true);
}
$user->createLastLoginDate(array($user_data['id']));
$response['id'] = $user_data['id'];
$response['ref'] = empty(Cookie::get('ref')) ? url('main') : Cookie::get('ref');
$response['status'] = 1;
$response['message'] = "Login successful.";
Cookie::delete('ref');
response()->json($response);
}
}