/**
  * \brief initialization
  */
 protected function setUp()
 {
     global $PG_CONN;
     $sysconfig = dirname(__FILE__) . '/sysconfigDirTest';
     if (!is_callable('pg_connect')) {
         $this->markTestSkipped("php-psql not found");
     }
     $PG_CONN = DBconnect($sysconfig);
 }
function PrepareSQL()
{
    $db = DBconnect();
    //if (!$db) die("Oops! Looks like you could not access main database for unknown reasons. Please try again later or contact admin.");
    mysql_select_db("tricking_dbMain", $db);
    mysql_query("SET NAMES UTF8");
    return "tricking_dbMain";
    //$MainDBConn;
}
function createOrder($data)
{
    $dbcon = DBconnect();
    $stmt = $dbcon->prepare("INSERT into tbl_orders (orderFName, orderLName, orderEmail, orderType, orderPlaceDateTime, orderDueDate, paid, baked, readyForPickup, pickedUp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    $stmt->bind_param("ssssssssss", $data['orderFName'], $data['orderLName'], $data['orderEmail'], $data['orderType'], $data['orderPlaceDateTime'], $data['orderDueDate'], $data['paid'], $data['baked'], $data['readyForPickup'], $data['pickedUp']);
    $stmt->execute();
    $id = $dbcon->insert_id;
    DBdisconnect($dbcon);
    echo $id;
}
 /**
  * \brief initialization with db
  */
 protected function setUpDb()
 {
     if (!is_callable('pg_connect')) {
         $this->markTestSkipped("php-psql not found");
     }
     global $PG_CONN;
     global $DB_COMMAND;
     global $sys_conf;
     $DB_COMMAND = dirname(dirname(dirname(dirname(__FILE__)))) . "/testing/db/createTestDB.php";
     exec($DB_COMMAND, $dbout, $rc);
     $sys_conf = $dbout[0];
     $PG_CONN = DBconnect($sys_conf);
 }
Exemple #5
0
function getserviceslist()
{
    $con = DBconnect();
    $getservice = DBfetchall("SELECT serviceid,shopid,name,price FROM Service", $con);
    $Arr = array();
    foreach ($getservice as $row) {
        $row2 = DBfetchone("select name,pic,latitude,longtitude from Shop where shopid=" . $row["shopid"] . ";", $con);
        $a = array("serviceid" => $row["serviceid"], "shopname" => $row2["name"], "servicename" => $row["name"], "price" => $row["price"], "pic" => $row2["pic"], "latitude" => $row2["latitude"], "longtitude" => $row2["longtitude"]);
        //var_dump($row2);
        array_push($Arr, $a);
    }
    echo json_encode($Arr);
}
 protected function setUp()
 {
     global $PG_CONN;
     global $DB_COMMAND;
     global $DB_NAME;
     print "Starting unit test for common-pkg.php\n";
     $DB_COMMAND = "../../../testing/db/createTestDB.php";
     exec($DB_COMMAND, $dbout, $rc);
     preg_match("/(\\d+)/", $dbout[0], $matches);
     $test_name = $matches[1];
     $db_conf = $dbout[0];
     $DB_NAME = "fosstest" . $test_name;
     #$sysconfig = './sysconfigDirTest';
     $PG_CONN = DBconnect($db_conf);
 }
 protected function setUp()
 {
     if (!is_callable('pg_connect')) {
         $this->markTestSkipped("php-psql not found");
     }
     global $PG_CONN;
     global $DB_COMMAND;
     global $DB_NAME;
     print "Starting unit test for common-pkg.php\n";
     $DB_COMMAND = dirname(dirname(dirname(dirname(__FILE__)))) . "/testing/db/createTestDB.php";
     exec($DB_COMMAND, $dbout, $rc);
     preg_match("/(\\d+)/", $dbout[0], $matches);
     $test_name = $matches[1];
     $db_conf = $dbout[0];
     $DB_NAME = "fosstest" . $test_name;
     #$sysconfig = './sysconfigDirTest';
     $PG_CONN = DBconnect($db_conf);
 }
Exemple #8
0
function getCountryCode()
{
    $ip = getIp();
    // debug:
    // $ip = "193.51.208.14"; // French IP
    // $ip = "71.164.115.181"; // US IP
    $location = null;
    if ($ip) {
        // db credentials, see db.php.example
        require 'db.php';
        DBconnect($server, $username, $password, $database);
        $location = ipRoughLocate($ip);
    }
    if (!$location || !$location["countryCode"] || $location["countryName"] == "(Unknown Country?)") {
        return "US";
    } else {
        return $location["countryCode"];
    }
}
Exemple #9
0
 function __construct($dbName = null, $sysConf = null)
 {
     $dbName = strtolower($dbName);
     $testDbFactory = new \TestDbFactory();
     $this->sys_conf = $sysConf;
     if (empty($this->sys_conf)) {
         $this->sys_conf = $testDbFactory->setupTestDb($dbName);
         $dbName = $testDbFactory->getDbName($this->sys_conf);
     }
     $this->dbName = $dbName;
     require_once dirname(dirname(__FILE__)) . '/common-db.php';
     $this->connection = DBconnect($this->sys_conf);
     require dirname(dirname(__FILE__)) . '/common-container.php';
     global $container;
     $logger = new Logger('default');
     // $container->get('logger');
     $this->logFileName = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . 'db.pg.log';
     $logger->pushHandler(new StreamHandler($this->logFileName, Logger::DEBUG));
     $container->get('db.manager')->setDriver(new Postgres($this->connection));
     $this->dbManager = $container->get('db.manager');
     $this->dbManager->queryOnce("DEALLOCATE ALL");
     $this->dropAllTables();
     $this->dropAllSequences();
 }
 /**
  * \brief Generate output.
  */
 function Output()
 {
     global $PG_CONN;
     global $Plugins;
     // make sure there is a db connection since I've pierced the core-db abstraction
     if (!$PG_CONN) {
         DBconnect();
         if (!$PG_CONN) {
             echo "NO DB connection";
         }
     }
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     $V = "";
     // tmp  $this->popmd5();
     switch ($this->OutputType) {
         case "XML":
             break;
         case "Text":
             break;
         case "HTML":
             // micro menus
             $V .= menu_to_1html(menu_find($this->Name, $MenuDepth), 0);
             //debugprint($_REQUEST, "_REQUEST");
             $errorstr = "License not added";
             // update the db
             if (@$_POST["updateit"]) {
                 $resultstr = $this->Updatedb($_POST);
                 $V .= $resultstr;
                 if (strstr($resultstr, $errorstr)) {
                     $V .= $this->Updatefm(0);
                 } else {
                     $V .= $this->Inputfm();
                 }
                 break;
             }
             if (@$_REQUEST['add'] == 'y') {
                 $V .= $this->Updatefm(0);
                 break;
             }
             // Add new rec to db
             if (@$_POST["addit"]) {
                 $resultstr = $this->Adddb($_POST);
                 $V .= $resultstr;
                 if (strstr($resultstr, $errorstr)) {
                     $V .= $this->Updatefm(0);
                 } else {
                     $V .= $this->Inputfm();
                 }
                 break;
             }
             // bring up the update form
             $rf_pk = @$_REQUEST['rf_pk'];
             if ($rf_pk) {
                 $V .= $this->Updatefm($rf_pk);
                 break;
             }
             $V .= $this->Inputfm();
             if (@$_POST["req_shortname"]) {
                 $V .= $this->LicenseList($_POST["req_shortname"], $_POST["req_marydone"]);
             }
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print $V;
     return;
 }
Exemple #11
0
function DBInsert($sql)
{
    DBconnect();
    return mysql_query($sql);
}
Exemple #12
0
 public static function getRights()
 {
     try {
         // Effectue une connexion à la DB.
         $pdo = DBconnect();
         // Prépare la requête.
         $stmt = $pdo->prepare("SELECT * FROM t_right ORDER BY id");
         // Execute la requête.
         if ($stmt->execute()) {
             // Set le type de traitement de la réponse.
             $stmt->setFetchMode(PDO::FETCH_CLASS, 'Right');
             // Récupère le résultat de la requête.
             if ($r = $stmt->fetchAll()) {
                 return $r;
             }
         }
         // Retourne un objet null si l'utilisateur n'a pas été récuperé.
         return null;
     } catch (Exception $e) {
         // Retourne un objet null si une erreur c'est produite.
         return null;
     } finally {
         // Ferme le traitement.
         $stmt->closeCursor();
         // Ferme la connexion vers la base de donnée.
         $pdo = null;
     }
 }
Exemple #13
0
 function CheckConfigurationFile()
 {
     global $DB, $ZBX_SERVER, $ZBX_SERVER_PORT;
     if (!empty($DB)) {
         $old_DB = true;
         $old_DB_TYPE = $DB['TYPE'];
         $old_DB_SERVER = $DB['SERVER'];
         $old_DB_PORT = $DB['PORT'];
         $old_DB_DATABASE = $DB['DATABASE'];
         $old_DB_USER = $DB['USER'];
         $old_DB_PASSWORD = $DB['PASSWORD'];
         $old_ZBX_SERVER = $ZBX_SERVER;
         $old_ZBX_SERVER_PORT = $ZBX_SERVER_PORT;
     }
     $error = null;
     $error_msg = null;
     global $ZBX_CONFIGURATION_FILE;
     if (file_exists($ZBX_CONFIGURATION_FILE)) {
         include $ZBX_CONFIGURATION_FILE;
         if (isset($DB['TYPE']) && isset($DB['SERVER']) && isset($DB['DATABASE']) && isset($DB['USER']) && isset($DB['PASSWORD']) && isset($ZBX_SERVER) && isset($ZBX_SERVER_PORT) && isset($IMAGE_FORMAT_DEFAULT) && $DB['TYPE'] == $this->getConfig('DB_TYPE', null) && $DB['SERVER'] == $this->getConfig('DB_SERVER', null) && $DB['PORT'] == $this->getConfig('DB_PORT', null) && $DB['DATABASE'] == $this->getConfig('DB_DATABASE', null) && $DB['USER'] == $this->getConfig('DB_USER', null) && $DB['PASSWORD'] == $this->getConfig('DB_PASSWORD', null)) {
             if (!DBconnect($error_msg)) {
                 $error_msg = 'Can not connect to database';
             }
         } else {
             $error_msg = 'Incorrect configuration file[' . $ZBX_CONFIGURATION_FILE . ']';
         }
         DBclose();
     } else {
         $error = 'Missing configuration file[' . $ZBX_CONFIGURATION_FILE . ']';
     }
     if (isset($error_msg)) {
         error($error_msg);
     }
     /* restore connection */
     global $DB;
     if (isset($old_DB)) {
         $DB['TYPE'] = $old_DB_TYPE;
         $DB['SERVER'] = $old_DB_SERVER;
         $DB['PORT'] = $old_DB_PORT;
         $DB['DATABASE'] = $old_DB_DATABASE;
         $DB['USER'] = $old_DB_USER;
         $DB['PASSWORD'] = $old_DB_PASSWORD;
         $ZBX_SERVER = $old_ZBX_SERVER;
         $ZBX_SERVER_PORT = $old_ZBX_SERVER_PORT;
     }
     DBconnect($error2);
     return !isset($error) && !isset($error_msg);
 }
?>
</TH>
 <TH class="tbLogHeader">Location</TH>
 <TH class="tbLogHeader">Dist<br><?php 
echo $units->distanceString();
?>
</TH>
 <TH class="tbLogHeader">Time</TH>
 <TH class="tbLogHeader">Avg<br><?php 
echo $units->velocityString();
?>
</TH>
 <TH class="tbLogHeader">Effort</TH>
</TR>
<?php 
$rides = new RDride(DBconnect(), $units);
$result = $rides->queryRides($currentQuery->getWhereStatement(), $start, $num + 1);
$totalTime = 0;
$totalDist = 0;
$numRides = 0;
//Not really num rides, used to see if more data is available.
while ($rides->parseNextRow($result)) {
    $numRides++;
    if ($numRides > $num) {
        break;
    }
    echo "<TR>";
    echo "<TD class=\"tbLogBody\">" . "<a href=\"showRide.php";
    $tgetvars = $getVars;
    $tgetvars["rideID"] = $rides->f_rideID;
    echo encodeGet($tgetvars) . "\">" . $rides->getDatePart() . " " . $rides->getTimePart() . "</a>&nbsp;" . "<img width='10' height='16' src=\"" . getImgForTemp($rides->f_temperature, $units) . "\">" . "<img width='25' height='16' src=\"s" . $rides->f_sky . ".png\">" . "<img width='16' height='16' src=\"w" . $rides->f_wind . ".png\">" . "</TD>";
Exemple #15
0
 /**
  * \brief This is where the magic for
  * Authentication happens.
  */
 function PostInitialize()
 {
     global $PG_CONN;
     global $SysConf;
     if (siteminder_check() == -1) {
         return;
     }
     $UID = siteminder_check();
     global $container;
     /** @var Session $session */
     $session = $container->get('session');
     $session->setName('Login');
     $session->start();
     if (array_key_exists(Auth::USER_ID, $_SESSION)) {
         $SysConf['auth'][Auth::USER_ID] = $_SESSION[Auth::USER_ID];
     }
     $Now = time();
     if (!empty($_SESSION['time'])) {
         /* Logins older than 60 secs/min * 480 min = 8 hr are auto-logout */
         if (@$_SESSION['time'] + 60 * 480 < $Now) {
             $_SESSION['User'] = NULL;
             $_SESSION[Auth::USER_ID] = NULL;
             $_SESSION[Auth::USER_LEVEL] = NULL;
             $SysConf['auth'][Auth::USER_ID] = NULL;
             $_SESSION['UserEmail'] = NULL;
             $_SESSION['Folder'] = NULL;
             $_SESSION['UiPref'] = NULL;
             /* TODO: need to clear SiteMinder session */
         }
     }
     /* check db connection */
     if (!$PG_CONN) {
         DBconnect();
         if (!$PG_CONN) {
             echo "NO DB connection";
         }
     }
     /* Enable or disable plugins based on login status */
     $Level = PLUGIN_DB_NONE;
     if (@$_SESSION['User']) {
         //TODO: also need to check SiteMinder session
         /* If you are logged in, then the default level is "Download". */
         if ("X" . $_SESSION[Auth::USER_LEVEL] == "X") {
             $Level = PLUGIN_DB_WRITE;
         } else {
             $Level = $_SESSION[Auth::USER_LEVEL];
         }
         /* Recheck the user in case he is suddenly blocked or changed. */
         if (empty($_SESSION['time_check'])) {
             $_SESSION['time_check'] = time() + 480 * 60;
         }
         if (time() >= @$_SESSION['time_check']) {
             $sql = "SELECT * FROM users WHERE user_pk='" . @$_SESSION['UserId'] . "';";
             $result = pg_query($PG_CONN, $sql);
             DBCheckResult($result, $sql, __FILE__, __LINE__);
             $R = pg_fetch_assoc($result);
             pg_free_result($result);
             $_SESSION['User'] = $R['user_name'];
             $_SESSION['Folder'] = $R['root_folder_fk'];
             $_SESSION[Auth::USER_LEVEL] = $R['user_perm'];
             $_SESSION['UserEmail'] = $R['user_email'];
             $_SESSION['UserEnote'] = $R['email_notify'];
             if (empty($R['ui_preference'])) {
                 $_SESSION['UiPref'] = 'simple';
             } else {
                 $_SESSION['UiPref'] = $R['ui_preference'];
             }
             $Level = $_SESSION[Auth::USER_LEVEL];
         }
     } else {
         $this->CheckUser($UID);
         $Level = $_SESSION[Auth::USER_LEVEL];
     }
     /* Disable all plugins with >= $Level access */
     plugin_disable($Level);
     $this->State = PLUGIN_STATE_READY;
 }
            $reference_flag = 1;
            break;
        case 'h':
            /* help */
            Usage();
        default:
            echo "Invalid Option \"{$Option}\".\n";
            Usage();
    }
}
/** for no any flag scenario, meanning, list all licenses */
if (0 == $reference_flag && 0 == $nomos_flag) {
    $reference_flag = 1;
    $nomos_flag = 1;
}
$PG_CONN = DBconnect($sysconfig);
list_license($reference_flag, $nomos_flag);
function list_license($reference_flag, $nomos_flag)
{
    global $PG_CONN;
    $sql_statment = "SELECT rf_shortname from license_ref ";
    if ($reference_flag && $nomos_flag) {
    } else {
        if ($reference_flag) {
            $sql_statment .= " where rf_detector_type = 1";
        } else {
            if ($nomos_flag) {
                $sql_statment .= " where rf_detector_type = 2";
            }
        }
    }
Exemple #17
0
 /**
  * Check if frontend can connect to DB.
  * @throws DBException
  */
 protected function initDB()
 {
     $error = null;
     if (!DBconnect($error)) {
         throw new DBException($error);
     }
 }
Exemple #18
0
 public static function deleteById($id)
 {
     // Vérifie que l'email est de format text.
     if (!Tools::isIntegerValid($id)) {
         return null;
     }
     try {
         // Effectue une connexion à la DB.
         $pdo = DBconnect();
         // Prépare la requête.
         $stmt = $pdo->prepare("DELETE FROM t_user WHERE id = :id");
         // Set les paramètres
         $stmt->bindParam(':id', $id);
         // Execute la requête.
         if ($stmt->execute()) {
             return true;
         }
         // Retourne un objet null si l'utilisateur n'a pas été récuperé.
         return null;
     } catch (Exception $e) {
         // Retourne un objet null si une erreur c'est produite.
         return false;
     } finally {
         // Ferme le traitement.
         $stmt->closeCursor();
         // Ferme la connexion vers la base de donnée.
         $pdo = null;
     }
 }
require("infos.php");
$_SESSION['where_sup']="";
$_SESSION['NM_TABLE']="";
$_SESSION['DBName']="";
sess_start();
//include_once("reg_glob.inc");
$title=trad("LB_title"). $_SERVER["HTTP_HOST"] ."( IP=".gethostbyname($_SERVER["HTTP_HOST"]).")";
$lnkbdd=DBconnect($_REQUEST['lc_parenv[MySqlBddName]']);
//mysql_connect($DBHost,$DBUser, $DBPass) or die ("Impossible de se connecter au serveur $DBHost (user: $DBUser, passwd: $DBPass)");

$resb=db_show_bases();

// liste toutes les bases
foreach ($resb as $tresb) {
	$DBName = $tresb;
	DBconnect($DBName);
	$dbg=db_show_tables($GLOBALS["CisChpp"].$tresb.$GLOBALS["CisChpp"]);
  	$admok=($dbg && in_array($TBDname,$dbg));
  // n'affiche le lien pour �ition que si la table d'admin existe dans la base
  if ($admok) {
  	$theecho.= "<LI> <A HREF=\"LIST_TABLES.php?lc_DBName=$tresb&cfLB=vrai\">$tresb</A></LI>";
  	$dbok = $tresb;
  	$nbbases ++;
  }
}

if ($nbbases ==0) $theecho = "Aucune base actuellement paramétrée pour PhpYourAdmin; veuillez lancer l'utilitaire de configuration";
if ($nbbases != 1) { // si pas une seule base affiche écran
	include ("header.php"); ?>
	<H1><?php 
echo $title;
    }
}
if (file_exists($ZBX_CONFIGURATION_FILE) && !isset($_COOKIE['ZBX_CONFIG']) && !isset($DENY_GUI)) {
    $config = new CConfigFile($ZBX_CONFIGURATION_FILE);
    if ($config->load()) {
        $config->makeGlobal();
    } else {
        $show_warning = true;
        define('ZBX_DISTRIBUTED', false);
        define('ZBX_PAGE_NO_AUTHORIZATION', true);
        error($config->error);
    }
    require_once 'include/db.inc.php';
    if (!isset($show_warning)) {
        $error = '';
        if (!DBconnect($error)) {
            $_REQUEST['message'] = $error;
            define('ZBX_DISTRIBUTED', false);
            define('ZBX_PAGE_NO_AUTHORIZATION', true);
            $show_warning = true;
        } else {
            global $ZBX_LOCALNODEID, $ZBX_LOCMASTERID;
            // Init LOCAL NODE ID
            if ($local_node_data = DBfetch(DBselect('SELECT * FROM nodes WHERE nodetype=1 ORDER BY nodeid'))) {
                $ZBX_LOCALNODEID = $local_node_data['nodeid'];
                $ZBX_LOCMASTERID = $local_node_data['masterid'];
                $ZBX_NODES[$local_node_data['nodeid']] = $local_node_data;
                define('ZBX_DISTRIBUTED', true);
            } else {
                define('ZBX_DISTRIBUTED', false);
            }
function ttChpLink($valb0,$reqsup="",$valc=""){
global $DBHost,$DBUser,$DBName,$carsepldef,$TBDname;
//$valb0=str_replace (' ','',$valb0); // enlève espaces indésirables
$valbrut=explode(';',$valb0);
if (count($valbrut)>1) { // connection à une base différente
  $lntable=$valbrut[1];
  $defdb=explode(',',$valbrut[0]);
  $newbase=true;
 // si user et/ou hote d'accès à mysql est différent, on etablit une nvlle connexion Mysql
   if (($defdb[1]!="" && $defdb[1]!=$DBHost)||($defdb[2]!="" && $defdb[2]!=$DBUser)) {
     $lnc=mysql_connect($defdb[1],$defdb[2],$defdb[3]) or die ("Impossible de se connecter au serveur $defdb[1], user: $defdb[2], passwd: ***** ");
	 $newconnect=true;
     }
   mysql_select_db($defdb[0]) or die ("Impossible d'ouvrir la base de données $defdb[0].");
  }
else { //commme avant
   $lntable=$valbrut[0];
   $newbase=false;
   $newconnect=false;
   }
// 0: table, 1: champ lié (clé); 2: ET SUIVANTS champs affichés
$defl=explode(',',$lntable);
$nbca=0; // on regarde les suivants pour construire la requete
$rcaf="";
/* si le 1er à afficher champ comporte un & au début, il faut aller cherche les valeurs dans une 
table; les paramètres sont  indiqués dans les caractéristiques d'édition de CE champ dans la table  de définition*/
if (strstr($defl[2],"&")) { // si chainage
    $nmchp=substr ($defl[2],1); // enlève le &
       if (strstr($nmchp,"@")) { // si classement sur ce champ
         $nmchp=substr ($nmchp,1); // enlève le @
         $orderby=" order by $nmchp ";
         }
     $rcaf=$nmchp;
     $rqvc=msq("select VALEURS from $TBDname where NM_CHAMP='$nmchp' AND NM_TABLE='$defl[0]'");
     $resvc=mysql_fetch_row($rqvc);
     $valbchain=$resvc[0];
    }
else {
     while ($defl[$nbca+2]!="") {
       $nmchp=$defl[$nbca+2];
       if (strstr($nmchp,"!")) { // caractère spérateur défini
         $nmchp=explode("!",$nmchp);
       $tbcs[$nbca+1]=$nmchp[0]; // séparateur avant le "!"
       $nmchp=$nmchp[1];
         }
       if (strstr($nmchp,"@")) { // si classement sur ce champ
         $nmchp=substr ($nmchp,1); // enlève le @
       $orderby=" order by $nmchp "; 
         }
       $rcaf=$rcaf.",".$nmchp;
       $nbca++;
       }
}
 // soit on cherche 1 et 1 seule valeur
if  ($valc!="") {
    $whsl=" where $defl[1]='$valc'";
    }
// soit la liste est limitée par une clause where supplémentaire
else {
     $whsl=$reqsup;
     }
$rql=msq("SELECT $defl[1] $rcaf from $defl[0] $whsl $orderby");
// constitution du tableau associatif à 2 dim de corresp code ->lib
//echo "<!--debug2 rql=SELECT $defl[1] $rcaf from $defl[0] $whsl $orderby <BR>-->";
$tabCorlb=array();
while ($resl=mysql_fetch_row($rql)) {
  //$cle=strtoupper($resl[0]);
	$cle=$resl[0];
	//echo "<!--debug2: $cle\n-->";
  if (isset($valbchain)) { // champ lié à nouveau
     $resaf=ttChpLink($valbchain,"",$cle); // on réentre dans la fonction et on va chercher dans le champ 
     }
  else { // pas de liaison, on construit
    $resaf=$resl[1];
    for ($k=2;$k<=$nbca;$k++) {
      $cs=($tbcs[$k]!="" ? $tbcs[$k] : $carsepldef);
      $resaf=$resaf.$cs.$resl[$k];
      }
  }
  $tabCorlb[$cle]=$resaf; // tableau associatif de correspondance code -> libellé
  //echo "<!--debug2 cle: $cle; val: $resaf ; valverif:   ".$tabCorlb[$cle]."-->\n";  
  } 
  // fin boucle sur les résultats
// retablit les paramètres normaux si nécéssaire
if ($newconnect) {
	mysql_close($lnc);
	DBconnect(); // réouvre la session normale
	}
if ($newbase) mysql_select_db($DBName) or die ("Impossible d'ouvrir la base de données $DBName.");
if ($valc!="") {
  if ($resaf=="") $resaf="N.C.";
  return ($resaf);
  }
else {
	return($tabCorlb); // retourne le tableau associatif
	}
}
Exemple #22
0
session_start();
require 'main_Lib.php';
include_once "class/class_style.php";
/***********************************
Librería para los templates
***********************************/
require "smartyLib/Smarty.class.php";
$smarty = new Smarty();
smartyTemplate($smarty);
$usuarioSIGA = new stdClass();
$colegioSIGA = new stdClass();
$bdSIGA = new stdClass();
$styleSIGA = new stdClass();
//$_SESSION['PATH'] = PATH;
DBconnect($dbh, "dorcl_siga");
//Seteando tiempo
$smarty->assign('fecha', $fecha_latin);
$smarty->assign('hora', HORA_SERVIDOR . " [hrs]");
$smarty->assign('ip', $_SERVER['REMOTE_ADDR']);
//Fin seteo de tiempo
$SQL = "SELECT * FROM usuarios";
$result = mysql_query($SQL, $dbh);
if (isset($_POST['login'])) {
    while ($usuarios = mysql_fetch_array($result, MYSQL_ASSOC)) {
        if ($_POST["login"] == $usuarios["login"] && $_POST["password"] == $usuarios["password"]) {
            $_SESSION["MATRICULA_ANIO"] = MATRICULA_ANIO;
            $_SESSION["token"] = "d076safs324szszfsfaeeqewrww15wwdsffgjf";
            $smarty->assign('name', $usuarios["login"]);
            $SQL = "SELECT * FROM colegios WHERE colegio_ID = '" . $usuarios['FK_colegios_colegio_ID'] . "'";
            $result2 = mysql_query($SQL, $dbh);
Exemple #23
0
 function checkConnection()
 {
     global $DB;
     if (!$this->getConfig('check_fields_result')) {
         return false;
     }
     $DB['TYPE'] = $this->getConfig('DB_TYPE');
     if (is_null($DB['TYPE'])) {
         return false;
     }
     $DB['SERVER'] = $this->getConfig('DB_SERVER', 'localhost');
     $DB['PORT'] = $this->getConfig('DB_PORT', '0');
     $DB['DATABASE'] = $this->getConfig('DB_DATABASE', 'zabbix');
     $DB['USER'] = $this->getConfig('DB_USER', 'root');
     $DB['PASSWORD'] = $this->getConfig('DB_PASSWORD', '');
     $DB['SCHEMA'] = $this->getConfig('DB_SCHEMA', '');
     $error = '';
     // during setup set debug to false to avoid displaying unwanted PHP errors in messages
     if (!($result = DBconnect($error))) {
         error($error);
     } else {
         $result = true;
         if (!zbx_empty($DB['SCHEMA']) && $DB['TYPE'] == ZBX_DB_DB2) {
             $db_schema = DBselect('SELECT schemaname FROM syscat.schemata WHERE schemaname=\'' . db2_escape_string($DB['SCHEMA']) . '\'');
             $result = DBfetch($db_schema);
         }
         if ($result) {
             $result = DBexecute('CREATE TABLE zabbix_installation_test (test_row INTEGER)');
             $result &= DBexecute('DROP TABLE zabbix_installation_test');
         }
     }
     DBclose();
     $DB = null;
     return $result;
 }
 /**
  * \brief initialization
  */
 protected function setUp()
 {
     global $PG_CONN;
     global $upload_pk;
     global $uploadtree_pk_parent;
     global $uploadtree_pk_child;
     global $pfile_pk_parent;
     global $pfile_pk_child;
     global $agent_pk;
     global $DB_COMMAND;
     global $DB_NAME;
     #$sysconfig = './sysconfigDirTest';
     $DB_COMMAND = "../../../testing/db/createTestDB.php";
     exec($DB_COMMAND, $dbout, $rc);
     preg_match("/(\\d+)/", $dbout[0], $matches);
     $test_name = $matches[1];
     $db_conf = $dbout[0];
     $DB_NAME = "fosstest" . $test_name;
     $PG_CONN = DBconnect($db_conf);
     /** preparation, add uploadtree, upload, pfile, license_file record */
     $upload_filename = "license_file_test";
     /* upload file name */
     /** add a pfile record */
     $sql = "INSERT INTO pfile (pfile_sha1,pfile_md5,pfile_size) VALUES" . "('AF1DF2C4B32E4115DB5F272D9EFD0E674CF2A0BC', '2239AA7DAC291B6F8D0A56396B1B8530', '4560'), " . "('B1938B14B9A573D59ABCBD3BF0F9200CE6E79FB6', '55EFE7F9B9D106047718F1CE9173B869', '1892');";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     pg_free_result($result);
     /** add nomos agent record **/
     $sql = "INSERT INTO agent (agent_name) VALUES('nomos');";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     pg_free_result($result);
     /** if didn't have license_ref record, add it */
     $sql = "SELECT rf_shortname FROM license_ref where rf_pk = 1;";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     if (pg_num_rows($result) <= 0) {
         $sql = "INSERT INTO license_ref (rf_pk, rf_shortname, rf_text, marydone, rf_active, rf_text_updatable, rf_detector_type) VALUES(1, 'test_ref', 'test_ref', false, true, false, 1);";
         $result = pg_query($PG_CONN, $sql);
         DBCheckResult($result, $sql, __FILE__, __LINE__);
     }
     pg_free_result($result);
     /** get pfile id */
     $sql = "SELECT pfile_pk from pfile where pfile_sha1 IN ('AF1DF2C4B32E4115DB5F272D9EFD0E674CF2A0BC', 'B1938B14B9A573D59ABCBD3BF0F9200CE6E79FB6');";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     $row = pg_fetch_assoc($result, 0);
     $pfile_pk_parent = $row['pfile_pk'];
     $row = pg_fetch_assoc($result, 1);
     $pfile_pk_child = $row['pfile_pk'];
     pg_free_result($result);
     /** add a license_file record */
     /** at first, get agent_id of 'nomos' */
     $sql = "SELECT agent_pk from agent where agent_name = 'nomos';";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     $row = pg_fetch_assoc($result);
     $agent_pk = $row['agent_pk'];
     pg_free_result($result);
     /** secondly add license_file record */
     $sql = "INSERT INTO license_file(rf_fk, agent_fk, pfile_fk) VALUES(1, {$agent_pk}, {$pfile_pk_parent}), (2, {$agent_pk}, {$pfile_pk_child});";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     pg_free_result($result);
     /** add an upload record */
     $sql = "INSERT INTO upload (upload_filename,upload_mode,upload_ts, pfile_fk, uploadtree_tablename) VALUES ('{$upload_filename}',40,now(), '{$pfile_pk_parent}', '{$this->uploadtree_tablename}');";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     pg_free_result($result);
     /** get upload id */
     $sql = "SELECT upload_pk from upload where upload_filename = '{$upload_filename}';";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     $row = pg_fetch_assoc($result);
     $upload_pk = $row['upload_pk'];
     pg_free_result($result);
     /** add parent uploadtree record */
     $sql = "INSERT INTO uploadtree (parent, upload_fk, pfile_fk, ufile_mode, lft, rgt, ufile_name) VALUES(NULL, {$upload_pk}, {$pfile_pk_parent}, 33188, 1, 2, 'license_test.file.parent');";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     pg_free_result($result);
     /** get uploadtree id */
     $sql = "SELECT uploadtree_pk from uploadtree where pfile_fk = {$pfile_pk_parent};";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     $row = pg_fetch_assoc($result);
     $uploadtree_pk_parent = $row['uploadtree_pk'];
     pg_free_result($result);
     /** add child uploadtree record */
     $sql = "INSERT INTO uploadtree (parent, upload_fk, pfile_fk, ufile_mode, lft, rgt, ufile_name) VALUES({$uploadtree_pk_parent}, {$upload_pk}, {$pfile_pk_child}, 33188, 1, 2, 'license_test.file.child')";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     pg_free_result($result);
     /** get uploadtree id */
     $sql = "SELECT uploadtree_pk from uploadtree where pfile_fk = {$pfile_pk_child};";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     $row = pg_fetch_assoc($result);
     $uploadtree_pk_child = $row['uploadtree_pk'];
     pg_free_result($result);
     $this->uploadtree_tablename = GetUploadtreeTableName($upload_pk);
 }
Exemple #25
0
<?php

include_once './include/config.php';
include_once './include/functions.php';
include_once './include/dashboard.php';
include SMARTY_LIB;
$spine = new Smarty();
$dbh = DBconnect();
// pobieramy liste serwerow z bazy
$HostMenu = serverList($dbh);
$spine->assign('HostMenu', $HostMenu);
$HostTotalCount = serverCount($dbh);
$spine->assign('HostTotalCount', $HostTotalCount);
// calkowita liczba wolnego miejsca na serwerach w GB
$FreeTotalGB = hddFreeTotal($dbh);
$spine->assign('FreeTotalGB', round($FreeTotalGB, 1));
// ilosc wolnego miejsca na poszczegolnych serwerach
$SrvHDDFree = hddFreePerServer($dbh);
$spine->assign('SrvHDDFree', $SrvHDDFree);
// uptime na poszczegolnych serwerach
$uptimePerHost = uptimePerServer($dbh);
$spine->assign('uptimePerHost', $uptimePerHost);
// calkowita liczba stron www
$websiteCount = allWebsitesCount($dbh);
$spine->assign('websiteCount', $websiteCount);
// status wszystkich hostow z z bazy
$allHostStatus = serverStatus($dbh);
$spine->assign('allHostStatus', $allHostStatus);
// tworzymy jsona z opcjami konfiguracyjnymi apacza
vhostOptionFile($dbh);
if (isset($_GET['serverid'])) {
Exemple #26
0
<?php

require 'include.php';
logMessage("IrrighinoTask - Started");
$db_handler = DBconnect();
// convert the actual date to the calendar one (2000-01-02 -> 2000-01-08, Sunday to Saturday)
$day_of_week = date("w");
$day = $day_of_week + 2;
$actual_time = date("H:i:s");
$actual_date = "2000-01-0{$day} {$actual_time}";
// retrieve the outputs to be managed by this task
$sql = "SELECT OUT_ID, OUT_STATUS FROM OUTPUTS WHERE MANAGED_BY = " . MANAGED_BY_AUTO;
$data_set = DBquery($db_handler, $sql);
if ($data_set) {
    foreach ($data_set as $row) {
        $out_id = intval($row['OUT_ID']);
        $out_status = intval($row['OUT_STATUS']);
        logMessage("IrrighinoTask - Checking OUT_ID {$out_id} now in OUT_STATUS {$out_status}");
        // check if we neeed to change the status
        $sql = "SELECT EVENT_ID FROM EVENTS WHERE OUT_ID = {$out_id} AND START < '{$actual_date}' AND END > '{$actual_date}'";
        $event_data_set = DBquery($db_handler, $sql);
        // a event has been found
        if ($event_data_set->fetch()) {
            logMessage("IrrighinoTask - An event was found for this OUT_ID");
            // if the output is OFF, turn it ON
            if ($out_status == STATUS_OFF) {
                $response = callArduino("on/{$out_id}");
                if (strpos($response, "OK") !== false) {
                    $sql = "UPDATE OUTPUTS SET OUT_STATUS = " . STATUS_ON . " WHERE OUT_ID = {$out_id}";
                    DBexec($db_handler, $sql);
                    logEvent($db_handler, TYPE_OUT_ON, "Output {$out_id} turned ON by a schedule");
<?
// utilitaire permettant de g��er la table DESC_TABLE qui d�rit les autres pour l'�ition

require("infos.php");
include("globvar.inc");
sess_start();
DBconnect();


$title="CREATION DE $TBDname";
$admadm=1; // titre avec les !!
include ("header.php"); 
include("reg_glob.inc"); 

?>
<H1>Super Administration de phpYourAdmin</H1>
<H2>Administration de la table de description <?php 
echo $TBDname;
?>
</H2> 
<?
if ($STEP=="") {
?>
<h2>Bonjour !</h2>
Cette page va vous permettre de visualiser ou (re)générer la table utilitaire (nommée <b><? echo $TBDname; ?></b>) permettant la description pour édition des autres tables de la base <b><? echo $DBName; ?></b><br><br>
<h3><u>Attention:</u> Les operations qui suivent sont excessivement risquees...</b></h3>
Selectionner une base dans la liste et cliquez sur le bouton SUITE ci-dessous pour commencer ...<Br>
<form action="./CREATE_DESC_TABLES.php" method="post">
<h3>Liste des bases du serveur <I><? echo "$LBHost </I>($DBHost)"; ?><br>

<? $tblbas=db_show_bases(); 
Exemple #28
0
 function index()
 {
     $ingreso_valido = false;
     session_destroy();
     $alumnoSIGA = new stdClass();
     $colegioSIGA = new stdClass();
     $bdSIGA = new stdClass();
     $rut = $_POST['rut'];
     DBconnect($dbh, "dorcl_siga");
     $SQL = "SELECT * FROM db INNER JOIN colegios AS c ON c.FK_db_db_ID = db_ID";
     $result = DBQuery($SQL, $dbh);
     while ($row = DBFetchArray($result)) {
         $bd = "dorcl_" . $row['bd'] . $row['anio'];
         $bdSIGA->db_ID = $row['db_ID'];
         $_SESSION['path'] = $bdSIGA->bd = $row['bd'];
         $bdSIGA->anio = $row['anio'];
         $bdSIGA->nombrebd = $bd;
         $_SESSION['base_datos'] = $bdSIGA;
         $SQL = "SELECT * FROM colegios WHERE FK_db_db_ID = '{$row['db_ID']}'";
         $colegioSIGA->nombre = $row['nombre'];
         $colegioSIGA->direccion = $row['direccion'];
         $colegioSIGA->telefono = $row['telefono'];
         $colegioSIGA->rbd = $row['rbd'];
         $_SESSION['colegio'] = $colegioSIGA;
         mysql_select_db($bd);
         //dpr($bd);
         $SQL = "SELECT * FROM alumnos WHERE rut = '{$rut}' AND ultima_matricula = '" . $row['anio'] . "'";
         $result3 = DBQuery($SQL, $dbh);
         //dpr($SQL);
         if ($row3 = DBFetchArray($result3)) {
             //dpr($row3);
             //dpr($_SESSION);
             $alumnoSIGA->rut = $row3['rut'];
             $alumnoSIGA->curso = $row3['curso'];
             $alumnoSIGA->nombres = $row3['nombres'];
             $alumnoSIGA->apellidop = $row3['apellidop'];
             $_SESSION['alumno'] = $alumnoSIGA;
             $data['nombre_alumno'] = $row3['nombres'] . " " . $row3['apellidop'];
             $_SESSION['token'] = TOKEN;
             $_SESSION['bd_siga'] = "dorcl_siga";
             //echo "XS";
             $ingreso_valido = true;
             break;
         }
     }
     //dpr($_SESSION);
     if ($ingreso_valido) {
         //dpr($_SESSION);
         //$ses = $_SERVER['HTTP_COOKIE'];
         //dpr($ses);
         $class_alumno = new alumno();
         $class_apoderado = new apoderado();
         $class_notas = new notas();
         $class_mensualidad = new mensualidad();
         $data['apoderado'] = $class_apoderado->obtenerApoderado($rut);
         $data['notas'] = $class_notas->obtenerNotasAlumno($rut);
         $data['mensualidad'] = $class_mensualidad->obtenerMensualidad($rut);
         //moveLocation("alumnos/ingreso",2,"","");
         $this->load->view('ALUM-ingreso_valido', $data);
         //moveLocation("alumnos/ingreso",2,"","");
     } else {
         moveLocation("../ingreso.php", 0, 6);
     }
 }
 function CheckConnection()
 {
     global $DB;
     //			global $ZBX_MESSAGES;
     $DB['TYPE'] = $this->getConfig('DB_TYPE');
     if (is_null($DB['TYPE'])) {
         return false;
     }
     $DB['SERVER'] = $this->getConfig('DB_SERVER', 'localhost');
     $DB['PORT'] = $this->getConfig('DB_PORT', '0');
     $DB['DATABASE'] = $this->getConfig('DB_DATABASE', 'zabbix');
     $DB['USER'] = $this->getConfig('DB_USER', 'root');
     $DB['PASSWORD'] = $this->getConfig('DB_PASSWORD', '');
     $DB['SCHEMA'] = $this->getConfig('DB_SCHEMA', '');
     $error = '';
     if (!($result = DBconnect($error))) {
         //				if(!is_null($ZBX_MESSAGES)) array_pop($ZBX_MESSAGES);
         error($error);
     } else {
         $result = true;
         if (!zbx_empty($DB['SCHEMA']) && $DB['TYPE'] == 'IBM_DB2') {
             $db_schema = DBselect("SELECT schemaname FROM syscat.schemata WHERE schemaname='" . db2_escape_string($DB['SCHEMA']) . "'");
             $result = DBfetch($db_schema);
         }
         if ($result) {
             $result = DBexecute('CREATE table zabbix_installation_test ( test_row integer )');
             $result &= DBexecute('DROP table zabbix_installation_test');
         }
     }
     DBclose();
     if ($DB['TYPE'] == 'SQLITE3' && !zbx_is_callable(array('sem_get', 'sem_acquire', 'sem_release', 'sem_remove'))) {
         error('SQLite3 requires IPC functions');
         $result = false;
     }
     $DB = null;
     return $result;
 }
 /**
  * \brief This function is called when user output is
  * requested.  This function is responsible for content.
  * (OutputOpen and Output are separated so one plugin
  * can call another plugin's Output.)
  * This uses $OutputType.
  * The $ToStdout flag is "1" if output should go to stdout, and
  * 0 if it should be returned as a string.  (Strings may be parsed
  * and used by other plugins.)
  */
 function Output()
 {
     global $PG_CONN;
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     if (!$PG_CONN) {
         DBconnect();
         if (!$PG_CONN) {
             echo "NO DB connection";
         }
     }
     $V = "";
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             if ($this->OutputToStdout) {
                 $this->ShowView(NULL, "browse");
             }
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print $V;
     return;
 }