Ejemplo n.º 1
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $formattedEraserList = Utils::generateEraserList($this->eraserList, $this->cluster);
     foreach ($formattedEraserList as $device) {
         $this->dispatch(new ControlPhone($device, $this->cluster));
     }
 }
 public function get($key, $defaultVal = null)
 {
     $val = $this->underlyingGet($key, $defaultVal);
     if ($this->isEncrypted($key, $val)) {
         $val = $this->decrypt($val);
     }
     $val = Utils::correctType($val);
     return $val;
 }
Ejemplo n.º 3
0
 public function run_post(Request $request, $id)
 {
     $msg = Utils::output($request);
     file_put_contents(storage_path("tmp/log" . $id . ".txt"), $msg, FILE_APPEND | LOCK_EX);
     $client = new \Hoa\Websocket\Client(new \Hoa\Socket\Client('tcp://127.0.0.1:8889'));
     $client->connect();
     $client->send(json_encode(["command" => webSocket::BROADCASTIF, "jobid" => $id, "msg" => $msg]));
     $client->close();
 }
 public function getCalendarDetail($membertoken, $regIdx)
 {
     $member = Member::whereHas('token', function ($query) use($membertoken) {
         $query->where('token', $membertoken);
     })->first();
     $data = new stdClass();
     $data->sleepInfo = $this->avgSleepRepo->getAvgSleep($member, $regIdx);
     $data->sleepRecords = $this->sleepRecordRepo->getRecordsByRegIdx($member, $regIdx);
     return Utils::result($data);
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // Query the CUCM to get numbers in the None partition
     $res = Utils::executeQuery('SELECT dnorpattern, description FROM numplan WHERE fkroutepartition IS NULL AND tkpatternusage = 2', $this->cluster);
     // Create a line in the CSV for the Cluster heading
     Storage::append($this->outFile, $this->cluster->name . ',' . $this->cluster->ip);
     //If we got results.....
     if ($res) {
         //Add the results to our CSV file
         foreach ($res as $dn) {
             Storage::append($this->outFile, implode(",", [$dn->dnorpattern, $dn->description]));
         }
     }
 }
Ejemplo n.º 6
0
 public function response(array $errors)
 {
     /* If the user is not validating from a mobile app - pass through parent::response */
     if (!isset($this->req->api_secret)) {
         return parent::response($errors);
     }
     /* If the user is validating from a mobile app - pass through first error string and return error */
     foreach ($errors as $error) {
         foreach ($error as $key => $value) {
             $message['error'] = ['message' => $value];
             $message = json_encode($message, JSON_PRETTY_PRINT);
             $headers = Utils::getApiHeaders();
             return Response::make($message, 400, $headers);
         }
     }
 }
Ejemplo n.º 7
0
 public function show($sql)
 {
     $sql = $this->sql->find($sql);
     $sql = $sql->sql;
     if (!\Auth::user()->activeCluster()) {
         alert()->error('Please set your active CUCM Cluster')->persistent('Close');
         return redirect()->action('SqlController@index');
     }
     $data = Utils::executeQuery($sql, \Auth::user()->activeCluster());
     if (is_null($data)) {
         alert()->error('No Results Found')->persistent('Close');
         return redirect()->back();
     }
     $format = $this->sql->getHeaders($data);
     $page_title = 'SQL';
     $page_description = 'Query';
     return view('sql.show', compact('data', 'format', 'sql', 'page_title', 'page_description'));
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     //Query the CUCM to get all DN's, descriptions and what number (if any) they are forwarded to
     $res = Utils::executeQuery('SELECT n.dnorpattern, n.description, cfwd.cfadestination FROM numplan n INNER JOIN callforwarddynamic cfwd ON n.pkid = cfwd.fknumplan', $this->cluster);
     // Create a line in the CSV for the Cluster heading
     Storage::append($this->outFile, $this->cluster->name . ',' . $this->cluster->ip);
     //If we got results.....
     if (!is_null($res)) {
         //Check to see what moron forwarded their line to themselves
         foreach ($res as $dn) {
             //If the right 10 digits of the dnorpattern matches the right 10 digits of the forward number....
             if (substr($dn->dnorpattern, -10) == substr($dn->cfadestination, -10)) {
                 //Write this to the report
                 Storage::append($this->outFile, implode(",", [$dn->dnorpattern, $dn->description, $dn->cfadestination]));
             }
         }
     }
 }
 /**
  * Register the blade directives
  *
  * @return void
  */
 private function bladeDirectives()
 {
     Blade::directive('strHead', function ($expression) {
         list($value, $limit, $end) = Utils::getParmsForStrHeadAndTails($expression);
         return "<?php echo e(App\\Libraries\\Str::head({$value}, {$limit}, '{$end}')); ?>";
     });
     Blade::directive('strTail', function ($expression) {
         list($value, $limit, $end) = Utils::getParmsForStrHeadAndTails($expression);
         return "<?php echo e(App\\Libraries\\Str::tail({$value}, {$limit}, '{$end}')); ?>";
     });
     Blade::directive('strHeadAndTail', function ($expression) {
         list($value, $limit, $end) = Utils::getParmsForStrHeadAndTails($expression);
         return "<?php echo e(App\\Libraries\\Str::head_and_tail({$value}, {$limit}, '{$end}')); ?>";
     });
     Blade::directive('userTimeZone', function ($expression) {
         $parms = Utils::splitBladeParameters($expression, true);
         $dateCode = $parms[0];
         return "<?php echo e(App\\Libraries\\Utils::userTimeZone({$dateCode})); ?>";
     });
 }
 public function test2()
 {
     // 태스트셋 만듬
     // $time1 = mktime(3, 0, 0, 7, 15, 2015); // 2015-07-15
     // $member = Member::find(1);
     // for($i = 0; $i < 3000; $i++ ) {
     // 	$sleepStep = (mt_rand() % 4) + 1;
     // 	$this->sleepRecordRepo->addSleepRecord($member, 1, $sleepStep, date('Y-m-d H:i:s', $time1) );
     // 	$time1 += 30;
     // }
     // $time2 = mktime(3, 0, 0, 7, 16, 2015); // 2015-07-16
     // for($i = 0; $i < 3000; $i++ ) {
     // 	$sleepStep = (mt_rand() % 4) + 1;
     // 	$this->sleepRecordRepo->addSleepRecord($member, 2, $sleepStep, date('Y-m-d H:i:s', $time2) );
     // 	$time2 += 30;
     // }
     // echo 'OK'.PHP_EOL;
     // -- getMinMaxTimeGroupByRegIdx --
     //$member = Member::find(1);
     //$data = $this->sleepRecordRepo->getMinMaxTimeGroupByRegIdx($member);
     return Utils::result($data);
 }
Ejemplo n.º 11
0
 public function caddAddUsers()
 {
     if (!Utils::isNinja()) {
         return true;
     } elseif (!$this->hasFeature(FEATURE_USERS)) {
         return false;
     }
     $account = $this->account;
     $company = $account->company;
     $numUsers = 1;
     foreach ($company->accounts as $account) {
         $numUsers += $account->users->count() - 1;
     }
     return $numUsers < $company->num_users;
 }
 public function load()
 {
     $envName = env('APP_ENV', 'production');
     try {
         $cnt = Setting::load($envName);
         if (0 == $cnt) {
             Utils::flashAndAudit(trans('admin/settings/general.audit-log.category'), trans('admin/settings/general.status.no-settings-loaded', ['env' => $envName]), FlashLevel::WARNING);
         } else {
             Utils::flashAndAudit(trans('admin/settings/general.audit-log.category'), trans('admin/settings/general.status.settings-loaded', ['number' => $cnt, 'env' => $envName]), FlashLevel::SUCCESS);
         }
     } catch (FileNotFoundException $fnfx) {
         Utils::flashAndAudit(trans('admin/settings/general.audit-log.category'), trans('admin/settings/general.status.settings-file-not-found', ['env' => $envName]), FlashLevel::ERROR);
     }
     return redirect('/admin/settings');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $locale = Utils::getUserOrAppOrDefaultSetting('locale', 'app.locale', 'en');
     App::setLocale($locale);
     return $next($request);
 }
 private function setLERNNotificationFormat()
 {
     //Change the subject
     LERN::setSubject("[" . Setting::get('lern.notify.channel') . "]: An Exception was thrown! (" . date("D M d, Y G:i", time()) . " UTC)");
     //Change the message body
     LERN::setMessage(function (Exception $exception) {
         $url = Request::url();
         $method = Request::method();
         $user = Auth::user();
         if ($user) {
             $user_id = $user->id;
             $user_name = $user->username;
             $user_first_name = $user->first_name;
             $user_last_name = $user->last_name;
         } else {
             $user_id = 'N/A';
             $user_name = 'unauthenticated';
             $user_first_name = 'Unauthenticated User';
             $user_last_name = 'N/A';
         }
         $exception_class = get_class($exception);
         $exception_file = $exception->getFile();
         $exception_line = $exception->getLine();
         $exception_message = $exception->getMessage();
         $exception_trace = $exception->getTrace();
         $input = Input::all();
         if (!empty($input)) {
             if (array_has($input, 'password')) {
                 $input['password'] = "******";
                 $input['password_confirmation'] = "hidden-secret";
             }
             $input = json_encode($input);
         } else {
             $input = "";
         }
         $exception_trace_formatted = [];
         foreach ($exception->getTrace() as $trace) {
             $formatted_trace = "";
             if (isset($trace['function']) && isset($trace['class'])) {
                 $formatted_trace = sprintf('at %s%s%s(...)', Utils::formatClass($trace['class']), $trace['type'], $trace['function']);
             } else {
                 if (isset($trace['function'])) {
                     $formatted_trace = sprintf('at %s(...)', $trace['function']);
                 }
             }
             if (isset($trace['file']) && isset($trace['line'])) {
                 $formatted_trace .= Utils::formatPath($trace['file'], $trace['line']);
             }
             $exception_trace_formatted[] = $formatted_trace;
         }
         $view = View::make('emails.html.lern_notification', compact('url', 'method', 'user_id', 'user_name', 'user_first_name', 'user_last_name', 'exception_class', 'exception_file', 'exception_line', 'exception_message', 'exception_trace', 'exception_trace_formatted', 'input'));
         $msg = $view->render();
         return $msg;
     });
 }
 public function logError()
 {
     return Utils::logError(Input::get('error'), 'JavaScript');
 }
Ejemplo n.º 16
0
 public function isDemo()
 {
     return $this->account->id == Utils::getDemoAccountId();
 }
Ejemplo n.º 17
0
 public static function hideIds($data, $mapped = false)
 {
     $publicId = null;
     if (!$mapped) {
         $mapped = [];
     }
     foreach ($data as $key => $val) {
         if (is_array($val)) {
             if ($key == 'account' || isset($mapped[$key])) {
                 unset($data[$key]);
             } else {
                 $mapped[$key] = true;
                 $data[$key] = Utils::hideIds($val, $mapped);
             }
         } elseif ($key == 'id' || strpos($key, '_id')) {
             if ($key == 'public_id') {
                 $publicId = $val;
             }
             unset($data[$key]);
         }
     }
     if ($publicId) {
         $data['id'] = $publicId;
     }
     return $data;
 }
 public static function userTimeZone($date)
 {
     $time_zone = Utils::getUserOrAppOrDefaultSetting('time_zone', 'app.time_zone', 'UTC');
     $time_format = Utils::getUserOrAppOrDefaultSetting('time_format', 'app.time_format', '24');
     // Get the time zone abbreviation to display from the time zone identifier
     $dateTime = new DateTime();
     $dateTime->setTimeZone(new DateTimeZone($time_zone));
     $tzAbrev = $dateTime->format('T');
     // Convert system time to user's timezone
     $locDate = $date;
     $locDate->setTimeZone(new DateTimeZone($time_zone));
     if ("12" == $time_format) {
         $finalSTR = $locDate->format('Y-m-d g:i A') . " " . $tzAbrev;
         // output: 2011-04-26 8:45 PM EST
     } else {
         $finalSTR = $locDate->format('Y-m-d H:i') . " " . $tzAbrev;
         // output: 2011-04-26 20:45 EST
     }
     return $finalSTR;
 }
Ejemplo n.º 19
0
 public function maxInvoiceDesignId()
 {
     return $this->isPro() ? 11 : (Utils::isNinja() ? COUNT_FREE_DESIGNS : COUNT_FREE_DESIGNS_SELF_HOST);
 }
Ejemplo n.º 20
0
 public function deactivateAccountSendEmail($user)
 {
     $deactivate = $user->deactivateByEmail();
     if ($deactivate) {
         if (Utils::sendEmail(['template' => 'emails.activation_account_email', 'subject' => 'Activate Accout', 'from' => '*****@*****.**', 'to' => $user->email, 'data' => array('activation_code' => $user->activation_code, "id" => $user->id), 'message' => '', 'user' => 'Activate Account', 'had_attached_files' => false])) {
             $this->set_message('Emeil sened');
             return true;
             return array('messages' => $this->messages(), 'type_msg' => 'success', 'result' => true);
         } else {
             $this->set_error('error_send_activation_email');
             return false;
             return array('errors' => $this->errors(), 'result' => false, 'type_msg' => 'danger');
         }
     } else {
         $this->set_error('error_deactivate_account');
         return false;
         return array('errors' => $this->errors(), 'result' => false, 'type_msg' => 'danger');
     }
 }
Ejemplo n.º 21
0
 public static function withinPastTwoWeeks($date)
 {
     $interval = Utils::getInterval($date);
     return $interval && $interval->d <= 14;
 }
Ejemplo n.º 22
0
 public static function remapPublicIds(array $data)
 {
     $return = [];
     foreach ($data as $key => $val) {
         if ($key === 'public_id') {
             $key = 'id';
         } elseif (strpos($key, '_id')) {
             continue;
         }
         if (is_array($val)) {
             $val = Utils::remapPublicIds($val);
         }
         $return[$key] = $val;
     }
     return $return;
 }
 public function load()
 {
     $envName = env('APP_ENV', 'production');
     $settingsFileName = ".settings-" . $envName;
     $settingsPath = $this->app->environmentPath();
     if (\File::exists($settingsPath . '/' . $settingsFileName)) {
         $cnt = SettingDotEnv::load($settingsPath, $settingsFileName);
         if (0 == $cnt) {
             Utils::flashAndAudit(trans('admin/settings/general.audit-log.category'), trans('admin/settings/general.status.no-settings-loaded', ['env' => $envName]), FlashLevel::WARNING);
         } else {
             Utils::flashAndAudit(trans('admin/settings/general.audit-log.category'), trans('admin/settings/general.status.settings-loaded', ['number' => $cnt, 'env' => $envName]), FlashLevel::SUCCESS);
         }
     } else {
         Utils::flashAndAudit(trans('admin/settings/general.audit-log.category'), trans('admin/settings/general.status.settings-file-not-found', ['env' => $envName]), FlashLevel::ERROR);
     }
     return redirect('/admin/settings');
 }
Ejemplo n.º 24
0
 public function isEmailBeingChanged()
 {
     return Utils::isNinjaProd() && $this->email != $this->getOriginal('email') && $this->getOriginal('confirmed');
 }
Ejemplo n.º 25
0
 public static function hideIds($data)
 {
     $publicId = null;
     foreach ($data as $key => $val) {
         if (is_array($val)) {
             $data[$key] = Utils::hideIds($val);
         } else {
             if ($key == 'id' || strpos($key, '_id')) {
                 if ($key == 'public_id') {
                     $publicId = $val;
                 }
                 unset($data[$key]);
             }
         }
     }
     if ($publicId) {
         $data['id'] = $publicId;
     }
     return $data;
 }
Ejemplo n.º 26
0
 public function getPopOverText()
 {
     if (!Utils::isNinja() || !Auth::check() || Session::has('error')) {
         return false;
     }
     $count = self::getRequestsCount();
     if ($count == 1 || $count % 5 == 0) {
         if (!Utils::isRegistered()) {
             return trans('texts.sign_up_to_save');
         } elseif (!Auth::user()->account->name) {
             return trans('texts.set_name');
         }
     }
     return false;
 }
 /**
  * 특정 회원의 지정된 알람을 삭제
  * @param String membertoken
  * @param Integer alarmseq
  * @return Array
  */
 public function removeAlarm($membertoken, $alarmseq)
 {
     // 멤버 토큰을 통해 멤버 가져옴.
     $memberToken = Membertoken::where('token', $membertoken)->first();
     $member = $memberToken->member()->first();
     $memberAlarm = Alarm::find($alarmseq);
     // 알람 업데이트
     if (isset($memberAlarm)) {
         if ($memberAlarm->memberSeq == $member->seq) {
             $affectedRow = $memberAlarm->delete();
             return Utils::result($affectedRow);
         }
     }
     return Utils::result(Utils::CANNOT_FIND_ALARM, true);
 }
Ejemplo n.º 28
0
 /**
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\BinaryFileResponse
  */
 public function firmwareStore(Request $request)
 {
     // Avoid PHP timeouts when querying large clusters
     set_time_limit(0);
     //Get the authenticated users active cluster
     $cluster = \Auth::user()->activeCluster();
     //Get the file submitted from the form
     $file = $request->file('file');
     //Make sure the file is a csv and redirect back if it's not
     if ($file->getClientMimeType() != "text/csv" && $file->getClientOriginalExtension() != "csv") {
         alert()->error('File type invalid.  Please use a CSV file format.');
         return redirect()->back();
     }
     //Create new Keboola\Csv Object with the submitted file
     $csvFile = new CsvFile($file);
     $csv = '';
     //Loop the csv file and store the device names in an array
     foreach ($csvFile as $key => $row) {
         $csv[] = $row[0];
     }
     // $deviceList will hold our array for RisPort
     $deviceList = [];
     // Loop device name array and assign devicename to $deviceList
     foreach ($csv as $phone) {
         $deviceList[]['DeviceName'] = $phone;
     }
     //Query the RisPort API to get IP/Registration status
     $devices = Utils::generateEraserList($deviceList, $cluster, false);
     //Get details for the phone_firmware report type
     $report = Report::where('type', 'phone_firmware')->first();
     //Create file name for report
     $fileName = storage_path() . '/' . $report->path . 'firmware-report-' . Carbon::now('America/New_York')->toDateTimeString() . '.csv';
     //Generate new output csv file
     new CsvFile($fileName);
     //Call the App\Jobs\GetPhoneFirmware Job
     $this->dispatch(new $report->job($devices, $fileName, $report->csv_headers));
     //Return a response with the firmware report
     return response()->download($fileName);
 }
Ejemplo n.º 29
0
 public static function wrapAdjustment($adjustment, $currencyId)
 {
     $class = $adjustment <= 0 ? 'success' : 'default';
     $adjustment = Utils::formatMoney($adjustment, $currencyId);
     return "<h4><div class=\"label label-{$class}\">{$adjustment}</div></h4>";
 }
 public function getMemberSleepRecordRecent($membertoken)
 {
     $member = Member::whereHas('token', function ($query) use($membertoken) {
         $query->where('token', $membertoken);
     })->first();
     // 회원의 최근 regIdx 가져옴.
     $recentRegIdx = $this->avgSleepRepo->getLastRegIdx($member);
     // 회원 regidx 에 대한 모든 레코드 가져옴
     $records = $this->sleepRecordRepo->getRecordsByRegIdx($member, $recentRegIdx);
     return Utils::result($records);
 }