示例#1
0
文件: Post.php 项目: jekt/blog-php
 static function create($title, $content, $author)
 {
     DBConnection::connect();
     DBConnection::insert('INSERT INTO post (title, content, author, pubDate) VALUES (\'' . DBConnection::getCleanVar($title) . '\', \'' . DBConnection::getCleanVar($content) . '\', ' . DBConnection::getCleanVar($author) . ', NOW())');
     return DBConnection::getDB()->insert_id;
 }
示例#2
0
 public function logApiCall($log)
 {
     $values['call_time'] = date('d-m-Y H:i:s');
     //Get caller ip
     if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
         $ip = $_SERVER['HTTP_CLIENT_IP'];
     } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
     } elseif (!empty($_SERVER['REMOTE_ADDR'])) {
         $ip = $_SERVER['REMOTE_ADDR'];
     } else {
         $ip = "not known";
     }
     $values['caller_ip'] = $ip;
     //Verplicht in $log!
     $values['url'] = $log['url'];
     $values['data'] = json_encode($log['data']);
     $values['response_code'] = $log['response_code'];
     unset($log['response']['code']);
     if ($log['response_code'] !== 200) {
         $values['response'] = $log['response']['db_code'];
     }
     $db = new DBConnection();
     $db->insert($values)->into("api_calls")->execute();
 }
示例#3
0
require_once "../includes/DB_Abstraction.inc";
?>
<title>Secure Your Images - ToyApp</title>
</head>
<body class="auth-user">
	<?php 
include_once "../includes/header.inc";
?>
	<div id="dash-board">
		<?php 
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $uinfo = get_user_info();
    $db = new DBConnection();
    $db->connect();
    $fid = substr($_POST['fid'], 4);
    $db->insert('temp', 'fid,uid,share', "{$fid},'{$uinfo['uid']}','{$_POST['shares']}'");
    $db->disconnect();
    //put ajax fecth code n finally display url
    ?>
<script>
function ajaxify(timer) {
		$.ajax({
			dataType : 'json',
			url: '/toyapp/includes/decrypt.inc.php?fid=<?php 
    echo $fid;
    ?>
',
			type: 'get',
			success: function(data) {	
				//alert(data['status']+' '+ data['data']);
				//ndata = JSON.parse(data);	
<?php

require_once '../model/DBConnection.php';
$db = new DBConnection();
/*
 * INSERT TEST.
 */
$lastInsertedId = $db->insert('truck', array('vehicle_capacity' => 0, 'brand' => 'Scania', 'age' => 4));
echo '<p> Last Inserted ID: ' . $lastInsertedId . '</p>';
/*
 * SELECT SINGLE TEST.
 */
echo '<p> All columns: ';
var_dump($db->select('truck', '*', 'id', $lastInsertedId));
echo '</p>';
echo '<p> Some columns: ';
var_dump($db->select('truck', array('brand', 'age'), 'id', $lastInsertedId));
echo '</p>';
/*
 * SELECT ALL TEST.
 */
$db->insert('truck', array('brand' => 'Mercedes', 'age' => 3));
echo '<p> All rows and columns: ';
var_dump($db->select('truck', '*'));
/*
 * UPDATE TEST.
 */
echo '<p> Before update: ';
var_dump($db->select('truck', '*', 'id', $lastInsertedId));
echo '</p>';
$db->update('truck', array('vehicle_capacity' => 0, 'brand' => 'MAN', 'age' => 0), $lastInsertedId);
			});
	}

</script>

<?php 
$login = $_POST['postlogin'];
$name = $_POST['postname'];
$password = $_POST['postpass'];
$email = $_POST['postemail'];
$endereco = $_POST['postendereco'];
$cidade = $_POST['postcidade'];
$telefone = $_POST['posttelefone'];
$documento = $_POST['postdocumento'];
$pais = $_POST['postpais'];
$loginStats = false;
$emailStats = false;
$data = DBConnection::select("Select * from hospede");
foreach ($data as $row) {
    if ($row['HonLog'] == $login) {
        $loginStats = true;
    }
    if ($row['HonEma'] == $email) {
        $loginStats = true;
    }
}
if ($loginStats) {
    echo "<script>signUp2()</script>";
} else {
    DBConnection::insert('Insert INTO hospede (HosNom,HosLog,HosPas,HosEma,HosEnd,HosCid,HosTel,HosDoc,HosPai) values("' . $name . '","' . $login . '","' . $password . '","' . $email . '","' . $endereco . '","' . $cidade . '","' . $telefone . '","' . $documento . '","' . $pais . '")');
}
示例#6
0
    $N = $sent[0];
    $K = $sent[1];
    $command = '/usr/bin/python /var/www/html/toyapp/toyapp-python/toyapp.py encrypt ' . $file_name . ' ' . $N . ' ' . $K;
    echo $command;
    //echo '<br />'.$command;
    //echo '<br />';
    #$result = #exec($command);#
    $result = json_decode(exec($command, $status), true);
    $size = sizeof($result);
    //print_r($result);
    $i = 0;
    require_once '../includes/shareholdersapi.inc';
    $shareholders = get_shareholders($sent[2]);
    //print_r($shareholders);
    require_once '../includes/DB_Abstraction.inc';
    $db_con = new DBConnection();
    $db_con->connect();
    foreach ($result as $pair) {
        $uid = $shareholders[$i]['uid'];
        $db_con->insert('secrets', 'fid,uid,secret', "{$sent['2']},'{$uid}','[{$pair['0']},{$pair['1']}]'");
        $i++;
        echo "<br />Secret {$i}: <input type='text' readonly='readonly' value='[{$pair['0']},{$pair['1']}]'/>";
    }
    //print_r($result);//. ' <br />';
    $db_con->update('file', "url='\\/toyapp\\/repo\\/{$fn}.enc',status=2", "fid={$sent['2']}");
    $db_con->disconnect();
    //unlink($file_name);
}
?>
</body>
</html>
 /**
  * Insert selected instance of this type in the database. The instance will 
  * not be inserted if it does not contain any data.
  * Returns the ID of the inserted instance on success.
  * @return int|null
  */
 public function submit_new()
 {
     $db = new DBConnection();
     $dataToInsert = array();
     foreach ($this->classFields as $variable => $value) {
         if ($value) {
             $dataToInsert[$variable] = $value;
         }
     }
     if (count($dataToInsert)) {
         return $db->insert($this->convert_to_table_name($this->get_class_name()), $dataToInsert);
     } else {
         return null;
     }
 }