public function error($message) { require 'lib/controllers/error.controller.php'; $error = new Error(); $error->show($message); exit; }
public function getList() { //Run::$DEBUG_PRINT = true; $dataList = array(); $this->prepareList(); $sql = $this->buildSQL("list", $this->model->dataIntern, $this->model->schema, $this->model->schema_unions); $this->queryResult = $this->query->setLog(__LINE__, __FUNCTION__, __CLASS__, __FILE__)->setConnection($this->model->settings['database_id'])->setReturnId()->execute($sql)->getResult(); //$this->fetchData = $this->queryResult; //$this->query->returnFetchAssoc($this->queryResult); Run::$benchmark->writeMark("SelectData/select/buildSQL", "SelectData/select/database->query(sql)"); if (!$this->queryResult) { Error::show(0, "MODEL:: Houve um erro ao executar o select query automaticamente: " . $sql); } if ($this->queryResult === -2) { Error::show(0, "MODEL:: Houve um erro ao executar o select query automaticamente: " . $sql); } else { if ($this->query->returnNumRows($this->queryResult) > 0) { $dataSelectSequencial = $this->buildSQLDataList('list', $this->queryResult, $this->model->schema, $this->model->settings, $this->model->dataIntern); Run::$benchmark->writeMark("SelectData/select/Inicio", "SelectData/select/Final"); } } $sql_total = $this->buildSQLTotal("list", $this->model->dataIntern, $this->model->schema); $total = $this->query->setLog(__LINE__, __FUNCTION__, __CLASS__, __FILE__)->setConnection($this->model->settings['database_id'])->setReturnId()->execute($sql_total)->getResult(); //$this->queryResult = $this->query->execute($sql, false, false, __LINE__, __FUNCTION__, __CLASS__, __FILE__, $this->model->settings['database_id']); //Debug::p($sql); //Debug::p($sql_total); //Debug::p($dataSelectSequencial); //Debug::p($dataSelectTabulated); //Debug::p($dataSelectRecursive); return array("list" => $dataSelectSequencial, "total" => $total); //Debug::p("sql", $sql); //exit; }
public function error($exception) { require 'lib/controllers/error.controller.php'; $error = new Error(); $error->show($exception->getMessage() . '<br />Code: ' . $exception->getCode()); exit; }
public function getOrderedTables($data, $schema) { $tables_order_ref = $this->prepareOrdertables($schema); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (count($tables_order_ref) < 1) { Error::show(0, "tables_order_ref:: Não foram geradas ordens a serem gravadas"); } //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - return $tables_order_ref; }
public function getPropertiesToSession($file, $path = false) { if ($path === false) { $file = CONFIG_PATH . "properties/" . $file; } else { if ($path !== false) { $file = $path . $file; } } $name = explode("/", $file); $name = $name[count($name) - 1]; $this->session->set(array('PROPERTIES', $name), false); if (strrpos($file, ".properties") < 1) { $file_path = $file . ".properties"; } $open_config = fopen($file_path, "r") or Error::show(0, "{$file_path} não foi encontrado ou não pode ser aberto"); $settings = fread($open_config, filesize($file_path)); $settings = $this->string->encodeUtf8($settings); $settings = explode("\n", $settings); $sc = count($settings); $i = 0; $array_return = array(0); foreach ($settings as $k => $linha) { $prop = explode("=", $linha); $prop[0] = trim($prop[0]); // $this->string->clearSpecials(trim($prop[0])); $prop[0] = $this->string->removeSpecialsNormalize($prop[0]); $p_name = $prop[0]; unset($prop[0]); $p_string = implode("=", $prop); if ($p_name != "" && substr(trim($p_name), 0, 1) != "#" && substr(trim($p_name), 0, 1) != "//") { $array_return[$p_name] = trim($p_string); } } $propertie_session = $this->session->get(array('PROPERTIES', $name)); return $propertie_session; }
public function show() { parent::show(); $this->bye(); //On arrete le script }
public function multi_query($sql, $_line = __LINE__, $_function = __FUNCTION__, $_class = __CLASS__, $_file = __FILE__, $conn = false) { if ($conn == false) { $conn = self::$active; } Debug::log("Mysql->multi_query: {$sql}", __LINE__, __FUNCTION__, __CLASS__, __FILE__); $return = array(); $result = false; if (self::$connection[$conn]) { if (mysqli_multi_query(self::$connection[$conn], $sql)) { do { if ($result = mysqli_store_result(self::$connection[$conn])) { while ($row = mysqli_fetch_row($result)) { array_push($return, $row[0]); } mysqli_free_result($result); } if (mysqli_more_results(self::$connection[$conn])) { //printf("-----------------\n"); } } while (mysqli_next_result(self::$connection[$conn])); return $return; } else { Error::sqlError("Erro ao executar QUERY." . " na linha " . $_line . " / " . $_function . " / " . $_class . " ", self::$connection[$conn]->error, $result); return -2; } } else { Error::show(5553, "A conexão " . $conn . " não está disponível. Por favor, tente mais tarde. (" . self::$connection[$conn] . ")", $_file, $_line, ''); return -2; } }
/** * 视图文件 * * @param string $file * @return string */ public function getRenderFile($file = null) { if (empty($file)) { $file = Imp::app()->instance('mvcBuilder')->viewBuilder()->file(); } else { $file = Imp::app()->instance('mvcBuilder')->viewBuilder()->getRenderFile($file); } if (!is_file($file)) { Error::show(Error::getError(Error::$errorType['no_view_file']) . ': ' . $file); return; } return $file; }
public function renderReporting($obj = "", $url_index = false, $link = "?", $gets = "", $name = "items") { if (!isset($obj->PAGING_TOTAL) || !isset($obj->PAGING)) { Error::show(0, "Query:: Há um erro na classe, não será possivel renderizar a paginação corretamente."); } $html = ""; if (!$url_index) { $html .= "{$link}{$obj->SETTINGS['PAGING_REF']}index=[index]"; } else { $html .= "{$link}/[index]"; } if (isset($_GET[$obj->SETTINGS['PAGING_REF'] . 'ordem'])) { $html .= "&{$obj->SETTINGS['PAGING_REF']}ordem=" . $obj->DATA_INT[$obj->SETTINGS['PAGING_REF'] . 'ordem']; } if (isset($_GET[$obj->SETTINGS['PAGING_REF'] . 'modo'])) { $html .= "&{$obj->SETTINGS['PAGING_REF']}modo=" . $obj->DATA_INT[$obj->SETTINGS['PAGING_REF'] . 'modo']; } if (isset($_GET[$obj->SETTINGS['PAGING_REF'] . 'num'])) { $html .= "&{$obj->SETTINGS['PAGING_REF']}num=" . $obj->DATA_INT[$obj->SETTINGS['PAGING_REF'] . 'num']; } if (isset($_GET[$obj->SETTINGS['PAGING_REF'] . 'busca'])) { $html .= "&{$obj->SETTINGS['PAGING_REF']}busca=" . $obj->DATA_INT[$obj->SETTINGS['PAGING_REF'] . 'busca']; } // echo "<div class=\"getExcel\"><a href='?".$html."&". $obj->SETTINGS['REF'] ."export=excel' title='Gerar Relatório em Excel'><img src='". Config::$PATH ."cms/img/themes/default/logo_excel.gif' alt='relatório' /></a></div>"; }
function queue() { if (!$this->query_transaction) { return $this; } $result = $this->postgre->transactionQuery($this->query_string); if (!$result) { Error::show(5200, "Model->query->queue() Erro na Transaction: " . $this->postgre->getpostgreError() . __FUNCTION__, __FILE__, __LINE__, ''); $this->query_transaction = false; } return $this; }
public function query($sql, $returnId = false, $_line = __LINE__, $_function = __FUNCTION__, $_class = __CLASS__, $_file = __FILE__, $conn = false) { if ($conn == false) { $conn = self::$active; } Debug::log("Postgre->query: {$sql}", __LINE__, __FUNCTION__, __CLASS__, __FILE__); if (isset(self::$connection[$conn])) { $sql = $this->treatSpecials($sql); //self::$connection[$conn]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); try { if ($returnId != false) { $sql .= " RETURNING " . $returnId; } //echo "<br><br>sql: ".$sql; $result = pg_query(self::$connection[$conn], $sql) or Error::show(5552, "Ocorreu um erro na query da conexão " . $conn . ". " . pg_result_error($this->resultQuery) . " / " . pg_last_error(self::$connection[$conn]) . ". Por favor, tente mais tarde. \r\n {$sql}", $_file, $_line, ''); $id = pg_fetch_row($result); $this->lastId = $id[0]; $this->resultQuery = $result; return $this->resultQuery; } catch (PDOException $e) { Debug::log("Postgre->query: ERRO: " . $e->getMessage() . " na linha " . $_line . " / " . $_function . " / " . $_class . " ", $this->_line, $this->_function, $this->_class, $this->_file); Error::sqlError("Erro ao executar QUERY." . " na linha " . $_line . " / " . $_function . " / " . $_class . " ", $e->getMessage(), $sql); return -1; } } else { Error::show(5552, "A conexão " . $conn . " não está disponível. Por favor, tente mais tarde.", $_file, $_line, ''); return -2; } }
/** * Get the Bungie account. * Get membership information for each console fro the fetched Bungie account. * * @throws Exception if the servers are unreachable */ function get_accounts() { // This endpoint returns relevant data on each console account linked to a Bungie account $url = "https://www.bungie.net/platform/user/GetBungieAccount/" . $this->temp_account_id . "/" . $this->console; $lookup = file_get_contents($url); $response = json_decode(preg_replace('/NaN/', '"NaN"', $lookup)); if (isset($response->Response->bungieNetUser)) { $this->display_name = $response->Response->bungieNetUser->displayName; } else { $this->display_name = $response->Response->destinyAccounts[0]->userInfo->displayName; } if (count($response->Response->destinyAccounts) == 0) { // No destiny account mean something went wrong (because we looked // up the bungie account using a destiny account, so it must exist. DUH) $this->error = Error::show(Error::ERROR, "Destiny is in maintenance"); throw new Exception(); } foreach ($response->Response->destinyAccounts as $account) { if ($account->userInfo->membershipType != $this->console && count($response->Response->destinyAccounts) == 1) { // This is a weird error. If you only played the Alpha or Beta on a console, // but left to play the complete game on another console, this would show up. $this->error = Error::show(Error::WARNING, "Account found but played an earlier version of the game"); } $this->add_account($account->userInfo->membershipType, json_decode(json_encode($account->userInfo), true)); } }
public function triggerPeriodicAutoSendMail() { ob_clean(); ob_flush(); flush(); if (!$this->database) { $this->database = Model::connect($this->connectionID); } $query = Model::$query; $result = $query->select(array('pk_mail', 'fk_user', 'fk_table', 'fk_table_ref', 'from_name', 'from_mail', 'to_name', 'to_mail', 'subject', 'content', 'date_insert', 'status_int'))->from("mail_manager")->where(" status_int = 1 AND sent_status <= 0")->order("pk_mail ASC")->limit(0, Run::MAIL_AUTO_SEND_LIMIT)->execute()->returnAssoc(); $warMsg = $this->database->getWarning(); if ($warMsg != "" && $this->database->getError() != "00000") { Error::show(5200, "Model-> Erro ao selecionar mailManager:\n " . $warMsg . "\n " . $this->database->getError() . " \n{$sql_query} " . __FUNCTION__, __FILE__, __LINE__, ''); } else { if (count($result) == 0) { return false; } foreach ($result as $pk => $field) { if ($field['content'] == "") { $result = $query->update("mail_manager")->set(" sent_status = '-3', try_count = try_count+1, status_int = -2, date_update = '" . Run::$control->date->getDateUs() . "'")->where(" pk_mail = '" . $field['pk_mail'] . "'")->execute()->getResult(); continue; } if ($field['from_mail'] == "") { $result = $query->update("mail_manager")->set(" sent_status = '-4', try_count = try_count+1, status_int = -2, date_update = '" . Run::$control->date->getDateUs() . "'")->where(" pk_mail = '" . $field['pk_mail'] . "'")->execute()->getResult(); continue; } if ($field['to_mail'] == "") { $result = $query->update("mail_manager")->set(" sent_status = '-5', try_count = try_count+1, status_int = -2, date_update = '" . Run::$control->date->getDateUs() . "'")->where(" pk_mail = '" . $field['pk_mail'] . "'")->execute()->getResult(); continue; } $this->ref_pk = $field['pk_mail']; $field['content'] = str_replace('[id]', $field['pk_mail'], $field['content']); $this->setFrom($field['from_mail'], $field['from_name']); $this->setTo($field['to_mail'], $field['to_name']); $this->setMessage($field['content']); $this->setSubject($field['subject']); $resultSend = $this->send(); $result = $query->update("mail_manager")->set(" sent_status = '" . $resultSend . "', try_count = try_count+1, date_update = '" . Run::$control->date->getDateUs() . "'")->where(" pk_mail = '" . $field['pk_mail'] . "'")->execute()->getResult(); if ((is_integer($result) || $warMsg != "") && $this->database->getError() != "00000") { Error::show(5200, "Model-> Erro ao atualizar mailManager:\n " . $warMsg . "\n " . $this->database->getError() . " \n{$sql_query} " . __FUNCTION__, __FILE__, __LINE__, ''); } Debug::p("enviado {$resultSend}", $field); flush(); sleep(1); } } return true; }
private function deletePKFromMultipleRegistersTable($refs, $table, $schema) { // //Debug::p("deletePKFromMultipleRegistersTable ".$table, $this->dataDeletes); foreach ($this->dataDeletes[$table] as $k => $v) { // $sql_query = "DELETE FROM ". $refs['table'] ." WHERE ". $refs['pk'] ." = ". $v .""; // USANDO DELETE LÓGICO $updateTime = $this->getDateUpdateName($refs, $schema); $sql_query = "UPDATE " . $refs['table'] . " SET {$updateTime} " . $refs['status_name'] . "='-1' WHERE " . $refs['pk'] . " = {$v} "; //Debug::p("SQL_DELETE", $sql_query); $sql_obj = $this->database->query($sql_query, __LINE__, __FUNCTION__, __CLASS__, __FILE__, $this->settings['database_id']); //Debug::p($this->database->getError()); $warMsg = $this->database->getWarning(); if (is_integer($sql_obj) || $warMsg != "") { $this->query_errors++; Error::show(5200, "Model-> Erro ao deletar multiplo registro não selecionado no form:\n " . $warMsg . "\n " . $this->database->getError() . " \n{$sql_query}" . __FUNCTION__, __FILE__, __LINE__, ''); } else { $log = "Model: SQL Executado com sucesso (returnID:" . $this->database->getID($this->settings['database_id']) . "): \n {$sql_query}"; // Debug::print_r($log); // Debug::log($log, __LINE__, __FUNCTION__, __CLASS__, __FILE__); } } }
private function loadPageContent($pag) { Debug::log("Router - loadPageContent() ", __LINE__, __FUNCTION__, __CLASS__, __FILE__); $class = ucwords(str_replace("-", "_", $pag)) . "Controller"; $method = isset(self::$levels[$this->level_to_load_method]) ? self::$levels[$this->level_to_load_method] : "index"; $method = $this->checkFullUrlExist($class, $method); //Debug::p($class, $method); //echo "CHECK $class, $method :".method_exists($class,$method); //exit; if (class_exists($class)) { self::$controller = new $class(); //Debug::print_r("acceptNextIndexUnknownLevels: ".self::$controller->acceptNextIndexUnknownLevels); } if (class_exists($class) && method_exists($class, $method)) { for ($i = self::$levelRef + 2; $i < self::$levelRef; $i++) { $this->{$params}[$i - (self::$levelRef + 2)] = self::$levels[$i]; } Debug::log("Router->loadPageContent : Chamando metodo {$method} para a URL. (control/" . $pag . "_control.php) - {$class}"); Action::registerAccess(); Run::$ajaxMethod->start(); if (!isset(self::$controller->autoLoadMethod) || self::$controller->autoLoadMethod !== false) { Run::$benchmark->writeMark("startRouter/Inicio", "loadPageContent/if/controller/method"); self::$controller->{$method}(); } } else { if ((int) self::$controller->acceptNextIndexUnknownLevels > 0) { if (!isset(self::$controller->autoLoadMethod) || self::$controller->autoLoadMethod !== false) { $method = "index"; Debug::log("Router->loadPageContent : Chamando metodo index/{self::{$controller->acceptNextIndexUnknownLevels}} para a URL. (control/" . $pag . "_control.php) - {$class}"); Action::registerAccess(); Run::$benchmark->writeMark("startRouter/Inicio", "loadPageContent/else/controller/method"); if (method_exists($class, $method)) { self::$controller->{$method}(); } else { Error::show(8, "Router->loadPageContent: Metodo <b>{$method}</b> não existe. {self::{$controller->acceptNextUnknownLevels}} (control/" . $pag . "_control.php).", __FILE__, __LINE__); $this->load("404"); } } } else { if (!class_exists($class)) { Error::show(8, "Router->loadPageContent: Classe <b>{$class}</b> não existe. (control/" . $pag . "_control.php).", __FILE__, __LINE__); } else { Error::show(8, "Router->loadPageContent: Metodo <b>{$method}</b> não existe. {self::{$controller->acceptNextUnknownLevels}} (control/" . $pag . "_control.php).", __FILE__, __LINE__); } echo "<!-- {$class} ou {$method} não existe -->"; $this->load("404"); } } $this->flush(); //Run::$benchmark->writeMark("loadPageContent1", "loadPageContent2"); }
private function checkSchema($schema, $settings) { Debug::log("Model->checkschema:", __LINE__, __FUNCTION__, __CLASS__, __FILE__); //Debug::print_r($schema['from'][0]); if (!array_key_exists('pk', $schema['from'][0])) { Error::show(0, "FORM_MODEL:: Não foi declarado o PK para o schema."); } if (!array_key_exists('table', $schema['from'][0])) { Error::show(0, "FORM_MODEL:: Não foi declarado o table para o schema."); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- if (!array_key_exists('join', $schema)) { $schema['join'] = array(); } if (!array_key_exists('where', $schema)) { $schema['where'] = ""; } if (!array_key_exists('having', $schema)) { $schema['having'] = ""; } if (!array_key_exists('order', $schema)) { $schema['order'] = ""; } if (!array_key_exists('group', $schema)) { $schema['group'] = ""; } if (!array_key_exists('group_list', $schema)) { $schema['group_list'] = $schema['group']; } if (!array_key_exists('group_view', $schema)) { $schema['group_view'] = $schema['group']; } if (!array_key_exists('limit', $schema)) { $schema['limit'] = array(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- // LEMBRAR DE ATUALIZAR A CLASSE OrderTables->recursiveOrderJoinCheck // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- foreach ($schema['from'] as $k => $table) { $if0_false = $k == 0 ? false : true; if (!array_key_exists('save', $table)) { $schema['from'][$k]['save'] = ""; } if (!array_key_exists('view', $table)) { $schema['from'][$k]['view'] = true; } if (!array_key_exists('idPad', $table)) { $schema['from'][$k]['idPad'] = 4; } if (!array_key_exists('list', $table)) { $schema['from'][$k]['list'] = true; } if (!array_key_exists('listAsColumn', $table)) { $schema['from'][$k]['listAsColumn'] = true; } if (!array_key_exists('list_fields', $table)) { $schema['from'][$k]['list_fields'] = $schema['from'][$k]['list']; } if (!array_key_exists('list_inner', $table)) { $schema['from'][$k]['list_inner'] = $schema['from'][$k]['list']; } if (!array_key_exists('export', $table)) { $schema['from'][$k]['export'] = true; } if (!array_key_exists('order', $table)) { $schema['from'][$k]['order'] = ""; } if (!array_key_exists('status_name', $table)) { $schema['from'][$k]['status_name'] = 'status_int'; } if (!array_key_exists('delete_pk_empties', $table)) { $schema['from'][$k]['delete_pk_empties'] = $if0_false; } if (!array_key_exists('table_prefix', $table)) { $schema['from'][$k]['table_prefix'] = $settings['sql_table_prefix']; } $checkPos = strpos($schema['from'][$k]['table'], $schema['from'][$k]['table_prefix']); $schema['from'][$k]['table'] = $checkPos === 0 || $checkPos > 0 ? $schema['from'][$k]['table'] : $schema['from'][$k]['table_prefix'] . $schema['from'][$k]['table']; if (!array_key_exists('table_nick', $table)) { $schema['from'][$k]['table_nick'] = $table['table']; } if ($settings['check_schema'] === true) { $check = false; foreach ($schema['fields'] as $key => $val) { if (!isset($val['name'])) { $val['name'] = false; } if ($key == $table['pk'] || $val['name'] == $table['pk']) { $check = true; break; } } if ($check == false) { Error::show(0, "MODEL:: A referência PK: <b>" . $table['pk_ref'] . "</b> no FROM <b>" . $table['table'] . "</b> deve ser declarada corretamente na lista do schema."); } } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- foreach ($schema['join'] as $k => $table) { if (!array_key_exists('save', $table)) { $schema['join'][$k]['save'] = true; } if (!array_key_exists('view', $table)) { $schema['join'][$k]['view'] = true; } if (!array_key_exists('idPad', $table)) { $schema['join'][$k]['idPad'] = 4; } if (!array_key_exists('list', $table)) { $schema['join'][$k]['list'] = true; } if (!array_key_exists('listAsColumn', $table)) { $schema['join'][$k]['listAsColumn'] = false; } if (!array_key_exists('list_fields', $table)) { $schema['join'][$k]['list_fields'] = $schema['join'][$k]['list']; } if (!array_key_exists('list_inner', $table)) { $schema['join'][$k]['list_inner'] = $schema['join'][$k]['list']; } if (!array_key_exists('export', $table)) { $schema['join'][$k]['export'] = true; } if (!array_key_exists('delete_pk_empties', $table)) { $schema['join'][$k]['delete_pk_empties'] = true; } if (!array_key_exists('on', $table)) { $schema['join'][$k]['on'] = ""; } if (!array_key_exists('order', $table)) { $schema['join'][$k]['order'] = ""; } if (!array_key_exists('status_name', $table)) { $schema['join'][$k]['status_name'] = 'status_int'; } if (!array_key_exists('table_prefix', $table)) { $schema['join'][$k]['table_prefix'] = $settings['sql_table_prefix']; } $checkPos = strpos($schema['join'][$k]['table'], $schema['join'][$k]['table_prefix']); $schema['join'][$k]['table'] = $checkPos === 0 || $checkPos > 0 ? $schema['join'][$k]['table'] : $schema['join'][$k]['table_prefix'] . $schema['join'][$k]['table']; if (!array_key_exists('table_nick', $table)) { $schema['join'][$k]['table_nick'] = $schema['join'][$k]['table']; } if ($settings['check_schema'] === true) { $check = false; foreach ($schema['fields'] as $key => $val) { if (!isset($val['name'])) { $val['name'] = false; } if ($key == $table['pk_ref'] || $val['name'] == $table['pk_ref']) { $check = true; break; } } if ($table['table_ref'] != "" && $check == false) { Error::show(0, "MODEL:: A referência PK_REF: <b>" . $table['pk_ref'] . "</b> no JOIN <b>" . $table['table'] . "</b> deve ser declarada corretamente na lista do schema."); } $check = false; foreach ($schema['fields'] as $key => $val) { if (!isset($val['name'])) { $val['name'] = false; } if ($key == $table['pk'] && $val['name'] != false && $val['name'] != $table['pk']) { $check = false; break; } if ($key == $table['pk'] || $val['name'] == $table['pk']) { $check = true; break; } } if ($check == false) { Error::show(0, "MODEL:: A referência PK: <b>" . $table['pk'] . "</b> no JOIN <b>" . $table['table'] . "</b> deve ser declarada corretamente na lista do schema."); } } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- //Run::$DEBUG_PRINT = true; $order = (int) $settings['order_fields_index']; foreach ($schema['fields'] as $key => $val) { $multiple = false; $listAsColumn = true; $idPad = 4; if (!array_key_exists('belongsTo', $val)) { $schema['fields'][$key]['belongsTo'] = false; } if ($schema['fields'][$key]['belongsTo'] !== false) { /**/ $from_index = -1; $join_index = -1; foreach ($schema['from'] as $k => $from) { if ($from['table_nick'] == $schema['fields'][$key]['belongsTo'] || $from['table'] == $schema['fields'][$key]['belongsTo']) { $from_index = $k; $listAsColumn = $from['listAsColumn']; $idPad = $from['idPad']; //Debug::print_r("ACHOU $key / {$schema['fields'][$key]['belongsTo']} :".$from_index); break; } else { if ($join['table'] == $from['table_prefix'] . $schema['fields'][$key]['belongsTo']) { $schema['fields'][$key]['belongsTo'] = $from['table_prefix'] . $schema['fields'][$key]['belongsTo']; $join_index = $k; break; } } $multiple = false; } if ($from_index == -1) { foreach ($schema['join'] as $k => $join) { //Debug::p($schema['fields'][$key]['belongsTo'], $join['table']); if ($join['table_nick'] == $schema['fields'][$key]['belongsTo'] || $join['table'] == $schema['fields'][$key]['belongsTo']) { $join_index = $k; $listAsColumn = $join['listAsColumn']; $idPad = $join['idPad']; break; } else { if ($join['table'] == $join['table_prefix'] . $schema['fields'][$key]['belongsTo']) { $schema['fields'][$key]['belongsTo'] = $join['table_prefix'] . $schema['fields'][$key]['belongsTo']; $join_index = $k; break; } } } $multiple = isset($schema['join'][$join_index]['multiple']) ? $schema['join'][$join_index]['multiple'] : false; } if ($from_index == -1 && $join_index == -1) { Error::show(0, "MODEL:: O campo <b>" . $key . "</b> possui uma referência belongsTo <b>" . $schema['fields'][$key]['belongsTo'] . "</b> não encontrada em from ou em join no schema."); } } //Debug::print_r("ACHOU $key / {$schema['fields'][$key]['belongsTo']} :"); if (!array_key_exists('name', $val)) { $schema['fields'][$key]['name'] = $key; } if (!array_key_exists('label', $val)) { $schema['fields'][$key]['label'] = $key; } if (!array_key_exists('belongsTo', $val)) { $schema['fields'][$key]['belongsTo'] = $schema['from'][0]['table_nick'] != "" ? $schema['from'][0]['table_nick'] : $schema['from'][0]['table']; } if (!array_key_exists('fieldRef', $val)) { $schema['fields'][$key]['fieldRef'] = $key; } if (!array_key_exists('view', $val)) { $schema['fields'][$key]['view'] = true; } if (!array_key_exists('list', $val)) { $schema['fields'][$key]['list'] = false; } if (!array_key_exists('listLabel', $val)) { $schema['fields'][$key]['listLabel'] = $schema['fields'][$key]['label']; } if (!array_key_exists('listOrder', $val)) { $schema['fields'][$key]['listOrder'] = $order++; } if (!array_key_exists('listInClass', $val)) { $schema['fields'][$key]['listInClass'] = false; } if (!array_key_exists('listImplode', $val)) { $schema['fields'][$key]['listImplode'] = ", "; } if (!array_key_exists('listWidth', $val)) { $schema['fields'][$key]['listWidth'] = false; } if ($this->checkPkInTable($schema, $schema['fields'][$key]['name']) === true) { if (!array_key_exists('listAsColumn', $val)) { $schema['fields'][$key]['listAsColumn'] = false; } $schema['fields'][$key]['idPad'] = $idPad; $schema['fields'][$key]['isKey'] = true; } else { if (!array_key_exists('listAsColumn', $val)) { $schema['fields'][$key]['listAsColumn'] = $listAsColumn; } } if (!array_key_exists('exportWidth', $val)) { $schema['fields'][$key]['exportWidth'] = $schema['fields'][$key]['listWidth']; } if (!array_key_exists('export', $val)) { $schema['fields'][$key]['export'] = true; } if (!array_key_exists('skipRecEmpty', $val)) { $schema['fields'][$key]['skipRecEmpty'] = false; } // retira todos os campos do registro para o insert/update se for vazio if (!array_key_exists('skipFieldEmpty', $val)) { $schema['fields'][$key]['skipFieldEmpty'] = false; } // retira apenas o campo vazio para o insert/update if (!array_key_exists('type', $val)) { $schema['fields'][$key]['type'] = "string"; } if (!array_key_exists('insert', $val)) { $schema['fields'][$key]['insert'] = true; } if (!array_key_exists('update', $val)) { $schema['fields'][$key]['update'] = false; } if (!array_key_exists('multiple', $val)) { $schema['fields'][$key]['multiple'] = $multiple; } if (!array_key_exists('allowJS', $val)) { $schema['fields'][$key]['allowJS'] = false; } if (!array_key_exists('allowHTML', $val)) { $schema['fields'][$key]['allowHTML'] = false; } if (!array_key_exists('realScape', $val)) { $schema['fields'][$key]['realScape'] = true; } if (!array_key_exists('maxLength', $val)) { $schema['fields'][$key]['maxLength'] = false; } if (!array_key_exists('removeSpecials', $val)) { $schema['fields'][$key]['removeSpecials'] = false; } if (!array_key_exists('convertSpecials', $val)) { $schema['fields'][$key]['convertSpecials'] = true; } if (!array_key_exists('protectData', $val)) { $schema['fields'][$key]['protectData'] = true; } if (!array_key_exists('addSlashe', $val)) { $schema['fields'][$key]['addSlashe'] = true; } if (!array_key_exists('convertValue', $val)) { $schema['fields'][$key]['convertValue'] = false; } if (!array_key_exists('sqlSelect', $val)) { $schema['fields'][$key]['sqlSelect'] = false; } // 'select_as' => 'CONVERT(INT, COLUMN)', // COLUMN = NOME DA COLUNA if (!array_key_exists('value', $val)) { $schema['fields'][$key]['value'] = false; } if (!array_key_exists('mask', $val)) { $schema['fields'][$key]['mask'] = ""; } if (!array_key_exists('validation', $val)) { $schema['fields'][$key]['validation'] = array(); } if (!array_key_exists('labelEmpty', $val)) { $schema['fields'][$key]['labelEmpty'] = ""; } if (!array_key_exists('labelList', $val)) { $schema['fields'][$key]['labelList'] = array(); } if ($schema['fields'][$key]['type'] == "datetime" || $schema['fields'][$key]['type'] == "date_time" || $schema['fields'][$key]['type'] == "date_insert" || $schema['fields'][$key]['type'] == "date_update" and !isset($this->data[$key])) { $this->data[$key] = date("Y-m-d H:i:s"); //echo "<br /> >>>>$key: ".$this->data[$key]; } ksort($schema['fields'][$key]); } if ($settings['redirect_insert'] != false && $this->data['action'] == "insert") { $settings['redirect'] = $settings['redirect_insert']; } if ($settings['redirect_update'] != false && $this->data['action'] == "update") { $settings['redirect'] = $settings['redirect_update']; } return array("schema" => $schema, "settings" => $settings); }
/** * Handles errors. if no error library is available sends a basic one. * * @param msg mixed Error message, empty by default. * @param tit mixed Error title. 'Error' by default (can be replaced in content) **/ public static function &error($msg = false, $tit = false, $error = _error, $class = _class) { // all core methods have the option to hide erros and return false instead. // Since some of those return by reference, we need to do it here too, hence the variable $tmp if ($error !== true) { $tmp = false; return $tmp; } // Get the classname where the error is being generated. // [we cannot send an error from here, it would generate recursion] if (!($class = self::class_get($class, false))) { $class = strtolower(__CLASS__); } // if error library available, redirect error. if (Core::library('error', false, false)) { Error::show($msg, $tit, $class); } // In case the library isn't available send a simple error (converting arrays to strings) error($msg, $tit); }
public function exeDatabaseConnect($ignoreCheckForm = false) { // Iniciar banco de dados se houver instancia, inicia classes Token, Data, SaveData e SelectData //Run::$DEBUG_PRINT = 1; // Debug::print_r("dataForm", $this->dataForm); if ($ignoreCheckForm === false || ((int) $this->dataIntern[$this->settings['ref']] > 0 || isset($this->dataForm['form_id']) && $this->dataForm['form_id'] == $this->settings['form_id'] && count($this->dataErrors) <= 0)) { $this->database = Model::connect($this->settings['database_id']); if (!$this->database) { Error::show(5200, "Model-> A conexão com o banco não foi iniciada. " . __FUNCTION__, __FILE__, __LINE__, ''); $this->settings['auto_load'] = false; $this->settings['auto_save'] = false; } $this->query = Model::$query; $this->orderData = new orderData($this); $this->saveData = new SaveData($this, $this->database, $this->query); $this->selectData = new selectData($this); } }
function start() { if (isset($_GET["ajax_method"])) { $method_request = $_GET["ajax_method"]; } else { $method_request = false; } if ($method_request) { // @header("Content-Type: text/html; charset=ISO-8859-1",true); @header("Content-Type: text/html; charset=ISO-8859-1", true); //$__obj = (Run::$router->content); //echo $method_request ." // ".get_class(Router::$controller->model);exit; //echo (int)method_exists(get_class(Router::$controller->model), $method_request);exit; if (method_exists(get_class(Router::$controller), $method_request)) { $__obj = Router::$controller; } else { if (method_exists(get_class(Router::$controller->model), $method_request)) { $__obj = Router::$controller->model; } else { Error::show(0, "O método {$method_request} não foi encontrado: " . get_class(Run::$router->controller)); exit; } } try { if (isset($_GET["ajax_value1"]) && !isset($_GET["ajax_value2"])) { $str = $__obj->{$method_request}($_GET["ajax_value1"]); } else { if (isset($_GET["ajax_value2"]) && !isset($_GET["ajax_value3"])) { $str = $__obj->{$method_request}($_GET["ajax_value1"], $_GET["ajax_value2"]); } else { if (isset($_GET["ajax_value3"]) && !isset($_GET["ajax_value4"])) { $str = $__obj->{$method_request}($_GET["ajax_value1"], $_GET["ajax_value2"], $_GET["ajax_value3"]); } else { if (isset($_GET["ajax_value4"]) && !isset($_GET["ajax_value5"])) { $str = $__obj->{$method_request}($_GET["ajax_value1"], $_GET["ajax_value2"], $_GET["ajax_value3"], $_GET["ajax_value4"]); } else { if (isset($_GET["ajax_value5"]) && !isset($_GET["ajax_value6"])) { $str = $__obj->{$method_request}($_GET["ajax_value1"], $_GET["ajax_value2"], $_GET["ajax_value3"], $_GET["ajax_value4"], $_GET["ajax_value5"]); } else { if (isset($_GET["ajax_value6"]) && !isset($_GET["ajax_value7"])) { $str = $__obj->{$method_request}($_GET["ajax_value1"], $_GET["ajax_value2"], $_GET["ajax_value3"], $_GET["ajax_value4"], $_GET["ajax_value5"], $_GET["ajax_value6"]); } else { if (isset($_GET["ajax_value7"]) && !isset($_GET["ajax_value8"])) { $str = $__obj->{$method_request}($_GET["ajax_value1"], $_GET["ajax_value2"], $_GET["ajax_value3"], $_GET["ajax_value4"], $_GET["ajax_value5"], $_GET["ajax_value6"], $_GET["ajax_value7"]); } else { if (isset($_GET["ajax_value8"]) && !isset($_GET["ajax_value9"])) { $str = $__obj->{$method_request}($_GET["ajax_value1"], $_GET["ajax_value2"], $_GET["ajax_value3"], $_GET["ajax_value4"], $_GET["ajax_value5"], $_GET["ajax_value6"], $_GET["ajax_value7"], $_GET["ajax_value8"]); } else { if (isset($_GET["ajax_value9"]) && !isset($_GET["ajax_value10"])) { $str = $__obj->{$method_request}($_GET["ajax_value1"], $_GET["ajax_value2"], $_GET["ajax_value3"], $_GET["ajax_value4"], $_GET["ajax_value5"], $_GET["ajax_value6"], $_GET["ajax_value7"], $_GET["ajax_value8"], $_GET["ajax_value9"]); } else { $str = $__obj->{$method_request}($_GET["ajax_value1"], $_GET["ajax_value2"], $_GET["ajax_value3"], $_GET["ajax_value4"], $_GET["ajax_value5"], $_GET["ajax_value6"], $_GET["ajax_value7"], $_GET["ajax_value8"], $_GET["ajax_value9"], $_GET["ajax_value10"]); } } } } } } } } } if (is_array($str)) { echo Run::$json->encode($str); } else { echo $str; } exit; } catch (Exception $e) { echo "<div class='error'> Função {$method_request} (ajax) não executada. </div>"; exit; } } }
$controller->createLike($url[2], $url[3]); exit; } } if ($url[0] == 'post' && $url[1] != 'index') { if ($url[1] == 'create') { $controller->create(); exit; } if ($url[1] == 'search') { $controller->search(); exit; } if ($url[1] == 'show') { if (isset($url[2])) { $controller->show($url[2]); exit; } } if ($url[1] == "newsfeed") { $controller->newsFeed(); exit; } header('Location:' . URL . '/post/index/' . $url[1]); exit; } else { if (method_exists($controller, $url[1])) { if (isset($url[2])) { $controller->{$url[1]}($url[2]); } else { $controller->{$url[1]}();
public static function loadPath($path, $evalPath = false, $show404 = true, $checkFileExist = false) { if ($evalPath) { if (defined('CMS_PATH')) { $path = file_exists(APP_PATH . $path) ? APP_PATH . $path : CMS_PATH . $path; } else { $path = APP_PATH . $path; } } Debug::log("View->loadPath: {$path}", __LINE__, __FUNCTION__, __CLASS__, __FILE__); if ($checkFileExist) { if (file_exists($path)) { require_once $path; return true; } else { Error::show(2, "View->loadPath: {$path} não encontrado."); if ($show404) { View::load("404"); } return false; //exit; } } else { try { require_once $path; } catch (Exception $e) { throw new Exception('View::loadPath - Arquivo não encontrado.' . $path); } } }
public function send() { $resposta = false; $mail = new PHPMailer(); flush(); ob_start(); //Debug::p("CONTEUDO", Run::$control->string->encodeFixUtf8($this->mailManager->content_html)); //exit; //$mail->IsSendmail(); // telling the class to use SendMail transport $mail->IsSMTP(); // usando função padrão de email php //$mail->Debugoutput = 'html'; $mail->Subject = Run::$control->string->encodeFixUtf8($this->mailManager->send_subject); $mail->AltBody = strip_tags($this->mailManager->send_message); // optional, comment out and test $mail->setFrom($this->mailManager->send_from['mail'], Run::$control->string->encodeFixUtf8($this->mailManager->send_from['name'])); $mail->AddAddress($this->mailManager->send_to['mail'], Run::$control->string->encodeFixUtf8($this->mailManager->send_to['name'])); if (isset($this->mailManager->send_reply['mail']) && $this->mailManager->send_reply['mail'] != "") { $mail->AddReplyTo($this->mailManager->send_reply['mail'], Run::$control->string->encodeFixUtf8($this->mailManager->send_reply['name'])); } $this->mailManager->content_html = str_replace("[id]", $this->mailManager->ref_pk, $this->mailManager->content_html); if (count($this->mailManager->send_copy) > 0) { foreach ($this->mailManager->send_copy as $k => $copy) { $mail->AddCC($copy['mail'], $copy['name']); } } if (count($this->mailManager->send_hidden) > 0) { foreach ($this->mailManager->send_hidden as $k => $copy) { $mail->AddBCC($copy['mail'], $copy['name']); } } $mail->CharSet = 'UTF-8'; $mail->MsgHTML(Run::$control->string->encodeFixUtf8($this->mailManager->content_html)); $mail->IsHTML(true); $mail->Host = $this->mailManager->properties[$this->mailManager->send_prefix . 'host']; $mail->SMTPAuth = $this->mailManager->properties[$this->mailManager->send_prefix . 'smtp']; $mail->Sender = $this->mailManager->properties[$this->mailManager->send_prefix . 'mail']; $mail->Username = $this->mailManager->properties[$this->mailManager->send_prefix . 'login']; $mail->Password = $this->mailManager->properties[$this->mailManager->send_prefix . 'pass']; // enable SMTP authentication $door = $this->mailManager->properties[$this->mailManager->send_prefix . 'door']; $crypt = $this->mailManager->properties[$this->mailManager->send_prefix . 'crypt']; if (isset($door) && $door != "") { $mail->Port = $door; } else { $mail->Port = 25; } if (isset($crypt) && $crypt != "") { $mail->SMTPSecure = $crypt; } $mail->SMTPDebug = 1; // sets the prefix to the servier $resposta = $mail->Send(); //echo ">>>> ".$mail->SMTPAuth; $error = ob_get_contents(); ob_end_clean(); flush(); if (!$resposta) { Error::writeLog("Erro MailInfo: " . $mail->ErrorInfo . "\n" . $error, __FILE__, __LINE__, ''); Debug::p("Erro: " . $mail->ErrorInfo, $error); Error::show(0, "MailSender: Ocorreu um erro ao enviar e-mail: \n " . $mail->ErrorInfo . __FUNCTION__, __FILE__, __LINE__, ''); if (Config::MAIL_TRY_SEND_SERVER === true) { $mail->IsMail(); $resposta = $mail->Send(); ob_flush(); flush(); if (!$resposta) { return -2; } else { return 2; } } return -1; } return 1; }
/** * 启动控制器 * */ public function runController() { $cBuilder = Imp::app()->instance('mvcBuilder')->controllerBuilder(); $cBuilder->init(); $cFile = $cBuilder->file(); $cName = $cBuilder->controller(); $cAction = $cBuilder->action(); $cParams = $cBuilder->params(); $config = Imp::app()->instance('config')->get(); if (!is_file($cFile)) { if ($config['debug']) { CError::show("Controller file \"<font color=\"red\">{$cFile}</font>\" not found"); } else { View::show404(); } return; } // 应用基类 $myController = Imp::app()->basePath() . '/MyController/BaseController.php'; if (is_file($myController)) { require $myController; } require $cFile; if (!class_exists($cName)) { if ($config['debug']) { Error::show(Error::getError(Error::$errorType['no_controller']) . ': ' . $cName); } else { View::show404(); } } // 检查最终的控制器及其方法 if (!method_exists($cName, $cAction)) { Imp::app()->instance('router')->unShiftParams($cAction); $cAction = Imp::app()->instance('config')->get('default_action'); $cParams = Imp::app()->instance('router')->getParams(); Imp::app()->instance('router')->setAction($cAction); } // action 钩子 Imp::app()->instance('hook')->call('action'); // 实例化操作模块 $cInstance = new $cName(); // 检查最终的控制器及其方法 if (!method_exists($cInstance, $cAction)) { if ($config['debug']) { Error::show(Error::getError(Error::$errorType['no_action']) . ': ' . $cAction); } else { View::show404(); } return; } // 调用当前控制器方法 call_user_func_array(array($cInstance, $cAction), $cParams); }
static function loadPluginModel($file = "") { if ($file == "") { Error::show(0, "loadPluginModel: É preciso definir um plugin/model a ser carregado."); } if (file_exists(APP_PATH . "pags/model/" . $file . "_model.php")) { require_once APP_PATH . "pags/model/" . $file . "_model.php"; } elseif (file_exists(APP_PATH . "plugins/model/" . $file . "_model.php")) { require_once APP_PATH . "plugins/model/" . $file . "_model.php"; } else { Error::show(0, "loadPluginModel: plugin " . $file . "_model não encontrado."); } }