public function postIndex() { $input = Input::only('first_name', 'last_name', 'email', 'username', 'password', 'domain_id'); $domain_id = Cookie::get('domain_hash') ? Cookie::get('domain_hash') : 'NULL'; $rules = array('first_name' => 'required|min:1', 'email' => 'required|email|unique:users,email,NULL,id,deleted_at,NULL,domain_id,' . $domain_id, 'username' => 'required|min:3|must_alpha_num|unique:users,username,NULL,id,deleted_at,NULL,domain_id,' . $domain_id, 'password' => 'required|min:6'); $v = Validator::make($input, $rules); if ($v->fails()) { return Output::push(array('path' => 'register', 'errors' => $v, 'input' => TRUE)); } $profile = new Profile(array('first_name' => $input['first_name'], 'last_name' => $input['last_name'], 'website' => '')); $profile->save(); $user = new User(array('domain_id' => Cookie::get('domain_hash') ? Cookie::get('domain_hash') : NULL, 'email' => $input['email'], 'username' => $input['username'], 'password' => Hash::make($input['password']), 'status' => Cookie::get('domain_hash') ? 4 : 3)); $user->profile()->associate($profile); $user->save(); if ($user->id) { if ($user->status == 4) { $this->add_phone_number($user->id); } $cookie = Cookie::forget('rndext'); $confirmation = App::make('email-confirmation'); $confirmation->send($user); Mail::send('emails.register', array('new_user' => $input['username']), function ($message) { $message->from(Config::get('mail.from.address'), Config::get('mail.from.name'))->to(Input::get('email'))->subject(_('New user registration')); }); Event::fire('logger', array(array('account_register', array('id' => $user->id, 'username' => $user->username), 2))); // return Output::push(array( // 'path' => 'register', // 'messages' => array('success' => _('You have registered successfully')), // )); return Redirect::to('register')->with('success', _('You have registered successfully'))->withCookie($cookie); } else { return Output::push(array('path' => 'register', 'messages' => array('fail' => _('Fail to register')), 'input' => TRUE)); } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $input = Input::only('email', 'username', 'password'); $rules = array('email' => 'required|email|unique:users,email,' . Auth::user()->id . ',id,deleted_at,NULL,status,' . Auth::user()->status . ''); if ($input['password']) { $rules['password'] = '******'; } $v = Validator::make($input, $rules); if ($v->fails()) { return Output::push(array('path' => 'user', 'errors' => $v, 'input' => TRUE)); } if ($input['password'] && $id && Auth::user()->id == $id) { $user = user::find($id); //$user->username = $input['username']; $user->email = $input['email']; if ($input['password']) { $user->password = Hash::make($input['password']); Event::fire('logger', array(array('account_password_update', array('id' => $id, 'username' => $user->username), 2))); } $user->save(); return Output::push(array('path' => 'user', 'errors' => 'Change Password Successfully', 'messages' => array('success', _('User data has been saved')), 'input' => TRUE)); } else { return Output::push(array('path' => 'user', 'errors' => 'Unable to update user', 'messages' => array('fail', _('Unable to update user')), 'input' => TRUE)); } }
/** * Handle a POST request to reset a user's password. * * @return Response */ public function postReset() { $credentials = Input::only('email', 'password', 'token'); //hack password_confirmation for package $credentials['password_confirmation'] = $credentials['password']; $rules = array('email' => 'required|email', 'password' => 'required|min:6', 'token' => 'required'); $v = Validator::make($credentials, $rules); if ($v->fails()) { return Output::push(array('path' => 'password/reset', 'errors' => $v, 'input' => TRUE)); } //new style $validtoken = $this->_isValidToken($credentials['email'], $credentials['token']); if ($validtoken) { $id = $this->_getUserId($credentials['email']); if ($id) { $user = user::find($id); //$user->username = $input['username']; $user->email = $credentials['email']; if ($credentials['password']) { $user->password = Hash::make($credentials['password']); Event::fire('logger', array(array('account_password_update', array('id' => $id, 'username' => $user->username), 2))); } $user->save(); return Output::push(array('path' => 'login', 'messages' => array('success' => _('Password has been reset')))); } else { return Output::push(array('path' => 'password/recovery', 'messages' => array('fail' => _('Unable to process password reset')))); } } else { return Output::push(array('path' => 'password/recovery', 'messages' => array('fail' => _('Invalid token')))); } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $input = Input::only('first_name', 'last_name', 'website'); $rules = array('first_name' => 'required'); $v = Validator::make($input, $rules); if ($v->fails()) { return Output::push(array('path' => 'profile', 'errors' => $v, 'input' => TRUE)); } if ($id && Auth::user()->profile_id == $id) { $profile = Profile::find($id); $profile->first_name = $input['first_name']; $profile->last_name = $input['last_name']; $profile->website = $input['website']; $profile->save(); return Output::push(array('path' => 'profile', 'messages' => array('success', _('Profile has been saved')))); } else { return Output::push(array('path' => 'profile', 'messages' => array('fail', _('Unable to update profile')), 'input' => TRUE)); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store($hash) { $input = Input::only('first_name', 'last_name', 'email', 'username', 'password'); $rules = array('first_name' => 'required|min:1', 'email' => 'required|email|unique:users', 'username' => 'required|min:3|alpha_num|unique:users', 'password' => 'required|min:6'); $v = Validator::make($input, $rules); if ($v->fails()) { return Output::push(array('path' => 'panel/' . $hash . '/register', 'errors' => $v, 'input' => TRUE)); } $profile = new Profile(array('first_name' => $input['first_name'], 'last_name' => $input['last_name'])); $profile->save(); $user = new User(array('domain_id' => $hash, 'email' => $input['email'], 'username' => $input['username'], 'password' => Hash::make($input['password']), 'status' => 4)); $user->profile()->associate($profile); $user->save(); if ($user->id) { $confirmation = App::make('email-confirmation'); $confirmation->send($user); Mail::send('emails.register', array('new_user' => $input['username']), function ($message) { $message->from(Config::get('mail.from.address'), Config::get('mail.from.name'))->to(Input::get('email'))->subject(_('New user registration')); }); return Output::push(array('path' => 'login', 'messages' => array('success' => _('You have registered successfully')))); } else { return Output::push(array('path' => 'panel/' . $hash . '/register', 'messages' => array('fail' => _('Fail to register')), 'input' => TRUE)); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function getDelete($id) { $domain = Domain::find($id); $domain->delete(); $user = User::whereDomainId($id)->first(); if ($user) { $user->delete(); $phone_number = PhoneNumber::whereUserId($user->id)->first(); $phone_number->delete(); Event::fire('logger', array(array('phone_number_remove', array('id' => $phone_number->id, 'extension' => $phone_number->extension), 2))); } Event::fire('logger', array(array('domain_remove', array('id' => $id, 'domain_name' => $domain->domain), 2))); return Output::push(array('path' => 'domain', 'messages' => array('success' => _('Domain has been deleted')))); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function getDelete($id, $c_id = null) { $id = $c_id ? $c_id : $id; $phone_number = PhoneNumber::find($id); $phone_number->delete(); Event::fire('logger', array(array('phone_number_remove', array('id' => $id, 'extension' => $phone_number->extension), 2))); $path = Request::segment(2) == "manage" ? "manage/" . Request::segment(3) : ""; return Output::push(array('path' => 'phone_number/' . $path, 'messages' => array('success' => _('Phone number has been deleted')))); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function getDelete($id) { $gateway = Gateway::find($id); $gateway->delete(); Event::fire('logger', array(array('gateway_remove', array('id' => $id, 'gateway_name' => $gateway->gateway_name), 2))); return Output::push(array('path' => 'gateway', 'messages' => array('success' => _('Gateway has been deleted')))); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $user = User::find($id); $profile = Profile::find($user->profile_id); $user->delete(); $profile->delete(); if ($user->domain_id == NULL) { $domain = Domain::whereUserId($id)->first(); if ($domain) { $domain->delete(); $subuser = User::whereDomainId($domain->id)->first(); $subuser->delete(); PhoneNumber::whereUserId($subuser->id)->delete(); } } Event::fire('logger', array(array('account_remove', array('id' => $id, 'username' => $user->username), 2))); $path = Request::segment(4) ? 'domain/users/' . Request::segment(4) : 'users'; $path = $user->domain_id ? $path : "managers"; return Output::push(array('path' => $path, 'messages' => array('success' => _('User has been deleted')))); }
public function getLogout() { Auth::logout(); return Output::push(array('path' => 'login', 'messages' => array('success' => _('You have been logged out')))); }
public function getDelete($id) { $token = Token::find($id); $token->delete(); return Output::push(array('path' => 'token', 'messages' => array('success' => _('Token has been deleted')))); }
/** * Update the specified resource in storage. * * @return Response */ public function postUpdate() { $input = Input::only('global_prefix', 'panel_path', 'domain_limit', 'phone_number_limit', 'email_address_for_notification', 'email_address_for_admin', 'sender_name', 'sip_server', 'reserved_extension', 'reserved_domain_prefix', 'log_file', 'available_css'); $rules = array('global_prefix' => 'required|min:1|max:10', 'panel_path' => 'required|min:1', 'domain_limit' => 'required|numeric', 'phone_number_limit' => 'required|numeric', 'email_address_for_notification' => 'required|email', 'email_address_for_admin' => 'required|email', 'sender_name' => 'required|min:1', 'sip_server' => 'required|min:3', 'reserved_extension' => 'required|min:3', 'reserved_domain_prefix' => 'required|min:3', 'log_file' => 'required|min:3', 'available_css' => 'required'); $v = Validator::make($input, $rules); if ($v->fails()) { return Output::push(array('path' => 'main_config', 'errors' => $v, 'input' => TRUE)); } $panel_path = Setting::whereName('global_prefix')->first(); $panel_path->value = $input['global_prefix']; $panel_path->save(); $panel_path = Setting::whereName('panel_path')->first(); $panel_path->value = $input['panel_path']; $panel_path->save(); $domain_limit = Setting::whereName('domain_limit')->first(); $domain_limit->value = $input['domain_limit']; $domain_limit->save(); $phone_number_limit = Setting::whereName('phone_number_limit')->first(); $phone_number_limit->value = $input['phone_number_limit']; $phone_number_limit->save(); $mail_address = Setting::whereName('email_address_for_notification')->first(); $mail_address->value = $input['email_address_for_notification']; $mail_address->save(); $mail_address = Setting::whereName('email_address_for_admin')->first(); $mail_address->value = $input['email_address_for_admin']; $mail_address->save(); $sender_name = Setting::whereName('sender_name')->first(); $sender_name->value = $input['sender_name']; $sender_name->save(); $sip_server = Setting::whereName('sip_server')->first(); $sip_server->value = $input['sip_server']; $sip_server->save(); $reserved_extension = Setting::whereName('reserved_extension')->first(); $reserved_extension->value = $input['reserved_extension']; $reserved_extension->save(); $available_css = Setting::whereName('available_css')->first(); $available_css->value = $input['available_css']; $available_css->save(); $log_file = Setting::whereName('log_file')->first(); $log_file->value = $input['log_file']; $log_file->save(); $reserved_domain_prefix = Setting::whereName('reserved_domain_prefix')->first(); $reserved_domain_prefix->value = $input['reserved_domain_prefix']; $reserved_domain_prefix->save(); if ($panel_path->id && $domain_limit->id && $phone_number_limit && $mail_address && $sender_name && $sip_server && $reserved_domain_prefix && $reserved_extension && $log_file && $available_css) { return Output::push(array('path' => 'main_config', 'messages' => array('success' => _('You have updated main configuration successfully')))); } else { return Output::push(array('path' => 'main_config', 'messages' => array('fail' => _('Fail to update main configuration')), 'input' => TRUE)); } }
public function getFilter() { $status = Auth::user()->status; if ($status == 2) { $call_detail_report = Cdr::all(); $condq = "created is not null"; } elseif ($status == 3) { $domain = Domain::whereUserId(Auth::user()->id)->get(array('sip_server')); $sip_server = array(); foreach ($domain as $row) { $sip_server[] = $row['sip_server']; } if ($sip_server) { $call_detail_report = $this->_orWhereIn('caller_domain', 'callee_domain', $sip_server); } else { $call_detail_report = []; } $condq = $this->_orGenerator('caller_domain', 'callee_domain', $sip_server); } else { $sip_server = Domain::find(Cookie::get('domain_hash'))->whereDomain(Request::getHttpHost())->get(array('sip_server')); $domainc = array(); foreach ($sip_server as $row) { $domainc[] = $row['sip_server']; } $extension_arr = PhoneNumber::whereUserId(Auth::user()->id)->get(array('extension')); $extension = array(); foreach ($extension_arr as $row) { $extension[] = $row['extension']; } $call_detail_report = $this->_orWhereInAnd('src_uri', 'dst_uri', $extension, 'caller_domain', 'callee_domain', $domainc); $condq = $this->_orGeneratorAnd('src_uri', 'dst_uri', $extension, 'caller_domain', 'callee_domain', $domainc); } $input = Input::only(array('datefilter', 'datefrom', 'dateto', 'timefilter', 'timefrom', 'timeto', 'durationparam', 'durationfilter', 'duration', 'fromfilter', 'from', 'tofilter', 'to')); $rules = array('datefrom' => 'required_with:datefilter', 'timefrom' => 'required_with:timefilter', 'duration' => 'required_with:durationfilter'); $v = Validator::make($input, $rules); if ($v->fails()) { return Output::push(array('path' => 'call_detail_reports', 'errors' => $v, 'input' => TRUE)); } $bulan_ayeuna = "AND YEAR(call_start_time) = YEAR(curdate()) AND MONTH(call_start_time) = MONTH(curdate()) "; if ($input['datefilter'] || $input['timefilter'] || $input['durationfilter'] || $input['fromfilter'] || $input['tofilter']) { $q = "select * from opensips.cdrs where "; $q = $q . "(" . $condq . ") "; if ($input['datefilter']) { if ($input['datefrom'] && $input['dateto']) { $fromdate = $this->_intlDate($input['datefrom']); $todate = $this->_intlDate($input['dateto']); $q = $q . "AND (date(call_start_time) BETWEEN '" . $fromdate . "' AND '" . $todate . "') "; } elseif ($input['datefrom'] && !$input['dateto']) { $fromdate = $this->_intlDate($input['datefrom']); $todate = date("Y-m-d"); $q = $q . "AND (date(call_start_time) >= '" . $fromdate . "') "; } } else { $q = $q . $bulan_ayeuna; } if ($input['timefilter']) { if ($input['timefrom'] && $input['timeto']) { $q = $q . "AND (time(call_start_time) BETWEEN '" . $input['timefrom'] . "' AND '" . $input['timeto'] . "') "; } elseif ($input['timefrom'] && !$input['timeto']) { $q = $q . "AND (time(call_start_time) >= "; $q = $q . "'" . $input['timefrom'] . "') "; } } if ($input['durationfilter']) { $duration = $this->_getDuration($input['duration']); $q = $q . "AND (duration " . $input['durationparam'] . " " . $duration . ") "; } if ($input['fromfilter']) { $fromarr = explode("@", $input['from']); if (!isset($fromarr[1])) { $fromarr[1] = null; } if ($fromarr[1] == null) { $q = $q . "AND (src_uri = '" . $input['from'] . "') "; } else { $q = $q . "AND (src_uri = '" . $fromarr[0] . "' and caller_domain = '" . $fromarr[1] . "') "; } } if ($input['tofilter']) { $toarr = explode("@", $input['to']); if (!isset($toarr[1])) { $toarr[1] = null; } if ($toarr[1] == null) { $q = $q . "AND (dst_uri = '" . $input['to'] . "') "; } else { $q = $q . "AND (dst_uri = '" . $toarr[0] . "' and callee_domain = '" . $toarr[1] . "') "; } } $q = $q . "order by call_start_time desc"; $results = []; $results = DB::connection('mysql2')->select($q); //print_r($q); return View::make('call_detail_reports.index')->with('call_detail_reports', $results); } else { return View::make('call_detail_reports.index')->with('call_detail_reports', $call_detail_report); } }