Beispiel #1
1
 public function post_new()
 {
     $input = Input::all();
     //grab our input
     $rules = array('name' => 'required|alpha', 'lastName' => 'required|alpha', 'permit' => 'required|min:2', 'lot' => 'required|integer', 'msc' => 'integer', 'ticket' => 'required|min:2|numeric|unique:tickets,ticketID', 'fineAmt' => 'required|numeric', 'licensePlate' => 'required|alpha_num', 'licensePlateState' => 'required|max:2', 'dateIssued' => 'required', 'violations' => 'required', 'areaOfViolation' => 'required|alpha_num', 'appealLetter' => 'required|max:700');
     //validation rules
     $validation = Validator::make($input, $rules);
     //let's run the validator
     if ($validation->fails()) {
         return Redirect::to('appeal/new')->with_errors($validation);
     }
     //hashing the name of the file uploaded for security sake
     //then we'll be dropping it into the public/uploads file
     //get the file extension
     $extension = File::extension($input['appealLetter']['name']);
     //encrypt the file name
     $file = Crypter::encrypt($input['appealLetter']['name'] . time());
     //for when the crypter likes to put slashes in our scrambled filname
     $file = preg_replace('#/+#', '', $file);
     //concatenate extension and filename
     $filename = $file . "." . $extension;
     Input::upload('appealLetter', path('public') . 'uploads/', $filename);
     //format the fine amount in case someone screws it up
     $fineamt = number_format(Input::get('fineAmt'), 2, '.', '');
     //inserts the form data into the database assuming we pass validation
     Appeal::create(array('name' => Input::get('name'), 'lastName' => Input::get('lastName'), 'permitNumber' => Input::get('permit'), 'assignedLot' => Input::get('lot'), 'MSC' => Input::get('msc'), 'ticketID' => Input::get('ticket'), 'fineAmt' => $fineamt, 'licensePlate' => Str::upper(Input::get('licensePlate')), 'licensePlateState' => Input::get('licensePlateState'), 'dateIssued' => date('Y-m-d', strtotime(Input::get('dateIssued'))), 'violations' => Input::get('violations'), 'areaOfViolation' => Input::get('areaOfViolation'), 'letterlocation' => URL::to('uploads/' . $filename), 'CWID' => Session::get('cwid')));
     return Redirect::to('appeal/')->with('alertMessage', 'Appeal submitted successfully.');
 }
 /**
  * Return the credentials for the call.
  * 
  * @return mixed The array of credentials or an empty array if we couldn't find them, or false if the supplied
  * 					credentials were in an invalid format
  */
 public static function get_credentials()
 {
     if (\V1\APIRequest::is_static()) {
         return static::decode_credentials(\V1\Model\APIs::get_api());
     } else {
         $account_data = \V1\Model\Account::get_account();
         /**
          * Check for stored credentials
          */
         $formatted_credentials = static::decode_credentials($account_data);
         /**
          * Credentials provided through the request
          */
         if (is_array($posted_credentials = \V1\APIRequest::get('auth', false)) && !empty($posted_credentials)) {
             foreach ($posted_credentials as $variable => $value) {
                 // Bad format
                 if (!is_string($value)) {
                     return false;
                 }
                 $formatted_credentials[\Str::upper($variable)] = $value;
             }
             // Do they want the credentials stored in the DB?
             if ($account_data['store_credentials'] === 1) {
                 // Store their credentials encrypted.
                 $credentials[\V1\APIRequest::get('api')] = $formatted_credentials;
                 $existing_credentials = static::decode_credentials($account_data);
                 $credentials = array_replace_recursive($existing_credentials, $credentials);
                 $credentials_encrypted = \Crypt::encode(json_encode($credentials));
                 \V1\Model\AccountsMetaData::set_credentials($account_data['id'], $credentials_encrypted);
             }
         }
         return $formatted_credentials;
     }
 }
Beispiel #3
0
 public function getItemAttribute()
 {
     if (empty($this->item_type)) {
         return null;
     }
     // todo fix this to be right
     $model = '\\' . \Str::upper($this->item_type);
     return $model::find($this->item_id);
 }
Beispiel #4
0
 public static function applyclaims($input)
 {
     $user = new Claims_App();
     $refno = 'MC' . Str::upper(Str::random(4, 'alpha')) . time();
     try {
         $id = $user->insert_get_id(array('claimscat' => $input['claimscat'], 'flowid' => $input['claimscat'], 'claimsref' => $refno, 'status' => Flow::next(), 'userid' => Auth::user()->userid, 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s"), 'applymonth' => $input['applymonth']));
         Log::write('Claims', 'Claims Application ' . $refno . ' successfully created');
         return $id;
     } catch (Exception $e) {
         Log::write('Claims', 'Claims Application not success');
     }
 }
 /**
  * breadcrumb function
  * Create breadcrumb
  * @return string
  * @author joharijumali
  **/
 public static function breadcrumb()
 {
     $Menu = Admin_Menu::menuGenerator();
     $butternbread = array();
     foreach ($Menu as $floor => $packet) {
         foreach ($packet->page->action as $key => $action) {
             if ($packet->packet == Str::lower(URI::segment(1)) && $packet->controller->name == Str::lower(URI::segment(2)) && $action->name == Str::lower(URI::segment(3)) || URI::segment(3) == NULL && $action->name == $packet->controller->name && Str::lower(URI::segment(2)) == $packet->controller->name) {
                 $butternbread[Str::upper($packet->controller->alias)] = '#';
                 array_push($butternbread, Str::title($action->alias));
             }
         }
     }
     return Breadcrumb::create($butternbread);
 }
Beispiel #6
0
 public function post_datagroup()
 {
     $input = Input::get();
     $existed = Group::checkTable($input['group_model'], $input['group_key']);
     if ($existed) {
         if ($input['groupid'] == NULL) {
             $dataGroup = new Group();
         } else {
             $dataGroup = Group::find($input['groupid']);
         }
         $dataGroup->group_name = Str::upper($input['group_name']);
         $dataGroup->group_model = $input['group_model'];
         $dataGroup->group_key = $input['group_key'];
         $dataGroup->save();
         return json_encode(Group::listData());
     } else {
         return json_encode(array('fail' => Str::title(Lang::line('admin.groupfail')->get())));
     }
 }
Beispiel #7
0
 /**
  * Write a message to the log file.
  *
  * <code>
  *		// Write an "error" message to the log file
  *		Log::write('error', 'Something went horribly wrong!');
  *
  *		// Log an arrays data
  *		Log::write('info', array('name' => 'Sawny', 'passwd' => '1234', array(1337, 21, 0)));
  *      //Result: Array ( [name] => Sawny [passwd] => 1234 [0] => Array ( [0] => 1337 [1] => 21 [2] => 0 ) )
  * </code>
  *
  * @param  string  $type
  * @param  string  $message
  * @return void
  */
 public static function write($type, $message)
 {
     if (is_array($message) || is_object($message)) {
         $message = print_r($message, true);
     }
     $trace = debug_backtrace();
     foreach ($trace as $item) {
         if (isset($item["class"]) and $item["class"] == __CLASS__) {
             continue;
         }
         $caller = $item;
         break;
     }
     $function = $caller["function"];
     if (isset($caller["class"])) {
         $class = $caller["class"] . "::";
     } else {
         $class = "";
     }
     File::mkdir(J_APPPATH . "storage" . DS . "logs" . DS);
     File::append(J_APPPATH . "storage" . DS . "logs" . DS . date("Y-m-d") . ".log", date("Y-m-d H:i:s") . " " . Str::upper($type) . " - " . $class . $function . " - " . $message . CRLF);
 }
Beispiel #8
0
 public function __construct($name, $label, $path)
 {
     parent::__construct($name, $label);
     $this->type = "upload";
     $id = uniqueID();
     $this->sessionKey = "manager_" . $this->type . $id;
     $this->updateURL = "fields/" . $this->type . $id;
     $this->limit = 1;
     $this->hasCaption = false;
     $this->path = $path;
     $this->defaultValue = array();
     $this->accepts = array();
     $this->acceptsMask = null;
     $that = $this;
     Router::register("POST", "manager/api/" . $this->updateURL . "/(:segment)/(:num)/(:segment)", function ($action, $id, $flag) use($that) {
         if (($token = User::validateToken()) !== true) {
             return $token;
         }
         $flag = Str::upper($flag);
         $that->module->flag = $flag;
         switch ($action) {
             default:
             case "update":
                 return Response::json($that->upload($flag, $id));
                 break;
             case "sort":
                 return Response::json($that->sort(Request::post("from", -1), Request::post("to", -1)));
                 break;
             case "caption":
                 return Response::json($that->setCaption((int) Request::post("index", -1), Request::post("caption")));
                 break;
             case "delete":
                 return Response::json($that->delete((int) Request::post("index", -1)));
                 break;
         }
         return Response::code(500);
     });
 }
 public static function render()
 {
     $rolelist = Admin_UserRole::all();
     $page = Acltree::datasource();
     //all();
     $acl = Admin_UserAcl::aclRegistered();
     $content = array();
     $fot = 1;
     foreach ($rolelist as $role) {
         $subcontent = '<h3>' . Str::upper($role->role . " Setup") . '</h3>';
         $subcontent .= '<ul class="nav nav-list">';
         foreach ($page as $controller => $selection) {
             $subcontent .= '<li class="nav-header"><i class="icon-hdd"></i>&nbsp;' . Str::upper($selection['alias']) . '</li>';
             $subcontent .= '<div class="row-fluid">';
             foreach ($selection['page'] as $action => $alias) {
                 $subcontent .= '<span style="padding-right:5px;width:auto;">';
                 $subcontent .= Form::hidden($role->role . '[id]', $role->roleid);
                 if (in_array($role->roleid, array_keys($acl)) && in_array($controller, array_keys($acl[$role->roleid])) && in_array($action, array_keys($acl[$role->roleid][$controller])) && $acl[$role->roleid][$controller][$action] == true) {
                     $subcontent .= Form::inline_labelled_checkbox($role->role . '[' . $controller . '][' . $action . ']', Str::title($alias), null, array('checked' => true, 'style' => 'padding:2px'));
                 } else {
                     $subcontent .= Form::inline_labelled_checkbox($role->role . '[' . $controller . '][' . $action . ']', $alias);
                 }
                 $subcontent .= '</span>';
             }
             $subcontent .= '</div >';
             $subcontent .= '<li class="divider"></li>';
         }
         $subcontent .= '</ul>';
         $active = $fot == 1 ? true : false;
         $fot++;
         array_push($content, array(Str::upper($role->role), $subcontent, $active));
     }
     $nav = Navigation::links($content);
     $tab = Tabbable::tabs_left($nav);
     return $tab;
 }
 /**
  * Run the request
  * 
  * @param \Raml\SecurityScheme $securityscheme_obj The security scheme to process the call data for
  * @param \V1\APICall $apicall_obj					The APICall object
  * 
  * @return mixed The object we just completed or an array describing the next step in the security process
  */
 public function run(\Raml\SecurityScheme $securityscheme_obj, \V1\APICall $apicall_obj)
 {
     $settings = $securityscheme_obj->getSettings();
     $credentials = $apicall_obj->get_credentials();
     // Save the credentials
     \V1\Keyring::set_credentials($credentials);
     /**
      * By default we'll return the response from the authentication request so that it's meaningful.
      * However, in doing so, we'll need to block the main request, so developers may set this flag
      * to ignore the authentication, signifying that they've already got the information they needed
      * from it.
      * 
      * NOTE: This security method is meant as a basic way to catch security methods we otherwise
      * haven't implemented in our system. Take it for what it's worth. 
      * 
      * @TODO When using this security method, skip processing the APICall object for a speedup.
      */
     if (!empty($credentials['CUSTOM_IGNORE_AUTH'])) {
         return true;
     }
     // Remove unused credentials so as not to replace bad variables in the template.
     foreach ($credentials as $variable => $entry) {
         if (strpos($variable, 'CUSTOM_') !== 0) {
             unset($credentials[$variable]);
         }
     }
     // We need the method or we'll fail the call.
     if (empty($settings['method'])) {
         $this->error = true;
         return $this;
     }
     // Normalize the data into arrays.
     $described_by = $securityscheme_obj->getDescribedBy();
     $headers = $this->get_param_array($described_by->getHeaders());
     $query_params = $this->get_param_array($described_by->getQueryParameters());
     $bodies = $described_by->getBodies();
     $method = \Str::upper($settings['method']);
     $url = $settings['url'];
     // Grab the body if we have one, and the method supports one.
     $body = null;
     $body_type = null;
     if (count($bodies) > 0 && !in_array($method, array('GET', 'HEAD'))) {
         reset($bodies);
         $body_type = key($bodies);
         $body = $bodies[$body_type]->getExamples()[0];
     }
     /**
      * NOTE: These replacements may ruin the formatting or allow for people to inject data into them.
      * API Providers should be aware of that possibility.
      * 
      * @TODO In the future, we can consider implementing checking to verify that people aren't sending
      * crap data through the system.
      */
     $headers = $this->remove_cr_and_lf($this->replace_variables($headers, $credentials));
     $query_params = $this->remove_cr_and_lf($this->replace_variables($query_params, $credentials));
     $body = $this->replace_variables($body, $credentials);
     if (!empty($query_params)) {
         $query_string = http_build_query($query_params, null, '&');
         if (strpos($url, '?') === false) {
             $url .= '?' . $query_string;
         } else {
             $url .= '&' . $query_string;
         }
     }
     /**
      * RUNCLE RICK'S RAD RUN CALLS (The second coming!)
      */
     $curl = \Remote::forge($url, 'curl', $method);
     // Set the headers
     $headers = \V1\RunCall::get_headers($headers);
     foreach ($headers as $header_name => $header_value) {
         $curl->set_header($header_name, $header_value);
     }
     // Return the headers
     $curl->set_option(CURLOPT_HEADER, true);
     // If we need a body, set that.
     if (!empty($body) && !in_array($method, array('GET', 'HEAD'))) {
         $curl->set_header('Content-Type', $body_type);
         $curl->set_params($body);
     }
     // Run the request
     try {
         $response = $curl->execute()->response();
     } catch (\RequestStatusException $e) {
         $response = \Remote::get_response($curl);
     } catch (\RequestException $e) {
         $this->error = true;
         return $this;
     }
     // Set the usage stats, and format the response
     return \V1\Socket::prepare_response(array('status' => $response->status, 'headers' => $response->headers, 'body' => $response->body));
 }
 public static function generate()
 {
     $admin = Arcone::getadministrator();
     $totalStruct = $struct = Arcone::getstructures();
     $structModeling = Admin_ModulPage::getRegPages();
     $totalStruct = Arcone::getallstructures();
     $view = '<ul class="nav nav-list">';
     foreach ($totalStruct as $modul => $content) {
         if (!empty($structModeling[$modul])) {
             $view .= '<li class="nav-header alert alert-info"><i class="icon-hdd"></i>&nbsp;' . Str::upper($modul) . '</li>';
             $view .= Form::hidden($modul . '[id]');
             $registered = !empty($structModeling[$modul]) ? 'alert alert-success' : 'alert';
             $view .= '<li class="' . $registered . '">';
             $idiv = count($content);
             foreach ($content as $submodul => $subcontent) {
                 if (isset($structModeling[$modul][$submodul])) {
                     $view .= '<ul class="nav nav-list">';
                     $view .= '<li style="height:30px" ><i class="icon-folder-close"></i>&nbsp;' . Str::title($submodul);
                     $submodulID = isset($structModeling[$modul][$submodul]) ? $structModeling[$modul][$submodul]['modulpageid'] : null;
                     $view .= Form::hidden($modul . '[' . $submodul . '][id]', $submodulID);
                     // 			$view .= '<div class="span6 form-inline pull-right" >';
                     // 			$submodulArrg = isset($structModeling[$modul][$submodul])?$structModeling[$modul][$submodul]['arrangement']:null;
                     // $view .= Form::mini_text($modul.'['.$submodul.'][arrangement]', $submodulArrg , array('class' => 'input-small',
                     // 	'style'=>'height:10px;width:10px;box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);background:none repeat scroll 0 0 rgba(0, 0, 0, 0.2);color:#fff','placeholder' => '#'));
                     // $submodulAlias = isset($structModeling[$modul][$submodul])? $structModeling[$modul][$submodul]['controlleralias']:'';
                     // $view .= Form::mini_text($modul.'['.$submodul.'][controlleralias]', $submodulAlias, array('class' => 'input-small','style'=>'height:10px;font-size:12px;','placeholder' => 'Alias'));
                     // $view .= '&nbsp;';
                     // $submodulVisible = isset($structModeling[$modul][$submodul])? $structModeling[$modul][$submodul]['visible']:0;
                     // $submodulVisibleChecked = ($submodulVisible == 1)? array('checked') : array();
                     // $view .= Form::labelled_checkbox($modul.'['.$submodul.'][show]', '<em><small>Show</small></em>',null,$submodulVisibleChecked);
                     // $view .= '&nbsp;';
                     // $submodulAuth = isset($structModeling[$modul][$submodul])? $structModeling[$modul][$submodul]['auth']:0;
                     // $submodulAuthChecked = ($submodulAuth == 1)? array('checked') : array();
                     // $view .= Form::labelled_checkbox($modul.'['.$submodul.'][auth]', '<em><small>Auth</small></em>',null,$submodulAuthChecked);
                     // $view .= '&nbsp;';
                     // $submodulAdmin = isset($structModeling[$modul][$submodul]['admin'])? $structModeling[$modul][$submodul]['admin']:0;
                     // $submodulAdminChecked = ($submodulAdmin == 1)? array('checked') : array();
                     // $view .= Form::labelled_checkbox($modul.'['.$submodul.'][admin]', '<em><small>Admin Only</small></em>',null,$submodulAdminChecked);
                     // $view .= '&nbsp;';
                     // 			$view .= '</div>';
                     $view .= '</li>';
                     $arrayBal = array();
                     $view .= '<li ><ul class="nav nav-list">';
                     foreach ($subcontent as $action) {
                         $registered = !isset($structModeling[$modul][$submodul][$action]) ? 'class ="alert" style="border:none;background-color:transparent;padding:0px;height:30px;margin-bottom:0px;" ' : 'style="height:30px" ';
                         $view .= '<li ' . $registered . '>';
                         $view .= '<i class="icon-list-alt "></i>&nbsp;' . Str::title($action) . '&nbsp;<em><small>' . Str::title($modul . '/' . $submodul . '/' . $action) . '</small></em>';
                         $actionID = isset($structModeling[$modul][$submodul][$action]) ? $structModeling[$modul][$submodul][$action]['modulpageid'] : null;
                         $view .= Form::hidden($modul . '[' . $submodul . '][' . $action . '][id]', $actionID);
                         $view .= '<div class="span6 form-inline pull-right" >';
                         $actionArrg = isset($structModeling[$modul][$submodul][$action]) ? $structModeling[$modul][$submodul][$action]['arrangement'] : null;
                         $view .= Form::mini_text($modul . '[' . $submodul . '][' . $action . '][arrangement]', $actionArrg, array('class' => 'input-small', 'style' => 'height:10px;width:10px', 'placeholder' => '#'));
                         $actionAlias = isset($structModeling[$modul][$submodul][$action]) ? $structModeling[$modul][$submodul][$action]['actionalias'] : '';
                         $view .= Form::mini_text($modul . '[' . $submodul . '][' . $action . '][actionalias]', $actionAlias, array('class' => 'input-small', 'style' => 'height:10px;font-size:12px;', 'placeholder' => 'Alias'));
                         $view .= '&nbsp;';
                         $actionVisible = isset($structModeling[$modul][$submodul][$action]) ? $structModeling[$modul][$submodul][$action]['visible'] : 0;
                         $actionVisibleChecked = $actionVisible == 1 ? array('checked') : array();
                         $view .= Form::labelled_checkbox($modul . '[' . $submodul . '][' . $action . '][show]', '<em><small>Show</small></em>', null, $actionVisibleChecked);
                         $view .= '&nbsp;';
                         $actionAuth = isset($structModeling[$modul][$submodul][$action]) ? $structModeling[$modul][$submodul][$action]['auth'] : 0;
                         $actionAuthChecked = $actionAuth == 1 ? array('checked') : array();
                         $view .= Form::labelled_checkbox($modul . '[' . $submodul . '][' . $action . '][auth]', '<em><small>Auth</small></em>', null, $actionAuthChecked);
                         $view .= '&nbsp;';
                         $actionAdmin = isset($structModeling[$modul][$submodul][$action]) ? $structModeling[$modul][$submodul][$action]['admin'] : 0;
                         $actionAdminChecked = $actionAdmin == 1 ? array('checked') : array();
                         $view .= Form::labelled_checkbox($modul . '[' . $submodul . '][' . $action . '][admin]', '<em><small>Admin Only</small></em>', null, $actionAdminChecked);
                         $view .= '&nbsp;';
                         $view .= '</div>';
                         $view .= '</li>';
                         unset($structModeling[$modul][$submodul][$action]);
                     }
                     $view .= '</ul></li>';
                     $idiv--;
                     if ($idiv != 0) {
                         $view .= '<li class="divider"></li>';
                     }
                     unset($structModeling[$modul][$submodul]['modulpageid']);
                     unset($structModeling[$modul][$submodul]['arrangement']);
                     unset($structModeling[$modul][$submodul]['controlleralias']);
                     unset($structModeling[$modul][$submodul]['visible']);
                     unset($structModeling[$modul][$submodul]['auth']);
                     unset($structModeling[$modul][$submodul]['admin']);
                     unset($structModeling[$modul][$submodul]['header']);
                     unset($structModeling[$modul][$submodul]['footer']);
                     if (!empty($structModeling[$modul][$submodul])) {
                         $view .= '<li class="alert-error">';
                         foreach ($structModeling[$modul][$submodul] as $deletedaction => $deletedcontent) {
                             $view .= '<ul class="nav nav-list">';
                             $view .= '<li>';
                             $view .= '<i class="icon-remove"></i>&nbsp;' . Str::title($deletedcontent['actionalias']) . '&nbsp;<em>' . $modul . '/' . $submodul . '/' . $deletedaction . '</em>';
                             $view .= Form::hidden($modul . '[' . $submodul . '][' . $deletedaction . '][id]', $deletedcontent['modulpageid']);
                             $view .= '<div class="span6 form-inline pull-right" >';
                             $view .= Form::labelled_checkbox($modul . '[' . $submodul . '][' . $deletedaction . '][remove]', '<em><small>Remove</small></em>');
                             $view .= '</div>';
                             $view .= '</li>';
                             $view .= '</ul >';
                             unset($structModeling[$modul][$submodul][$deletedaction]);
                         }
                         $view .= '</li>';
                     }
                     $view .= '</ul>';
                     if (empty($structModeling[$modul][$submodul])) {
                         unset($structModeling[$modul][$submodul]);
                         unset($structModeling[$modul]['modulalias']);
                     }
                 }
             }
             $view .= '</li>';
             if (empty($structModeling[$modul])) {
                 unset($structModeling[$modul]);
             }
         }
     }
     if (!empty($structModeling)) {
         $view .= '<li class="divider"></li>';
         foreach ($structModeling as $modulDeleted => $contentDeleted) {
             $view .= '<li class="nav-header alert alert-error"><i class="icon-hdd"></i>&nbsp;' . Str::upper($modulDeleted) . '</li>';
             unset($contentDeleted['modulalias']);
             $view .= '<li class="alert alert-error">';
             $view .= '<ul class="nav nav-list">';
             foreach ($contentDeleted as $submodulDeleted => $subcontentDeleted) {
                 $view .= '<li  style="height:30px;">';
                 $view .= '<i class="icon-remove"></i>&nbsp;' . Str::title($subcontentDeleted['controlleralias']) . '&nbsp;<em>' . $modulDeleted . '/' . $submodulDeleted . '</em>';
                 $view .= Form::hidden($modulDeleted . '[' . $submodulDeleted . '][id]', $subcontentDeleted['modulpageid']);
                 $view .= '<div class="span6 form-inline pull-right" >';
                 $view .= Form::labelled_checkbox($modulDeleted . '[' . $submodulDeleted . '][remove]', '<em><small>Remove</small></em>');
                 $view .= '</div>';
                 $view .= '</li>';
                 unset($subcontentDeleted['controlleralias']);
                 unset($subcontentDeleted['visible']);
                 unset($subcontentDeleted['auth']);
                 unset($subcontentDeleted['admin']);
                 unset($subcontentDeleted['header']);
                 unset($subcontentDeleted['footer']);
                 unset($subcontentDeleted['arrangement']);
                 unset($subcontentDeleted['modulpageid']);
                 $view .= '<li >';
                 $view .= '<ul class="nav nav-list">';
                 foreach ($subcontentDeleted as $deletedaction => $deletedcontent) {
                     $view .= '<li style="height:30px;">';
                     $view .= '<i class="icon-remove"></i>&nbsp;' . Str::title($deletedcontent['actionalias']) . '&nbsp;<em>' . $modulDeleted . '/' . $submodulDeleted . '/' . $deletedaction . '</em>';
                     $view .= Form::hidden($modulDeleted . '[' . $submodulDeleted . '][' . $deletedaction . '][id]', $deletedcontent['modulpageid']);
                     $view .= '<div class="span6 form-inline pull-right" >';
                     $view .= Form::labelled_checkbox($modulDeleted . '[' . $submodulDeleted . '][' . $deletedaction . '][remove]', '<em><small>Remove</small></em>');
                     $view .= '</div>';
                     $view .= '</li>';
                     unset($structModeling[$modulDeleted][$submodulDeleted][$deletedaction]);
                 }
                 $view .= '</ul >';
                 $view .= '</li>';
             }
             $view .= '</ul>';
             $view .= '</li>';
         }
     }
     $view .= '</ul>';
     return $view;
 }
 /**
  * Format a log message for logging.
  *
  * @param  string  $type
  * @param  string  $message
  * @return string
  */
 protected static function format($type, $message)
 {
     return date('Y-m-d H:i:s') . ' ' . Str::upper($type) . " - {$message}" . PHP_EOL;
 }
Beispiel #13
0
 private function execDBFunc($func, $name)
 {
     $alias = Str::lower($func);
     $func = Str::upper($func);
     if ($name != "*") {
         $name = $this->quoteField($name);
     }
     $this->selectRaw($func . "(" . $name . ")", $alias);
     $orm = $this->findFirst();
     $result = 0;
     if ($orm) {
         $result = $orm->{$alias};
     }
     array_pop($this->selectFields);
     if (count($this->selectFields) == 0) {
         $this->selectFields = "*";
     }
     if ((int) $result == (double) $result) {
         return (int) $result;
     } else {
         return (double) $result;
     }
 }
Beispiel #14
0
 /**
  * Write a message to the log file.
  *
  * <code>
  *		// Write an "error" messge to the log file
  *		Log::write('error', 'Something went horribly wrong!');
  *
  *		// Write an "error" message using the class' magic method
  *		Log::error('Something went horribly wrong!');
  * </code>
  *
  * @param  string  $type
  * @param  string  $message
  * @return void
  */
 public static function write($type, $message)
 {
     $message = date('Y-m-d H:i:s') . ' ' . Str::upper($type) . " - {$message}" . PHP_EOL;
     File::append(path('storage') . 'logs/' . date('Y-m-d') . '.log', $message);
 }
Beispiel #15
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //Get book name from session
     $title = Session::get('book_title');
     //Set variables
     $data['issue_id'] = $id;
     $book_id = Comicbooks::series($title)->select('comicdb_books.id')->first();
     $book_issue = Comicissues::issues($title, $id)->select('book_id', 'issue_id')->first();
     //If book issue exists, then get data for it
     if (!is_null($book_issue)) {
         $data['book_title'] = '<em>' . Str::upper($title) . '</em>';
         $data['book_id'] = Comicbooks::series($title)->select('comicdb_books.id')->first();
         $data['book_info'] = Comicissues::issues($title, $id)->select('issue_id', 'summary', 'published_date', 'cover_image', 'artist_name', 'author_name')->distinct()->get();
         $this->layout->content = View::make('editissues', $data);
     } else {
         return Redirect::to('browse')->with('postMsg', 'Looks like that issue does not exist! Please check out any other titles here.');
     }
 }
| implementation in your application.
|
*/
IoC::singleton('fireanbu', function () {
    $fb = new FirePHP();
    $fb->setEnabled(Config::get('fireanbu::fireanbu.profiler', true));
    return $fb;
});
/*
|--------------------------------------------------------------------------
| Listen to `laravel.log` events
|--------------------------------------------------------------------------
*/
Event::listen('laravel.log', function ($type, $message) {
    $fb = IoC::resolve('fireanbu');
    switch (Str::upper($type)) {
        case FirePHP::INFO:
        case FirePHP::WARN:
        case FirePHP::LOG:
        case FirePHP::ERROR:
            $fb->{$type}($message);
            break;
        default:
            $fb->log($message);
            break;
    }
});
/*
|--------------------------------------------------------------------------
| Listen to `laravel.query` events
|--------------------------------------------------------------------------
Beispiel #17
0
 protected function filterTime($value)
 {
     try {
         $value = 'PT' . Str::upper($value);
         $time = Carbon::now()->sub(new DateInterval($value));
         $this->builder->where('created_at', '>', carbon_to_md($time));
     } catch (\Exception $e) {
     }
 }
 /**
  * Set the full URL for an API call.
  */
 protected function set_url()
 {
     if (empty($this->url)) {
         $base_uri = $this->api_def->getBaseUrl();
     } else {
         $base_uri = $this->url;
     }
     // Prevent endless loops.
     foreach (\Config::get('engine.forbidden_domains', array('api.bitapihub.com')) as $domain) {
         if (substr_count($base_uri, $domain) > 0) {
             $this->errors = \Utility::format_error(500, \V1\Err::BAD_DOMAIN, \Lang::get('v1::errors.bad_domain'));
             return false;
         }
     }
     // Custom calls cannot use the non-existant RAML data for the call.
     if (\V1\APIRequest::get('api', false) !== 'custom') {
         if ($this->custom_dynamic === true) {
             $route = $this->api_def;
         } else {
             $route = $this->api_def->getResourceByUri($this->raml_route)->getMethod($this->method);
         }
         // Base URI Parameters
         foreach ($route->getBaseUriParameters() as $named_parameter => $named_parameter_obj) {
             $base_uri = str_replace('{' . $named_parameter . '}', $named_parameter_obj->getDefault(), $base_uri);
         }
     }
     /**
      * Protocols
      */
     // Force HTTPS only on integrated APIs stating that they have that capability.
     if (\V1\APIRequest::get('api') !== 'custom') {
         // If the URL is an HTTP URL, but it supports HTTPS, we'll use HTTPS.
         if (substr($base_uri, 0, 7) === 'http://' && $route->supportsHttps()) {
             $base_uri = 'https://' . substr($base_uri, 7);
         }
     } else {
         $protocols = $this->api_def->getProtocols();
         $url_protocol = \Str::upper(parse_url($base_uri, PHP_URL_SCHEME));
         // No protocol specified, so we default to HTTP since every server speaks it.
         if (empty($url_protocol)) {
             $base_uri = 'http://' . $base_uri;
         } elseif (!in_array($url_protocol, $protocols)) {
             // Invalid protocol specified.
             $this->errors = \Utility::format_error(400, \V1\Err::BAD_PROTOCOL, \Lang::get('v1::errors.bad_protocol', array('protocols' => implode(', ', $protocols))));
             return false;
         }
     }
     $query_string = null;
     // $query_params is used only for validation, so we don't need it on custom dynamic calls.
     if ($this->custom_dynamic === false) {
         $this->query_params = $this->api_def->getResourceByUri($this->raml_route)->getMethod($this->method)->getQueryParameters();
     } else {
         $this->query_params = array();
     }
     // If we have an error or unusable data, then fail.
     if (!is_array($this->query_params = static::validate_params($this->query_params, 'query'))) {
         return false;
     }
     // We'll need to fix some symbols.
     if (!empty($this->query_params)) {
         $query_string = '?' . http_build_query($this->query_params, null, '&');
     }
     // Set the parsed URL with the call URI and any query parameters attached.
     $this->url = $base_uri . $this->call_uri . $query_string;
 }
Beispiel #19
0
 protected function _config($key)
 {
     if (isset($_SERVER['CLI'][Str::upper($key)])) {
         return $_SERVER['CLI'][Str::upper($key)] == '' ? true : $_SERVER['CLI'][Str::upper($key)];
     } else {
         return false;
     }
 }
Beispiel #20
0
 /**
  * Test the Str::upper method.
  *
  * @group laravel
  */
 public function testStringCanBeConvertedToUppercase()
 {
     $this->assertEquals('TAYLOR', Str::upper('taylor'));
     $this->assertEquals('ΆΧΙΣΤΗ', Str::upper('άχιστη'));
 }
Beispiel #21
0
 /**
  * Test for Str::upper()
  *
  * @test
  */
 public function test_upper()
 {
     $output = Str::upper('hello world');
     $expected = "HELLO WORLD";
     $this->assertEquals($expected, $output);
 }
Beispiel #22
0
 /**
  * Generates products.
  *
  * @return void
  */
 protected static function products()
 {
     foreach (self::$sellers as $seller) {
         $product = \Service_Product::create('Product Line ' . \Str::upper(\Str::random('alpha', 1)), $seller);
         if ($product) {
             for ($i = 1; $i <= 3; $i++) {
                 $option = \Service_Product_Option::create('Product ' . \Str::upper(\Str::random('alpha', 1)), $product);
                 if ($option) {
                     self::$product_options[$seller->id][] = $option;
                     \Service_Product_Option_Fee::create('Subscription', 1, 'month', mt_rand(5, 15), $option);
                 }
             }
         }
     }
     \Cli::write('Product Simulation Complete', 'green');
 }
Beispiel #23
0
 /**
  * Retrieve a command line switch, as false of not set,
  * true if set with no value, and string if given a value.
  *
  * @param string The switch name to query, lowercase.
  * @return mixed Bool or value.
  */
 public static function config($key)
 {
     if (isset($_SERVER['CLI'][Str::upper($key)])) {
         return $_SERVER['CLI'][Str::upper($key)] == '' ? true : $_SERVER['CLI'][Str::upper($key)];
     } else {
         return false;
     }
 }
Beispiel #24
0
    echo $output;
});
HTML::macro('alert', function ($type, $messages, $head = null) {
    $message = '';
    $count = 1;
    foreach ($messages as $value) {
        $message .= $count++ . '- ' . $value . '<br>';
    }
    $script = '
		<script type="text/javascript">
			setTimeout(function () {
				$(".errors").removeClass("in");
				$(".errors").slideToggle("slow");
			}, 10000);
		</script>';
    return '<div class="errors alert alert-' . $type . '"><strong>' . $head . '</strong>' . Str::upper($message) . '</div>' . $script;
});
Form::macro('selectRange2', function ($name, $begin, $end, $selected = null, $options = array()) {
    $list = '<option></option>';
    $range = array_combine($range = range($begin, $end), $range);
    foreach ($range as $key => $value) {
        $list .= "<option value='{$key}'>{$value}</option>";
    }
    //		Tools::printr($options);
    //		die();
    $options = attributes($options);
    unset($range);
    return '<select name=' . e($name) . $options . '>' . $list . '</select>';
});
function attributes($attributes)
{
 /**
  * Parse the WWW-Authenticate data
  * 
  * @param array $headers The array of headers from the response
  * @return mixed The array of parsed WWW-Authentication data, or boolean false on fail
  */
 private function parse_www_auth(array $headers)
 {
     /*
      * Looking for:
      * WWW-Authenticate: Digest realm="*****@*****.**",qop="auth,auth-int",nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",opaque="5ccc069c403ebaf9f0171e9517f40e41"
      */
     $return = false;
     // Loop the response headers
     foreach ($headers as $header_name => $header_value) {
         // Find the WWW-Authenticate header
         if (\Str::lower($header_name) === 'www-authenticate') {
             $params = explode(' ', $header_value);
             if (\Str::upper($params[0]) !== 'DIGEST') {
                 return false;
             }
             unset($params[0]);
             $param_array = explode(',', implode(' ', $params));
             $return = array();
             // Loop the tokens (array('nonce=675858','poq=...'))
             foreach ($param_array as $param) {
                 // Find that fish!
                 $token_data = explode('=', $param);
                 $token_name = $token_data[0];
                 unset($token_data[0]);
                 // Remove the quotes if we need to.
                 $token_value = implode('=', $token_data);
                 if (substr($token_value, 0, 1) === '"') {
                     $token_value = substr($token_value, 1, strlen($token_value) - 2);
                 }
                 // Set out tokens.
                 $return[$token_name] = $token_value;
             }
             if (empty($return)) {
                 // We found the header and attempted to parse it.
                 return false;
             }
         }
     }
     return $return;
 }
 /**
  * Create an array from the header data
  * 
  * @param array $headers The array of headers from the response
  * @return array The array of headers
  */
 protected static function build_headers(array $headers)
 {
     // Find the status code.
     foreach ($headers as $header_key => $header_data) {
         if (substr(\Str::upper($header_data), 0, 5) === 'HTTP/' && substr_count($header_data, ':') === 0) {
             $http_vers_explode = explode(' ', $header_data);
             if (is_numeric($http_vers_explode[1]) && strlen((int) $http_vers_explode[1]) === 3) {
                 $status_code = (int) $http_vers_explode[1];
                 $headers['BAH-STATUS'] = $status_code;
                 unset($headers[$header_key]);
             }
         } else {
             // Create an array with the header name as the key.
             $header_parts = explode(':', $header_data);
             $header_name = trim($header_parts[0]);
             unset($header_parts[0]);
             $headers[$header_name] = trim(implode(':', $header_parts));
             unset($headers[$header_key]);
         }
     }
     if (empty($headers['BAH-STATUS'])) {
         $headers['BAH-STATUS'] = 200;
     }
     return $headers;
 }