/** * Create user from LDAP attributes * * @param $ldapatttibutes * @return array|bool */ function createUserFromLdap($ldapatttibutes) { //Get LDAP attribute config $ldap_result_username = Setting::getSettings()->ldap_username_field; $ldap_result_emp_num = Setting::getSettings()->ldap_emp_num; $ldap_result_last_name = Setting::getSettings()->ldap_lname_field; $ldap_result_first_name = Setting::getSettings()->ldap_fname_field; $ldap_result_email = Setting::getSettings()->ldap_email; //Get LDAP user data $item = array(); $item["username"] = isset($ldapatttibutes[$ldap_result_username][0]) ? $ldapatttibutes[$ldap_result_username][0] : ""; $item["employee_number"] = isset($ldapatttibutes[$ldap_result_emp_num][0]) ? $ldapatttibutes[$ldap_result_emp_num][0] : ""; $item["lastname"] = isset($ldapatttibutes[$ldap_result_last_name][0]) ? $ldapatttibutes[$ldap_result_last_name][0] : ""; $item["firstname"] = isset($ldapatttibutes[$ldap_result_first_name][0]) ? $ldapatttibutes[$ldap_result_first_name][0] : ""; $item["email"] = isset($ldapatttibutes[$ldap_result_email][0]) ? $ldapatttibutes[$ldap_result_email][0] : ""; //create user if (!empty($item["username"]) && !empty($item['email'])) { $pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10); $newuser = array('first_name' => $item["firstname"], 'last_name' => $item["lastname"], 'username' => $item["username"], 'email' => $item["email"], 'employee_num' => $item["employee_number"], 'password' => $pass, 'activated' => 1, 'location_id' => null, 'permissions' => '{"user":1}', 'notes' => 'Imported from LDAP'); DB::table('users')->insert($newuser); $updateuser = Sentry::findUserByLogin($item["username"]); // Update the user details $updateuser->password = $pass; // Update the user $updateuser->save(); } else { throw new Cartalyst\Sentry\Users\UserNotFoundException(); } //$item["note"] = "<strong>created</strong>"; $credentials = array('username' => $item["username"], 'password' => $pass); return $credentials; }
/** * Execute the console command. * * @return mixed */ public function fire() { $expiring_assets = Asset::getExpiringWarrantee(60); $data['count'] = count($expiring_assets); $data['email_content'] = ''; foreach ($expiring_assets as $asset) { $now = date("Y-m-d"); $expires = $asset->warrantee_expires(); $difference = round(abs(strtotime($expires) - strtotime($now)) / 86400); if ($difference > 30) { $data['email_content'] .= '<tr style="background-color: #fcffa3;">'; } else { $data['email_content'] .= '<tr style="background-color:#d9534f;">'; } $data['email_content'] .= '<td><a href="' . Config::get('app.url') . '/hardware/' . $asset->id . '/view">'; $data['email_content'] .= $asset->name . '</a></td><td>' . $asset->asset_tag . '</td>'; $data['email_content'] .= '<td>' . $asset->warrantee_expires() . '</td>'; $data['email_content'] .= '<td>' . $difference . ' days</td>'; $data['email_content'] .= '</tr>'; } if (Setting::getSettings()->alert_email != '' && Setting::getSettings()->alerts_enabled == 1) { if (count($expiring_assets) > 0) { Mail::send('emails.expiring-report', $data, function ($m) { $m->to(Setting::getSettings()->alert_email, Setting::getSettings()->site_name); $m->subject('Expiring Assets Report'); }); } } else { if (Setting::getSettings()->alert_email == '') { echo "Could not send email. No alert email configured in settings. \n"; } elseif (Setting::getSettings()->alerts_enabled != 1) { echo "Alerts are disabled in the settings. No mail will be sent. \n"; } } }
public function show_custom_css() { $custom_css = Setting::getSettings()->custom_css; $custom_css = e($custom_css); // Needed for modifying the bootstrap nav :( $custom_css = str_ireplace('script', 'SCRIPTS-NOT-ALLOWED-HERE', $custom_css); $custom_css = str_replace('>', '>', $custom_css); return $custom_css; }
public static function getDefaultEula() { $Parsedown = new Parsedown(); if (Setting::getSettings()->default_eula_text) { return $Parsedown->text(e(Setting::getSettings()->default_eula_text)); } else { return null; } }
private static function isFullMultipleCompanySupportEnabled() { $settings = Setting::getSettings(); // NOTE: this can happen when seeding the database if (is_null($settings)) { return FALSE; } else { return $settings->full_multiple_companies_support == 1; } }
public function getEula() { $Parsedown = new Parsedown(); if ($this->category->eula_text) { return $Parsedown->text(e($this->category->eula_text)); } elseif (Setting::getSettings()->default_eula_text && $this->category->use_default_eula == '1') { return $Parsedown->text(e(Setting::getSettings()->default_eula_text)); } else { return null; } }
<?php return array('table' => array('class' => 'table table-bordered', 'id' => '', 'options' => array("pagingType" => "full_numbers", 'processing' => true, 'language' => array('processing' => '<i class="fa fa-spinner fa-spin"></i> Loading...'), 'deferRender' => true, 'stateSave' => true, 'paging' => true, 'pageLength' => Setting::getSettings()->per_page, 'lengthMenu' => array(array(10, 25, 50, 75, 100, 125, 150, -1), array(10, 25, 50, 75, 100, 125, 150, 'All')), 'tableTools' => array('sSwfPath' => Config::get('app.url') . '/assets/swf/copy_csv_xls_pdf.swf', 'aButtons' => array(array('sExtends' => 'copy', 'sButtonText' => 'Copy', 'mColumns' => 'visible', 'bFooter' => false), array('sExtends' => 'print', 'sButtonText' => 'Print', 'mColumns' => 'visible', 'bShowAll' => true), array('sExtends' => 'collection', 'sButtonText' => 'Export', 'aButtons' => array(array('sExtends' => 'csv', 'sButtonText' => 'csv', 'mColumns' => 'visible', 'bFooter' => false), array('sExtends' => 'xls', 'sButtonText' => 'XLS', 'mColumns' => 'visible', 'bFooter' => false), array('sExtends' => 'pdf', 'sButtonText' => 'PDF', 'mColumns' => 'visible', 'bFooter' => false)))))), 'callbacks' => array("stateSaveCallback" => "function (oSettings, oData) {\n localStorage.setItem('DataTables_'+window.location.pathname, JSON.stringify(oData));\n }", "stateLoadCallback" => "function (oSettings) {\n return JSON.parse(localStorage.getItem('DataTables_'+window.location.pathname));\n }"), 'noScript' => false, 'table_view' => 'datatable::template', 'script_view' => 'datatable::javascript'), 'engine' => array('exactWordSearch' => false, 'enableDisplayAll' => false, 'defaultDisplayLength' => 10));
<a class='selected' href="editsetting.php"></a> </div> <div id='logoff'> <a href="index.php?logoff=1"></a> </div> </div> <ul> <li><a href="view.php">view</a></li> <li><a href="edit.php">edit</a></li> </ul> </div> <div class="hline"></div> <div class="admin-content"> <div class="admin-nav"><?php $records = Setting::getSettings(); if ($records) { echo "<h3>available settings:</h3>\n<table>\n"; $firsttime = true; foreach ($records as $setting) { echo "<tr><td class='label'>\n<a href='" . $_SERVER['PHP_SELF'] . "?id=" . $setting[0] . "'>" . $setting[1] . "</a></td>\n</tr>\n"; } echo "</table>\n"; } ?> </div> <div class="admin-content-edit"> <?php if ($id) { ?> <h2><?php
/** * Account sign in form processing. * * @return Redirect */ public function postSignin() { // Declare the rules for the form validation $rules = array('username' => 'required', 'password' => 'required'); // Create a new validator instance from our validation rules $validator = Validator::make(Input::all(), $rules); // If validation fails, we'll exit the operation now. if ($validator->fails()) { // Ooops.. something went wrong return Redirect::back()->withInput()->withErrors($validator); } try { // Should we even check for LDAP users? if (Setting::getSettings()->ldap_enabled == '1') { LOG::debug("LDAP is enabled."); // Check if the user exists in the database $user = User::where('username', '=', Input::get('username'))->whereNull('deleted_at')->first(); LOG::debug("Sentry lookup complete"); // The user does not exist in the database. Try to get them from LDAP. // If user does not exist and authenticates sucessfully with LDAP we // will create it on the fly and sign in with default permissions if (!$user) { LOG::debug("Local user " . Input::get('username') . " does not exist"); if ($userattr = $this->ldap(Input::get('username'), Input::get('password'), true)) { LOG::debug("Creating local user from authenticated LDAP user."); $credentials = $this->createUserFromLdap($userattr); } else { LOG::debug("User did not authenticate correctly against LDAP. No local user was created."); } // If the user exists and they were imported from LDAP already } else { LOG::debug("Local user " . Input::get('username') . " exists in database. Authenticating existing user against LDAP."); if ($this->ldap(Input::get('username'), Input::get('password'))) { LOG::debug("Valid LDAP login. Updating the local data."); $sentryuser = Sentry::findUserById($user->id); //need the Sentry object, not the Eloquent object, to access critical password hashing functions $sentryuser->password = Input::get('password'); $sentryuser->save(); } else { LOG::debug("User did not authenticate correctly against LDAP. Local user was not updated."); } // End LDAP auth } // End if(!user) // NO LDAP enabled - just try to login the user normally } LOG::debug("Authenticating user against database."); // Try to log the user in if (!Sentry::authenticate(Input::only('username', 'password'), Input::get('remember-me', 0))) { LOG::debug("Local authentication failed."); throw new Cartalyst\Sentry\Users\UserNotFoundException(); } // Get the page we were before $redirect = Session::get('loginRedirect', 'account'); // Unset the page we were before from the session Session::forget('loginRedirect'); // Redirect to the users page return Redirect::to($redirect)->with('success', Lang::get('auth/message.signin.success')); } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) { LOG::debug("Local authentication: User " . Input::get('username') . " not found"); $this->messageBag->add('username', Lang::get('auth/message.account_not_found')); } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) { LOG::debug("Local authentication: Password for " . Input::get('username') . " is incorrect."); $this->messageBag->add('username', Lang::get('auth/message.account_not_found')); } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) { LOG::debug("Local authentication: User not activated"); $this->messageBag->add('username', Lang::get('auth/message.account_not_activated')); } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) { LOG::debug("Local authentication: Account suspended"); $this->messageBag->add('username', Lang::get('auth/message.account_suspended')); } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) { LOG::debug("Local authentication: Account banned."); $this->messageBag->add('username', Lang::get('auth/message.account_banned')); } // Ooops.. something went wrong return Redirect::back()->withInput()->withErrors($this->messageBag); }