Esempio n. 1
0
 public function post_login()
 {
     $messages = array('check_login' => Lang::line('auth::lang.Invalid credentials')->get(APP_LANG), 'check_user_status' => Lang::line('auth::lang.This account is inactive. Please contact support')->get(APP_LANG));
     Validator::register('check_login', function ($attribute, $value, $parameters) {
         $credentials = array('username' => Input::get('username'), 'password' => Input::get('password'), 'remember' => Input::get('remember'));
         return Auth::attempt($credentials) ? true : false;
     });
     Validator::register('check_user_status', function ($attribute, $value, $parameters) {
         if (isset(Auth::user()->status) and Auth::user()->status != 'active') {
             Auth::logout();
             return false;
         }
         return true;
     });
     $rules = array('username' => 'required', 'password' => 'required|check_login|check_user_status');
     $validation = Validator::make(Input::all(), $rules, $messages);
     if ($validation->fails()) {
         return Redirect::to('login')->with_input()->with_errors($validation);
     } else {
         if (Session::has('last_page')) {
             $url = Session::get('last_page');
             Session::forget('last_page');
             return Redirect::to($url);
         } else {
             return Redirect::to('/');
         }
     }
     return $this->theme->render('auth::frontend.login', $this->data);
 }
Esempio n. 2
0
 /**
  * Site Setting post
  * @return redirect Redirecting to user list
  */
 public function post_site()
 {
     if (!Auth::can('edit_settings')) {
         Vsession::cadd('y', __('site.not_allowed'))->cflash('status');
         return Redirect::to_action('site@status');
     }
     if (Input::get('submit')) {
         // Registering language validator
         Validator::register('language_exists', function ($attribute, $value, $parameters) {
             if (array_key_exists($value, Config::get('site.languages'))) {
                 return true;
             }
         });
         // So these are the rules
         $rules = array('language' => 'required|language_exists');
         $input = Input::all();
         $validation = Validator::make($input, $rules);
         if ($validation->fails()) {
             Vsession::cadd('r', $validation->errors->first())->cflash('status');
         } else {
             foreach ($input as $field => $value) {
                 if (!empty($value)) {
                     $value = trim(filter_var($value, FILTER_SANITIZE_STRING));
                     DB::table('settings')->where_field($field)->take(1)->update(array('value' => $value));
                 }
             }
             Vsession::cadd('g', __('site.st_settings_up'))->cflash('status');
             return Redirect::to_action('setting@site');
         }
     }
     return $this->get_site();
 }
Esempio n. 3
0
 /**
  * Construct
  * Sets login/register mode (classic|ajax)
  * Sets register validation rules & messages
  *
  * @return void
  */
 public function __construct()
 {
     if (Config::get('gotin::gotin.login_mode') == "ajax") {
         $this->ajax = true;
     } else {
         $this->ajax = false;
     }
     /**
      *
      */
     Validator::register('question', function ($attribute, $value) {
         return Str::lower($value) == Session::get("Register_question");
     });
     $this->register_rules = array('username-register' => 'required|unique:users,username', 'email-register' => 'unique:users,email|required|email', 'password-register' => 'required|confirmed', 'question' => 'required|question');
     $this->register_messages = array('question' => __('gotin::gotin.question_error'), 'email-register_required' => __('gotin::gotin.email-register_required'), 'email-register_unique' => __('gotin::gotin.email-register_unique'), 'username-register_required' => __('gotin::gotin.username-register_required'), 'username-register_unique' => __('gotin::gotin.username-register_unique'), 'password-register_required' => __('gotin::gotin.password-register_required'), 'password-register_confirmed' => __('gotin::gotin.password-register_confirmed'));
 }
Esempio n. 4
0
<?php

// Create a Form macro which generates the fake honeypot field
// as well as the time check field
Form::macro('honeypot', function ($honey_name, $honey_time) {
    return View::make("honeypot::fields", get_defined_vars());
});
// We add a custom validator to validate the honeypot text and time check fields
Validator::register('honeypot', function ($attribute, $value, $parameters) {
    // We want the value to be empty, empty means it wasn't a spammer
    return $value == '';
});
Validator::register('honeytime', function ($attribute, $value, $parameters) {
    // The timestamp is encrypted so let's decrypt it
    $value = Crypter::decrypt($value);
    // The current time should be greater than the time the form was built + the speed option
    return is_numeric($value) && time() > $value + $parameters[0];
});
Esempio n. 5
0
 public function action_do_edit($modpack_id)
 {
     if (empty($modpack_id)) {
         return Redirect::to('dashboard');
     }
     $modpack = Modpack::find($modpack_id);
     if (empty($modpack_id)) {
         return Redirect::to('dashboard');
     }
     Validator::register('checkresources', function ($attribute, $value, $parameters) {
         if (FileUtils::check_resource($value, "logo_180.png") && FileUtils::check_resource($value, "icon.png") && FileUtils::check_resource($value, "background.jpg")) {
             return true;
         } else {
             return false;
         }
     });
     $rules = array('name' => 'required|unique:modpacks,name,' . $modpack->id, 'slug' => 'required|checkresources|unique:modpacks,slug,' . $modpack->id);
     $messages = array('name_required' => 'You must enter a modpack name.', 'slug_required' => 'You must enter a modpack slug', 'slug_checkresources' => 'Make sure to move your resources to the new location! (Based on your slug name)');
     $validation = Validator::make(Input::all(), $rules, $messages);
     if ($validation->fails()) {
         return Redirect::back()->with_errors($validation->errors);
     }
     $url = Config::get('solder.repo_location') . Input::get('slug') . '/resources/';
     $modpack->name = Input::get('name');
     $modpack->slug = Input::get('slug');
     $modpack->icon_md5 = UrlUtils::get_remote_md5($url . 'icon.png');
     $modpack->logo_md5 = UrlUtils::get_remote_md5($url . 'logo_180.png');
     $modpack->background_md5 = UrlUtils::get_remote_md5($url . 'background.jpg');
     $modpack->hidden = Input::get('hidden') ? true : false;
     $modpack->save();
     return Redirect::to('modpack/view/' . $modpack->id)->with('success', 'Modpack edited');
 }
Esempio n. 6
0
 public function post_create()
 {
     $this->data['section_bar_active'] = __('groups::lang.New Group')->get(ADM_LANG);
     $messages = array('unique_name_slug' => __('groups::lang.Name or Short name already taken')->get(ADM_LANG));
     Validator::register('unique_name_slug', function ($attribute, $value, $parameters) {
         $group_name = Groups\Model\Group::where('name', '=', Input::get('name'))->or_where('slug', '=', Input::get('slug'))->first();
         if (!isset($group_name) or empty($group_name)) {
             return true;
         }
         return false;
     });
     $this->validation_rules = array('name' => 'required|min:4|max:30|unique_name_slug', 'slug' => 'required|min:4|max:30|alpha_dash');
     $validation = Validator::make(Input::all(), $this->validation_rules, $messages)->speaks(ADM_LANG);
     $this->data['errors'] = $validation->errors;
     if ($validation->passes()) {
         $this->data['message'] = __('groups::lang.Group was successfully created')->get(ADM_LANG);
         $this->data['message_type'] = 'success';
         $group = new Groups\Model\Group();
         $group->name = Input::get('name');
         $group->slug = Input::get('slug');
         $group->description = Input::get('description');
         $group->save();
         Event::fire('mwi.group_created', array($group));
         return Redirect::to(ADM_URI . '/' . 'groups')->with($this->data);
     } else {
         $this->data['errors'] = $validation->errors;
     }
     return $this->theme->render('groups::backend.new', $this->data);
 }
<?php

namespace Blog;

\Autoloader::namespaces(array('Blog\\Models' => \Bundle::path('blog') . 'models'));
\Validator::register('date', function ($attribute, $value, $parameters) {
    $regex = '/^[0-9]{4}-(((0[13578]|(10|12))-(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30)))$/';
    return preg_match($regex, $value);
});
\Validator::register('time', function ($attribute, $value, $parameters) {
    $regex = '/^(20|21|22|23|[01]\\d|\\d)(([:.][0-5]\\d){1,2})$/';
    return preg_match($regex, $value);
});
Esempio n. 8
0
 protected function createValidator()
 {
     $validator = new Validator();
     $validator->register($this);
     $validator->setDisplayNames($this->displayNames);
     return $validator;
 }
Esempio n. 9
0
 public function post_step_4()
 {
     if (!Session::get('step_1_passed')) {
         return Redirect::to('install/step_1');
     }
     if (!Session::get('step_2_passed')) {
         return Redirect::to('install/step_2');
     }
     if (!Session::get('step_3_passed')) {
         return Redirect::to('install/step_3');
     }
     $messages = array('check_uuid' => 'The uuid provided is invalid.');
     Validator::register('check_uuid', function ($attribute, $value, $parameters) {
         return Installer::validate_uuid($value);
     });
     $rules = array('uuid' => 'required|check_uuid', 'user_name' => 'required|alpha_dash', 'avatar_first_name' => 'required|alpha_dash', 'avatar_last_name' => 'required|alpha_dash', 'email' => 'required|email', 'password' => 'required');
     $validation = Validator::make(Input::all(), $rules, $messages)->speaks(Session::get('adm_lang'));
     if ($validation->passes()) {
         Session::put('uuid', Input::get('uuid'));
         Session::put('user_name', Input::get('user_name'));
         Session::put('avatar_first_name', Input::get('avatar_first_name'));
         Session::put('avatar_last_name', Input::get('avatar_last_name'));
         Session::put('email', Input::get('email'));
         Session::put('password', Input::get('password'));
         Session::put('step_4_passed', true);
         if (!Installer::install()) {
             FirePHP::getInstance(true)->warn('installation failed');
             die;
         } else {
             $salt = md5(Installer::gen_uuid());
             $hash = md5(md5(Session::get('password') . ':' . $salt));
             //Create Default User
             $user_admin = array('uuid' => Session::get('uuid'), 'group_id' => 1, 'username' => Session::get('user_name'), 'avatar_first_name' => Session::get('avatar_first_name'), 'avatar_last_name' => Session::get('avatar_last_name'), 'hash' => $hash, 'salt' => $salt, 'password' => Hash::make(Session::get('password')), 'email' => Session::get('email'), 'status' => 'active', 'is_core' => 1, 'created_at' => date("Y-m-d H:i:s", time()), 'updated_at' => date("Y-m-d H:i:s", time()));
             $user = DB::table('users')->insert_get_id($user_admin);
             Auth::login($user);
             return Redirect::to('install/complete');
         }
     } else {
         return Redirect::to('install/step_4')->with_errors($validation)->with_input();
     }
 }
Esempio n. 10
0
<?php

//--------------------------------------------------------------------------
// Check for correct password. Custom message can be found in 'language/en/validation.php'.
//--------------------------------------------------------------------------
Validator::register('verify_password', function ($attribute, $value, $parameters) {
    return Hash::check($value, Auth::user()->pass);
});
//--------------------------------------------------------------------------
// Validation rules
//--------------------------------------------------------------------------
return array('login' => array('login_email' => 'required|max:30|email|exists:users,email', 'login_password' => 'required|between:6,20'), 'change_password' => array('current_password' => 'required|between:6,20|verify_password', 'new_password' => 'required|between:6,20|match:/^(\\w*(?=\\w*\\d)(?=\\w*[a-z])(?=\\w*[A-Z])\\w*)$/', 'confirm_password' => 'required|same:new_password'), 'forgot_password' => array('email' => 'required|between:3,30|email|exists:users'), 'register' => array('first_name' => 'required|between:3,30|alpha_dash', 'last_name' => 'required|between:3,30|alpha_dash', 'username' => 'required|between:3,30|alpha_dash|unique:users', 'email' => 'required|between:3,30|email|unique:users', 'password' => 'required|between:6,20|match:/^(\\w*(?=\\w*\\d)(?=\\w*[a-z])(?=\\w*[A-Z])\\w*)$/', 'confirm_password' => 'required|same:password'), 'add_page' => array('title' => 'required|max:64', 'category_id' => 'required|exists:categories,id', 'description' => 'required|max:128', 'content' => 'required|max:1024'), 'add_pdf' => array('title' => 'required|max:64', 'description' => 'required|max:128', 'pdf' => 'required|mimes:pdf|max:1000'));
Esempio n. 11
0
 public function put_update($user_id)
 {
     if (!ctype_digit($user_id)) {
         $this->data['message'] = Lang::line('Invalid id to edit user')->get(ADM_LANG);
         $this->data['message_type'] = 'error';
         return Redirect::to(ADM_URI . '/users')->with($this->data);
     }
     $edit_user = Users\Model\User::find($user_id);
     if (!isset($edit_user) or empty($edit_user)) {
         $this->data['message'] = Lang::line('Sorry can\'t find user to update')->get(ADM_LANG);
         $this->data['message_type'] = 'error';
         return Redirect::to(ADM_URI . '/users')->with($this->data);
     }
     $messages = array('valid_uuid' => Lang::line('Invalid UUID.')->get(ADM_LANG), 'unique_avatar_name' => Lang::line('This combination of avatar first name and avatar last name is already in use')->get(ADM_LANG));
     Validator::register('valid_uuid', function ($attribute, $value, $parameters) {
         return (bool) preg_match('#^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$#', $value);
     });
     Validator::register('unique_avatar_name', function ($attribute, $input_value) {
         $user = Users\Model\User::where('uuid', '!=', Input::get('uuid'))->where(function ($query) use($attribute, $input_value) {
             $query->where($attribute, '=', $input_value);
             $query->where('avatar_first_name', '=', Input::get('avatar_first_name'));
         })->first();
         if (!isset($user) or empty($user)) {
             return true;
         }
         return false;
     });
     $rules = array('uuid' => 'required|min:3|max:50|valid_uuid|unique:users,uuid,' . $edit_user->id, 'username' => 'required|min:3|max:50|alpha_dash|unique:users,username,' . $edit_user->id, 'avatar_first_name' => 'required|min:3|max:50', 'avatar_last_name' => 'required|min:3|max:50|unique_avatar_name', 'email' => 'required|email|unique:users,email,' . $edit_user->id, 'status' => 'required', 'password' => 'min:8');
     $validation = Validator::make(Input::all(), $rules, $messages);
     if ($validation->passes()) {
         $group_id = Input::get('group_id');
         if (!isset($group_id) or empty($group_id)) {
             $group_id = 0;
         }
         $password = Input::get('password');
         if (isset($password) and !empty($password)) {
             $password = Users\Helper::hash_password(Input::get('password'));
             $edit_user->password = Hash::make(Input::get('password'));
             $edit_user->hash = $password['hash'];
             $edit_user->salt = $password['salt'];
         }
         $edit_user->uuid = Input::get('uuid');
         $edit_user->username = Input::get('username');
         // Disable change of avatar name for now
         //
         //$edit_user->avatar_first_name = Input::get('avatar_first_name');
         //$edit_user->avatar_last_name  = Input::get('avatar_last_name');
         $edit_user->email = Input::get('email');
         $edit_user->status = Input::get('status');
         $edit_user->group_id = $group_id;
         $edit_user->save();
         Event::fire('users.updated', array($edit_user));
         $this->data['message'] = __('users::lang.User information was successfully updated', array('avatar_name' => Input::get('avatar_first_name') . ' ' . Input::get('avatar_last_name')))->get(ADM_LANG);
         $this->data['message_type'] = 'success';
         return Redirect::to(ADM_URI . '/users')->with($this->data);
     } else {
         return Redirect::to(ADM_URI . '/users/' . $edit_user->id . '/edit')->with_errors($validation)->with_input();
     }
 }
Esempio n. 12
0
 public function post_pwreset()
 {
     $rules = array('email' => 'required|email|account_exists');
     $messages = array('account_exists' => Lang::line('registration::lang.This email was not found.')->get(APP_LANG));
     $account = null;
     Validator::register('account_exists', function ($attribute, $value, $parameters) use(&$account) {
         $account = Users\Model\User::where('email', '=', Input::get('email'))->first();
         if (isset($account) and !empty($account)) {
             return true;
         }
         return false;
     });
     $validation = Validator::make(Input::all(), $rules, $messages);
     if ($validation->passes()) {
         $pwreset_record = new Registration\Model\Code();
         $pwreset_record->user_id = $account->id;
         $pwreset_record->code = Mwi_Core::keygen();
         $pwreset_record->save();
         // send password reset email
         // new xblade to parse the email template
         $xblade = new Xblade();
         $xblade->scopeGlue(':');
         // data to be passed to email template
         $data['user'] = $account;
         $data['forgotten_password_code'] = $pwreset_record->code;
         $data['url']['base'] = URL::base();
         $data['settings']['site_name'] = Config::get('settings::core.site_name');
         $data['request']['ip'] = Request::ip();
         $data['request']['user_agent'] = implode(', ', Request::header('user-agent'));
         $data['request']['languages'] = implode(', ', Request::languages());
         // get email template based on settings
         $email_address = Config::get('settings::core.server_email');
         $template_id = Config::get('settings::core.registration_pwreset_email_template');
         $email_data = Email\Model\Template::find($template_id);
         // send email to user
         Email\Message::to($account->email)->from($email_address)->subject($xblade->parse($email_data->subject, $data))->body($xblade->parse($email_data->body, $data))->html($email_data->type)->send();
         $this->data['message'] = __('registration::lang.An email was sent to you with instructions to reset your password')->get(APP_LANG);
         $this->data['message_type'] = 'success';
         return Redirect::to('page/home')->with($this->data);
     }
     return Redirect::back()->with_errors($validation)->with_input();
 }
Esempio n. 13
0
 /**
  * Edit user submit
  * @return Response
  */
 public function post_edit($id = null)
 {
     if (!Auth::can('edit_users')) {
         if (!Auth::can('edit_self') || Auth::user()->id !== (int) $id) {
             dd((int) $id);
             Vsession::cadd('y', __('site.not_allowed'))->cflash('status');
             return Redirect::to_action('site@status');
         }
     }
     // Input ID
     if ($id == null || !$this->user_exists($id, 'users')) {
         return Redirect::to_action('user@list');
     }
     if (Input::get('submit')) {
         // User data
         $user = $this->fetch_user($id);
         $user = $user[0];
         // Registering unique role validator
         Validator::register('role_exists', function ($attribute, $value, $parameters) {
             $category = DB::table('roles')->find($value);
             if ($category !== null) {
                 return true;
             }
         });
         //If input email is own
         $mailunique = Input::get('email') != $user->email ? '|unique:users' : '';
         // So these are the rules
         $rules = array('name' => 'required|max:200', 'password1' => 'max:16|same:password2', 'password2' => 'max:16|same:password1', 'email' => 'required|email' . $mailunique, 'role' => 'required|numeric|role_exists');
         $input = Input::all();
         $validation = Validator::make($input, $rules);
         if ($validation->fails()) {
             Vsession::cadd('r', $validation->errors->first())->cflash('status');
         } else {
             foreach ($input as $key => $value) {
                 $input[$key] = $value !== '' ? trim(filter_var($value, FILTER_SANITIZE_STRING)) : null;
             }
             $user = new \Verify\Models\User();
             $user = Auth::retrieve($id);
             $user->name = $input['name'];
             $user->email = $input['email'];
             !is_null($input['password1']) ? $user->password = $input['password1'] : '';
             $user->save();
             $user->roles()->sync($input['role']);
             Vsession::cadd('g', __('site.st_user_up'))->cflash('status');
             return Redirect::to_action('user@edit/' . $id);
         }
     }
     // Reusing view
     return $this->get_edit($id, $user);
 }
Esempio n. 14
0
    }
    $query = DB::table('files')->where($attribute, '=', $value . '.' . $ext);
    return $query->count() == 0;
});
Validator::register('valid_datetime', function ($attribute, $value, $parameters) {
    //match the format of the date
    if (!empty($value)) {
        $d = DateTime::createFromFormat(GET_DATETIME(), $value);
        return !$d ? false : true;
    }
    return false;
});
Validator::register('valid_date', function ($attribute, $value, $parameters) {
    //match the format of the date
    if (!empty($value)) {
        $d = DateTime::createFromFormat(GET_DATETIME(false), $value);
        return !$d ? false : true;
    }
    return false;
});
// BLADE MODIFICATION
Blade::extend(function ($value) {
    return preg_replace('/\\{\\{([^\\-].+?)\\}\\}/s', '<?php echo $1; ?>', $value);
});
//BUNDLE CONSTANTS
define('USERNAME', Session::get('USERNAME'));
define('AUTHORID', Session::get('AUTHORID'));
define('ROLE', Session::get('ROLE', 0));
define('LANG', Session::get('LANG', Config::get('cms::settings.language')));
define('CMSLANG', Session::get('CMSLANG', Config::get('cms::settings.language')));
define('CACHE', Config::get('cms::settings.cache_engine'));
define('BASE', Config::get('application.url'));
Esempio n. 15
0
<?php

/**
 * Validate that the password submitted is this user password
 */
Validator::register('current_password', function ($attribute, $value, $parameter) {
    try {
        $user = Sentry::user();
        if ($user->check_password($value)) {
            return true;
        } else {
            return false;
        }
    } catch (Sentry\SentryException $e) {
        return false;
    }
});
/*
 * Image Validation
 */
Validator::register('upload_err_ini_size', function ($attribute, $value, $parameter) {
    return false;
});
Validator::register('upload_err_partial', function ($attribute, $value, $parameter) {
    return false;
});
Esempio n. 16
0
 /**
  * Post checkout item
  * @return Response
  */
 public function post_checkout($id = null)
 {
     if (!Auth::can('add_checkout')) {
         Vsession::cadd('y', __('site.not_allowed'))->cflash('status');
         return Redirect::to_action('item@list');
     }
     if (Input::get('submit')) {
         // Registering unique code validator
         Validator::register('code_exists', function ($attribute, $value, $parameters) {
             $code = trim(filter_var($value, FILTER_SANITIZE_STRING));
             $code = DB::table('items')->where_code($code)->first('id');
             if ($code !== null) {
                 return true;
             }
         });
         // All the rules
         $rules = array('code' => 'required|max:50|code_exists', 'selling_price' => 'numeric', 'quantity' => 'required|numeric', 'contact' => 'max:200', 'date' => 'max:20');
         $msg = "";
         $status = 0;
         $inputs = Input::all();
         foreach ($inputs['body'] as $input) {
             $validation = Validator::make($input, $rules);
             // Validating
             if ($validation->fails()) {
                 Vsession::cadd('r', $validation->errors->first())->cflash('status');
             } elseif (false === $this->check_stock(trim(filter_var($input['code'], FILTER_SANITIZE_STRING)), $input['quantity'])) {
                 Vsession::cadd('r', __('site.st_inventory_out'))->cflash('status');
                 $msg = __('site.st_trans_inserting_ok');
                 $status = 0;
             } else {
                 // Sanitizing trough all the Inputs
                 foreach ($input as $key => $value) {
                     $input[$key] = $value !== '' ? trim(filter_var($value, FILTER_SANITIZE_STRING)) : null;
                 }
                 // User inserted a name into the source field
                 if ($input['contact'] !== null) {
                     // Is there a contact in Database?
                     $contact = $this->fetch_contact('name', $input['contact'], 'id');
                     if ($contact == null) {
                         $input['contact'] = $this->insert_contact($input['contact']);
                     } else {
                         $input['contact'] = $contact->id;
                     }
                 }
                 if ($input['document'] !== null) {
                     $document = $this->fetch_document('name', $input['document'], 'id');
                     if ($document == null) {
                         $data_array = array('name' => $input['document'], 'po_num' => $input['po_num']);
                         $input['document'] = $this->insert_document($data_array);
                     } else {
                         $input['document'] = $document->id;
                     }
                 }
                 // Getting all the Item data
                 // based on either the ID or the Code
                 if ($id != null) {
                     $id = trim(filter_var($id, FILTER_SANITIZE_NUMBER_INT));
                     $item = $this->fetch_item('id', $id);
                 } else {
                     $item = $this->fetch_item('code', $input['code']);
                 }
                 // So we have the Item data
                 if ($item !== null) {
                     if (is_numeric($item->quantity)) {
                         $input['quantity'] = abs($input['quantity']);
                         $input['selling_price'] = abs($input['selling_price']);
                         $input['new_quantity'] = (int) $item->quantity - (int) $input['quantity'];
                         // Total quantity
                         $input['new_price'] = (int) $item->income_total + (int) $input['quantity'] * (int) $input['selling_price'];
                         // Total price
                         try {
                             $date = new \DateTime();
                             DB::connection()->pdo->beginTransaction();
                             DB::table('transactions')->insert(array('items_id' => $item->id, 'transactions_types_id' => 1, 'date' => date("Y-m-d H:i:s", strtotime($input['date'])), 'contacts_id' => $input['contact'], 'documents_id' => $input['document'], 'users_id' => Auth::user()->id, 'quantity' => 0 - $input['quantity'], 'price' => $input['selling_price'], 'sum' => $input['quantity'] * $input['selling_price'], 'note' => $input['note'], 'created_at' => $date, 'doc_number' => $input['doc_number'], 'pd_date' => $input['pd_date']));
                             DB::table('items')->where('id', '=', $item->id)->update(array('income_total' => $input['new_price'], 'quantity' => $input['new_quantity']));
                             DB::connection()->pdo->commit();
                         } catch (PDOException $e) {
                             DB::connection()->pdo->rollBack();
                             Vsession::cadd('r', __('site.st_inserting_error'))->cflash('status');
                             $msg = __('site.st_inserting_error');
                             $status = 0;
                         }
                         Vsession::cadd('g', __('site.st_trans_inserting_ok'))->cflash('status');
                         $msg = __('site.st_trans_inserting_ok');
                         $status = 1;
                     }
                 }
             }
         }
     }
     if ($this->isMobile()) {
         echo json_encode(array('status' => $status, 'msg' => $msg));
     } else {
         return $this->get_checkout($id);
     }
 }
Esempio n. 17
0
    $normAssets('styles');
    $normAssets('scripts');
    $view->data += array('headEnd' => '', 'bodyEnd' => '');
    $view->classes = (array) $view['classes'];
    if (Request::$route and $name = array_get(Request::$route->action, 'as')) {
        $view->data['classes'][] = preg_replace('/[^\\w\\-]+/', '-', $name);
    }
});
View::composer('vanemart::mail.full', function ($view) {
    if (isset($view->mail)) {
        $view->mail->styleLocal('vanemart::mail.full');
        // new value of 'styles' set by styleLocal() won't be passed to this view
        // because it's already being rendered when the composer is called.
        $view->data['styles'] = $view->mail->view->data['styles'];
    }
});
View::composer('vanemart::block.user.reg', function ($view) {
    $view->data['regFields'] = VaneMart\userFields(array('name', 'surname', 'phone', 'email'), 'user');
});
View::composer('vanemart::block.checkout.fields', function ($view) {
    $view->data['checkoutFields'] = VaneMart\userFields(array('name', 'surname', 'phone'), 'order');
});
View::composer('vanemart::block.order.show', function ($view) {
    $view->data['orderFields'] = VaneMart\userFields(array('name', 'surname', 'phone', 'address', 'notes'), 'order');
});
View::composer('vanemart::block.user.login', function ($view) {
    $view->data['reset_error'] = !isset($view->data['reset_error']) ? \Session::get('reset_error') : $view->data['reset_error'];
});
Validator::register('vanemart_phone', function ($attribute, $value, $parameters) {
    return ltrim($value, '0..9()-+ ') === '';
});