Example #1
0
 /**
  *
  * @param <Inventory> $inventory
  * @return <Inventory>
  * @SQL Insert into inventory values (NULL,1,1,1)
  */
 public function addToInventory($inventory)
 {
     $con = Connection::createConnection();
     $artifact = $inventory->artifact;
     $user = $inventory->user;
     $result = mysql_query("Insert into inventory values (NULL,{$inventory->artifactLvl},{$artifact->id},{$user->id})");
     $inventory->id = mysql_insert_id();
     mysql_query("commit");
     Connection::closeConnection($con);
     return $inventory;
 }
Example #2
0
 /**
  *
  * @param <User> $username
  * @return <User>
  * @SQL Select * From user Where username = 1
  */
 public function isUsernameAvailable($username)
 {
     $con = Connection::createConnection();
     $result = mysql_query("Select * From user Where username = '******'");
     $loginid = -1;
     $tempArray = mysql_fetch_array($result);
     if (mysql_num_rows($result) == 1) {
         $user = new User();
         $user->id = $tempArray['id'];
         $user->username = $tempArray['username'];
     }
     Connection::closeConnection($con);
     return $user;
 }
Example #3
0
 /** constructor **/
 public function __construct()
 {
     // validate arguments
     $num = func_num_args();
     $argumments = func_get_args();
     // create an empty object
     if ($num == 0) {
         $this->id = 0;
         $this->description = '';
         $this->ip = '';
     }
     // 1 values received
     if ($num == 1) {
         // pass the value to the id
         $id = $argumments[0];
         // create the instruction
         $instruction = 'SELECT station_description, station_ip_address FROM station WHERE station_id = ?';
         // open the connection
         parent::openConnection();
         // create the command
         $command = parent::$connection->prepare($instruction);
         // parameters
         $command->bind_param('i', $id);
         // execute command
         $command->execute();
         // link the results to local values
         $command->bind_result($description, $ip);
         // read data
         $found = $command->fetch();
         // close command
         mysqli_stmt_close($command);
         // close the connection
         parent::closeConnection();
         if ($found) {
             $this->id = $id;
             $this->description = $description;
             $this->ip = $ip;
         } else {
             $this->id = 0;
             $this->description = 'asdasd';
             $this->ip = 'asdasd';
         }
     }
 }
Example #4
0
 function getStationReadings($i)
 {
     $ids = array();
     $readings = array();
     $instruction = 'SELECT reading_id FROM readings WHERE date(reading_date)= curdate() AND reading_id_station=? ORDER BY reading_id DESC LIMIT 10';
     parent::openConnection();
     $command = parent::$connection->prepare($instruction);
     $command->bind_param('i', $i);
     $command->execute();
     $command->bind_result($id);
     while ($command->fetch()) {
         array_push($ids, $id);
     }
     mysqli_stmt_close($command);
     parent::closeConnection();
     foreach ($ids as $id) {
         array_push($readings, new Reading($id));
     }
     return $readings;
 }
Example #5
0
 public function getWeekAverages()
 {
     $instruction = 'SELECT 
         avg(case when `reading_id_station` = 1 then `reading_temperature` else null end) as Station1,
         avg(case when `reading_id_station` = 2 then `reading_temperature` else null end) as Station2,
         avg(case when `reading_id_station` = 3 then `reading_temperature` else null end) as Station3
         FROM readings 
         Where YEARWEEK (`reading_date`) = YEARWEEK(current_date)';
     parent::openConnection();
     $command = parent::$connection->prepare($instruction);
     $command->execute();
     $command->bind_result($s1, $s2, $s3);
     $found = $command->fetch();
     mysqli_stmt_close($command);
     parent::closeConnection();
     $averages = new ArrayObject();
     if ($found) {
         $averages['station1'] = $s1;
         $averages['station2'] = $s2;
         $averages['station3'] = $s3;
     } else {
         $averages['station1'] = 0;
         $averages['station2'] = 0;
         $averages['station3'] = 0;
     }
     return $averages;
 }
Example #6
0
 /**
  *
  * @param <Inventory> $inventory
  * @param <int> $artifactPrice
  * @param <GameProfile> $updatedGameProfile
  * @return <Boolean>
  * @SQL update gameprofile set gold = 100 where userid = 1
  * @SQL delete from inventory where id=1 AND userid=1
  *
  */
 public function sellArtifact($inventory, $artifactPrice, $updatedGameProfile)
 {
     $con = Connection::createConnection();
     $user = $updatedGameProfile->user;
     $updateGameProfile = mysql_query("update gameprofile set gold = {$updatedGameProfile->gold} where userid = {$user->id}");
     //delete from inventory
     $deleteInventory = mysql_query("delete from inventory where id={$inventory->id} AND userid={$user->id}");
     mysql_query("commit");
     Connection::closeConnection($con);
     return true;
 }
Example #7
0
 /**
  *
  * @param <String> $columnName
  * @param <GameProfile> $gameProfile
  * @return <Boolean>
  * @SQL update gameprofile set spylvl=spylvl+1 where globallvl > spylvl+scoutlvl+buylvl+sharelvl AND userid =1
  */
 public function addSkill($columnName, $gameProfile)
 {
     $con = Connection::createConnection();
     $user = $gameProfile->user;
     $addPoints = mysql_query("update gameprofile set {$columnName}={$columnName}+1 where globallvl > spylvl+scoutlvl+buylvl+sharelvl AND userid ={$user->id}");
     if (mysql_affected_rows() < 1) {
         Connection::closeConnection($con);
         return false;
     } else {
         return true;
     }
 }
Example #8
0
 public function getShareProgress($gameProfile, $gameProgress)
 {
     $con = Connection::createConnection();
     $share = ServerConstants::SHARE;
     $csp = $gameProgress->csp;
     $friendUser = $gameProgress->friend->user;
     $count = mysql_query("SELECT count(*) as count FROM gameprogress,progresstype where gameprogress.progresstypeid = progresstype.id AND progresstype.progresstype = '{$share}' AND gameprogress.cspid = {$csp->id} AND gameprogress.friendid = {$friendUser->id}");
     while ($row = mysql_fetch_array($count)) {
         $rowcount = $row['count'];
     }
     $base = 0.5;
     $rowcount = $rowcount + 1;
     $progress = pow($base, $rowcount) * $gameProfile->shareLvl * 5;
     $progressType = $this->giveProgressTypeObj(ServerConstants::SHARE);
     $insert = mysql_query("insert into gameprogress values (NULL,{$csp->id},{$friendUser->id},{$progressType->id})");
     mysql_query("commit");
     Connection::closeConnection($con);
     return $progress;
 }
Example #9
0
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once '../scriptsPHP/DAO/Connection.php';
require_once './utilidades/Authenticator.php';
header("Content-Type: text/html");
$authenticator = new Authenticator("Tirate una autenticacion papa", "No vas a pasar ni en pedo, puto");
$authenticator->setUser("jose");
$authenticator->setPassword("1234");
$authenticator->authenticate(TRUE, TRUE);
$conexionObject = new Connection("localhost", "matias", "", "diccionario");
$conexion = $conexionObject->getConnection();
$conexion = $conexionObject->getConnection();
$query = "select * from palabra";
$resultSet = $conexion->query($query);
while ($currentRow = mysqli_fetch_assoc($resultSet)) {
    echo $currentRow["palabra"] . " - ";
    echo "<br><br>";
}
$conexionObject->closeConnection();
 /**
  *
  * @param <CurrentSearchParty> $currentSearchParty
  * @return <CurrentSearchParty>
  * @SQL update  currentsearchparty,artifactinfo  set progress = 10 where currentsearchparty.id = 1 AND (select isactive from artifactinfo where artifactinfo.id= currentsearchparty.artifactid) = 1
  */
 public function updateCurrentSearchPartyProgress($currentSearchParty)
 {
     $con = Connection::createConnection();
     $result = mysql_query("update  currentsearchparty,artifactinfo  set progress = '{$currentSearchParty->progress}' where currentsearchparty.id = '{$currentSearchParty->id}' AND (select isactive from artifactinfo where artifactinfo.id= currentsearchparty.artifactid) = 1");
     if (mysql_affected_rows() < 1) {
         //means the current search party we want to update the artifact of that party is not active
         Connection::closeConnection($con);
         return null;
     }
     Connection::closeConnection($con);
     return $currentSearchParty;
 }
Example #11
0
    $reference = $_POST['check_tel'];
}
if (isset($_POST['check_email'])) {
    $reference = $_POST['check_email'];
}
echo "<h1>Recuperation variables</h1>";
echo "Nom : {$nom} <br />";
echo "Prénom : {$prenom} <br />";
echo "Adresse : {$adresse} <br />";
echo "Type : {$type} <br />";
echo "Description : {$description} <br />";
echo "severite : {$severite} <br />";
echo "Référence : {$reference} <br />";
if (isset($_FILES['photo'])) {
    echo "Photo : " . $_FILES['photo']['name'];
}
$incident = new Incident($description, $type, $adresse, $severite, $reference, $target);
/*** La connection à la DB ***/
$database = new Connection("localhost", "root", "root");
/*** L'insertion dans la table incident ***/
$count = $database->insertIntoIncident($incident);
echo $count;
/*** Déconnexion de la DB ***/
$database->closeConnection();
$html = "<br/><br/><button class=\"btn btn-success\" type=\"button\" onclick=\"window.location.href='Display.php'\">Montrer les plaintes</button>";
echo $html;
?>

</body>
</HTML>