Example #1
0
function selectDb($config)
{
    if (connectDb($config)) {
        return mysql_selectdb($config['db']['dbname']);
    }
    return false;
}
Example #2
0
function insertComment($username, $text) {
   //  if were not connected, connect.
    global $isConnected;
    if (isset($isConnected) == false)
    connectDb ();

//Escape all strings and use the strip_tags() to be more safe
    
   $safe_strings = TRUE;

   function safeString($string){
    $string = mysql_real_escape_string(strip_tags($string));
    return $string;
   }
   
   $username = safeString($username);
   $text = safeString($text);
  
//$username = mysql_real_escape_string($username);
  //$ $text = mysql_real_escape_string($text);
    
// date and time
    $date = getCurrentDate();
    
//Inserts a comment dB. 
    mysql_query("INSERT INTO comment (`username`, `text`, `date`) VALUES ('$username' , '$text', '$date')")
    or die("Something went wrong with the insert query" . mysql_error());
}
Example #3
0
function getDiaryData($person_id, $date = null)
{
    $db = connectDb();
    $sql_arg = array(":id" => $person_id);
    $date_sql = null;
    if ($date != null) {
        $sql_arg[":date"] = sprintf("%04d", $date);
        $date_sql = "AND DATE_FORMAT(a_diary.create_day, \"%Y%m%d\")= :date";
    }
    $sql = <<<SQL_END
SELECT
\ta_diary.create_day,
\tDATE_FORMAT(a_diary.create_day, "%Y%m%d") AS yyyymmdd,
\ta_diary.post,
\ta_person.name
FROM a_diary
LEFT JOIN a_person
\tON a_person.person_id = a_diary.person_id
WHERE a_diary.person_id = :id
{$date_sql}
ORDER BY a_diary.create_day
;
SQL_END;
    $stmt = $db->prepare($sql);
    $stmt->execute($sql_arg);
    if ($date != null) {
        return $stmt->fetch(PDO::FETCH_ASSOC);
    }
    return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
Example #4
0
function insertNewExercise($data)
{
    $sql = "INSERT INTO exercises SET topic = \"{$data->topic}\",  exercise = \"{$data->exercise}\", enable = \"{$data->enable}\"";
    $mysqli = connectDb();
    $mysqli->query($sql);
    echo $mysqli->insert_id;
    closeDb($mysqli);
}
Example #5
0
function insertSolution($mysqli, $data)
{
    $sql = "INSERT INTO solvings SET studentName = \"{$data->studentName}\", solving = \"{$data->solving}\", class = \"{$data->class}\", topic = \"{$data->topic}\", ip = \"{$_SERVER['REMOTE_ADDR']}\", exerciseId = \"{$data->exerciseId}\", teacherName = \"{$data->teacherName}\"";
    $mysqli = connectDb();
    //~ dblog($mysqli, "sql: $sql");
    $mysqli->query($sql);
    closeDb($mysqli);
}
Example #6
0
 public function __construct($db)
 {
     require_once 'bdd/gestion_bdd.php';
     if (is_null($db)) {
         $this->_db = connectDb();
     } else {
         $this->_db = $db;
     }
 }
Example #7
0
function getimage($a)
{
    $dbh = connectDb();
    $sql = "select * from images where id = " . $a;
    $stmt = $dbh->query($sql);
    $stmt->execute;
    $image = $stmt->fetch();
    return $image;
}
Example #8
0
function loadView()
{
    global $app;
    load_head();
    $mysqli = connectDb();
    $ids = getEnableds($mysqli);
    $teacherNames = getTeacherNames($mysqli);
    showStudentForm($ids, $teacherNames);
    closeDb($mysqli);
    load_foot();
}
Example #9
0
function loadDonView()
{
    global $app;
    load_head();
    echo $app["version"];
    $mysqli = connectDb();
    $ids = getEnableds($mysqli);
    showTeacherForm($ids);
    closeDb($mysqli);
    load_foot();
}
Example #10
0
function getGenreName($genre_id)
{
    $name = "";
    $pdo = connectDb();
    $sql = "SELECT * FROM genre WHERE genre_id=?";
    $stmt = $pdo->prepare($sql);
    $stmt->bindValue(1, $genre_id, PDO::PARAM_INT);
    $stmt->execute();
    foreach ($stmt as $row) {
        $name = $row["name"];
    }
    $pdo = null;
    return $name;
}
Example #11
0
 function initializeSystemSettings()
 {
     global $dbHost, $dbUser, $dbUserPw, $dbName, $includeDumpJs;
     global $gorumroll, $speedStopWatch, $gorumview, $jQueryLib;
     $_GET = filterInput($_GET);
     $_COOKIE = filterInput($_COOKIE);
     $_SERVER = filterInput($_SERVER);
     $_FILES = filterInput($_FILES);
     if (class_exists("speedstat")) {
         $speedStopWatch = new Stopwatch();
         $speedStopWatch->start();
     }
     ini_set("session.use_cookies", 1);
     ini_set("session.use_only_cookies", 1);
     ini_set("session.use_trans_sid", 0);
     if (!session_id()) {
         session_start();
     }
     $this->kbfu = chr(103) . chr(111) . chr(114) . chr(117) . chr(109) . chr(117) . chr(115) . chr(101) . chr(114);
     $this->kbfk = chr(105) . chr(115) . chr(65) . chr(100) . chr(109);
     $this->kbfr = chr(103) . chr(111) . chr(114) . chr(117) . chr(109) . chr(114) . chr(101) . chr(99) . chr(111) . chr(103) . chr(110) . chr(105) . chr(115) . chr(101) . chr(100);
     // http://hu.php.net/manual/en/reserved.variables.session.php#85448:
     // azert, hogy az infoTextek ne ragadjanak be:
     if (ini_get('register_globals')) {
         foreach ($_SESSION as $key => $value) {
             if (isset($GLOBALS[$key])) {
                 unset($GLOBALS[$key]);
             }
         }
     }
     connectDb($dbHost, $dbUser, $dbUserPw, $dbName);
     authenticate();
     $gorumroll = new Roll();
     $gorumroll->isAction() ? include GORUM_DIR . "/gorum_action.php" : (include GORUM_DIR . "/gorum_view.php");
     $this->initializeUserSettings();
     if (class_exists("cronjob")) {
         executeCronJobs();
     }
     if (!$gorumroll->isAction()) {
         $gorumview = new View();
         $gorumview->addElement("contentTemplate");
         View::init();
     }
     if ($includeDumpJs && !$gorumroll->isAction()) {
         JavaScript::addInclude(GORUM_JS_DIR . $jQueryLib);
         JavaScript::addInclude(GORUM_JS_DIR . "/jquery/jquery.dump.js");
         JavaScript::addInclude(GORUM_JS_DIR . "/dump.js");
     }
     $this->kbf();
 }
Example #12
0
function getDiaryByPersonId($person_id)
{
    $db = connectDb();
    $sql = <<<END_SQL
SELECT
\ta_diary.create_day,
\tDATE_FORMAT(a_diary.create_day, "%Y%m%d") AS yyyymmdd,
\ta_person.name
FROM a_diary
LEFT JOIN a_person
\tON a_person.person_id = a_diary.person_id
WHERE a_diary.person_id = :id
ORDER BY create_day
;
END_SQL;
    $stmt = $db->prepare($sql);
    $stmt->execute(array(":id" => $person_id));
    return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
Example #13
0
function getDiaryByPersonIdAndDate($id, $date)
{
    $dbh = connectDb();
    $sql = <<<SQL_END
SELECT
\ta_person.name,
\ta_diary.create_day,
\ta_diary.post
FROM a_diary
LEFT JOIN a_person
\tON  a_person.person_id = a_diary.person_id
WHERE
\ta_person.person_id = :id
\tAND a_diary.create_day = :date
;
SQL_END;
    $stmt = $dbh->prepare($sql);
    $stmt->execute(array(':id' => $id, ':date' => $date));
    return $stmt->fetch(PDO::FETCH_ASSOC);
}
Example #14
0
File: db.php Project: nas05/OLDEXAM
function create_user($account, $password, $email)
{
    connectDb();
    # check if username is already exists
    if (username_exists($account)) {
        return false;
    }
    $password = md5($password);
    # add new user
    global $pdo;
    $stmt = $pdo->prepare('
    INSERT INTO user_table
    (username, password,email)
    values (:username, :password, :email)');
    $stmt->execute(array(':username' => $account, ':password' => $password, ':email' => $email));
    if ($pdo->lastInsertId()) {
        header('Location:index.php');
    } else {
        return false;
    }
}
Example #15
0
function getMovieInfo($post)
{
    $post = '\'' . $post . '\'';
    $sql = '
		SELECT
		title 		AS title,
		title_origin AS title_origin,
		year 		AS year,
		country 	AS country,
		duration 	AS duration,
		director 	AS director,
		writer  	AS writer,
		cast 		AS cast
		FROM movie WHERE id=' . $post . ' LIMIT 0, 1
		';
    header('Content-Type/json: application/json');
    // MySQLの返り値が null([]) でない場合に実行
    if (json_encode(connectDb()->query($sql)->fetchAll(PDO::FETCH_ASSOC)) != '[]') {
        echo "{movie: " . json_encode(connectDb()->query($sql)->fetchAll(PDO::FETCH_ASSOC)) . "}";
    }
}
        }
        $json_object['document'] = $data;
        //		echo json_encode($data);
        $sql = "select * from document_routing inner join routing_targets where status='PENDING' and destination_office='SUP' and synced='false'";
        $rs = $db->query($sql);
        $nm = $rs->num_rows;
        for ($i = 0; $i < $nm; $i++) {
            $row = $rs->fetch_assoc();
            $actionSQL = "select * from document_actions where action_code='" . $row['action_id'] . "'";
            $actionRS = $db->query($actionSQL);
            $actionRow = $actionRS->fetch_assoc();
            $data["action_" . $i]["document_id"] = $row['reference_no'];
            $data["action_" . $i]["from_office"] = $row['from_office'];
            $data["action_" . $i]["from_person"] = $row['from_name'];
            $data["action_" . $i]["send_date"] = $row['request_date'];
            $data["action_" . $i]["action"] = $actionRow['action_description'];
        }
        echo json_encode($data);
        //		$json_object['document_action']=$data;
        //		echo json_encode($jsonobject);
    }
}
if (isset($_POST['dataSynced'])) {
    if ($_POST['dataSynced'] == 'Y') {
        $db = connectDb();
        $update = "update document set synced='true'";
        $updateRS = $db->query($update);
        $update = "update document_routing set synced='true'";
        $updateRS = $db->query($update);
    }
}
Example #17
0
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */
include_once "includes/config.php";
include_once "includes/utils.php";
include_once "includes/headfoot.php";
initSession();
if (!($_SESSION['loggedinUserPerms'] & VIEW_ZONES)) {
    die('You do not have permission to view this page!');
}
$dbTrackHandler = connectDb();
// Query All Zones
$zonesQuery = $dbTrackHandler->query('SELECT * FROM zones WHERE `parent_id`=0;');
foreach ($zonesQuery as $entry) {
    $thisZone['id'] = $entry['id'];
    $thisZone['name'] = $entry['region_name'];
    $zones[] = $thisZone;
}
$totalComputers = $dbTrackHandler->query('SELECT count(*) FROM computers;')->fetch(PDO::FETCH_NUM);
$offlineComputers = $dbTrackHandler->query('SELECT count(*) FROM computers WHERE laststatus=' . AVAIBILITY_TYPE_OFFLINE . ';')->fetch(PDO::FETCH_NUM);
echo _header("System Overview");
?>
		<div id="yui-main">
				<div class="yui-b">
			
				<h2>System Overview</h2>
Example #18
0
function uninstallMain(&$s)
{
    global $dbName, $dbUser, $dbUserPw, $dbHost;
    $s = "";
    if (!isset($dbName)) {
        iPrint($s1, "err", $sp);
        $s .= $sp;
        $txt = "dbName not set";
        handleErr($txt, __FILE__, __LINE__);
    }
    showInstallHeader($s1);
    $s .= $s1;
    $s .= "<h1>Uninstall</h1>";
    connectDb($dbHost, $dbUser, $dbUserPw, $dbName);
    $query = "DROP DATABASE {$dbName}";
    $result = executeQuery($query);
    iPrint("Db dropped", "ok", $sp);
    $s .= $sp;
    iPrint("Uninstall successful", "hurra", $sp);
    $s .= $sp;
    return ok;
}
Example #19
0
<?php

require_once 'functions.php';
require_once "post_mapper.php";
require_once "post.php";
$post_mapper = new PostMapper(connectDb());
$posts = $post_mapper->all();
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>投稿内容</title>
    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
          integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    <link rel="stylesheet" href="./css/style.css">
</head>
<body>
<div class="container">
    <h1>投稿された内容</h1>
    <?php 
if (count($posts)) {
    ?>
        <ul>
            <?php 
    foreach ($posts as $post) {
        ?>
                <li>
                    <div class="post-header">
                        <?php 
Example #20
0
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container -->
    </nav>

    <!-- Page Content -->
    <div class="container">
 
        <div class="row">
            <div class="col-xs-12 text-center">
             <?php 
///////////////////CONTENIDO DEL TEST////////////////////
//por defecto se muestran todos
$test = array();
$connection = connectDb();
//establecemos conexion con la base de datos.
$resultIdsCategory = $connection->query("SELECT id FROM " . TABLE_PREFIX . TABLE_TITLE . " where active = 1");
$tempArrayIdsCategory = array();
while ($temp = $resultIdsCategory->fetch_assoc()) {
    $tempArrayIdsCategory[] = intval($temp["id"]);
}
$test = validateResponse($test, $tempArrayIdsCategory);
//comprobamos los valores de respuesta de la pagina y syncronizamos los datos con el array.
if (count($test) == 0) {
    $count = 0;
    foreach ($tempArrayIdsCategory as $key => $value) {
        $test[$value] = intval($value);
        $count++;
    }
}
<?php

connectDb("mysql.hostinger.web.tr", "u507889671_alumn", "u507889671_izu", "0kJGNnYLZo");
Example #22
0
    $post = htmlspecialchars($_POST['list']);
    $sql = '
		SELECT
		title 		AS title,
		title_origin AS title_origin,
		title_no 	AS title_no,
		year 		AS year,
		country 	AS country,
		duration 	AS duration,
		director 	AS director,
		writter 	AS writter,
		cast 		AS cast
		FROM movie LIMIT $post, 3
		';
    header('Content-Type/json: application/json');
    echo "{filmarks: " . json_encode(connectDb()->query($sql)->fetchAll(PDO::FETCH_ASSOC)) . "}";
} elseif (isset($_POST['grid3'])) {
    $post = htmlspecialchars($_POST['grid3']);
    $number = 3;
    getSql($post, $number);
} elseif (isset($_POST['grid4'])) {
    $post = htmlspecialchars($_POST['grid4']);
    $number = 4;
    getSql($post, $number);
} elseif (isset($_POST['grid5'])) {
    $post = htmlspecialchars($_POST['grid5']);
    $number = 5;
    getSql($post, $number);
} elseif (isset($_POST['info'])) {
    // ---- 映画情報の取得
    $post = htmlspecialchars($_POST['info']);
Example #23
0
 function validate()
 {
     $this->db = connectDb();
     $this->dbPrefix = getDbPrefix();
     $this->t = new TextFilter();
     return true;
 }
Example #24
0
<?php

$pdo = null;
function connectDb()
{
    global $pdo;
    try {
        $pdo = new PDO('mysql:host=localhost;dbname=examen', 'root', '');
    } catch (PDOException $e) {
        die('MySQL connection failed! ' . $e->getMessage());
    }
}
connectDb();
if (isset($_FILES['files'])) {
    $errors = array();
    $req = "";
    $req = " select USER_ID from ";
    $req .= $_POST['level'] . ' ';
    $req .= " where course_id= ";
    $req .= $_POST['Sn'];
    $req .= " ORDER BY id DESC LIMIT 1";
    $query = $pdo->prepare($req);
    $query->execute();
    $list = $query->fetchAll(PDO::FETCH_ASSOC);
    foreach ($list as $key => $value) {
        $user_id = $value['USER_ID'];
    }
    $user_id += 1;
    foreach ($_FILES['files']['tmp_name'] as $key => $tmp_name) {
        $file_name = $key . $_FILES['files']['name'][$key];
        //$file_name = $_FILES['files']['name'][$key];
Example #25
0
function setVehiculeSessionSurf($noVeh, $noSes)
{
    $dbh = connectDb();
    // connexion à la bdd
    $sql = "INSERT INTO VehiculeSessionSurf VALUES (:noVeh, :noSes, :nbrPlacesDispo, :nbrPlanchesDispo);";
    $sth = $dbh->prepare($sql);
    $sth->bindParam(":noVeh", $noVeh, PDO::PARAM_STR);
    $sth->bindParam(":noSes", $noSes, PDO::PARAM_STR);
    $sth->bindParam(":nbrPlacesDispo", $_REQUEST["nbrPlacesDispo"], PDO::PARAM_STR);
    $sth->bindParam(":nbrPlanchesDispo", $_REQUEST["nbrPlanchesDispo"], PDO::PARAM_STR);
    if ($sth->execute() == 0) {
        print $dbh->errorInfo();
    }
    // affiche message d'érreur de la bdd
    $dbh = null;
    // déconnexion de la bdd
}
Example #26
0
File: db.php Project: batnyam/shop
function query($query)
{
    $result = mysql_query($query, connectDb());
    return $result;
}
Example #27
0
<!DOCTYPE html>
<html lang="ja">
    <head>
        <meta charset="shift_jis">
    </head>
    <body>
<?php 
//課題5:nameに「茂」を含む情報を取得し、画面に取得した情報を表示してください
require_once "07kadai1.php";
$pdo = connectDb();
if (is_string($pdo)) {
    //    return $pdo;
    echo $pdo;
    exit;
}
$sql = "select * from profiles where name like :name";
$stmt = $pdo->prepare($sql);
$name = "%茂%";
$stmt->bindValue(':name', $name, PDO::PARAM_STR);
$stmt->execute();
$data = $stmt->fetch(PDO::FETCH_ASSOC);
foreach ($data as $value) {
    echo $value . "<BR>";
}
?>
    </body>
</html>
Example #28
0
 $register_guid = guidv4();
 $form_data = array('name' => $name, 'email' => $email, 'register_password' => $password, 'register_verified' => 'false');
 // Users
 //Check if user is already registered
 $conn = connectDb();
 if ($conn->connect_error) {
     die("Connection failed: " . $conn->connect_error);
 }
 $sql = "SELECT * FROM users WHERE email='" . $email . "' AND register_verified='true'";
 $result = $conn->query($sql);
 #echo "$result->num_rows".$result->num_rows;
 if ($result->num_rows > 0) {
     echo "Sorry this user is already registered, you will need to login.";
 } else {
     //Create User and Send Verification Email
     $conn = connectDb();
     // Check connection
     if ($conn->connect_error) {
         die("Connection failed: " . $conn->connect_error);
     }
     $fields = array_keys($form_data);
     $sql = "INSERT INTO " . $table_name . " (`" . implode('`,`', $fields) . "`,`register_guid`)  VALUES('" . implode("','", $form_data) . "', '" . $register_guid . "')";
     #$sql = "INSERT INTO users (`name`, `email`) VALUES ('".$_POST["firstname"]." ".$_POST["surname"]."', '".$_POST["email"]."')";
     #echo "SQL :".$sql;
     if ($conn->query($sql) === TRUE) {
         echo "New user created successfully";
     } else {
         echo "Error: ";
         #. $sql . "<br>" . $conn->error;
     }
     $conn->close();
Example #29
0
<?php

require_once '../config.php';
require_once '../functions.php';
$dbh = connectDb();
$id = (int) $_POST['id'];
$dbh->query("update entries set status = 'deleted' where id ={$id}");
echo $id;
Example #30
0
 public function getAll()
 {
     $spots = array();
     $dbh = connectDb();
     // connexion à la bdd
     $sql = "SELECT nomSpot, photoSpot, urlGoogleMap, idFSI FROM Spot";
     $result = $dbh->query($sql);
     if ($result) {
         while ($occ = $result->fetch(PDO::FETCH_ASSOC)) {
             //echo '<option value="'."DEBUG".'">'.$occ['nomSpot'].'</option>';
             $spots[$occ['nomSpot']] = new Spot($occ);
             // construit un objet Spot et l'ajoute au tableau
         }
     } else {
         print $dbh->errorInfo();
     }
     return $spots;
 }