Newer
Older
// Komprimierung der Ausgabe zwischen 0 & 10 wobei 0 die Komprimierung der Ausgabe deaktiviert Empfohlener Wert: 1
$gzip_rate = 0;
/**
* create_code()
*
* @author designerscripte.net
* @category system
* @version 2.5.0
* @example create_code(32);
* @param mixed $code_laenge Gewünschte stringlänge
* @return DECIMALE z.b. 6565556
*/
function create_code($code_laenge) {
srand((double)microtime() * 1000000);
$created_code = '';
$zeichen = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
for ($i = 0;$i < $code_laenge;$i++) {
$n = rand() % strlen($zeichen);
$created_code .= substr($zeichen, $n, 1);
}
return $created_code;
}
/**
* kontobuchung()
*
* @author designerscripte.net
* @category system user
* @version 2.5.0
* @example kontobuchung('+',100000,10);
* @param mixed $art '+' oder '-'
* @param mixed $trans_menge Numerischer wert
* @param int $fuer Userid
* @return keine
*/
function kontobuchung ($art, $trans_menge, $buchungs_id, $fuer, $verwendung) {
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
global $db_prefix,$sql_open;
$buchung = db_query("UPDATE " . $db_prefix . "_kontodaten SET `kontostand` = `kontostand` " . mysqli_real_escape_string($sql_open,$art) . " " . mysqli_real_escape_string($sql_open,$trans_menge) . " WHERE uid=" . mysqli_real_escape_string($sql_open,$fuer) . "");
if($buchung == true){
$buchung_ok = 1;
}else{
$buchung_ok = 2;
}
db_query("INSERT INTO " . $db_prefix . "_buchungen (uid,buchungszeit,buchungs_id,buchungsmenge,verwendungszweck,buchung_ok) VALUES (" . mysqli_real_escape_string($sql_open,$fuer) . "," . time() . ",'" . mysqli_real_escape_string($sql_open,$buchungs_id) . "','" . mysqli_real_escape_string($sql_open,$art.$trans_menge) . "','" . mysqli_real_escape_string($sql_open,$verwendung) . "', '". $buchung_ok ."' )");
}
/**
* userstatus()
*
* @author designerscripte.net
* @category system
* @version 2.5.0
* @example userstatus();
* @return Leitet bei keinem zugriff auf die entsprechenden fehlerseiten weiter
*/
function userstatus () {
global $_SESSION, $db_prefix;
if ($_SESSION['login'] == 'true') {
$us = db_query("SELECT `uid`,`passwort`,`status`,`hinweis` FROM " . $db_prefix . "_kontodaten WHERE uid=" . $_SESSION['uid'] . " and passwort='" . $_SESSION['passwort'] . "' LIMIT 1");
$login_check = mysqli_fetch_array($us);
// nicht aktiviert oder nicht angemeldet!
if (!mysqli_num_rows($us) or $login_check['status'] == 0) {
setCookie('uid', '', time() - 86400 * 30);
setCookie('passwort', '', time() - 86400 * 30);
setCookie('autologin', '', time() - 86400 * 30);
$_SESSION['uid'] = "";
$_SESSION['passwort'] = "";
$_SESSION['login'] = "";
@include_once('content/error/kein_zutritt.php');
@include_once('lib/footer.php');
die();
}
// gesperrt
if ($login_check['status'] == 2) {
setCookie('uid', '', time() - 86400 * 30);
setCookie('passwort', '', time() - 86400 * 30);
setCookie('autologin', '', time() - 86400 * 30);
$_SESSION['uid'] = "";
$_SESSION['passwort'] = "";
$_SESSION['login'] = "";
@include_once('content/error/user_gesperrt.php');
@include_once('lib/footer.php');
die();
}
}else {
@include_once('content/error/kein_zutritt.php');
@include_once('lib/footer.php');
die();
}
}
/**
* refumsatz()
*
* @author designerscripte.net
* @category system user
* @version 2.5.0
* @example refumsatz(100000,10);
* @param mixed $buchungssumme transaktionssumme
* @param unt $fuer Userid
* @return keine
*/
function refumsatz ($buchungssumme, $fuer) {
global $db_prefix;
db_query ('UPDATE ' . $db_prefix . '_werberdaten SET umsatz = umsatz + ' . $buchungssumme . ', aktivzeit=' . time() . ' WHERE uid = ' . $fuer . ' and werber != 0');
}
/**
* rallysystem()
*
* @author designerscripte.net
* @category system rally
* @version 2.5.0
* @example rallysystem(10,1,10000);
* @param int $uid userid
* @param int $was rallynummer (1 für forcedbanner z.b.)
* @param mixed $anzahl wert Numerischer string
* @return keine
*/
function rallysystem ($uid,$was,$anzahl) {
global $time;
db_query("UPDATE vms_kontodaten SET eintap = eintap + ".$anzahl."/100 WHERE uid= ".$uid." LIMIT 1");
$rallyorte=mysqli_fetch_array(db_query("SELECT welche_rallys FROM vms_rallyorte WHERE id = '".$was."' LIMIT 1"));
$rally = db_query("SELECT * FROM `vms_rallydaten` WHERE `id` IN (".$rallyorte['welche_rallys'].") AND `status` = 'aktive' AND `start` <= UNIX_TIMESTAMP() AND ((`ende_art` = 'zeit' AND `ende_zeit` > UNIX_TIMESTAMP()) OR (`ende_art` = 'punkt' AND `ende_punkte` > `ende_punkte_aktuell`)) ");
while($rallys = mysqli_fetch_array($rally)){
$gesperrt = explode(',',$rallys['sperruser']);
if (!in_array($uid, $gesperrt)) {
$anzahl2 = $anzahl.$rallys['ende_punkte_anzahl'];
eval("\$anzahl2 = $anzahl2;");
$steigerung = $anzahl.$rallys['gewinn_dyn_steigerung'];
eval("\$steigerung = $steigerung;");
if ($rallys['gewinn_art'] == 'dynamisch') db_query ("UPDATE vms_rallydaten SET gewinn_topf=gewinn_topf+'".$steigerung."' WHERE id = '".$rallys['id']."' LIMIT 1");
if ($rallys['ende_art'] == 'punkt') db_query ("UPDATE vms_rallydaten SET ende_punkte_aktuell = ende_punkte_aktuell + '".$anzahl2."' WHERE id = ".$rallys['id']." LIMIT 1");
db_query ("UPDATE vms_rallyuser SET punkte = punkte + '".$anzahl2."' WHERE uid = '".$_SESSION['uid']."' AND rally = '".$rallys['name']."' AND ausgezahlt < '1'");
if (mysqli_affected_rows () == 0) db_query ("INSERT INTO vms_rallyuser (rally,uid,punkte) VALUES ('".$rallys['name']."','".$uid."','".$anzahl2."')");
}
}
}
/**
* bilanz()
*
* @param number $gruppe Die Gruppe in die die Bilanz fallen soll
* @param number $was Der Name der in der Gruppe angezeigt werden soll
if(empty($ein)){ $ein = 0;}
if(empty($aus)){ $aus = 0;}
$datum = mktime(0,0,0,date("m",time()),date("d",time()),date("Y",time()));
$ab = db_query("SELECT id FROM ". $db_prefix ."_bilanz WHERE datum = '". $datum ."' AND name = '". $name ."' ");
if(mysqli_num_rows($ab) == 0){
db_query("INSERT INTO ". $db_prefix ."_bilanz (ein,aus,datum,gruppe,name) VALUES ('". $ein ."', '". $aus ."', '". $datum ."', '". $gruppe ."', '". $name ."') ");
}else{
$id = mysqli_fetch_array($ab);
db_query("UPDATE ". $db_prefix ."_bilanz SET aus = aus+". $aus .", ein = ein+". $ein ." WHERE id = '". $id['id'] ."' ");
}
echo mysqli_error($sql_open);
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
}
// GZip
if ($gzip_rate > 0) {
ini_set('zlib.output_compression_level', $gzip_rate);
if (ereg("gzip", getenv("HTTP_ACCEPT_ENCODING"))) ob_start("ob_gzhandler");
else ob_start();
}
// Datum im Facebook Stil
function niceDate($timestamp)
{
$difference = time() - $timestamp;
$periods = array("Sekunde",
"Minute",
"Stunde",
"Tage",
"Woche",
"Monate",
"Jahre",
"Jahrzehnte"
);
$lengths = array("60","60","24","7","4.35","12","10");
if ($difference > 0) {
// Vergangenheit
$ending = "vor";
} else {
// Zukunft
$difference = -$difference;
$ending = "noch"; }
for($j = 0; $difference >= $lengths[$j]; $j++) {
$difference /= $lengths[$j];
$difference = round($difference); }
if($difference != 1) {
$periods[$j].= "n"; }
else {
if($periods[$j] == "Woche" || $periods[$j] == "Stunde" || $periods[$j] == "Minute" || $periods[$j] == "Sekunde") {
$periods[$j] = $periods[$j];
} else {
$periods[$j] = substr($periods[$j], 0, -1); }
}
$date= "$ending $difference $periods[$j]";
return $date;
}
//Text kürzen
function shortText($string,$lenght) {
if(strlen($string) > $lenght) {
$string = substr($string,0,$lenght)."...";
$string_ende = strrchr($string, " ");
$string = str_replace($string_ende," ", $string);
}
return $string;
}
//Alter berechnen
function ageCalculator( $day, $month, $year ) {
if ( !checkdate($month, $day, $year) )
return false;
$cur_day = date("d");
$cur_month = date("m");
$cur_year = date("Y");
$calc_year = $cur_year - $year;
if( $month > $cur_month )
return $calc_year - 1;
elseif ( $month == $cur_month && $day > $cur_day )
return $calc_year - 1;
else
return $calc_year;
}
function sonderzeichen($text){
if(preg_match('#[!"§$%&/()=?`\']#', $text)){
$err = true;
}else{
$err = false;
}
return $err;
}
function check_email($email) {
if(!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
return false;
}
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if(!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if(!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
$domain_array = explode(".", $email_array[1]);
if(sizeof($domain_array) < 2) {
return false;
}
for($i = 0; $i < sizeof($domain_array); $i++) {
if(!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}
function geoIP($ip){
$output = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=".$ip,"r"));
return $output['geoplugin_countryCode'];
}
function versch($text){
global $ver_schluessel;
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$crypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $ver_schluessel, $text, MCRYPT_MODE_ECB, $iv);
return $crypted;
}
function entsch($text){
global $ver_schluessel;
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$encrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $ver_schluessel, $text, MCRYPT_MODE_ECB, $iv);
return $encrypted;
}
function meldung($error,$meldung){
$meldung = array("error" => $error, "meldung" => $meldung);
return $meldung;
}
function navigationsLeiste($SitesComplete,$seiteAktuell,$extVariables,$art,$link){
$string = '';
$NavCeil = floor(NAV_LEISTE / 2);
if($seiteAktuell > 1){
$string .= '<a class="btn btn-default" href="'. $link .'&'.$art.'=1'.$extVariables.'"><<</a> ';
$string .= '<a class="btn btn-default" href="'. $link .'&'.$art.'='.($seiteAktuell-1).$extVariables.'">
<</a> ';
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
for($x=$seiteAktuell-$NavCeil;$x<=$seiteAktuell+$NavCeil;$x++){
// Alle Seitenzahlen vor und nach der aktuellen Seite verlinken
if(($x>0 && $x<$seiteAktuell) || ($x>$seiteAktuell && $x<=$SitesComplete))
$string .= '<a class="btn btn-default" href="'. $link .'&'.$art.'='.$x.$extVariables.'">'.$x.'</a> ';
if($x==$seiteAktuell)
$string .= '<a class="btn btn-default" disabled>'.$x . '</a>';
}
if($seiteAktuell < $SitesComplete){
$string .= '<a class="btn btn-default" href="'. $link .'&'.$art.'='.($seiteAktuell+1).$extVariables.'">>
</a> ';
$string .= '<a class="btn btn-default" href="'. $link .'&'.$art.'='.$SitesComplete.$extVariables.'">>>
</a> ';
}
return $string;
}
function userinfo($uid){
global $db_prefix;
if(!is_numeric($uid)){ $uid = 0;}
$user = mysqli_fetch_array(db_query("
SELECT
".$db_prefix."_userdaten.*,
".$db_prefix."_kontodaten.*,
".$db_prefix."_werberdaten.*,
".$db_prefix."_nickpage.*
FROM ".$db_prefix."_userdaten
LEFT JOIN ".$db_prefix."_kontodaten ON(".$db_prefix."_userdaten.uid = ".$db_prefix."_kontodaten.uid)
LEFT JOIN ".$db_prefix."_werberdaten ON(".$db_prefix."_kontodaten.uid = ".$db_prefix."_werberdaten.uid)
LEFT JOIN ".$db_prefix."_nickpage ON(".$db_prefix."_werberdaten.uid = ".$db_prefix."_nickpage.uid)
WHERE ".$db_prefix."_userdaten.uid= ".$uid.";"));
return $user;
}