/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { //$token = Input::post('token'); if (Request::has('token')) { $token = Request::input('token'); $compare = GlobalLibrary::compareToken($token); if ($compare) { $fullname = Request::input('f'); $username = Request::input('u'); $phone = Request::input('pn'); $email = Request::input('e'); $password = Request::input('pwd'); $roles = Request::input('r'); $field_users = array('name' => $username, 'email' => $email, 'password' => bcrypt($password)); $count_users = User::where('email', '=', $email)->count(); if ($count_users <= 0) { $user = User::create($field_users); $user_login = User::where('email', '=', $email)->first(); foreach ($user_login as $key => $value) { $id = $user_login->id; } $field_user_detail = array('users_id' => $id, 'users_name' => $username, 'users_fullname' => $fullname, 'users_group_id' => $roles, 'users_email' => $email, 'users_status_id' => '1'); $user = table_users_detail::create($field_user_detail); return (new Response(array('status' => true, 'msg' => 'Register successfully'), 200))->header('Content-Type', "json"); } else { return (new Response(array('status' => false, 'msg' => 'Email already registered'), 200))->header('Content-Type', "json"); } } else { return (new Response(array('status' => false, 'msg' => 'Authentication Failed 2'), 200))->header('Content-Type', "json"); } } else { return (new Response(array('status' => false, 'msg' => 'Authentication Failed 1'), 200))->header('Content-Type', "json"); } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { if (Request::has('token')) { $token = Request::input('token', ''); $compare = GlobalLibrary::compareToken($token); if ($compare) { $this->middleware('guest', ['except' => 'getLogout']); $email = Request::input('u', ''); $password = Request::input('pwd', ''); if (Auth::attempt(array('email' => $email, 'password' => $password))) { $users_detail = table_users_detail::where('users_email', '=', $email)->first(); $users_default = User::where('email', '=', $email)->first(); $status = $users_detail->users_status_id; if ($status == "2") { //return (new Response(array('status' => true,'msg' => 'You are Logged in'),200))->header('Content-Type', "json"); $field_users = array(); $field_users['id'] = $users_default->id; $field_users['ids'] = $users_detail->users_detail_id; $field_users['users_name'] = $users_detail->users_name; $field_users['users_email'] = $email; $field_users['users_group_id'] = $users_detail->users_group_id; $field_users['users_fullname'] = $users_detail->users_fullname; $field_users = (object) $field_users; $token = GlobalLibrary::tokenGenerator($field_users); $js = array(); $js = (object) $js; $js->i = $users_detail->users_detail_id; $js->n = $users_detail->users_name; $js->fu = $users_detail->users_fullname; $js->d = $users_detail->users_description; $js->ugid = $users_detail->users_group_id; $js->token = $token; return (new Response(array('status' => true, 'msg' => 'You are Logged in', 'data' => $js), 200))->header('Content-Type', "json"); } else { return (new Response(array('status' => true, 'msg' => 'You are still pending verification'), 200))->header('Content-Type', "json"); } } else { return (new Response(array('status' => false, 'msg' => 'Authentication Failed '), 200))->header('Content-Type', "json"); } } else { return (new Response(array('status' => false, 'msg' => 'Authentication Failed2'), 200))->header('Content-Type', "json"); } } else { return (new Response(array('status' => false, 'msg' => 'Authentication Failed1'), 200))->header('Content-Type', "json"); } }
public static function CheckUsersToken($data) { $uname = $data[4]; $uid = $data[6]; $email = $data[3] . '@' . $data[2] . '.' . $data[0]; $users_detail = table_users_detail::where('users_email', '=', $email)->where('users_name', '=', $uname)->where('users_detail_id', '=', $uid)->first(); $values = array(); if (count($users_detail) > 0) { $values[0] = true; $values[1] = $uname; $values[2] = $uid; $values[3] = $email; return $values; } else { $values[0] = false; return $values; } }
/** * Show the application dashboard to the user. * * @return Response */ public function index() { if (!isset($is_public)) { $user_id = Auth::id(); $cek = DB::table('table_users_detail')->where('users_id', '=', $user_id)->first(); $user = table_users_detail::where('users_id', '=', $user_id)->first(); $group = table_users_group::where('users_group_id', '=', $user->users_group_id)->first(); $is_public = $group->users_group_is_public; } if ($is_public == "0") { session(['is_public' => 'yes']); return redirect('admin/dashboard'); } else { echo "<center><h1>HOME</h1>You are not an ADMIN, <br/>\n\t\t\t\tYou redirected to HOME page that corresponds to your authentication.<br/> This page is under construction</center>"; die; } // if($cek->users_group_id == 1 ){ // return redirect('admin/dashboard'); // } // else if($cek->users_group_id == 2 ){ // return redirect('admin/dashboard'); // } // else if($cek->users_group_id == 3 ){ // echo "You are logged in as Content Writer. Your page is under construction"; // die(); // } // else if($cek->users_group_id == 4 ){ // echo "You are logged in as Jamaah. Your page is under construction"; // die(); // } // else if($cek->users_group_id == 5 ){ // echo "You are logged in as Ustadz. Your page is under construction"; // die(); // } // else if($cek->users_group_id == 6 ){ // echo "You are logged in as Masjid. Your page is under construction"; // die(); // } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $detail = table_users_detail::where('users_id', '=', $id)->first(); if (isset($detail->users_detail_id)) { $idusersdetail = $detail->users_detail_id; table_users_detail::find($idusersdetail)->delete(); } user::find($id)->delete(); return redirect('admin/users-detail')->with('warning', 'Data have been removed!'); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $app = app(); if (Request::has('token')) { $token = Request::input('token', ''); $compare = GlobalLibrary::tokenExtractor($token); $users_checker = GlobalLibrary::CheckUsersToken($compare); //echo '<pre>'.print_r($compare).'</pre>'; if ($users_checker[0]) { $uname = $users_checker[1]; $uid = $users_checker[2]; $email = $users_checker[3]; //get query $result = DB::select('Select ts.*, tud.users_name as users_name_creator, st.schedule_type_name, tud.users_name as users_name_source from table_schedule ts, table_schedule_type st, table_users_detail tud WHERE ts.schedule_type_id = st.content_category_id AND tud.users_id = ts.schedule_users_creator AND ts.schedule_users_creator = ' . $uid . ' ORDER BY schedule_id DESC '); //this foreach for get media manager name and source foreach ($result as $res => $value) { $idsplit = explode(',', $value->schedule_media_id); //get user source $cekuser = table_users_detail::where('users_id', '=', $value->schedule_users_source)->first(); if ($cekuser != null) { $value->users_name_source = $cekuser->users_name; } $length = count($idsplit); $name = ''; for ($i = 0; $i < $length; $i++) { $cek = table_media_manager::where('media_manager_id', '=', $idsplit[$i])->first(); if ($cek != null) { $name = $name . $cek->media_manager_title . ', '; } } $value->schedule_media_id = $name; } //this code for convert $dataConverted = array(); $app = app(); $i = 0; foreach ($result as $row) { $dataConverted[$i] = $app->make('stdClass'); $dataConverted[$i]->id = $row->schedule_id; $dataConverted[$i]->ttl = $row->cschedule_title; $dataConverted[$i]->typ = $row->schedule_type_id; $dataConverted[$i]->suc = $row->schedule_users_creator; $dataConverted[$i]->usc = $row->schedule_users_source; $dataConverted[$i]->dst = $row->schedule_date_start; $dataConverted[$i]->dnd = $row->schedule_date_end; $dataConverted[$i]->des = $row->schedule_description; $dataConverted[$i]->hed = $row->schedule_headline; $dataConverted[$i]->med = $row->schedule_media_id; $dataConverted[$i]->pub = $row->schedule_publish; $dataConverted[$i]->rpt = $row->schedule_repeat; $dataConverted[$i]->uns = $row->users_name_source; $dataConverted[$i]->utn = $row->schedule_type_name; $dataConverted[$i]->unc = $row->users_name_creator; $i++; } return (new Response(array('status' => true, 'msg' => 'success', 'data' => $dataConverted), 200))->header('Content-Type', "json"); } else { return (new Response(array('status' => false, 'msg' => 'Authentication Failed2'), 200))->header('Content-Type', "json"); } } else { return (new Response(array('status' => false, 'msg' => 'Authentication Failed1'), 200))->header('Content-Type', "json"); } }
public function accept_request_follower() { $app = app(); if (Request::has('token')) { $token = Request::input('token', ''); $compare = GlobalLibrary::tokenExtractor($token); $users_checker = GlobalLibrary::CheckUsersToken($compare); if ($users_checker[0]) { $uname = $users_checker[1]; $uid = $users_checker[2]; $email = $users_checker[3]; $followingid = Request::input('fol', ''); $users = table_users_detail::where('users_id', '=', $followingid)->first(); $jsonfollow = $users->users_json_following; //insert my id to his/her detail $datausersdetail = array('users_json_following' => $jsonfollow . ',' . $uid); $data = table_users_detail::find($followingid); $data->update($datausersdetail); //delete his/her request because it has accepted $follow_requesting = table_request_follow::where('users_id', '=', $followingid)->first(); $request_following = $follow_requesting->json_request_follow; $arrayfollow = explode(',', $request_following); if (($key = array_search($uid, $arrayfollow)) !== false) { unset($arrayfollow[$key]); } $new_json_request_follow = implode(',', $arrayfollow); //update his/her request $new_json = array('json_request_follow' => $new_json_request_follow); $data2 = table_request_follow::find($followingid); $data2->update($new_json); return (new Response(array('status' => true, 'msg' => 'success'), 200))->header('Content-Type', "json"); } else { return (new Response(array('status' => false, 'msg' => 'Authentication Failed2'), 200))->header('Content-Type', "json"); } } else { return (new Response(array('status' => false, 'msg' => 'Authentication Failed1'), 200))->header('Content-Type', "json"); } }
public function upload() { if (Request::hasFile('file')) { $rules = array('file' => 'mimes:png,jpeg,jpg,bmp'); $validator = Validator::make(Request::all(), $rules); if ($validator->fails()) { return (new Response(array('status' => false, 'msg' => 'Please choose a picture'), 200))->header('Content-Type', "json"); } else { $str = ""; try { $param_picture = Request::input('param_picture'); $id = Request::input('param'); $token = Request::input('token'); $file = Request::file('file'); $filename = ""; $field_update = array(); if ($param_picture == "ava") { $filename = md5('Avatar -' . date("Y-m-d H:i:s") . '-') . '.' . $file->getClientOriginalExtension(); $field_update = array('users_avatar' => $filename); } else { $filename = md5('Cover -' . date("Y-m-d H:i:s") . '-') . '.' . $file->getClientOriginalExtension(); $field_update = array('users_cover' => $filename); } $destinationPath = 'UPLOADED'; $file->move($destinationPath, $filename); $data_find = table_users_detail::find($id); $data_find->update($field_update); $str = "success "; return (new Response(array('status' => true, 'msg' => $str, 'f' => $filename), 200))->header('Content-Type', "json"); } catch (Exception $e) { $str = $e->getMessage(); return (new Response(array('status' => false, 'msg' => $str), 200))->header('Content-Type', "json"); } } } else { return (new Response(array('status' => false, 'msg' => 'Authentication Failed'), 200))->header('Content-Type', "json"); } }
public function search_content() { $app = app(); if (Request::has('token')) { $token = Request::input('token', ''); $compare = GlobalLibrary::tokenExtractor($token); $users_checker = GlobalLibrary::CheckUsersToken($compare); //echo '<pre>'.print_r($compare).'</pre>'; if ($users_checker[0]) { $uname = $users_checker[1]; $uid = $users_checker[2]; $email = $users_checker[3]; $users = table_users_detail::where('users_email', '=', $email)->where('users_name', '=', $uname)->where('users_detail_id', '=', $uid)->first(); $follow = $users->users_json_following; //get query $keyword = Request::input('qwr'); $result = DB::select('Select tc.*, tud.users_name, tcc.content_category_title from table_content_category tcc, table_content tc, table_users_detail tud WHERE tc.content_category_id = tcc.content_category_id AND tud.users_id = tc.content_users_uploader AND tc.content_title like ' . $keyword . ' '); foreach ($result as $res => $value) { //get media manager $idsplit = explode(',', $value->content_media_id); $length = count($idsplit); $name = ''; for ($i = 0; $i < $length; $i++) { $cek = table_media_manager::where('media_manager_id', '=', $idsplit[$i])->first(); if ($cek != null) { $name = $name . $cek->media_manager_title . ', '; } } //get content repost $cekrepost = table_content::where('content_id', '=', $value->content_repost_from)->first(); if ($cekrepost != null) { $value->content_repost_from = $cekrepost->content_title; } //get hashtag $idsplittag = explode(',', $value->hashtag_id); $lengthtag = count($idsplittag); $hashtag = ''; for ($j = 0; $j < $lengthtag; $j++) { $cektag = table_hashtag::where('hashtag_id', '=', $idsplittag[$j])->first(); if ($cektag != null) { $hashtag = $hashtag . $cektag->media_manager_title . ', '; } } $value->hashtag_id = $hashtag; } //this code for convert $dataConverted = array(); $app = app(); $i = 0; foreach ($result as $row) { $dataConverted[$i] = $app->make('stdClass'); $dataConverted[$i]->id = $row->content_id; $dataConverted[$i]->ttl = $row->ccontent_title; $dataConverted[$i]->hed = $row->content_headline; $dataConverted[$i]->det = $row->content_detail; $dataConverted[$i]->med = $row->content_media_id; $dataConverted[$i]->upl = $row->content_users_uploader; $dataConverted[$i]->uun = $row->content_users_uploader_name; $dataConverted[$i]->cle = $row->content_last_editor; $dataConverted[$i]->cdi = $row->content_date_insert; $dataConverted[$i]->cdu = $row->content_date_update; $dataConverted[$i]->cde = $row->content_date_expired; $dataConverted[$i]->pub = $row->content_publish; $dataConverted[$i]->cat = $row->content_category_id; $dataConverted[$i]->ccn = $row->content_category_name; $dataConverted[$i]->chi = $row->content_hashtag_id; $dataConverted[$i]->crf = $row->content_repost_from; $dataConverted[$i]->crn = $row->content_repost; $i++; } return (new Response(array('status' => true, 'msg' => 'success', 'data' => $dataConverted), 200))->header('Content-Type', "json"); } else { return (new Response(array('status' => false, 'msg' => 'Authentication Failed2'), 200))->header('Content-Type', "json"); } } else { return (new Response(array('status' => false, 'msg' => 'Authentication Failed1'), 200))->header('Content-Type', "json"); } }