Compare commits
14 Commits
new-mysql
...
385a02c90f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
385a02c90f | ||
|
|
8638f28847 | ||
|
|
5f2502877b | ||
|
|
8eccdffb1e | ||
|
|
c858d5dd32 | ||
|
|
234e187a54 | ||
| d8f5fd7f3a | |||
|
|
a30fd21842 | ||
|
|
57421ead5e | ||
| a846fe2fa7 | |||
|
|
06a3112617 | ||
|
|
064d8f0df3 | ||
|
|
19dcea8344 | ||
| b8e078f470 |
@@ -1,3 +1,2 @@
|
|||||||
git submodule add https://git.seemsleg.it/ef/php-func-lib lib
|
# php-func-lib
|
||||||
|
git submodule add https://git.seemsleg.it/pub/php-func-lib lib
|
||||||
test
|
|
||||||
|
|||||||
15
mail.php
15
mail.php
@@ -1,14 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
function send_mail($an, $betreff, $text, $ok = '', $error = '') {
|
||||||
function send_mail($an, $betreff, $text, $ok = '', $error = '')
|
include 'secret.php';
|
||||||
{
|
$sender = 'noreply@troy-grunt.de';
|
||||||
$header = 'From: noreply@isleofhope.de' . "\r\n";
|
if (isset ( $_sendermail )) {
|
||||||
|
$sender = $_sendermail;
|
||||||
|
}
|
||||||
|
$header = 'From: ' . $sender . "\r\n";
|
||||||
$header .= 'To: ' . $an . "\r\n";
|
$header .= 'To: ' . $an . "\r\n";
|
||||||
$header .= 'Content-Type:text/html' . "\r\n";
|
$header .= 'Content-Type:text/html' . "\r\n";
|
||||||
$header .= 'Content-Transfer-Encoding: 8bit' . "\r\n";
|
$header .= 'Content-Transfer-Encoding: 8bit' . "\r\n";
|
||||||
$header .= 'X-Mailer: PHP/' . phpversion();
|
$header .= 'X-Mailer: PHP/' . phpversion ();
|
||||||
|
|
||||||
if (mail($an, $betreff, $text, $header) === true) {
|
if (mail ( $an, $betreff, $text, $header ) === true) {
|
||||||
echo $ok;
|
echo $ok;
|
||||||
} else {
|
} else {
|
||||||
echo $error;
|
echo $error;
|
||||||
|
|||||||
@@ -7,4 +7,6 @@ $_m['pass'] = '';
|
|||||||
$_m['data'] = '';
|
$_m['data'] = '';
|
||||||
$_m['pre'] = 'efcms2_';
|
$_m['pre'] = 'efcms2_';
|
||||||
$_m['salt'] = '';
|
$_m['salt'] = '';
|
||||||
|
|
||||||
|
$_sendermail = 'noreply@troy-grunt.de';
|
||||||
?>
|
?>
|
||||||
211
sql.php
211
sql.php
@@ -1,12 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
* $query = sprintf("SELECT firstname, lastname, address, age FROM friends
|
|
||||||
* WHERE firstname='%s' AND lastname='%s'",
|
|
||||||
* mysql_real_escape_string($firstname),
|
|
||||||
* mysql_real_escape_string($lastname));
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class SQL {
|
class SQL {
|
||||||
private $h;
|
private $h;
|
||||||
private $res = false;
|
private $res = false;
|
||||||
@@ -24,95 +16,12 @@ class SQL {
|
|||||||
if (SQL_LOG)
|
if (SQL_LOG)
|
||||||
$this->f = fopen ( 'sql.log', 'w' );
|
$this->f = fopen ( 'sql.log', 'w' );
|
||||||
|
|
||||||
$this->h = mysqli_connect ( $_m ['host'], $_m ['user'], $_m ['pass'] );
|
$this->h = new mysqli ( $_m ['host'], $_m ['user'], $_m ['pass'], $_m ['data'] );
|
||||||
//var_dump ( $this->h );
|
if ($this->h->connect_errno) {
|
||||||
if (! $this->h) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mysqli_select_db ( $this->h, $_m ['data'] );
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private function prepare($q, $t, $p) {
|
|
||||||
$t = str_split ( $t );
|
|
||||||
$v = array ();
|
|
||||||
$q = str_replace ( "?", "%s", $q );
|
|
||||||
foreach ( $t as $i => $c ) {
|
|
||||||
switch ($c) {
|
|
||||||
case 's' :
|
|
||||||
$v [] = "'" . mysqli_real_escape_string ( $this->h, $p [$i] ) . "'";
|
|
||||||
break;
|
|
||||||
case 'i' :
|
|
||||||
$v [] = ( int ) $p [$i];
|
|
||||||
break;
|
|
||||||
case 'd' :
|
|
||||||
$v [] = ( double ) $p [$i];
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
//return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$res = array ();
|
|
||||||
switch (count ( $p )) {
|
|
||||||
case 0 :
|
|
||||||
$res = mysqli_query ( $this->h, $q );
|
|
||||||
break;
|
|
||||||
case 1 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0] ) );
|
|
||||||
break;
|
|
||||||
case 2 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0], $v [1] ) );
|
|
||||||
break;
|
|
||||||
case 3 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0], $v [1], $v [2] ) );
|
|
||||||
break;
|
|
||||||
case 4 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0], $v [1], $v [2], $v [3] ) );
|
|
||||||
break;
|
|
||||||
case 5 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0], $v [1], $v [2], $v [3], $v [4] ) );
|
|
||||||
break;
|
|
||||||
case 6 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0], $v [1], $v [2], $v [3], $v [4], $v [5] ) );
|
|
||||||
break;
|
|
||||||
case 7 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0], $v [1], $v [2], $v [3], $v [4], $v [5], $v [6] ) );
|
|
||||||
break;
|
|
||||||
case 8 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0], $v [1], $v [2], $v [3], $v [4], $v [5], $v [6], $v [7] ) );
|
|
||||||
break;
|
|
||||||
case 9 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0], $v [1], $v [2], $v [3], $v [4], $v [5], $v [6], $v [7], $v [8] ) );
|
|
||||||
break;
|
|
||||||
case 10 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0], $v [1], $v [2], $v [3], $v [4], $v [5], $v [6], $v [7], $v [8], $v [9] ) );
|
|
||||||
break;
|
|
||||||
case 11 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0], $v [1], $v [2], $v [3], $v [4], $v [5], $v [6], $v [7], $v [8], $v [9], $v [10] ) );
|
|
||||||
break;
|
|
||||||
case 12 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0], $v [1], $v [2], $v [3], $v [4], $v [5], $v [6], $v [7], $v [8], $v [9], $v [10], $v [11] ) );
|
|
||||||
break;
|
|
||||||
case 13 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0], $v [1], $v [2], $v [3], $v [4], $v [5], $v [6], $v [7], $v [8], $v [9], $v [10], $v [11], $v [12] ) );
|
|
||||||
break;
|
|
||||||
case 14 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0], $v [1], $v [2], $v [3], $v [4], $v [5], $v [6], $v [7], $v [8], $v [9], $v [10], $v [11], $v [12], $v [13] ) );
|
|
||||||
break;
|
|
||||||
case 15 :
|
|
||||||
$res = mysqli_query ( $this->h, sprintf ( $q, $v [0], $v [1], $v [2], $v [3], $v [4], $v [5], $v [6], $v [7], $v [8], $v [9], $v [10], $v [11], $v [12], $v [13], $v [14] ) );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//echo 'ERROR:';
|
|
||||||
//var_dump ( mysqli_error_list ( $this->h ) );
|
|
||||||
//echo '<br>';
|
|
||||||
/*
|
|
||||||
* if (! $res || mysqli_errno ( $this->h )) {
|
|
||||||
* return false;
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
public function get($que, $t = '', $p = array ()) {
|
public function get($que, $t = '', $p = array ()) {
|
||||||
// echo $que;
|
// echo $que;
|
||||||
$this->cnt_get ++;
|
$this->cnt_get ++;
|
||||||
@@ -124,23 +33,56 @@ class SQL {
|
|||||||
' ',
|
' ',
|
||||||
''
|
''
|
||||||
), $que ) . "\n" . print_r ( $p, true ) . "\n\n" );
|
), $que ) . "\n" . print_r ( $p, true ) . "\n\n" );
|
||||||
$res = $this->prepare ( $que, $t, $p );
|
$statement = $this->h->prepare ( $que );
|
||||||
//var_dump ( $res );
|
switch (count ( $p )) {
|
||||||
//echo '<hr>';
|
case 0 :
|
||||||
|
break;
|
||||||
|
case 1 :
|
||||||
|
$statement->bind_param ( $t, $p [0] );
|
||||||
|
break;
|
||||||
|
case 2 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1] );
|
||||||
|
break;
|
||||||
|
case 3 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2] );
|
||||||
|
break;
|
||||||
|
case 4 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3] );
|
||||||
|
break;
|
||||||
|
case 5 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4] );
|
||||||
|
break;
|
||||||
|
case 6 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5] );
|
||||||
|
break;
|
||||||
|
case 7 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5], $p [6] );
|
||||||
|
break;
|
||||||
|
case 8 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5], $p [6], $p [7] );
|
||||||
|
break;
|
||||||
|
case 9 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5], $p [6], $p [7], $p [8] );
|
||||||
|
break;
|
||||||
|
case 10 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5], $p [6], $p [7], $p [8], $p [9] );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$statement->execute ();
|
||||||
|
|
||||||
$ret = array ();
|
$ret = array ();
|
||||||
|
|
||||||
// print_r($statement);
|
// print_r($statement);
|
||||||
if (! $res) {
|
if (isset ( $statement->error ) && $statement->error != '') {
|
||||||
if (SQL_LOG)
|
if (SQL_LOG)
|
||||||
fputs ( $this->f, mysqli_error ( $this->h ) );
|
fputs ( $this->f, $statement->error );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
while ( $row = $res->fetch_assoc () ) {
|
$result = $statement->get_result ();
|
||||||
|
// print_r($result);
|
||||||
|
while ( $row = $result->fetch_assoc () ) {
|
||||||
$ret [] = $row;
|
$ret [] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
//var_dump ( $ret );
|
|
||||||
//echo '<hr><hr>';
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
public function single($que, $t = '', $p = array ()) {
|
public function single($que, $t = '', $p = array ()) {
|
||||||
@@ -177,6 +119,7 @@ class SQL {
|
|||||||
public function set($que, $t = '', $p = array (), $id = false) {
|
public function set($que, $t = '', $p = array (), $id = false) {
|
||||||
// echo $que;
|
// echo $que;
|
||||||
$this->cnt_set ++;
|
$this->cnt_set ++;
|
||||||
|
$statement = $this->h->prepare ( $que );
|
||||||
if (SQL_LOG)
|
if (SQL_LOG)
|
||||||
fputs ( $this->f, str_replace ( array (
|
fputs ( $this->f, str_replace ( array (
|
||||||
"\n",
|
"\n",
|
||||||
@@ -185,22 +128,72 @@ class SQL {
|
|||||||
' ',
|
' ',
|
||||||
''
|
''
|
||||||
), $que ) . "\n" . print_r ( $p, true ) . "\n\n" );
|
), $que ) . "\n" . print_r ( $p, true ) . "\n\n" );
|
||||||
$res = $this->prepare ( $que, $t, $p );
|
switch (count ( $p )) {
|
||||||
|
case 0 :
|
||||||
if (! $res) {
|
break;
|
||||||
|
case 1 :
|
||||||
|
$statement->bind_param ( $t, $p [0] );
|
||||||
|
break;
|
||||||
|
case 2 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1] );
|
||||||
|
break;
|
||||||
|
case 3 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2] );
|
||||||
|
break;
|
||||||
|
case 4 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3] );
|
||||||
|
break;
|
||||||
|
case 5 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4] );
|
||||||
|
break;
|
||||||
|
case 6 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5] );
|
||||||
|
break;
|
||||||
|
case 7 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5], $p [6] );
|
||||||
|
break;
|
||||||
|
case 8 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5], $p [6], $p [7] );
|
||||||
|
break;
|
||||||
|
case 9 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5], $p [6], $p [7], $p [8] );
|
||||||
|
break;
|
||||||
|
case 10 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5], $p [6], $p [7], $p [8], $p [9] );
|
||||||
|
break;
|
||||||
|
case 11 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5], $p [6], $p [7], $p [8], $p [9], $p [10] );
|
||||||
|
break;
|
||||||
|
case 12 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5], $p [6], $p [7], $p [8], $p [9], $p [10], $p [11] );
|
||||||
|
break;
|
||||||
|
case 13 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5], $p [6], $p [7], $p [8], $p [9], $p [10], $p [11], $p [12] );
|
||||||
|
break;
|
||||||
|
case 14 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5], $p [6], $p [7], $p [8], $p [9], $p [10], $p [11], $p [12], $p [13] );
|
||||||
|
break;
|
||||||
|
case 15 :
|
||||||
|
$statement->bind_param ( $t, $p [0], $p [1], $p [2], $p [3], $p [4], $p [5], $p [6], $p [7], $p [8], $p [9], $p [10], $p [11], $p [12], $p [13], $p [14] );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$statement->execute ();
|
||||||
|
if (isset ( $statement->error ) && $statement->error != '') {
|
||||||
if (SQL_LOG)
|
if (SQL_LOG)
|
||||||
fputs ( $this->f, mysqli_error ( $this->h ) );
|
fputs ( $this->f, $statement->error );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
return mysqli_insert_id ( $this->h );
|
return $statement->insert_id;
|
||||||
} else {
|
} else {
|
||||||
return ( bool ) mysqli_affected_rows ( $this->h );
|
return $statement->affected_rows;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function __destruct() {
|
function __destruct() {
|
||||||
mysqli_close ( $this->h );
|
if (SQL_LOG)
|
||||||
|
$this->h->close ();
|
||||||
|
// echo 'DESTROY';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ function endsWith($haystack, $needle) {
|
|||||||
return $length === 0 || (substr ( $haystack, - $length ) === $needle);
|
return $length === 0 || (substr ( $haystack, - $length ) === $needle);
|
||||||
}
|
}
|
||||||
function onlyAlpha($str, $zus = '') {
|
function onlyAlpha($str, $zus = '') {
|
||||||
return preg_replace ( "/[^a-zA-Z0-9 \-\{$zus}_]+/", "", $str );
|
return preg_replace ( "/[^a-zA-Z0-9 \-\_{$zus}]+/", "", $str );
|
||||||
}
|
}
|
||||||
function shortener($str, $len = 50, $fill = '...') {
|
function shortener($str, $len = 50, $fill = '...') {
|
||||||
if (strlen ( $str ) > $len) {
|
if (strlen ( $str ) > $len) {
|
||||||
|
|||||||
Reference in New Issue
Block a user