public function __construct() { // load the config object $config = Load::library('Config'); // get the connection name based off the enviroment $connection = $config->getEnvironment(); // load the connection details $details = $config->get('connections.' . $connection); try { // instantiate the PDO object $this->dbh = parent::__construct($details[0], $details[1], $details[2]); } catch (PDOException $e) { if ($config->isDev()) { // throw the original exception throw new Exception('PDO exception caught: ' . $e->getMessage()); } else { // throw the generic DB exception throw new Exception('Database connection error'); } } // set the PDO error mode to exception parent::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // return the DB handle return $this->dbh; }
public function ws() { Load::library('WebService'); $server = new SoapServer(null, array('uri' => 'http://localhost/freekore/test/ws')); // Asignamos la Clase $server->setClass('WebService'); // Atendemos las peticiones $server->handle(); $server->getFunctions(); }
<? Load::library('ODateInterval'); class ODateTime extends DateTime { public function __construct($dateTime=null, $timezone=null) { if(!$dateTime) throw new Exception('Date/time is null'); parent::__construct($dateTime); } public function __toString() { return $this->format('d M Y h:i a'); } public function diff($dateTime=null, $absolute=false, $invert=false) { if($dateTime === null) $dateTime = new DateTime(); $x = parent::diff($dateTime, $absolute); if($invert) { if($x->invert) $x->invert = 0; else $x->invert = 1; } return new DTDateInterval($x); } public function icalDateTime() { $utc = new DateTimeZone('UTC'); $tmp = clone $this; $tmp->setTimezone($utc); return $tmp->format('Ymd')."T".$tmp->format('His')."Z"; } public function icalDate() { $utc = new DateTimeZone('UTC'); $tmp = clone $this; $tmp->setTimezone($utc); return $tmp->format('Ymd'); }
<?php // define several important path constants define('SYS_PATH', realpath('../system/')); define('APP_PATH', realpath('../system/application')); define('LIB_PATH', realpath('../system/library')); define('LOG_PATH', realpath('../system/logs')); // include the Load class for all future object instantiation require_once LIB_PATH . '/Load.php'; // include the base Controller class require_once LIB_PATH . '/Controller.php'; // include the base Model class require_once LIB_PATH . '/Model.php'; // create the Config instance and set to singleton $config = Load::library('Config'); // instantiate the router class $router = Load::library('Router'); // EOF
public function importExcelData($file, $tablefields) { // Test CVS set_time_limit(0); //require_once 'Excel/reader.php'; Load::library('phpExcelReader/Excel/reader'); // ExcelFile($filename, $encoding); $data = new Spreadsheet_Excel_Reader(); // Set output Encoding. $data->setOutputEncoding('CP1251'); /*** * if you want you can change 'iconv' to mb_convert_encoding: * $data->setUTFEncoder('mb'); * **/ /*** * By default rows & cols indeces start with 1 * For change initial index use: * $data->setRowColOffset(0); * **/ /*** * Some function for formatting output. * $data->setDefaultFormat('%.2f'); * setDefaultFormat - set format for columns with unknown formatting * * $data->setColumnFormat(4, '%.3f'); * setColumnFormat - set format for column (apply only to number fields) * **/ //$data->read(SYSTEM_PATH.'app/libraries/phpExcelReader/RP 030 LG13 0206WM MBA1PR COLOTLAN columnas.xls'); $data->read($file); /* $data->sheets[0]['numRows'] - count rows $data->sheets[0]['numCols'] - count columns $data->sheets[0]['cells'][$i][$j] - data from $i-row $j-column $data->sheets[0]['cellsInfo'][$i][$j] - extended info about cell $data->sheets[0]['cellsInfo'][$i][$j]['type'] = "date" | "number" | "unknown" if 'type' == "unknown" - use 'raw' value, because cell contain value with format '0.00'; $data->sheets[0]['cellsInfo'][$i][$j]['raw'] = value if cell without format $data->sheets[0]['cellsInfo'][$i][$j]['colspan'] $data->sheets[0]['cellsInfo'][$i][$j]['rowspan'] */ error_reporting(E_ALL ^ E_NOTICE); echo '<table border="1" class="tbl-1">'; for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) { if ($i == 1) { // HEader echo '<thead><tr>'; echo '<th><input type="checkbox" name="chkAll" id="chkAll" onclick="checkAll($(this),\'chkRow\');" value="all" ></th>'; for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) { foreach ($tablefields as $fieldName => $fieldLabel) { $array[$fieldName] = $fieldLabel; } echo "<th>"; echo '<select name="col-' . ($j - 1) . '"><option value="">[X]Ignorar</option>' . fk_select_options_r($array) . '</select>'; if ($this->display_rules) { echo '<textarea name="rules[]" placeholder="Reglas"></textarea>'; } echo "</th>"; } echo '</tr></thead>'; } $trTieneDatos = 0; $tr = '<tr>'; $tr .= '<th><input type="checkbox" class="chkRow" name="rows[]" value="' . $i . '" ></th>'; for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) { $tr .= '<td>'; $tr .= utf8_encode($data->sheets[0]['cells'][$i][$j]); //$tr .= '<input type="hidden" name="txt_'.$i.'[]" value="'.$data->sheets[0]['cells'][$i][$j].'">'; $tr .= '<textarea style="display:none" name="txt_' . $i . '[]">' . utf8_encode($data->sheets[0]['cells'][$i][$j]) . '</textarea>'; $tr .= '</td>'; if (trim($data->sheets[0]['cells'][$i][$j]) != '') { $trTieneDatos++; } } $tr .= '</tr>'; if ($trTieneDatos > 0) { echo $tr; } } echo '</table>'; echo '<h3> ' . $data->sheets[0]['numRows'] . ' registros encontrados</h3>'; }
public function __construct() { $this->db = Load::library('DB'); }
private function setEnvironment($overwrite = false) { $uri = Load::library('URI'); if (!empty($overwrite)) { // we're overwriting the default environment $env = $overwrite; } else { $prod_exps = $this->get('server.prod_exps'); foreach ($prod_exps as $exp) { if (preg_match($exp, $_SERVER['SCRIPT_URI'])) { // we're on the production site $env = 'prod'; // break as we have a valid match break; } } } if (empty($env)) { // we're on the development site $env = 'dev'; } // set the server enviroment $this->set('server.environment', $env); // store environment in a session $this->session->set('sess_env', $env); }
public function __construct() { $this->view = Load::library('View'); $this->config = Load::library('Config'); }
public function __construct() { $this->Uri = Load::library('URI'); $this->Config = Load::library('Config'); $this->initRouting(); }
public function recuperar_clave() { $this->template = 'mailer'; if ($this->has_post('login') && $this->Usuarios->loginExist($this->post('login'))) { Load::library('mail'); $this->passNew = Mail::generarClave(6); $this->usuario = $this->Usuarios->updateUsuarioByMail($this->post('login'), $this->passNew); $this->render('mailer'); } }
public function __construct() { $this->Uri = Load::library('URI'); $this->Config = Load::library('Config'); $this->parseRoute(); }
public function recuperar_clave() { View::template('mailer'); $usuarios = new Usuarios(); if (Input::hasPost('login') && $this->Usuarios->loginExist(Input::post('login'))) { Load::library('mail'); $this->passNew = Mail::generarClave(6); $this->usuario = $usuarios->updateUsuarioByMail(Input::post('login'), $this->passNew); View::select('mailer'); } }
<?php // define several important path constants define('SYS_PATH', realpath('../system/')); define('APP_PATH', realpath('../system/application')); define('LIB_PATH', realpath('../system/library')); define('LOG_PATH', realpath('../system/logs')); // include the Load class for all future object instantiation require_once LIB_PATH . '/Load.php'; // include the static logger class require_once LIB_PATH . '/Logger.php'; // include the base Controller class require_once LIB_PATH . '/Controller.php'; // include the base Model class require_once LIB_PATH . '/Model.php'; // include the global exception require_once APP_PATH . '/exceptions/global.php'; // create the Config instance and set to singleton $config = Load::library('Config'); // instantiate the router class $router = Load::library('Application'); // EOF
/** * loadLibrary method * @param null/string $library * */ private function loadLibrary($library) { $className = ucfirst($library); $this->library->{$className} = $this->library->{lcfirst($className)} = Load::library($className); }