/** * Load a mysql table parser * * @param string $tablename * @param string $action[recommended: insert, delete, update] * @param array $value */ function tableParser($tablename, $action, array $value = NULL) { global $mysql; static $loadedParser = array(); //require required table parser file if (!in_array($tablename, $loadedParser)) { $loadedParser[] = $tablename; reqFile(CM_ROOT . '/cm_includes/table/' . $tablename . '.table.php'); } //load table parser class $tableclass = ucfirst($tablename) . "Table"; return call_user_func(array($tableclass, $action), $mysql, $value); }
/** * Load a form parser * * @return array(1 -> parsed form/ 2 -> form verified/ 3 -> form is correct, function return value) * @param string $name * @param array $value * @param boolean $validate * @param string $correct */ function parseForm(&$frm, $name, array $value = NULL, $validate = true, $correct = true) { //require required form parser file $formpath = CM_ROOT . '/cm_includes/form/' . $name . '.form.php'; reqFile($formpath); //load form parser class $formclass = ucfirst($name) . "Form"; $return = call_user_func(array($formclass, 'form'), $frm, $value); $status = 1; //load form parser class validate method if ($validate && $frm->isSubmitted()) { $return = call_user_func(array($formclass, 'submitted'), $frm); $status = 2; //load form parser class correct method if ($correct && $frm->isCorrect()) { $return = call_user_func(array($formclass, 'correct'), $frm); $status = 3; } } return array($status, $return); }
if (!cmAuth::is_logined()) { header('Location: ' . CM_URL . '/login.php'); } } //load SpoonMysql if (defined('LOAD_MYSQL')) { $mysql = new SpoonDatabase('mysql', MYSQL_HOST, MYSQL_UN, MYSQL_PW, MYSQL_DB); reqFile(CM_ROOT . '/cm_includes/mysql.php'); } //load SpoonTemplate if (defined('LOAD_TEMPLATE')) { $tpl = reqFile(CM_ROOT . '/cm_includes/template.php'); } //load Form Functions if (defined('LOAD_FORM')) { reqFile(CM_ROOT . '/cm_includes/form.php'); } /** * Require File * * @return return true if file exists or else report error * @param string $filepath file's path * @param boolean $error report error or not * @param string $errorMsg custom error message */ function reqFile($filepath, $error = true, $errorMsg = NULL) { $filepath = str_replace('\\', '/', $filepath); if (is_file($filepath)) { return require_once $filepath; } else {