echo td($profile); echo td($str); echo "</TR>"; } echo '</TABLE>'; } $action = ""; if (isset($_GET["action"])) { $action = $_GET["action"]; } //---------------------------------------------------------------------- // Action = save //---------------------------------------------------------------------- if (isset($_POST['ok'])) { try { $cn->start(); $sec_User = new User($cn, $_POST['user_id']); // save profile $sec_User->save_profile($_POST['profile']); /* Save first the ledger */ $a = $cn->get_array('select jrn_def_id from jrn_def'); foreach ($a as $key) { $id = $key['jrn_def_id']; $priv = sprintf("jrn_act%d", $id); $count = $cn->get_value('select count(*) from user_sec_jrn where uj_login=$1 ' . ' and uj_jrn_id=$2', array($sec_User->login, $id)); if ($count == 0) { $cn->exec_sql('insert into user_sec_jrn (uj_login,uj_jrn_id,uj_priv)' . ' values ($1,$2,$3)', array($sec_User->login, $id, $_POST[$priv])); } else { $cn->exec_sql('update user_sec_jrn set uj_priv=$1 where uj_login=$2 and uj_jrn_id=$3', array($_POST[$priv], $sec_User->login, $id)); } }
/** *connect to folder and give to admin. the profile Admin(builtin) * @param int $p_id dossier::id() */ static function synchro_admin($p_id) { // connect to target $cn = new Database($p_id); if (!$cn->exist_table("profile_menu")) { echo_warning("Dossier invalide"); return; } // connect to repo $repo = new Database(); $a_admin = $repo->get_array("select use_login from ac_users where\n\t\t\tuse_admin=1 and use_active=1"); try { /** * synchro global */ $cn->start(); for ($i = 0; $i < count($a_admin); $i++) { $exist = $cn->get_value("select p_id from profile_user\n\t\t\t\t\twhere user_name=\$1", array($a_admin[$i]['use_login'])); if ($exist == "") { $cn->exec_sql("insert into profile_user(user_name,p_id) values(\$1,1)", array($a_admin[$i]['use_login'])); } } $cn->commit(); } catch (Exception $e) { echo_warning($e->getMessage()); $cn->rollback(); } }
$encoding = $repo->get_value("select encoding from pg_database where " . " datname=\$1", array($template_name)); if ($encoding != 6) { alert(_('Désolé vous devez migrer ce modèle en unicode')); echo '<span class="error">'; echo _('le modele ') . domaine . 'mod' . $_POST["FMOD_ID"] . _(" doit être migré en unicode."); echo _('Pour le passer en unicode, faites-en un backup puis restaurez le fichier reçu') . '</span>'; echo HtmlInput::button_anchor('Retour', 'admin_repo.php?action=dossier_mgt'); return; } } /* * Insert new dossier with description */ $desc = HtmlInput::default_value_post("DESCRIPTION", ""); try { $repo->start(); $Res = $repo->exec_sql("insert into ac_dossier(dos_name,dos_description)\n values (\$1,\$2)", array($dos, $desc)); $l_id = $repo->get_current_seq('dossier_id'); $repo->commit(); } catch (Exception $e) { $msg = _("Desole la creation de ce dossier a echoue,\n la cause la plus probable est" . ' deux fois le même nom de dossier'); alert($msg); $l_id = 0; $repo->rollback(); } // If the id is not null, name successfully inserted // Database created if ($l_id != 0) { /* * We don't create and empty database */
/** * Unit test for the class */ static function test_me() { $cn = new Database(25); $cn->start(); echo h2info('Test object vide'); $obj = new Fiche_Attr($cn); var_dump($obj); echo h2info('Test object NON vide'); $obj->set_parameter('j_id', 3); $obj->load(); var_dump($obj); echo h2info('Update'); $obj->set_parameter('j_qcode', 'NOUVEAU CODE'); $obj->save(); $obj->load(); var_dump($obj); echo h2info('Insert'); $obj->set_parameter('j_id', 0); $obj->save(); $obj->load(); var_dump($obj); echo h2info('Delete'); $obj->delete(); echo $obj->load() == 0 ? 'Trouve' : 'non trouve'; var_dump($obj); $cn->rollback(); }
<?php ini_set('display_errors', ON); error_reporting(E_ALL); require_once('config.php'); require_once('classes/database.php'); require_once('classes/model.php'); require_once('classes/item.php'); require_once('classes/creature.php'); require_once('classes/template.php'); $db = Database::start(); if(isset($_GET['id'])){ $creature_id = (int)$_GET['id']; $creature = Creature::find($creature_id); if($creature){ $loot = $creature->loot; $hero_loot = $creature->hero_loot; } else { $message = "No Creature With ID $creature_id Found!"; } echo Template::render('head', array('creature' => $creature, 'creature_id' => $creature_id)); } else { echo Template::render('head'); } ?> <?php if(isset($message)){ ?> <div id="message"><?php echo $message ?></div> <?php } ?>
/** * @brief this function is intended to test this class */ static function test_me($pCase = '') { if ($pCase == '') { echo Acc_Reconciliation::$javascript; html_page_start(); $cn = new Database(dossier::id()); $_SESSION['g_user'] = '******'; $_SESSION['g_pass'] = '******'; $id = isset($_REQUEST['p_jrn']) ? $_REQUEST['p_jrn'] : -1; $a = new Acc_Ledger($cn, $id); $a->with_concerned = true; // Vide echo '<FORM method="post">'; echo $a->select_ledger()->input(); echo HtmlInput::submit('go', 'Test it'); echo '</form>'; if (isset($_POST['go'])) { echo "Ok "; echo '<form method="post">'; echo $a->show_form(); echo HtmlInput::submit('post_id', 'Try me'); echo '</form>'; // Show the predef operation // Don't forget the p_jrn echo '<form>'; echo dossier::hidden(); echo '<input type="hidden" value="' . $id . '" name="p_jrn">'; $op = new Pre_operation($cn); $op->p_jrn = $id; $op->od_direct = 't'; if ($op->count() != 0) { echo HtmlInput::submit('use_opd', 'Utilisez une opération prédéfinie', "", "smallbutton"); echo $op->show_button(); } echo '</form>'; exit('test_me'); } if (isset($_POST['post_id'])) { echo '<form method="post">'; echo $a->show_form($_POST, 1); echo HtmlInput::button('add', 'Ajout d\'une ligne', 'onClick="quick_writing_add_row()"'); echo HtmlInput::submit('save_it', _("Sauver")); echo '</form>'; exit('test_me'); } if (isset($_POST['save_it'])) { print 'saving'; $array = $_POST; $array['save_opd'] = 1; try { $a->save($array); } catch (Exception $e) { alert($e->getMessage()); echo '<form method="post">'; echo $a->show_form($_POST); echo HtmlInput::submit('post_id', 'Try me'); echo '</form>'; } return; } // The GET at the end because automatically repost when you don't // specify the url in the METHOD field if (isset($_GET['use_opd'])) { $op = new Pre_op_advanced($cn); $op->set_od_id($_REQUEST['pre_def']); //$op->p_jrn=$id; $p_post = $op->compute_array(); echo '<FORM method="post">'; echo $a->show_form($p_post); echo HtmlInput::submit('post_id', 'Use predefined operation'); echo '</form>'; return; } } // if case = '' /////////////////////////////////////////////////////////////////////////// // search if ($pCase == 'search') { html_page_start(); $cn = new Database(dossier::id()); $ledger = new Acc_Ledger($cn, 0); $_SESSION['g_user'] = '******'; $_SESSION['g_pass'] = '******'; echo $ledger->search_form('ALL'); } /////////////////////////////////////////////////////////////////////////// // reverse // Give yourself the var and check in your tables /////////////////////////////////////////////////////////////////////////// if ($pCase == 'reverse') { $cn = new Database(dossier::id()); $jr_internal = 'OD-01-272'; try { $cn->start(); $jrn_def_id = $cn->get_value('select jr_def_id from jrn where jr_internal=$1', array($jr_internal)); $ledger = new Acc_Ledger($cn, $jrn_def_id); $ledger->jr_id = $cn->get_value('select jr_id from jrn where jr_internal=$1', array($jr_internal)); echo "Ouvrez le fichier " . __FILE__ . " à la ligne " . __LINE__ . " pour changer jr_internal et vérifier le résultat de l'extourne"; $ledger->reverse('01.07.2010'); } catch (Exception $e) { $cn->rollback(); var_dump($e); } $cn->commit(); } }
use Phalcon\Mvc\View\Simple as View; use Phalcon\Mvc\View\Engine\Volt as Engine; use Phalcon\Mvc\Url as UrlResolver; use Phalcon\Di\FactoryDefault; use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter; use Phalcon\Flash\Direct as Flash; require __DIR__ . '/Database.php'; $di = new FactoryDefault(); $di->set('flash', function () { $base = 'alert alert-'; return new Flash(array('error' => $base . 'danger', 'success' => $base . 'success', 'notice' => $base . 'info', 'warning' => $base . 'warning')); }); $di->setShared('session', function () use($config) { $conn = new DbAdapter($config->database->toArray()); $session = new Database(array('db' => $conn, 'table' => 'session_data')); $session->start(); return $session; }); /** * Sets the view component */ $di->setShared('view', function () use($config) { $view = new View(); $view->setViewsDir($config->application->viewsDir); $view->registerEngines(array(".volt" => 'Phalcon\\Mvc\\View\\Engine\\Volt', ".phtml" => 'Phalcon\\Mvc\\View\\Engine\\Php')); return $view; }); /** * The URL component is used to generate all kind of urls in the application */ $di->set('url', function () use($config) {