disconnect() static public method

Disconnects from the server
static public disconnect ( ) : boolean
return boolean
Exemplo n.º 1
0
 /**
  * Auslesen der Lehrer, des Fachs und des Raums durch
  * angabe von klasse_id, Datum und der Blocknummer
  */
 public function get_LFR($klasse_id = 0, $datum = "", $block_nr = 0)
 {
     //Instanz der Klasse db zur Verbindung zur Datenbank
     $klabu_db = new db();
     //sql-Befehl zur ausgabe der Zeiten und des Blocks
     $sql = "SELECT block_nr, datum, klasse_id,\n                    raum_id, lehrer_id, vertretung_id, fach_id FROM wochenplan\n                    WHERE klasse_id = " . $klasse_id . " " . "\n                    AND datum = '" . $datum . "' AND block_nr = " . $block_nr;
     $result = mysql_query($sql);
     echo $sql;
     /*
      * Fehlerbehandlung falls die Anfrage fehlt schlägt
      */
     if (!result) {
         echo "Die Anfrage " . $sql . " konnte nicht bearbeitet werden" . mysql_error();
     }
     /*
      * Datenbank ist leer ;)
      */
     if (mysql_num_rows($result) == 0) {
         echo "Error: Anfrage wurde nicht durchgeführt,\n                      da keine Zeilen zum ausgeben gefunden wurden";
     }
     /**
      * - Wenn alles glatt läuft gehts hier weiter:
      * - Alle Daten werden in ein Array ($ausgabe) geschrieben
      * - und mit return zurück gegeben
      */
     while ($data = mysql_fetch_assoc($result)) {
         $dummy['block_nr'] = $data['block_nr'];
         $dummy['datum'] = $data['datum'];
         $dummy['klasse'] = $klabu_db->resolve_Id(klasse, klasse_id, $data['klasse_id']);
         $dummy['raum'] = $klabu_db->resolve_Id(raume, raum_id, $data['raum_id']);
         $dummy['lehrer'] = $klabu_db->resolve_Lehrer($data['lehrer_id']);
         $dummy['fach'] = $klabu_db->resolve_Id(fach, fach_id, $data['fach_id']);
         //Vertretung nur Anzeigen falls eine Vertretung gewählt wurde
         if ($data['vertretung_id'] != 0) {
             $dummy['vertretung'] = $klabu_db->resolve_Lehrer($data['vertretung_id']);
         }
         $ausgabe[] = $dummy;
     }
     return $ausgabe;
     //Nachdem die While Schleife durchlaufen ist,
     //wird das array übergeben
     mysql_free_result($result);
     //Aufräumen
     $klabu_db->disconnect();
     //Verbindung trennen
 }
Exemplo n.º 2
0
if (isset($debug)) {
    $debug->addvar('$cfg', $cfg);
}
if (isset($debug)) {
    $debug->tracker("All upto HTML-Output");
}
$framework->html_out();
// Output of all HTML
unset($framework);
unset($smarty);
unset($templ);
unset($dsp);
### Statistics will be updated only at scriptend, so pagesize and loadtime can be insert
if ($db->success) {
    // Statistic Functions (for generating server- and usage-statistics)
    include_once "modules/stats/class_stats.php";
    $stats = new stats();
    unset($stats);
    // Check Cronjobs
    if (!$_GET['mod'] == 'install') {
        if (!isset($cron2)) {
            include_once 'modules/cron2/class_cron2.php';
            $cron2 = new cron2();
        }
        $cron2->CheckJobs();
        unset($cron2);
    }
    // Disconnect DB
    $db->disconnect();
    unset($db);
}
Exemplo n.º 3
0
                throw new Exception('query failed');
            }
        } catch (Exception $e) {
            die('couldn\'t add object: ' . $e->getMessage());
        }
        echo 'success';
        break;
    case 'addCategory':
        $category_name = isset($_POST['category_name']) ? $_POST['category_name'] : '';
        if (strlen($category_name) <= 0 || strlen($category_name) > 32) {
            die('invalid category name length');
        }
        if (db::query('select id from categories where name = ' . db::value($category_name))) {
            die('category \'' . $category_name . '\' already exists!');
        }
        // and try insert:
        try {
            $result = db::query('insert into categories values (default, ' . db::value($category_name) . ')');
            if (!$result) {
                throw new Exception('query failed');
            }
        } catch (Exception $e) {
            die('couldn\'t add category: ' . $e->getMessage());
        }
        echo 'success';
        break;
    default:
        break;
}
db::disconnect();
 function obtenerCamposField($tabla)
 {
     $arrayCampos = array();
     $db = new db();
     $link = $db->connect();
     $campos = pg_query($link, "SELECT column_name AS Field , udt_name AS Type , is_nullable AS null ,ordinal_position AS Key, column_default AS default FROM information_schema.columns WHERE table_name = '" . $tabla . "'");
     if ($campos) {
         if (pg_num_rows($campos) > 0) {
             $i = 0;
             while ($ca = pg_fetch_assoc($campos)) {
                 $arrayCampos[$i] = $ca['field'];
                 $i++;
             }
         }
     }
     $db->disconnect($link);
     return $arrayCampos;
 }
Exemplo n.º 5
0
 /**
  * Output management tools
  *
  * @access public
  * @return string Option
  */
 function manage()
 {
     global $parametersMod;
     //log off
     if (isset($_REQUEST['action']) && $_REQUEST['action'] == "logout" && !isset($_REQUEST['module_id'])) {
         $this->session->logout();
         $this->html->headerModules();
         $this->html->html('<script type="text/javascript">window.top.location=\'admin.php\';</script>');
         $this->deleteTmpFiles();
         $this->html->footer();
         $this->html->send();
         \db::disconnect();
         exit;
     }
     //eof log off
     //log in
     if (isset($_REQUEST['action']) && isset($_REQUEST['f_name']) && isset($_REQUEST['f_pass']) && $_REQUEST['action'] == "login" && !isset($_REQUEST['module_id'])) {
         if (\Backend\Db::incorrectLoginCount($_REQUEST['f_name'] . '(' . $_SERVER['REMOTE_ADDR'] . ')') > 2) {
             $this->loginError = $parametersMod->getValue('standard', 'configuration', 'system_translations', 'login_suspended');
             \Backend\Db::log('system', 'backend login suspended', $_REQUEST['f_name'] . '(' . $_SERVER['REMOTE_ADDR'] . ')', 2);
         } else {
             $id = \Backend\Db::userId($_REQUEST['f_name'], $_REQUEST['f_pass']);
             if ($id !== false) {
                 $this->session->login($id);
                 \Backend\Db::log('system', 'backend login', $_REQUEST['f_name'] . ' (' . $_SERVER['REMOTE_ADDR'] . ')', 0);
                 header("location:ip_backend_frames.php");
             } else {
                 $this->loginError = $parametersMod->getValue('standard', 'configuration', 'system_translations', 'login_incorrect');
                 \Backend\Db::log('system', 'backend login incorrect', $_REQUEST['f_name'] . '(' . $_SERVER['REMOTE_ADDR'] . ')', 1);
             }
         }
     }
     //eof log in
     if ($this->session->loggedIn()) {
         //login check
         //create module
         if (isset($_GET['module_id']) && $_GET['module_id'] != '' && \Backend\Db::allowedModule($_GET['module_id'], $this->session->userId())) {
             /*new module*/
             $newModule = \Db::getModule($_GET['module_id']);
             if ($newModule['core']) {
                 require MODULE_DIR . $newModule['g_name'] . '/' . $newModule['m_name'] . '/manager.php';
             } else {
                 require PLUGIN_DIR . $newModule['g_name'] . '/' . $newModule['m_name'] . '/manager.php';
             }
             $this->curModId = $newModule['id'];
             eval('$this->module = new \\Modules\\' . $newModule['g_name'] . '\\' . $newModule['m_name'] . '\\Manager();');
         } else {
             if (isset($_GET['action']) && $_GET['action'] == 'first_module') {
                 /*first module*/
                 $newModule = \Backend\Db::firstAllowedModule($this->session->userId());
                 if ($newModule != false) {
                     $this->curModId = $newModule['id'];
                     if ($newModule['core']) {
                         require MODULE_DIR . $newModule['g_name'] . '/' . $newModule['m_name'] . '/manager.php';
                     } else {
                         require PLUGIN_DIR . $newModule['g_name'] . '/' . $newModule['m_name'] . '/manager.php';
                     }
                     eval('$this->module = new \\Modules\\' . $newModule['g_name'] . '\\' . $newModule['m_name'] . '\\Manager();');
                 }
             } elseif (isset($_GET['action']) && ($_GET['action'] = 'ping')) {
                 $this->html->html('');
             } elseif (!isset($_GET['action'])) {
                 $this->html->html('<html><body><script type="text/javascript">parent.window.top.location=\'ip_backend_frames.php\';</script></body></html>');
             }
         }
         //eof create module
         if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'tep_modules') {
             $this->html->headerModules();
             $this->html->modules(\Backend\Db::modules(true, $this->session->userId()));
             $this->html->footer();
         } else {
             if ($this->module) {
                 $this->html->html($this->module->manage());
             }
         }
     } else {
         if (strpos(BASE_URL, $_SERVER['HTTP_HOST']) != 7 && strpos(BASE_URL, $_SERVER['HTTP_HOST']) != 8) {
             /*check if we are in correct subdomain. www.yoursite.com not allways equal to yoursite.com from session perspective)*/
             header("location: " . BASE_URL . "admin.php");
             \db::disconnect();
             exit;
         }
         $this->html->headerLogin();
         $this->html->html('<script type="text/javascript">if(parent.header && parent.content)parent.window.top.location=\'admin.php\';</script>');
         $this->html->loginForm($this->loginError);
         //login window
         $this->html->footer();
     }
     $this->html->send();
 }