public function __construct($db_name, $db_user = '******', $db_pass = '******', $db_host = 'localhost') { $config = new Config(); if ($config != null) { $this->db_name = $config->get("db_name"); $this->db_user = $config->get("db_user"); $this->db_pass = $config->get("db_pass"); $this->db_host = $config->get("db_host"); } }
public static function getRole($role_id) { //TODO let's not call the DB here. //return self::find($role_id); $roles = (array) \Config::get('mycustomvars.roles'); return array_search($role_id, $roles); }
public function __construct() { $adapter = Config::get('database.engine'); $this->created_at = date('Y-m-d H:i:s'); $this->update = (object) array(); $this->setAdapter(DatabaseAdapterFactory::create($adapter)); }
public static function createFromApi($placeId, $apiData) { $photo = self::create(['place_id' => $placeId, 'photo_reference' => $apiData->photo_reference, 'width' => $apiData->width, 'height' => $apiData->height]); $response = \App\Api\Place::getPhoto($apiData->photo_reference); file_put_contents(\Config::get('place.photo_path') . $photo->id . '.jpg', $response->getResultPhoto()); unset($response); }
public function getStatsAction() { $config = Config::get("kayako"); $db = new \PDO("mysql:dbname=" . $config["database"] . ";host=" . $config["host"], $config["username"], $config["password"]); $sql = "\n SELECT ticketstatusid, ticketstatustitle, ownerstaffid, ownerstaffname, count(*) as cnt FROM `swtickets`\n WHERE departmentid in (3,4)\n GROUP BY ticketstatusid, ownerstaffid, ownerstaffname\n "; $stats = array("status" => array("total" => 0), "user" => array("total" => 0)); foreach ($db->query($sql) as $row) { $stats['status']["total"] += $row["cnt"]; if (!isset($stats['status'][$row["ticketstatustitle"]])) { $stats['status'][$row["ticketstatustitle"]] = 0; } $stats['status'][$row["ticketstatustitle"]] += $row["cnt"]; if (!isset($stats['user'][$row["ownerstaffname"]])) { $stats['user'][$row["ownerstaffname"]] = array("total" => 0); } $stats['user'][$row["ownerstaffname"]]["total"] += $row["cnt"]; if (!isset($stats['user'][$row["ownerstaffname"]][$row["ticketstatustitle"]])) { $stats['user'][$row["ownerstaffname"]][$row["ticketstatustitle"]] = 0; } $stats['user'][$row["ownerstaffname"]][$row["ticketstatustitle"]] += $row["cnt"]; } if (isset($stats['user'][''])) { $stats['user']['Unassigned'] = $stats['user']['']; unset($stats['user']['']); } header('Content-type: application/json'); echo json_encode($stats); }
/** * Get list of number of days before expiration day * to send reminder email to company * * @return array */ public function getReminderDays() { $remindOnDaysStr = \Config::get('custom.remindOnDays'); $remindOnDays = explode(',', $remindOnDaysStr); foreach ($remindOnDays as $key => $value) { $remindOnDays[$key] = intval(trim($value)); } return $remindOnDays; }
/** * Get the users' material_categories. * * @return MaterialCategories */ public static function boot() { parent::boot(); static::creating(function ($user) { $key = \Config::get('app.key'); $confirmation_code = hash_hmac('sha256', str_random(40), $key); $user->confirmation_code = $confirmation_code; }); }
/** * Bootstrap the application services. * * @return void */ public function boot() { if (\Schema::hasTable('configs')) { $configs = \App\Config::get(); foreach ($configs as $config) { \Config::set($config->key, $config->value); } } }
protected function isComponentReady($component) { $compoTick = Config::get($component . 'Last'); $compoTick += Config::get($component . 'Interval'); if ($compoTick <= $this->tickCnt || $compoTick - 1440 > $this->tickCnt) { return true; } else { return false; } }
private function doRequest($payload) { if ($this->guzzle == null) { $conf = Config::get(); $baseurl = $conf["zabbix"]["url"]; $this->guzzle = new Client(array('cookies' => true, 'base_uri' => $baseurl)); } // var_dump($payload); $response = $this->guzzle->request('POST', 'api_jsonrpc.php', array('body' => $payload, 'headers' => array('content-type' => 'application/json-rpc'))); return $response->getBody()->getContents(); }
public function __construct() { try { $this->db = new \PDO(Config::get('database.providers.pdo.host'), Config::get('database.providers.pdo.user'), Config::get('database.providers.pdo.pass'), array(\PDO::ATTR_PERSISTENT => true)); $this->db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $this->connected = true; } catch (\PDOException $e) { $this->connected = false; die($e->getMessage()); } }
public function getPermissionsIdsArr() { $permissions_rows = \DB::table(\Config::get('entrust.permission_role_table'))->where('role_id', '=', $this->id)->get(['permission_id']); if (empty($permissions_rows)) { return []; } $permissions_ids_arr = []; foreach ($permissions_rows as $permission_row) { $permissions_ids_arr[] = $permission_row->permission_id; } return $permissions_ids_arr; }
public function getRolesIdsArr() { $roles_rows = \DB::table(\Config::get('entrust.role_user_table'))->where('user_id', '=', $this->id)->get(['role_id']); if (empty($roles_rows)) { return []; } $roles_ids_arr = []; foreach ($roles_rows as $role_row) { $roles_ids_arr[] = $role_row->role_id; } return $roles_ids_arr; }
public static function boot() { parent::boot(); // Hack for Entrust because it doesn't have a boot method static::deleting(function ($user) { if (!method_exists(Config::get('auth.model'), 'bootSoftDeletingTrait')) { $user->roles()->sync([]); } return true; }); static::bootStapler(); }
public function indexAction() { header('Content-type: application/json'); $screens = Config::get('screens'); $ret = []; foreach ($screens as $screen) { $obj = new \stdClass(); $obj->type = $screen; $ret[] = $obj; } return json_encode(array("screens" => $ret)); }
public function called() { $config = new Config(); $title = new \Dreamcoil\Codebowl\Title(); $auth = new \Dreamcoil\Auth(); $title->set($config->get('title')); $title->append('Home'); $layout = new \Dreamcoil\Layout('Bubo', array('title' => $title->get(), 'time' => time())); echo "We're going to miss you Dreamcoil v1<hr>"; \Models\UserModel::getData(); $auth->set(array('Name' => 'Florian')); if ($auth->check()) { echo '<br>Welcome!</br>'; } }
public function createPayment() { $payer = new Payer(); $payer->setPaymentMethod('paypal'); $item_1 = new Item(); $item_1->setName('Item 1')->setCurrency('USD')->setQuantity(2)->setPrice('15'); // unit price $item_2 = new Item(); $item_2->setName('Item 2')->setCurrency('USD')->setQuantity(4)->setPrice('7'); $item_3 = new Item(); $item_3->setName('Item 3')->setCurrency('USD')->setQuantity(1)->setPrice('20'); // add item to list $item_list = new ItemList(); $item_list->setItems(array($item_1, $item_2, $item_3)); $amount = new Amount(); $amount->setCurrency('USD')->setTotal(78); $transaction = new Transaction(); $transaction->setAmount($amount)->setItemList($item_list)->setDescription('Your transaction description'); $redirect_urls = new RedirectUrls(); $redirect_urls->setReturnUrl(route('payment.status'))->setCancelUrl(route('payment.status')); $payment = new Payment(); $payment->setIntent('Sale')->setPayer($payer)->setRedirectUrls($redirect_urls)->setTransactions(array($transaction)); try { $payment->create($this->_api_context); } catch (\PayPal\Exception\PPConnectionException $ex) { if (\Config::get('app.debug')) { echo "Exception: " . $ex->getMessage() . PHP_EOL; $err_data = json_decode($ex->getData(), true); exit; } else { die('Some error occur, sorry for inconvenient'); } } foreach ($payment->getLinks() as $link) { if ($link->getRel() == 'approval_url') { $redirect_url = $link->getHref(); break; } } // add payment ID to session Session::put('paypal_payment_id', $payment->getId()); if (isset($redirect_url)) { // redirect to paypal return Redirect::away($redirect_url); } return Redirect::route('original.route')->with('error', 'Unknown error occurred'); }
static function formaterDataFile($excel = array(), $fileName) { $result = array(); $config = \Config::get('user_import'); if (in_array(pathinfo($fileName)['extension'], $config['csv_extension'])) { //txt, csv $delimiter = detectedDelimiter($excel[0][0]); foreach ($excel as $key => $value) { $result[] = checkCountColspan('txt', $value, $delimiter); } } else { //xls foreach ($excel[0] as $key => $value) { $result[] = checkCountColspan('xls', $value); } } return $result; }
/** * @param $text * @return $this */ public function answer($text) { if (\Config::get('gitter.output')) { $client = \App::make(Client::class); $room = \App::make(Room::class); $client->request('message.send', ['roomId' => $room->id], ['text' => (string) $text], 'POST'); } return $this; }
public function roles() { return $this->belongsToMany(\Config::get('entrust.role'), 'permission_role'); }
$di->set('builder', new Builder('Smarty', 'layout/layout.tpl'))->setConfig(Config::get('builder')); if (isset(Config::get('builder')['fe_javascripts'])) { $di->get('builder')->setJavaScript(Config::get('builder')['fe_javascripts']); } if (isset(Config::get('builder')['fe_css'])) { $di->get('builder')->setCSS(Config::get('builder')['fe_css']); } $di->get('builder')->assign("cabinet", Config::get('app')['cabinet']); /* * Config init */ $di->set('config', new Config()); /* * Database init */ $di->set('db', new Database(Config::get('db')['connection_string'], Config::get('db')['user'], Config::get('db')['pass'])); /* * HTTP Request init */ $di->set('request', new Request()); /* * SessionManager init */ $di->set('session', new Session())->start(); /* * Dispatcher init */ $dispatcher = new Dispatcher($di); $_post = isset($_POST) && is_array($_POST) && count($_POST) > 0 ? $_POST : null; $content = $dispatcher->execute($_GET, $_post); /*
private function config($key) { return $this->config->get($key); }
public function teachers() { $role_id = (int) \Config::get('mycustomvars.roles.teacher'); return $this->morphToMany('app\\User', 'roleable')->wherePivot('role_id', $role_id); }
<?php namespace App; use ORM; // Application middlewares // CSRF protection App::add(new \App\Middleware\Csrf()); // Auth infos App::add(new \App\Middleware\Auth()); // Init database App::add(function ($req, $res, $next) { $settings = Config::get('database'); ORM::configure('mysql:host=' . $settings['host'] . ';dbname=' . $settings['dbname']); ORM::configure('username', $settings['username']); ORM::configure('password', $settings['password']); ORM::configure('logging', true); return $next($req, $res); }); // Permanently redirect paths with a trailing slash // to their non-trailing counterpart App::add(function ($req, $res, $next) { $uri = $req->getUri(); $path = $uri->getPath(); if ($path != '/' && substr($path, -1) == '/') { $uri = $uri->withPath(substr($path, 0, -1)); return $res->withRedirect((string) $uri, 301); } return $next($req, $res); }); // Load plugins hooks
/** * Roles can belong to many users. * * @return Model */ public function users() { return $this->belongsToMany(Config::get('App\\User'))->withTimestamps(); }
public function getSteamLink() { $api = new APIBridge(\Config::get('steam-api.api_key')); return $api->parseSteamID($this->steam_id)['profileurl']; }
public function __construct() { $this->db = new DB(Config::get('database')); }
<?php require_once 'engine/utils.php'; require_once 'engine/autoload.php'; Autoload::init('config/autoload.php'); use App\Config, App\Request, App\User, App\Route, App\View, App\Timer, App\Debug, App\Mysql, App\Response; try { Config::load('config/settings.php'); Config::applyHostSettings('config/hosts.php'); Mysql::setHost(Config::get('dbConnection')); Timer::start(); User::startSession(); Request::parse(); Route::add(['/dumper' => 'dumper', '/module' => 'module', '/login' => 'login', '/tasks' => 'page', '/profile' => 'page', '/projects' => 'page', '/workspace' => 'page', '/404' => 'error', '/' => 'page']); Route::go(); Timer::showExecutionTime(); Mysql::showResources(); Response::out(); } catch (\Exception $e) { Debug::showException($e); }
public function roles() { return $this->belongsToMany(\Config::get('entrust.role'), 'role_user'); }
public function connect() { $config = \App\Config::get('database'); $this->connection = new PDO('mysql:host=' . $config['hostname'] . ';dbname=' . $config['dbname'], $config['username'], $config['password']); }