public static function populateCombo($value, $texto, $sel = "") { $selec = $value == $sel ? " selected " : ""; $epi = new Epi(); //verifica a quantidade no estoque if ($epi->getQuantidade($value) <= 10) { echo "<option style='background-color:#f33;' {$selec} value=\"{$value}\">" . $texto . "</option>"; } else { echo "<option {$selec} value=\"{$value}\">" . $texto . "</option>"; } }
public function load() { $args = func_get_args(); foreach ($args as $file) { // Prepend config directory if the path doesn't start with . or / if ($file[0] != '.' && $file[0] != '/') { $file = Epi::getPath('config') . "/{$file}"; } if (!file_exists($file)) { EpiException::raise(new EpiConfigException("Config file ({$file}) does not exist")); break; // need to simulate same behavior if exceptions are turned off } $parsed_array = parse_ini_file($file, true); foreach ($parsed_array as $key => $value) { if (!is_array($value)) { $this->config->{$key} = $value; } else { if (!isset($this->config->{$key})) { $this->config->{$key} = new stdClass(); } foreach ($value as $innerKey => $innerValue) { $this->config->{$key}->{$innerKey} = $innerValue; } } } } }
/** * EpiApi::getRoute($route); * @name getRoute * @author Jaisen Mathai <*****@*****.**> * @param string $route * @method getRoute * @static method */ public function getRoute($route, $httpMethod) { foreach ($this->regexes as $ind => $regex) { if (preg_match($regex, $route, $arguments)) { array_shift($arguments); $def = $this->routes[$ind]; if ($httpMethod != $def['httpMethod']) { continue; } else { if (is_array($def['callback']) && method_exists($def['callback'][0], $def['callback'][1])) { if (Epi::getSetting('debug')) { getDebug()->addMessage(__CLASS__, sprintf('Matched %s : %s : %s : %s', $httpMethod, $this->route, json_encode($def['callback']), json_encode($arguments))); } return array('callback' => $def['callback'], 'args' => $arguments, 'postprocess' => true); } else { if (function_exists($def['callback'])) { if (Epi::getSetting('debug')) { getDebug()->addMessage(__CLASS__, sprintf('Matched %s : %s : %s : %s', $httpMethod, $this->route, json_encode($def['callback']), json_encode($arguments))); } return array('callback' => $def['callback'], 'args' => $arguments, 'postprocess' => true); } } } EpiException::raise(new EpiException('Could not call ' . json_encode($def) . " for route {$regex}")); } } EpiException::raise(new EpiException("Could not find route {$this->route} from {$_SERVER['REQUEST_URI']}")); }
private function getFilePath($file) { // Prepend config directory if the path doesn't start with . or / if ($file[0] != '.' && $file[0] != '/') { $file = Epi::getPath('config') . "/{$file}"; } return $file; }
public static function raise($exception) { $useExceptions = Epi::getSetting('exceptions'); if ($useExceptions) { throw new $exception($exception->getMessage(), $exception->getCode()); } else { echo sprintf("An error occurred and you have <strong>exceptions</strong> disabled so we're displaying the information.\n To turn exceptions on you should call: <em>Epi::setSetting('exceptions', true);</em>.\n <ul><li>File: %s</li><li>Line: %s</li><li>Message: %s</li><li>Stack trace: %s</li></ul>", $exception->getFile(), $exception->getLine(), $exception->getMessage(), nl2br($exception->getTraceAsString())); } }
/** * EpiRoute::get('/path/to/template.php', $array); * @name get * @author Jaisen Mathai <*****@*****.**> * @param string $template * @param array $vars * @method get * @static method */ public function get($template = null, $vars = null) { $templateInclude = Epi::getPath('view') . '/' . $template; if (is_file($templateInclude)) { if (is_array($vars)) { extract($vars); } ob_start(); include $templateInclude; $contents = ob_get_contents(); ob_end_clean(); return $contents; } else { EpiException::raise(new EpiException("Could not load template: {$templateInclude}", 404)); } }
public function upgradePost() { getAuthentication()->requireAuthentication(); getUpgrade()->performUpgrade(); $configObj = getConfig(); // Backwards compatibility // TODO remove in 2.0 $basePath = dirname(Epi::getPath('config')); $configFile = sprintf('%s/userdata/configs/%s.ini', $basePath, getenv('HTTP_HOST')); if (!file_exists($configFile)) { $configFile = sprintf('%s/generated/%s.ini', Epi::getPath('config'), getenv('HTTP_HOST')); } $config = $configObj->getString($configFile); $config = preg_replace('/lastCodeVersion *= *"\\d+\\.\\d+\\.\\d+"/', sprintf('lastCodeVersion="%s"', getUpgrade()->getCurrentVersion()), $config); $configObj->write($configFile, $config); $this->route->redirect('/'); }
public function upgradePost() { getAuthentication()->requireAuthentication(); getUpgrade()->performUpgrade(); $configObj = getConfig(); // Backwards compatibility // TODO remove in 2.0 $basePath = dirname(Epi::getPath('config')); $configFile = sprintf('%s/userdata/configs/%s.ini', $basePath, getenv('HTTP_HOST')); if (!file_exists($configFile)) { $configFile = sprintf('%s/generated/%s.ini', Epi::getPath('config'), getenv('HTTP_HOST')); } $config = $configObj->getString($configFile); // Backwards compatibility // TODO remove in 2.0 if (strstr($config, 'lastCodeVersion="') !== false) { $config = preg_replace('/lastCodeVersion="\\d+\\.\\d+\\.\\d+"/', sprintf('lastCodeVersion="%s"', getUpgrade()->getCurrentVersion()), $config); } else { // Before the upgrade code the lastCodeVersion was not in the config template $config = sprintf("[site]\nlastCodeVersion=\"%s\"\n\n", getUpgrade()->getCurrentVersion()) . $config; } $configObj->write($configFile, $config); $this->route->redirect('/'); }
<div class="formulario"> <div class="title-box" style="float:left"><div style="float:left"><img src="../images/search-icon.png" width="35px"></div><div style="float:left; margin-top:10px; margin-left:10px;"><span class="title">Pesquisar Equipamentos</span></div></div> <form method="POST" class="pesquisa-campos" id="pesquisa-campos" name="pesquisa-campos" action="pesquisa_epi.php"> <table id="table-search"> <tr> <td><span>Nome: </span></td> <td><input type="text" id="name_search" placeholder="Pesquise em branco para todos os resultados" name="name_search" title="Digite nome do equipamento queepi deseja pesquisar"></td> <td><input type="submit" value="Buscar" class="button"></td> </tr> </table> </form> <?php if (isset($_POST['name_search'])) { $epi = new Epi(); $epis = $epi->get_epi_by_name($_POST['name_search']); echo '<table class="exibe-pesquisa">'; $aux = 0; if (count($epis) > 0) { foreach ($epis as $key => $epi) { if ($aux % 2 == 0) { echo '<tr style="background-color:#bbb">'; } else { echo '<tr style="background-color:#cbcbcb">'; } echo '<td><a href="pesquisa_epi.php?verificador=1&id=' . $epis[$key][0] . '">' . $epis[$key][1] . " - " . $epis[$key][2] . '</a></td></tr>'; $aux++; } } echo '</table>';
public function insert(Epi $O_epi) { if (!is_null($O_epi->getDealer() && $O_epi->getOrderNumber() && $O_epi->getManufactureDate() && $O_epi->getPurchaseDate() && $O_epi->getProfile() && $O_epi->getInternalReference() && $O_epi->getCommissioningDate() && $O_epi->getLastCheckDate() && $O_epi->getNextCheckDate() && $O_epi->getEndOfLifeDate() && $O_epi->getLabelEpiId())) { // var_dump($O_epi); $S_dealer = $O_epi->getDealer(); $S_order_number = $O_epi->getOrderNumber(); $D_manufacture_date = $O_epi->getManufactureDate()->format('Y-m-d H:i:s'); $D_purchase_date = $O_epi->getPurchaseDate()->format('Y-m-d H:i:s'); $S_profile = $O_epi->getProfile(); $S_internal_reference = $O_epi->getInternalReference(); $D_commissioning_date = $O_epi->getCommissioningDate()->format('Y-m-d H:i:s'); $D_last_check_date = $O_epi->getLastCheckDate()->format('Y-m-d H:i:s'); $D_next_chack_date = $O_epi->getNextCheckDate()->format('Y-m-d H:i:s'); $D_end_of_life_date = $O_epi->getEndOfLifeDate()->format('Y-m-d H:i:s'); $I_label_epi_id = $O_epi->getLabelEpiId(); $I_team_id = $O_epi->getTeamId(); $S_sql = 'INSERT INTO `epi` (`dealer`, `order_number`, `manufacture_date`, `purchase_date`, `profile`, `internal_reference`, `commissioning_date`, `last_check_date`, `next_check_date`, `end_of_life_date`, `label_epi_id`, `team_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; $A_params = array($S_dealer, $S_order_number, $D_manufacture_date, $D_purchase_date, $S_profile, $S_internal_reference, $D_commissioning_date, $D_last_check_date, $D_next_chack_date, $D_end_of_life_date, $I_label_epi_id, $I_team_id); $O_connection = new Connection(); if ($I_epiId = $O_connection->requestDb($S_sql, $A_params)) { return $I_epiId; } else { throw new Exception("Des informations obligatoires sont manquantes, nous ne pouvons pas créer le modèle"); } } }
<?php error_reporting(E_ALL); ini_set('display_errors', 1); //max: set timezone // date_default_timezone_set('Europe/Stockholm'); try { // Start EPI include 'src/Epi.php'; Epi::init('api', 'database'); //include('config.php'); } catch (Exception $err) { // Make sure we always change the respose code to something else than 200 http_response_code(500); $err = array('error' => $err->getMessage(), 'file' => $err->getFile(), 'line' => $err->getLine()); response($err); } function p($data) { echo "<pre>" . print_r($data, true) . "</pre>"; } getRoute()->get('/', 'home', 'insecure'); //user getApi()->get('/users', array('users', 'getAll'), 'secure', EpiApi::external); getApi()->get('/users/self', array('users', 'getSelf'), 'secure', EpiApi::external); getApi()->get('/users/(\\d+)', array('users', 'get'), 'secure', EpiApi::external); getApi()->get('/users/relations', array('users', 'relations'), 'secure', EpiApi::external); getApi()->get('/users/relationsng', array('users', 'relationsng'), 'secure', EpiApi::external); getApi()->get('/users/phone/(\\w+)', array('users', 'phonenumber'), 'secure', EpiApi::external); //group
/** * load('api_config.ini') * @name load * @author Steve Mulligan <*****@*****.**> * @param string $api_config_ini_filename */ public function load($file) { $file = Epi::getPath('config') . "/{$file}"; if (!file_exists($file)) { EpiException::raise(new EpiException("Config file ({$file}) does not exist")); break; // need to simulate same behavior if exceptions are turned off } $parsed_array = parse_ini_file($file, true); foreach ($parsed_array as $route) { $method = strtolower($route['method']); $vis = strtolower($route['visibility']); // default visibiltiy is false. you MUST explcitly allow external access by adding visibility = external to the ini file $visibility = self::internal; if ($vis == "external") { $visibility = self::external; } if (isset($route['class']) && isset($route['function'])) { $this->{$method}($route['path'], array($route['class'], $route['function']), $visibility); } if (isset($route['instance']) && isset($route['function'])) { $this->{$method}($route['path'], array(new $route['instance'](), $route['function']), $visibility); } elseif (isset($route['function'])) { $this->{$method}($route['path'], $route['function'], $visibility); } } }
<?php include_once '../epiphany/src/Epi.php'; include_once 'controllers/home.class.php'; include_once 'controllers/login.class.php'; include_once 'controllers/dashboard.class.php'; include_once 'controllers/logout.class.php'; include_once 'lib/constants.class.php'; Epi::setSetting('exceptions', true); Epi::setPath('base', '../epiphany/src'); Epi::setPath('view', './views'); Epi::init('route', 'template', 'session'); getRoute()->get('/', array('HomeController', 'display')); getRoute()->get('/login', array('LoginController', 'display')); getRoute()->post('/login', array('LoginController', 'processLogin')); getRoute()->get('/dashboard', array('DashboardController', 'display')); getRoute()->get('/logout', array('LogoutController', 'processLogout')); getRoute()->run();
<?php chdir('..'); include_once '../src/Epi.php'; Epi::setPath('base', '../src'); Epi::init('route', 'session-php'); // If you'd like to use Memcached for sessions then init the 'session' or 'session-memcached' module and call EpiSession::employ() // EpiSession::employ(EpiSession::MEMCACHED); /* * This is a sample page which uses native php sessions * It's easy to switch the session backend by passing a different value to getInstance. * For example, EpiSession::getInstance(EpiSession::Memcached); */ getRoute()->get('/', array('MyClass', 'MyMethod')); getRoute()->run(); /* * ****************************************************************************************** * Define functions and classes which are executed by EpiRoute * ****************************************************************************************** */ class MyClass { public static function MyMethod() { $counter = (int) getSession()->get('counter'); $counter++; getSession()->set('counter', $counter); echo '<h1>You have clicked ' . getSession()->get('counter') . ' times <a href="">Reload</a></h1>'; } }
/** * addRoute('/', 'function', 'GET'); * @name addRoute * @author Jaisen Mathai <*****@*****.**> * @param string $route * @param mixed $callback * @param mixed $method * @param string $callback */ private function addRoute($route, $callback, $method, $postprocess = false) { $this->routes[] = array('httpMethod' => $method, 'path' => $route, 'callback' => $callback, 'postprocess' => $postprocess); $this->regexes[] = "#^{$route}\$#"; if (Epi::getSetting('debug')) { getDebug()->addMessage(__CLASS__, sprintf('Found %s : %s : %s', $method, $route, json_encode($callback))); } }
$epi = new Epi(); $is_epi = isset($_POST['is_epi']) ? $_POST['is_epi'] ? 1 : 0 : 0; //Ternário do if(isset($_POST['is_epi'])){if($_POST['is_epi']){$is_epi = 1;}else{$is_epi = 0;}}else{$is_epi = 0;} $epi->add_epi($is_epi, $_POST['codigo'], $_POST['nome'], $_POST['desc'], $_POST['empresa'], $_POST['quantidade']); // echo $exame->printExames(); if ($epi->add_epi_bd()) { echo '<div class="msg">Cadastrado com sucesso!</div>'; } else { echo '<div class="msg">Erro ao cadastrar!</div>'; } } } else { if (isset($_POST['tipo']) && $_POST['tipo'] == "editar") { if (isset($_POST['id'])) { if (validade()) { $epi = new Epi(); $is_epi = isset($_POST['is_epi']) ? $_POST['is_epi'] ? 1 : 0 : 0; //Ternário do if(isset($_POST['is_epi'])){if($_POST['is_epi']){$is_epi = 1;}else{$is_epi = 0;}}else{$is_epi = 0;} if ($epi->atualiza_epi($is_epi, $_POST['codigo'], $_POST['nome'], $_POST['desc'], $_POST['empresa'], $_POST['quantidade'], $_POST['id'])) { echo '<div class="msg">Atualizado com sucesso!</div>'; echo '<script>alert("EPI atualizado com sucesso")</script>'; } else { echo '<div class="msg">Falha na atualização!</div>'; } } //fim validade } //fim ifisset } //fim if }
<?php chdir('..'); include_once '../src/Epi.php'; Epi::setPath('base', '../src'); Epi::init('route', 'database'); EpiDatabase::employ('mysql', 'mysql', 'localhost', 'root', ''); // type = mysql, database = mysql, host = localhost, user = root, password = [empty] // Epi::init('base','cache','session'); // Epi::init('base','cache-apc','session-apc'); // Epi::init('base','cache-memcached','session-apc'); /* * This is a sample page whch uses EpiCode. * There is a .htaccess file which uses mod_rewrite to redirect all requests to index.php while preserving GET parameters. * The $_['routes'] array defines all uris which are handled by EpiCode. * EpiCode traverses back along the path until it finds a matching page. * i.e. If the uri is /foo/bar and only 'foo' is defined then it will execute that route's action. * It is highly recommended to define a default route of '' for the home page or root of the site (yoursite.com/). */ getRoute()->get('/', 'dbhandler'); getRoute()->run(); /* * ****************************************************************************************** * Define functions and classes which are executed by EpiCode based on the $_['routes'] array * ****************************************************************************************** */ function dbhandler() { $users = getDatabase()->all('SELECT * FROM user'); echo "<h2>All users</h2><ol>"; foreach ($users as $key => $user) {
<?php include_once './src/Epi.php'; Epi::setPath('base', './src'); Epi::init('api'); Epi::setSetting('exceptions', true); /* * We create 3 normal routes (think of these are user viewable pages). * We also create 2 api routes (this of these as data methods). * The beauty of the api routes are they can be accessed natively from PHP * or remotely via HTTP. * When accessed over HTTP the response is json. * When accessed natively it's a php array/string/boolean/etc. */ getRoute()->get('/', 'showEndpoints'); getRoute()->get('/version', 'showVersion'); getRoute()->get('/users', 'showUsers'); getRoute()->get('/users/javascript', 'showUsersJavaScript'); getRoute()->get('/params', 'showParams'); getApi()->get('/version.json', 'apiVersion', EpiApi::external); getApi()->get('/users.json', 'apiUsers', EpiApi::external); getApi()->get('/params.json', 'apiParams', EpiApi::external); getApi()->get('/params-internal.json', 'apiParams', EpiApi::internal); getApi()->get('/params-internal-from-external.json', 'apiParamsFromExternal', EpiApi::external); getRoute()->run(); /* * ****************************************************************************************** * Define functions and classes which are executed by EpiCode based on the $_['routes'] array * ****************************************************************************************** */ function showEndpoints()
<?php chdir('..'); include_once '../src/Epi.php'; Epi::setPath('base', '../src'); Epi::init('route', 'cache-apc'); // If you'd like to use Memcached for cache then init the 'cache' or 'cache-memcached' module and call EpiCache::employ() // EpiCache::employ(EpiCache::MEMCACHED); /* * This is a sample page which uses native php sessions * It's easy to switch the session backend by passing a different value to getInstance. * For example, EpiSession::getInstance(EpiSession::Memcached); */ getRoute()->get('/', array('MyClass', 'MyMethod')); getRoute()->run(); /* * ****************************************************************************************** * Define functions and classes which are executed by EpiRoute * ****************************************************************************************** */ class MyClass { public static function MyMethod() { if (isset($_GET['name'])) { getCache()->set('name', $_GET['name']); } $name = getCache()->get('name'); if (empty($name)) { $name = '[Enter your name]'; }
<?php date_default_timezone_set('America/Los_Angeles'); $basePath = dirname(dirname(__FILE__)); $libraryPath = sprintf('%s/libraries', $basePath); $epiPath = sprintf('%s/epi', $libraryPath); require sprintf('%s/Epi.php', $epiPath); Epi::setPath('base', $epiPath); Epi::setPath('view', sprintf('%s/templates', $basePath)); Epi::setSetting('exceptions', true); Epi::init('api', 'cache', 'config', 'logger', 'route', 'session', 'template', 'database'); EpiSession::employ(EpiSession::PHP); require sprintf('%s/initialize.php', $libraryPath); getRoute()->run();
/** * addRoute('/', 'function', 'GET'); * @name addRoute * @author Jaisen Mathai <*****@*****.**> * @param string $route * @param mixed $callback * @param mixed $method * @param string $callback */ private function addRoute($route, $callback, $method, $access, $postprocess = false) { /* if ( $access == "secure" ) { // user needs to be logged in if ( isset($_SESSION['sessionId']) ) { $this->routes[] = array('httpMethod' => $method, 'path' => $route, 'callback' => $callback, 'postprocess' => $postprocess); $this->regexes[]= "#^{$route}\$#"; if(Epi::getSetting('debug')) getDebug()->addMessage(__CLASS__, sprintf('Found %s : %s : %s', $method, $route, json_encode($callback))); } else { //return 401 http_response_code(401); trigger_error('Access is denied'); } } else if ( $access == "insecure" ) { // user can see this without being logged in $this->routes[] = array('httpMethod' => $method, 'path' => $route, 'callback' => $callback, 'postprocess' => $postprocess); $this->regexes[]= "#^{$route}\$#"; if(Epi::getSetting('debug')) getDebug()->addMessage(__CLASS__, sprintf('Found %s : %s : %s', $method, $route, json_encode($callback))); }*/ $this->routes[] = array('httpMethod' => $method, 'path' => $route, 'callback' => $callback, 'postprocess' => $postprocess, 'access' => $access); $this->regexes[] = "#^{$route}\$#"; if (Epi::getSetting('debug')) { getDebug()->addMessage(__CLASS__, sprintf('Found %s : %s : %s', $method, $route, json_encode($callback))); } }
private function prepare($sql, $params = array()) { try { $sth = $this->dbh->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY)); $sth->execute($params); return $sth; } catch (PDOException $e) { if (Epi::getSetting('showSql')) { EpiException::raise(new EpiDatabaseQueryException("Query error: {$e->getMessage()} - {$sql}")); } else { EpiException::raise(new EpiDatabaseQueryException("Query error: {$e->getMessage()}")); } return false; } }
<input style="width:80px;" type="button" name="button" class="button" onclick="window.location.href='add_epiXfunc.php'" id="button" value="Cancelar"> </td> </tr> </table> </form> <?php } } ?> <?php if (isset($_POST['tipo']) && $_POST['tipo'] == "cadastrar") { if (validate()) { $epixfunc = new EpiXFunc(); $class_epi_bd = new Epi(); $nome_epi = $class_epi_bd; $id_func = $_POST['id_func']; $data_entrega = $_POST['data']; $idepi = $_POST['selecionados']; $cont = 0; //echo '<script>alert("'.$arridepi[$i][0].'");</script>'; for ($i = 0; $i < count($idepi); $i++) { $quantidade = substr($idepi[$i], 1, strpos($idepi[$i], ']') - 1); //pega aquandidade que vem via post $id_epi = substr($idepi[$i], strpos($idepi[$i], ']') + 1); //pega o id $quantidade_bd = $class_epi_bd->getQuantidade($id_epi); //quantidade de epi no banco if ($quantidade_bd - $quantidade < 0) { echo '<div class="msg">Não existe ' . $class_epi_bd->getNome($id_epi) . ' suficiente em estoque<br /><a href="javascript:history.back()">Voltar</a></div>';
<?php chdir('..'); include_once '../src/Epi.php'; Epi::setPath('base', '../src'); Epi::init('api'); /* * We create 3 normal routes (think of these are user viewable pages). * We also create 2 api routes (this of these as data methods). * The beauty of the api routes are they can be accessed natively from PHP * or remotely via HTTP. * When accessed over HTTP the response is json. * When accessed natively it's a php array/string/boolean/etc. */ getRoute()->get('/', 'showEndpoints'); getRoute()->get('/version', 'showVersion'); getRoute()->get('/users', 'showUsers'); getRoute()->get('/users/javascript', 'showUsersJavaScript'); getRoute()->get('/params', 'showParams'); getApi()->get('/version.json', 'apiVersion', EpiApi::external); getApi()->get('/users.json', 'apiUsers', EpiApi::external); getApi()->get('/params.json', 'apiParams', EpiApi::external); getApi()->get('/params-internal.json', 'apiParams', EpiApi::internal); getApi()->get('/params-internal-from-external.json', 'apiParamsFromExternal', EpiApi::external); getRoute()->run(); /* * ****************************************************************************************** * Define functions and classes which are executed by EpiCode based on the $_['routes'] array * ****************************************************************************************** */ function showEndpoints()
<?php require 'vendor/autoload.php'; Epi::init('template', 'route'); Epi::setPath('view', 'templates'); getRoute()->get('/', array('DomainChecker', 'Run')); getRoute()->run(); class DomainChecker { public static function Run() { if (file_exists("cache.json")) { $cache = json_decode(file_get_contents("cache.json"), true); } else { $cache = array(); } $tlds = explode(",", isset($_GET['tlds']) ? $_GET['tlds'] : "com,co.uk,net,org"); $domains = explode(",", isset($_GET['domains']) ? $_GET['domains'] : ""); $whois = new Whois(); $rows = array(); foreach ($domains as $domain) { if (strlen($domain) == 0) { continue; } $results = array(); $domain = trim($domain); $alltaken = true; foreach ($tlds as $tld) { if (array_key_exists($domain . "." . $tld, $cache) && $cache[$domain . "." . $tld]['time'] > time() - 60 * 60 * 24) { $info = $cache[$domain . "." . $tld]['data']; } else {
<?php chdir('..'); include_once '../src/Epi.php'; Epi::setPath('base', '../src'); Epi::setSetting('debug', true); Epi::init('route', 'debug'); getRoute()->get('/', array('MyClass', 'MyMethod')); getRoute()->get('/sample', array('MyClass', 'MyOtherMethod')); getRoute()->get('/somepath/source', array('MyClass', 'ViewSource')); getRoute()->run(); echo '<pre>'; echo getDebug()->renderAscii(); echo '</pre>'; /* * ****************************************************************************************** * Define functions and classes which are executed by EpiCode based on the $_['routes'] array * ****************************************************************************************** */ class MyClass { public static function MyMethod() { echo '<h1>You are looking at the output from MyClass::MyMethod</h1> <ul> <li><a href="/debug">Call MyClass::MyMethod</a></li> <li><a href="/debug/sample">Call MyClass::MyOtherMethod</a></li> <li><a href="/debug/somepath/source">View the source of this page</a></li> </ul> <p><img src="https://github.com/images/modules/header/logov3-hover.png"></p>'; }
public function printFunc() { $empresa = new Empresa(); $empresa->get_empresa_by_id($this->id_empresa); $valor_custo = new Valor_custo(); $valor_custo->get_valor_custo_id($this->id_valor_custo); $vlr = $this->verificaValor($valor_custo->valor); if ($vlr == "") { $vlr = 0.0; } $sal = $this->verificaValor($this->salario_base); $filial = Filial::get_filial_id($this->id_empresa_filial); $cbo = new Cbo(); $cbo->get_cbo_by_id($this->id_cbo); $turno = new Turno(); $turno->getTurnoById($this->id_turno); $u = new Epi(); $epi_func = $u->get_epi_func($this->id); $texto = ""; $texto .= "<table class='table_pesquisa'><tr>"; $texto .= "<td colspan='2'><b><span>ID: <span></b></td><td><span><span>" . $this->id . "</span><td><span>Cod_Serie</span></td><td><span>" . $this->cod_serie . "</span></td></td>"; $texto .= "</tr>"; $texto .= "<tr>"; $texto .= "<td colspan='2'><b><span>Nome: <span></b></td><td colspan='3'><span>" . $this->nome . "</span></td>"; $texto .= "</tr>"; $texto .= "<tr>"; $texto .= "<td colspan='2'><b><span>Telefone: <span></b></td><td colspan='3'><span>" . $this->telefone . "</span></td>"; $texto .= "</tr>"; $texto .= "<tr>"; $texto .= "<td colspan='2'><b><span>CPF: <span></b></td><td colspan='3'><span>" . $this->cpf . "</span></td>"; $texto .= "</tr>"; $texto .= "<tr>"; $texto .= "<td colspan='2'><b><span>Data de Nascimento: <span></b></td><td colspan='3'><span>" . $this->data_nasc . "</span></td>"; $texto .= "</tr>"; $texto .= "<tr>"; $texto .= "<td colspan='2'><b><span>Email:<span> </b></td><td colspan='3'><span>" . $this->email . "</span></td>"; $texto .= "</tr>"; $texto .= "<tr>"; $texto .= "<td colspan='2'><b><span>Empresa: <span></b></td><td colspan='3'><span>" . $empresa->nome_fantasia . "</span></td>"; $texto .= "</tr>"; if ($filial) { $texto .= "<tr>"; $texto .= "<td colspan='2'><b><span>Filial: <span></b></td><td colspan='3><span>" . $filial->nome . "</span></td>"; $texto .= "</tr>"; } $texto .= "<tr>"; $texto .= "<td colspan='2'><b><span>Salário base: <span></b></td><td colspan='3'><span>R\$ " . number_format($sal, 2, ',', '.') . "</span></td>"; $texto .= "</tr>"; $texto .= "<tr>"; $texto .= "<td colspan='2'><b><span>Valor de Custo: <span></b></td><td colspan='3'><span>R\$ " . number_format($vlr, 2, ',', '.') . "</span></td>"; $texto .= "</tr>"; $texto .= "<tr>"; if (isset($cbo->descricao)) { $texto .= "<td colspan='2'><b><span>CBO: <span></b></td><td colspan='3'><span>" . $cbo->descricao . "</span></td>"; } $texto .= "</tr>"; $texto .= "<tr>"; $texto .= "<td colspan='2'><b><span>Turno: <span></b></td><td colspan='3'><span>" . $turno->nome . " - " . $turno->desc . "</span></td>"; $texto .= "</tr>"; if (count($epi_func) > 0) { $texto .= '<tr> <td colspan="5"><span><b>Equipamentos do funcionário:</b></span></td></tr>'; $texto .= '<tr> <td><span>ID</span></td> <td><span>Nome</span></td> <td><span>Data da entrega</span></td><td><span>Quantidade</span></td></tr>'; foreach ($epi_func as $key => $value) { $texto .= '<tr><td><span>' . $epi_func[$key]->id . '</span></td><td><span>' . $epi_func[$key]->nome_epi . '</span></td><td><span>' . $epi_func[$key]->data_entrega . '</span></td><td><span>' . $epi_func[$key]->quantidade . '</span></td></tr>'; } } $texto .= "</table>"; return $texto; }
?> </td> </tr> <tr> <td colspan="4" style="text-align:center"><input type="submit" name="button" class="button" id="button" value="Salvar"> <input class="button" type="button" name="button" onclick="window.location.href='add_func'" id="button" value="Cancelar"> </td> </tr> </table> </form> </div> <?php include_once "informacoes_func.php"; //exibe uma tabela com dados do funcionario echo '<div class="formulario dir">'; $u = new Epi(); $epi_func = $u->get_epi_func($func->id); $aux = 0; echo '<div style="float:right; margin-top:-10px;"><a title="Clique para adicionar ou alterar equipamentos desse funcionário" href="add_epiXfunc?tipo=cadastrar&id=' . $func->id . '"> <div style="float:left"><img style="height:20px;" src="../images/icon-edita.png" ></div><div style="padding-botton:10px; float:left;padding-top:5px;"><span>Editar</span></div></a></div>'; echo '<table class="exibe_equipamentos" border="0">'; echo '<tr><td colspan="4" style="padding:10px;"><span><b><a title="Clique para adicionar ou alterar equipamentos desse funcionário" href="add_epiXfunc?tipo=cadastrar&id=' . $func->id . '">EQUIPAMENTOS CADASTRADOS PARA ' . strtoupper($func->nome) . '</a></b></span></td></tr>'; echo '<tr> <td><span><b>ID</b></span></td> <td><span><b>Nome</b></span></td> <td><span><b>Data da entrega</b></span></td><td><span><b>Quantidade</b></span></td></tr>'; foreach ($epi_func as $key => $value) { if ($aux % 2 == 0) { //verifica se o numero é par ou impar, para imprimir a tabela zebrada echo '<tr style="background-color:#aaa"><td><span>' . $epi_func[$key]->id . '</span></td><td><span>' . $epi_func[$key]->nome_epi . '</span></td><td><span>' . $epi_func[$key]->data_entrega . '</span></td><td><span>' . $epi_func[$key]->quantidade . '</span></td></tr>'; } else { echo '<tr style="background-color:#ccc"><td><span>' . $epi_func[$key]->id . '</span></td><td><span>' . $epi_func[$key]->nome_epi . '</span></td><td><span>' . $epi_func[$key]->data_entrega . '</span></td><td><span>' . $epi_func[$key]->quantidade . '</span></td></tr>'; } $aux++; if ($aux >= 10) {
<?php chdir('..'); include_once '../src/Epi.php'; Epi::setPath('base', '../src'); Epi::init('route'); /* * This file is an example of using regular expressions in a route. * You can use subpatterns which are passed to the function as parameters. */ getRoute()->get('/', 'home'); getRoute()->get('/(\\w+)/(\\w+)', 'greeting'); getRoute()->run(); /* * ****************************************************************************************** * Define functions and classes which are executed by EpiRoute * ****************************************************************************************** */ function home() { echo '<h1>Home page. <a href="jaisen/mathai">Click for greeting</a></h1>'; } function greeting($firstName, $lastName) { echo "<h1>Welcome, {$firstName} {$lastName}</h1>"; }
<?php chdir('..'); include_once '../src/Epi.php'; Epi::setPath('base', '../src'); Epi::setPath('view', 'site-with-templates'); Epi::init('route', 'template'); /* * This is a sample page whch uses EpiCode. * There is a .htaccess file which uses mod_rewrite to redirect all requests to index.php while preserving GET parameters. * The $_['routes'] array defines all uris which are handled by EpiCode. * EpiCode traverses back along the path until it finds a matching page. * i.e. If the uri is /foo/bar and only 'foo' is defined then it will execute that route's action. * It is highly recommended to define a default route of '' for the home page or root of the site (yoursite.com/). */ getRoute()->get('/', array('MyClass', 'MyMethod')); getRoute()->run(); /* * ****************************************************************************************** * Define functions and classes which are executed by EpiCode based on the $_['routes'] array * ****************************************************************************************** */ class MyClass { public static function MyMethod() { $template = new EpiTemplate(); $params = array(); $params['heading'] = 'This is a heading'; $params['imageSrc'] = 'https://github.com/images/modules/header/logov3-hover.png'; $params['content'] = str_repeat('Lorem ipsum ', 100);