/** * updates title and description of an activity * @param array $activityDetails * @param Activity $activity * @return bool */ public function update(array $activityDetails, Activity $activity) { try { $this->database->beginTransaction(); $this->stepTwoRepo->update($activityDetails, $activity); $this->database->commit(); $this->logger->info('Step Two Completed!', ['for' => [$activity->title, $activity->description]]); $this->logger->activity("activity.step_two_completed", ['activity_id' => $activity->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]); return true; } catch (Exception $exception) { $this->database->rollback(); $this->logger->error($exception, ['stepTwo' => $activityDetails]); } return false; }
public static function factory($config = array()) { // The following values are required when creating the client $required = array('base_url', 'username', 'password'); // Merge in default settings and validate the config $config = Collection::fromConfig($config, array(), $required); // Create a new sData client $client = new self($config->get('base_url'), $config); // JSON by default $client->setDefaultOption('query/format', 'json'); // Authentication $client->setDefaultOption('auth', array($config->get('username'), $config->get('password'), 'Basic')); // Strip the BOM from results $client->addSubscriber(new StripBomPlugin()); // Optional logging if ($config->get('log')) { $client->getEventDispatcher()->addListener('request.before_send', function (Event $event) { $req = $event['request']; \Log::info('sData', ['request' => $req->getMethod() . ' ' . $req->getResource()]); }); } // Set the service description $services = \Config::get('sdata::services'); if (!empty($services)) { $client->setDescription(ServiceDescription::factory($services)); } // Done return $client; }
function update_judge_status() { if (!isset($_REQUEST['judgeid'], $_REQUEST['status'])) { return; } $status = $_REQUEST['status']; if ($_REQUEST['judgeid'] == 'all') { JudgeDaemon::set_status_all($status); $this->add_message('judge', 'confirm', 'Status of all judges set to ' . JudgeDaemon::status_to_text($status)); Log::info('Status of all judges set to ' . JudgeDaemon::status_to_text($status)); } else { $judge = JudgeDaemon::by_id($_REQUEST['judgeid']); if (!$judge) { return; } // it already died if ($status == JudgeDaemon::MUST_STOP && $judge->is_inactive()) { $status = JudgeDaemon::STOPPED; // stop right now } $judge->set_status($status); $this->add_message('judge', 'confirm', 'Status of judge "' . $judge->name . '" set to ' . $judge->status_text()); Log::info('Status of judge set to ' . $judge->status_text(), null, $judge->name); } }
/** * save new activity from wizard * @param array $identifier * @param $defaultFieldValues * @return bool */ public function store(array $identifier, $defaultFieldValues) { try { $this->database->beginTransaction(); $result = $this->activityRepo->store($identifier, $defaultFieldValues, $this->auth->user()->organization->id); $this->activityRepo->saveDefaultValues($result->id, $defaultFieldValues); $this->database->commit(); $this->logger->info('Activity identifier added!', ['for' => $identifier['activity_identifier']]); $this->logger->activity("activity.activity_added", ['identifier' => $identifier['activity_identifier'], 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]); return $result; } catch (Exception $exception) { $this->database->rollback(); $this->logger->error($exception, ['ActivityIdentifier' => $identifier]); } return false; }
/** * 金曜日になると今週の週報タグを生成する */ public function buildNextWeekTag() { \Log::info('Start generate tag of This week. '); $dt = new Carbon(); // $dt->setTestNow($dt->createFromDate(2015, 5, 31)); if ($dt->now()->dayOfWeek === Carbon::FRIDAY) { //翌月 $nextMonth = $dt->parse('next month')->month; // 現在が何週目か \Log::info('今日は' . $dt->now()->month . '月の第' . $dt->now()->weekOfMonth . '週目です'); //今週の金曜を取得 $thisFriday = $dt->parse('this friday'); \Log::info('来週の金曜は' . $thisFriday); // 月またぎの場合 if ($thisFriday->month === $nextMonth) { \Log::info($thisFriday->year . '年の' . $thisFriday->month . '月の第' . $thisFriday->weekOfMonth . '週目です'); $nextWeekTag = '週報@' . $thisFriday->year . '年' . $thisFriday->month . '月第' . $thisFriday->weekOfMonth . '週'; $this->tag->tag = $nextWeekTag; $this->tag->save(); } else { \Log::info('翌週は' . $thisFriday->month . '月の第' . $thisFriday->weekOfMonth . '週目です'); $nextWeekTag = '週報@' . $thisFriday->year . '年' . $thisFriday->month . '月第' . $thisFriday->weekOfMonth . '週'; $this->tag->tag = $nextWeekTag; $this->tag->save(); } \Log::info('End generate tag'); } else { \Log::info('Today is not Friday.'); } }
/** * Store a newly created qa in storage. * * @return Response */ public function store() { $qa = new Qa(); Session::flash('successMessage', 'Your post has been saved.'); Log::info(Input::all()); return $this->validateAndSave($qa); }
/** * @return bool|mixed * @throws \DreamFactory\Core\Events\Exceptions\ScriptException * @throws \DreamFactory\Core\Exceptions\BadRequestException * @throws \DreamFactory\Core\Exceptions\InternalServerErrorException */ protected function processRequest() { // Now all actions must be HTTP verbs if (!Verbs::contains($this->action)) { throw new BadRequestException('The action "' . $this->action . '" is not supported.'); } $logOutput = $this->request->getParameterAsBool('log_output', true); $data = ['request' => $this->request->toArray()]; $output = null; $result = ScriptEngineManager::runScript($this->content, 'script.' . $this->name, $this->engineConfig, $this->scriptConfig, $data, $output); if (!empty($output) && $logOutput) { \Log::info("Script '{$this->name}' output:" . PHP_EOL . $output . PHP_EOL); } // Bail on errors... if (is_array($result) && isset($result['script_result'], $result['script_result']['error'])) { throw new InternalServerErrorException($result['script_result']['error']); } if (is_array($result) && isset($result['exception'])) { throw new InternalServerErrorException(ArrayUtils::get($result, 'exception', '')); } // The script runner should return an array if (is_array($result) && isset($result['__tag__'])) { $scriptResult = ArrayUtils::get($result, 'script_result', []); return $scriptResult; } else { Log::error(' * Script did not return an array: ' . print_r($result, true)); } return $output; }
function _loadFromFile($view, $file, $moduleName) { $variables = array(); if (!file_exists($file)) { $this->_fatalError("ModuleBuilderParser: required viewdef file {$file} does not exist"); } Log::info('ModuleBuilderParser->_loadFromFile(): file=' . $file); require $file; // loads in a $viewdefs // Check to see if we have the module name set as a variable rather than embedded in the $viewdef array // If we do, then we have to preserve the module variable when we write the file back out // This is a format used by ModuleBuilder templated modules to speed the renaming of modules // Traditional Sugar modules don't use this format // We must do this in ParserModifyLayout (rather than just in ParserBuildLayout) because we might be editing the layout of a MB created module in Studio after it has been deployed $moduleVariables = array('module_name', '_module_name', 'OBJECT_NAME', '_object_name'); foreach ($moduleVariables as $name) { if (isset(${$name})) { $variables[$name] = ${$name}; } } $viewVariable = $this->_defMap[strtolower($view)]; // Now tidy up the module name in the viewdef array // MB created definitions store the defs under packagename_modulename and later methods that expect to find them under modulename will fail $defs = ${$viewVariable}; if (isset($variables['module_name'])) { $mbName = $variables['module_name']; if ($mbName != $moduleName) { Log::debug('ModuleBuilderParser->_loadFromFile(): tidying module names from ' . $mbName . ' to ' . $moduleName); $defs[$moduleName] = $defs[$mbName]; unset($defs[$mbName]); } } // Log::debug('ModuleBuilderParser->_loadFromFile(): '.print_r($defs,true)); return array('viewdefs' => $defs, 'variables' => $variables); }
private function startQueryLogger() { \DB::listen(function ($event) { $bindings = $event->bindings; $time = $event->time; $query = $event->sql; $data = compact('bindings', 'time'); // Format binding data for sql insertion foreach ($bindings as $i => $binding) { if (is_object($binding) && $binding instanceof \DateTime) { $bindings[$i] = '\'' . $binding->format('Y-m-d H:i:s') . '\''; } elseif (is_null($binding)) { $bindings[$i] = 'NULL'; } elseif (is_bool($binding)) { $bindings[$i] = $binding ? '1' : '0'; } elseif (is_string($binding)) { $bindings[$i] = "'{$binding}'"; } } $query = preg_replace_callback('/\\?/', function () use(&$bindings) { return array_shift($bindings); }, $query); \Log::info($query, $data); }); }
/** * Execute the console command. * * @return mixed */ public function fire() { // Log what we are going to do in the laravel.log file \Log::info('Started command ' . $this->name, array('src' => __CLASS__)); // Get the keys that are not disabled and process them. foreach (\SeatKey::where('isOk', '=', 1)->get() as $key) { // It is important to know the type of key we are working // with so that we may know which API calls will // apply to it. For that reason, we run the // Seat\EveApi\BaseApi\determineAccess() // function to get this. $access = EveApi\BaseApi::determineAccess($key->keyID); // If we failed to determine the access type of the // key, continue to the next key. if (!isset($access['type'])) { //TODO: Log this key's problems and disable it continue; } // If the key is a of type 'Character', then we can // continue to submit a updater job if ($access['type'] == 'Character') { // Do a fresh AccountStatus lookup Account\AccountStatus::update($key->keyID, $key->vCode); // Once the fresh account status lookup is done, call the // addToQueue helper to queue a new job. \App\Services\Queue\QueueHelper::addToQueue('\\Seat\\EveQueues\\Full\\Character', $key->keyID, $key->vCode, 'Character', 'Eve'); } } }
/** * This method registers all the functions on the service class * */ protected function registerFunction() { Log::info('Begin: registry->registerFunction'); parent::registerFunction(); Log::info('END: registry->registerFunction'); // END OF REGISTER FUNCTIONS }
/** * Setting the display of pages * * @uses Arr::merge * @uses Config::load * @uses Message::success */ public function action_settings() { $this->title = __('Page Settings'); $post = Config::load('page'); $action = Route::get('admin/page')->uri(array('action' => 'settings')); $vocabs = array(__('none')); $view = View::factory('admin/page/settings')->set('vocabs', $vocabs)->set('post', $post)->set('action', $action); $vocabs = Arr::merge($vocabs, ORM::factory('term')->where('lft', '=', 1)->where('type', '=', 'page')->find_all()->as_array('id', 'name')); if ($this->valid_post('page_settings')) { unset($_POST['page_settings'], $_POST['_token'], $_POST['_action']); $cats = $post->get('category', array()); foreach ($_POST as $key => $value) { if ($key == 'category') { $terms = array_diff($cats, $value); if ($terms) { DB::delete('posts_terms')->where('parent_id', 'IN', array_values($terms))->execute(); } } $post->set($key, $value); } Log::info('Page Settings updated.'); Message::success(__('Page Settings updated!')); $this->request->redirect(Route::get('admin/page')->uri(array('action' => 'settings')), 200); } $this->response->body($view); }
public function action_login() { if ($this->_auth->logged_in()) { // redirect to the user account $this->request->redirect(Route::get('admin')->uri(), 200); } // Disable sidebars on login page $this->_sidebars = FALSE; $this->title = __('Sign In'); $user = ORM::factory('user'); // Create form action $destination = isset($_GET['destination']) ? $_GET['destination'] : 'admin'; $params = array('action' => 'login'); $action = Route::get('admin/login')->uri($params) . URL::query(array('destination' => $destination)); if ($layout = kohana::find_file('views', 'layouts/login')) { $this->template->set_filename('layouts/login'); } $view = View::factory('admin/login')->set('use_username', Config::get('auth.username'))->set('post', $user)->set('action', $action)->bind('errors', $this->_errors); if ($this->valid_post('login')) { try { // Check Auth $user->login($this->request->post()); // If the post data validates using the rules setup in the user model Message::success(__('Welcome, %title!', array('%title' => $user->nick))); Log::info('User :name logged in.', array(':name' => $user->name)); // redirect to the user account $this->request->redirect(isset($_GET['destination']) ? $_GET['destination'] : 'admin', 200); } catch (Validation_Exception $e) { $this->_errors = $e->array->errors('login', TRUE); } } $this->response->body($view); }
function myErrorHandler($errno, $errstr, $errfile, $errline) { if (!class_exists('Log')) { require YYUC_LIB . 'sys/log.php'; } $err_msg = "信息:{$errno}。内容:{$errstr},发生在文件{$errfile}的{$errline}行"; switch ($errno) { case E_USER_ERROR: Log::error($err_msg); if (Conf::$is_developing) { echo $err_msg; } exit(1); break; case E_USER_WARNING: Log::warn($err_msg); break; case E_USER_NOTICE: Log::info($err_msg); break; default: Log::info($err_msg); break; } return true; }
/** * List of pages (blogs/posts/etc.) with a specific tag * * @throws HTTP_Exception_404 * * @uses Log::add * @uses Text::ucfirst * @uses ACL::check * @uses Meta::links * @uses URL::canonical * @uses Route::url */ public function action_view() { $id = (int) $this->request->param('id', 0); $tag = ORM::factory('tag', $id); if (!$tag->loaded()) { throw HTTP_Exception::factory(404, 'Tag :tag not found!', array(':tag' => $id)); } $this->title = __(':title', array(':title' => Text::ucfirst($tag->name))); $view = View::factory('tag/view')->set('teaser', TRUE)->bind('pagination', $pagination)->bind('posts', $posts); $posts = $tag->posts; if (!ACL::check('administer tags') and !ACL::check('administer content')) { $posts->where('status', '=', 'publish'); } $total = $posts->reset(FALSE)->count_all(); if ($total == 0) { Log::info('No posts found.'); $this->response->body(View::factory('page/none')); return; } $pagination = Pagination::factory(array('current_page' => array('source' => 'cms', 'key' => 'page'), 'total_items' => $total, 'items_per_page' => 15, 'uri' => $tag->url)); $posts = $posts->order_by('created', 'DESC')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all(); $this->response->body($view); // Set the canonical and shortlink for search engines if ($this->auto_render === TRUE) { Meta::links(URL::canonical($tag->url, $pagination), array('rel' => 'canonical')); Meta::links(Route::url('tag', array('action' => 'view', 'id' => $tag->id)), array('rel' => 'shortlink')); } }
/** * Execute the console command. * * @return mixed */ public function handle() { $client = new \Goutte\Client(); foreach (\MkmScraper\Card::all() as $card) { if ($card->todaysPrice()->count() < 1) { $crawler = $client->request('GET', 'https://www.magiccardmarket.eu/Products/Singles/' . rawurlencode($card->set) . '/' . rawurlencode($card->name)); \Log::info('https://www.magiccardmarket.eu/Products/Singles/' . rawurlencode($card->set) . '/' . rawurlencode($card->name)); $available = 0; $lowfinal = 0; $trendfinal = 0; try { if ($av = $crawler->filter('.sectioncontent .availTable .row_0 .cell_0_1')->first()) { $available = $av->text(); } if ($lo = $crawler->filter('.sectioncontent .availTable .row_1 .cell_1_1 span')->first()) { $low = $lo->text(); $lowfinal = str_replace(",", ".", $low); } if ($tr = $crawler->filter('.sectioncontent .availTable .row_2 .cell_2_1')->first()) { $trend = $tr->text(); $trendnumber = explode(" ", $trend); $trendfinal = str_replace(",", ".", $trendnumber[0]); } } catch (Exception $e) { print $e->getMessage(); } $cardPrice = \MkmScraper\CardPrice::create(array("id_card" => $card->id, "low" => $lowfinal, "trend" => $trendfinal, "sellers" => $available)); } } }
public function send_notification($devices, $message) { try { $errCounter = 0; $payload = json_encode(array("aps" => $message)); $result = 0; $bodyError = ""; foreach ($devices as $key => $value) { $msg = chr(0) . pack("n", 32) . pack('H*', str_replace(' ', '', $value)) . pack('n', strlen($payload)) . $payload; $result = fwrite($this->fp, $msg); $bodyError .= 'result: ' . $result . ', devicetoken: ' . $value; if (!$result) { $errCounter = $errCounter + 1; } } //echo "Result :- ".$result; if ($result) { Log::info('Delivered Message to APNS' . PHP_EOL); //echo 'Delivered Message to APNS' . PHP_EOL; $bool_result = true; } else { Log::error('Could not Deliver Message to APNS' . PHP_EOL); //echo 'Could not Deliver Message to APNS' . PHP_EOL; $bool_result = false; } fclose($this->fp); return $bool_result; } catch (Exception $e) { Log::error($e); } }
/** * Execute the console command. * * @return mixed */ public function fire() { // Log what we are going to do in the laravel.log file \Log::info('Started command ' . $this->name, array('src' => __CLASS__)); // Call the addToQueue helper to add a new update job. \App\Services\Queue\QueueHelper::addToQueue('\\Seat\\EveQueues\\Full\\Map', '0', NULL, 'Map', 'Eve'); }
public function get() { $user_id = false; if (Auth::check()) { // Authenticating A User And "Remembering" Them Session::regenerate(); $user_id = Auth::user()->id; if (Auth::user()->accountType == 1) { if (Session::has('admin_session')) { Log::info("admin_session already created before - " . Session::get('admin_session')); } else { Session::put('admin_session', $user_id); Log::info("admin_session created"); } } // Log::info("Session cre8 - " . Session::get('admin_session')); } // else if (Auth::viaRemember()) { // // Determining If User Authed Via Remember // $user_id = Auth::user()->id; // } if (!$user_id) { $error_response = array('error' => array('message' => 'User not logged in.', 'type' => 'OAuthException', 'code' => 400)); Log::info("User not logged in"); return Response::json($error_response, 400)->setCallback(Input::get('callback')); } $user = User::find(Auth::user()->id); return Response::json($user)->setCallback(Input::get('callback')); }
/** * Internal building method builds all static services and some dynamic * services from file annotations, otherwise swagger info is loaded from * database or storage files for each service, if it exists. * * @throws \Exception */ protected static function buildEventMaps() { \Log::info('Building event cache'); // Build event mapping from services in database // Initialize the event map $processEventMap = []; $broadcastEventMap = []; // Pull any custom swagger docs $result = ServiceModel::with(['serviceDocs' => function ($query) { $query->where('format', ApiDocFormatTypes::SWAGGER); }])->get(); // Spin through services and pull the events foreach ($result as $service) { $apiName = $service->name; try { if (empty($content = ServiceModel::getStoredContentForService($service))) { throw new \Exception(' * No event content found for service.'); continue; } $serviceEvents = static::parseSwaggerEvents($apiName, $content); // Parse the events while we get the chance... $processEventMap[$apiName] = ArrayUtils::get($serviceEvents, 'process', []); $broadcastEventMap[$apiName] = ArrayUtils::get($serviceEvents, 'broadcast', []); unset($content, $service, $serviceEvents); } catch (\Exception $ex) { \Log::error(" * System error building event map for service '{$apiName}'.\n{$ex->getMessage()}"); } } static::$eventMap = ['process' => $processEventMap, 'broadcast' => $broadcastEventMap]; // Write event cache file \Cache::forever(static::EVENT_CACHE_KEY, static::$eventMap); \Log::info('Event cache build process complete'); }
public function searchExample($key) { Log::info($this->getTimeToMicroseconds()); $result = $this->querySearch->actionSearchExample($key); Log::info($this->getTimeToMicroseconds()); return Response::json($result); }
/** * Saves/Edits an account * */ public function postEdit($id = false) { if ($id !== false) { $account = CloudAccount::where('user_id', Auth::id())->findOrFail($id); } try { if (empty($account)) { $account = new CloudAccount(); } else { if ($account->user_id !== Auth::id()) { throw new Exception('general.access_denied'); } } $account->name = Input::get('name'); $account->cloudProvider = Input::get('cloudProvider'); $account->credentials = json_encode(Input::get('credentials')); $account->user_id = Auth::id(); // logged in user id $conStatus = CloudProvider::authenticate($account); if ($conStatus == 1) { Log::info('Credentials are encrypted before saving to DB.'); CloudAccountHelper::save($account); return Redirect::intended('account')->with('success', Lang::get('account/account.account_updated')); } else { return Redirect::to('account')->with('error', Lang::get('account/account.account_auth_failed') . ' for ' . $account->cloudProvider); } } catch (Exception $e) { Log::error($e); return Redirect::to('account')->with('error', $e->getMessage()); } }
public function fire($job, $data) { $job_record = \SeatQueueInformation::where('jobID', '=', $job->getJobId())->first(); // Check that we have a valid jobid if (!$job_record) { // Sometimes the jobs get picked up faster than the submitter could write a // database entry about it. So, just wait 5 seconds before we come back and // try again $job->release(5); return; } // We place the actual API work in our own try catch so that we can report // on any critical errors that may have occurred. // By default Laravel will requeue a failed job based on --tries, but we // dont really want failed api jobs to continually poll the API Server try { $job_record->status = 'Working'; $job_record->output = 'Started Teamspeak transfer'; $job_record->save(); $eveTransfer = new EveApi\Eve\TeamspeakTransfer(); $eveTransfer->Update(); \Log::info("done with TS update"); $job_record->status = 'Done'; $job_record->output = null; $job_record->save(); $job->delete(); } catch (\Exception $e) { $job_record->status = 'Error'; $job_record->output = 'Last status: ' . $job_record->output . PHP_EOL . 'Error: ' . $e->getCode() . ': ' . $e->getMessage() . PHP_EOL . 'File: ' . $e->getFile() . ':' . $e->getLine() . PHP_EOL . 'Trace: ' . $e->getTraceAsString() . PHP_EOL . 'Previous: ' . $e->getPrevious(); $job_record->save(); $job->delete(); } }
/** * Execute the console command. * * @return mixed */ public function fire() { $commands = array('cd /home/elegefacil/web/elegefacil.com/', 'php artisan down', 'php artisan clear-compiled', 'git pull origin master', 'php -d memory_limit=-1 /usr/bin/composer install --no-scripts', 'php artisan migrate', 'php artisan optimize', 'php artisan up'); SSH::run($commands, function ($line) { Log::info($line); }); }
/** * Initializer. * * @access public * @return \BaseController */ public function __construct() { $this->beforeFilter('csrf', array('on' => 'post')); $action = explode('@', Route::current()->getAction()['controller'])[1]; Log::info($action); View::share('action', $action); }
/** * May be set as exception handler, i.e. set_exception_handler('alkemann\h2l\handleError'); * * @param \Throwable $e */ function handleError(\Throwable $e) { if ($e instanceof \alkemann\h2l\exceptions\InvalidUrl) { Log::info("InvalidUrl: " . $e->getMessage()); echo (new Error(404, $e->getMessage()))->render(); return; } if ($e instanceof \Exception) { Log::error(get_class($e) . ": " . $e->getMessage()); } elseif ($e instanceof \Error) { Log::alert(get_class($e) . ": " . $e->getMessage()); } if (DEBUG && isset($e->xdebug_message)) { header("Content-type: text/html"); echo '<table>' . $e->xdebug_message . '</table><br>'; dbp('xdebug_message'); d($e); } elseif (DEBUG) { header("Content-type: text/html"); echo '<h1>' . $e->getMessage() . '</h1>'; d($e); } else { (new Error(500, $e->getMessage()))->render(); } }
/** * Create a Job * @return \Illuminate\Http\JsonResponse */ public function create() { Log::info(\Input::all()); $inputdata = \Input::all(); $success = false; $inputdata["mandate_start"] = strtotime($inputdata["mandate_start"]); $inputdata["mandate_end"] = strtotime($inputdata["mandate_end"]); $inputdata["date_of_entry"] = strtotime($inputdata["date_of_entry"]); if ($this->validator->validate(\Input::all())) { $job = Job::create($inputdata); if (\Input::has('skills')) { $skills = []; foreach (\Input::get('skills') as $skill) { $skills[$skill['skill_id']] = ['description' => isset($skill['description']) ? $skill['description'] : '', 'level' => isset($skill['level']) ? $skill['level'] : 0]; } $job->skills()->attach($skills); } if (\Input::get('agent_id')) { $agent = Agent::find(\Input::get('agent_id')); // $job->agents()->attach($agent->user_id); $job->agent_id = $agent->user_id; } } $success = $job == true; return \Response::json(['success' => $success]); }
/** * Return all date in weeks for a month. * * @param Carbon $date The month. * @param integer $firstDayOfWeek The first day of the week. * * @return Array Array of dates. */ public static function getDatesInWeeksForMonth(Carbon $date, $firstDayOfWeek) { Log::info('Get all dates in weeks for month.', compact('date', 'firstDayOfWeek')); $days = array(); $date = $date->copy(); $date->day = 1; // Get next month. $nextMonth; if ($date->month === 12) { $nextMonth = 1; } else { $nextMonth = $date->month + 1; } // Get first day of the first week. if ($date->dayOfWeek > $firstDayOfWeek) { $date->day = -($date->dayOfWeek - $firstDayOfWeek - 1); } else { if ($date->dayOfWeek < $firstDayOfWeek) { $date->day = -(6 - ($firstDayOfWeek - $date->dayOfWeek)); } } // Get rest of the days in weeks until next month and before first day of week. while (!($date->month === $nextMonth && $date->dayOfWeek === $firstDayOfWeek)) { $days[] = Carbon::createFromDate($date->year, $date->month, $date->day); $date->day++; } return $days; }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $directory = 'img/uploads/'; $image = Input::file('img'); $event = new CalendarEvent(); $event->title = Input::get('title'); $event->description = Input::get('description'); $event->date = Input::get('date'); $event->price = Input::get('price'); $event->start_time = Input::get('start_time'); $event->end_time = Input::get('end_time'); $event->location = Input::get('location'); $event->address = Input::get('address'); $event->city = Input::get('city'); $event->state = Input::get('state'); $event->zip = Input::get('zip'); $event->user_id = 1; if (Input::hasFile('img')) { $event->img = $image->move($directory); } $event->save(); Log::info("Event successfully saved.", Input::all()); Session::flash('successMessage', 'You created ' . $event->title . ' event successfully'); return Redirect::action('EventsController@index'); }
public static function getAsJson($file, $force = false) { $json = array(); getimagesize($file, $info); if (isset($info["APP13"])) { $iptc = iptcparse($info["APP13"]); if (isset($iptc['2#120'])) { $caption = implode('|', $iptc['2#120']); // nb: '|' should never actually appear $caption = ensureUTF8($caption); // since could be 'local' encoding $caption = mysql_escape_string($caption); // safety. stackoverflow.com/q/1162491 $json['caption'] = $caption; } if (isset($iptc['2#025'])) { $json['keywords'] = $iptc['2#025']; } // keep as array set_error_handler("ignoreAnyError", E_ALL); // TOTEST, currently no exif enabled on localhost if (function_exists('exif_read_data')) { $json['exif'] = exif_read_data($tmpfile, 0, false); } // fails on a very few files (corrupt EXIF) restore_error_handler(); } Log::info("json for :" . $file); Log::info($json); return $json; }