Esempio n. 1
0
 private function _conexion()
 {
     //$entorno = new Entorno();
     //self::$config = $this->config_load($entorno->getEntorno().'app_config');
     $configApp = new Config();
     $this->config = $configApp->getBaseDatos();
     if (empty($this->config['driver'])) {
         die('Por favor, establece un controlador de base de datos valido ' . $this->config['driver']);
     }
     $driver = strtoupper($this->config['driver']);
     switch ($driver) {
         case 'MYSQL':
             $this->_dbHost = $this->config['host'];
             $this->_dbbd = $this->config['nombre'];
             $this->_dbusuario = $this->config['usuario'];
             $this->_dbclave = $this->config['clave'];
             $this->pdo = new PDO('mysql:host=' . $this->_dbHost . '; dbname=' . $this->_dbbd, $this->_dbusuario, $this->_dbclave);
             $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
             $this->pdo->exec("SET CHARACTER SET utf8");
             $this->_cnx = $this->pdo;
             break;
         default:
             die('Base de datos no soporta: ' . $this->config['driver']);
     }
 }
 public function sendEmail($template, $data = [], $to, $toName, $subject, $cc = null, $bcc = null, $replyTo = null)
 {
     $result = false;
     try {
         $config = new Config();
         $messageHeader = ['from' => $config->getValueByKey('address_sender_mail'), 'fromName' => $config->getValueByKey('display_name_send_mail'), 'to' => $to, 'toName' => $toName, 'cc' => $cc, 'bcc' => $bcc, 'replyTo' => $replyTo, 'subject' => $subject];
         \Mail::send($template, $data, function ($message) use($messageHeader) {
             $message->from($messageHeader['from'], $messageHeader['fromName']);
             $message->to($messageHeader['to'], $messageHeader['toName']);
             if (!is_null($messageHeader['cc'])) {
                 $message->cc($messageHeader['cc']);
             }
             if (!is_null($messageHeader['bcc'])) {
                 $message->bcc($messageHeader['bcc']);
             }
             if (!is_null($messageHeader['replyTo'])) {
                 $message->replyTo($messageHeader['replyTo']);
             }
             $message->subject($messageHeader['subject']);
         });
         $result = true;
     } catch (Exception $e) {
         $result = ['success' => false, 'message' => $e->getMessage()];
     }
     return \Response::json($result);
 }
Esempio n. 3
0
 public function run(Request $request, Response $response, array $args)
 {
     $db = new Db();
     $db->install();
     $config = new Config();
     return new RedirectResponse($config->baseUrl());
 }
Esempio n. 4
0
 public function run()
 {
     $config = new Config();
     $this->write("Upgrading " . $config->siteTitle() . " . . . ");
     $db = new Db();
     $db->install();
     $this->write("Upgrade complete");
 }
Esempio n. 5
0
 /**
  * Send an email message.
  *
  * @param \Swift_Message $message
  */
 public function email(\Swift_Message $message)
 {
     $config = $this->config->mail();
     $transport_classname = '\\Swift_' . ucfirst($config['transport']) . 'Transport';
     $transport = $transport_classname::newInstance();
     $mailer = \Swift_Mailer::newInstance($transport);
     $mailer->send($message);
 }
Esempio n. 6
0
 private function getToken($credencial)
 {
     $config = new Config();
     $dominio = $config->getGeneral();
     $token = '';
     $token = (new Builder())->setIssuer($dominio['dominio'])->setAudience($dominio['dominio'])->setId('jajwt', true)->setIssuedAt(time())->setNotBefore(time() + 60)->setExpiration(time() + 3600)->set('sub', 1)->set('user', $credencial->usuario)->set('roles', $credencial->rol)->getToken();
     // Retrieves the generated token
     return (string) $token;
 }
Esempio n. 7
0
 public function save(Request $request, Response $response, array $args)
 {
     $_POST = array_filter($_POST, 'trim');
     $metadata = array('id' => filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT), 'title' => filter_input(INPUT_POST, 'title'), 'description' => filter_input(INPUT_POST, 'description'), 'date' => filter_input(INPUT_POST, 'date'), 'date_granularity' => filter_input(INPUT_POST, 'date_granularity', FILTER_SANITIZE_NUMBER_INT), 'edit_group' => filter_input(INPUT_POST, 'edit_group', FILTER_SANITIZE_NUMBER_INT), 'read_group' => filter_input(INPUT_POST, 'read_group', FILTER_SANITIZE_NUMBER_INT));
     $tags = filter_input(INPUT_POST, 'tags');
     $item = new Item(null, $this->user);
     $item->save($metadata, $tags, $_FILES['file']['tmp_name'], filter_input(INPUT_POST, 'file_contents'));
     $config = new Config();
     return new RedirectResponse($config->baseUrl() . '/' . $item->getId());
 }
Esempio n. 8
0
 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");
     }
 }
Esempio n. 9
0
 /**
  * Get the filesystem manager.
  *
  * @return MountManager
  * @throws \Exception
  */
 public static function getFilesystem()
 {
     $config = new Config();
     $manager = new MountManager();
     foreach ($config->filesystems() as $name => $fsConfig) {
         $adapterName = '\\League\\Flysystem\\Adapter\\' . self::camelcase($fsConfig['type']);
         $adapter = new $adapterName($fsConfig['root']);
         $fs = new Filesystem($adapter);
         $manager->mountFilesystem($name, $fs);
     }
     return $manager;
 }
Esempio n. 10
0
 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>';
     }
 }
Esempio n. 11
0
 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);
 }
Esempio n. 12
0
 /**
  * @author: lmkhang (skype)
  * @date: 2016-01-15
  * Action: Admin login
  */
 public function login(Request $request)
 {
     //check islogged
     if ($this->isLoggedAdmin()) {
         //set Flash Message
         $this->setFlash('message', 'Logged!');
         return Redirect::intended('/adminntw')->with('message', 'Logged!');
     }
     $post = $request->all();
     $info = $this->trim_all($post['login']);
     //Setup validation
     $validator = Validator::make($info, ['account' => 'required|min:5|max:100', 'password' => 'required|min:5|max:50']);
     //Checking
     if ($validator->fails()) {
         // The given data did not pass validation
         //set Flash Message
         $this->setFlash('message', 'Errors!');
         return redirect()->back();
     }
     $salt = \App\Config::where(['prefix' => 'admin', 'name' => 'salt', 'del_flg' => 1])->get()[0]['value'];
     $pwd = $this->encryptString($info['password'], $salt);
     $admin_get = new \App\Admin();
     $admin = $admin_get->checkAccount($info['account'], $pwd);
     //set Session
     if (!$admin) {
         //set Flash Message
         $this->setFlash('message', 'This account is not available!');
         return redirect()->back()->with('message', 'This account is not available!');
     }
     //set Session
     $this->setLogSession($admin->toArray());
     //set Flash Message
     $this->setFlash('message', 'Login successfully!');
     return Redirect::intended('/adminntw')->with('message', 'Login successfully!');
 }
Esempio n. 13
0
 public function handle($request, Closure $next)
 {
     $today = Carbon::now('Asia/Manila');
     $report_date = Config::find(1);
     // Send a report if today is not set to our config table
     if ($report_date->report_date->day != $today->day || $report_date->report_date->month != $today->month || $report_date->report_date->year != $today->year) {
         $report_date->report_date = $today;
         $report_date->save();
         $deadline_names = [];
         $i = new \App\Info();
         foreach (\App\Info::all() as $info) {
             $deadline = $i->isDeadLineToday($info->dead_line);
             if ($deadline == 'deadline' && $info->claim_status != 'approved') {
                 $deadline_names[$info->name] = $info;
             }
         }
         $data = array('data' => $deadline_names);
         \Log::info('Sending mail....');
         \Mail::send('email.email', $data, function ($message) {
             $message->from('*****@*****.**', 'GIBX Internal System');
             $date = \Carbon\Carbon::today('Asia/Manila')->format('d/m/Y');
             $recipients = ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'];
             $message->to($recipients)->subject('GIBX Claims System Daily Report ' . $date);
         });
         // TODO: Send an email for reporting here...
     }
     return $next($request);
 }
Esempio n. 14
0
 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);
 }
Esempio n. 15
0
 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);
 }
Esempio n. 16
0
 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));
 }
 /**
  * Подключение шаблонизатора Twig
  */
 public function __construct()
 {
     $config = \App\Config::instance();
     $templates_dir = $config->data['templates']['dir'];
     $loader = new \Twig_Loader_Filesystem($templates_dir);
     $this->twig = new \Twig_Environment($loader);
 }
 /**
  * setMetadata for common pages
  */
 private function setMetadata($prefix = '')
 {
     // metadata
     $site_title = Config::findByKey('site_title')->first()->value;
     if ($prefix != '') {
         $site_title = $prefix . ' - ' . $site_title;
     }
     $meta_description = Config::findByKey('meta_description')->first()->value;
     $meta_keywords = Config::findByKey('meta_keywords')->first()->value;
     SEOMeta::setTitle($site_title);
     SEOMeta::setDescription($meta_description);
     SEOMeta::addKeyword([$meta_keywords]);
     OpenGraph::setTitle($site_title);
     OpenGraph::setDescription($meta_description);
     OpenGraph::setUrl(url());
     OpenGraph::addProperty('type', 'website');
     OpenGraph::addProperty('site_name', 'Kết Nối Mới');
     OpenGraph::addImage(url() . '/frontend/images/fb_share_1.jpg');
     OpenGraph::addImage(url() . '/frontend/images/fb_share_2.jpg');
     OpenGraph::addImage(url() . '/frontend/images/fb_share_3.jpg');
     OpenGraph::addImage(url() . '/frontend/images/fb_share_4.jpg');
     OpenGraph::addImage(url() . '/frontend/images/fb_share_5.jpg');
     OpenGraph::addImage(url() . '/frontend/images/fb_share_6.jpg');
     OpenGraph::addImage(url() . '/frontend/images/fb_share_7.jpg');
     // end metadata
 }
 public function store(Request $request)
 {
     $userPlayers = new UserPlayers();
     //$team->where('team_name', $request->team_name)->first()->contract_id;
     $playerContractId = Contracts::where('player_id', $request->player_id)->select('contract_id')->first()->contract_id;
     $playerClubId = Contracts::where('player_id', $request->player_id)->select('club_id')->first()->club_id;
     $countPlayers = $userPlayers->join('fantasy_contracts', 'fantasy_user_players.id', '=', 'fantasy_contracts.player_id')->join('fantasy_club', 'fantasy_contracts.club_id', '=', 'fantasy_club.club_id')->where('user_id', $request->user()->id)->where('fantasy_club.club_id', $playerClubId)->count();
     $config = Config::select()->first();
     if ($userPlayers->where('user_id', $request->user()->id)->where('id', $playerContractId)->first()) {
         $error = "havePlayer";
     } elseif (!($countPlayers < $config->same_team_player)) {
         $error = "playerLimit";
     } elseif ($request->user()->credits - Players::where('player_id', $request->player_id)->select('price')->first()->price <= 0) {
         $error = "noCredits";
     } else {
         User::where('id', $request->user()->id)->update(['credits' => $request->user()->credits - Players::where('player_id', $request->player_id)->select('price')->first()->price]);
         $userPlayers->team_id = $request->user()->team->team_id;
         $userPlayers->user_id = $request->user()->id;
         $userPlayers->id = $playerContractId;
         $userPlayers->save();
         return redirect()->back();
     }
     //return new RedirectResponse(url('add_player_in_team'));
     return redirect()->back()->with('error', trans('front/site.' . $error));
 }
Esempio n. 20
0
    public function getJSONLD()
    {
        return '{
			"@context": "http://schema.org",
			"@type": "NewsArticle",
			"mainEntityOfPage":{
				"@type":"WebPage",
				"@id":"' . $this->getLink($this->categories()->first()->key) . '"
			},
			"headline": "' . $this->name . '",
			"image": {
				"@type": "ImageObject",
				"url": "' . url() . Image::url($this->getFirstAttachment(), 748, 388, array('crop')) . '",
				"height": "748",
				"width": "388"
			},
			"datePublished": "' . $this->created_at->toW3CString() . '",
			"dateModified": "' . $this->updated_at->toW3CString() . '",
			"author": {
				"@type": "Person",
				"name": "' . $this->created_by . '"
			},
			"publisher": {
				"@type": "Organization",
				"name": "' . Config::findByKey('site_name')->first()->value . '",
				"logo": {
					"@type": "ImageObject",
					"url": "' . url() . '/frontend/images/logo.png",
					"width": "90",
					"height": "21"
    			}
			},
			"description": "' . $this->summary . '"
		}';
    }
Esempio n. 21
0
 public function getReset()
 {
     $config = Config::getConfig();
     if (Auth::check()) {
         return view('auth.reset', compact('config'));
     }
     return Redirect::route('getLogin');
 }
 /**
  * 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);
         }
     }
 }
Esempio n. 23
0
 /**
  * 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;
     });
 }
Esempio n. 24
0
 protected function __construct()
 {
     $config = Config::instance();
     try {
         $this->dbh = $this->getPdoObj($config);
     } catch (\PDOException $e) {
         throw new DbException('Не удалось подключиться к БД ' . '<br>' . $e->getMessage());
     }
 }
 /**
  * Download resume file
  *
  * @return Response
  */
 public function download()
 {
     $configs = Config::getConfigs(['resume'], 'real');
     if ($configs['resume']) {
         return response()->download($configs['resume'], 'Resume.docx');
     } else {
         redirect('cv');
     }
 }
Esempio n. 26
0
 /**
  * Update config via POST
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     if (Gate::denies('set-config')) {
         abort(403);
     }
     $config = Config::first();
     $config->update($request->only('registration_enabled'));
     return response()->json($config);
 }
Esempio n. 27
0
 public static function connect($section = 'default')
 {
     static $caches = [];
     if (isset($caches[$section])) {
         return $caches[$section];
     }
     $conf = \app\Config::load('database', $section);
     return $caches[$section] = new self($conf);
 }
 /**
  * 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;
 }
Esempio n. 29
0
 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;
     }
 }
Esempio n. 30
0
function database_start()
{
    $config = \App\Config::getInstance()->get('database');
    switch (strtolower($config['active'])) {
        case 'mysql':
            ORM::configure(sprintf('mysql:host=%s;dbname=%s', $config['mysql']['hostname'], $config['mysql']['name']));
            ORM::configure('username', $config['mysql']['username']);
            ORM::configure('password', $config['mysql']['password']);
    }
}