Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbusername="aaa";
- $dbpassword="aaa";
- $database="aaa";
- try {
- $dbh = new PDO('mysql:host=localhost;dbname=aaa', $dbusername, $dbpassword);
- } catch (PDOException $e) {
- echo "connection failed: " . $e->getMessage();
- }
- function log_event($data, $dbh) {
- $log = $dbh->prepare("INSERT INTO events (uid1, uid2, type) VALUES (?, ?, ?)");
- $log->execute($data);
- }
- function isSetAndNonZero ($arg) {
- if (isset($arg) and is_numeric($arg) and $arg != 0) {
- return true;
- } else {
- return false;
- }
- }
- function verifyGroup($dbh, $uid) {
- $g = $dbh->prepare("SELECT * FROM users WHERE uid = :uid LIMIT 1");
- $g->bindParam(':uid', $uid, PDO::PARAM_STR);
- if ($g->execute()) {
- $udata = $g->fetch();
- $_SESSION['usergroup'] = $udata['usergroup'];
- } else { echo "error"; }
- }
- function getRealIpAddr()
- {
- if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
- {
- $ip=$_SERVER['HTTP_CLIENT_IP'];
- }
- elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
- {
- $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
- }
- else
- {
- $ip=$_SERVER['REMOTE_ADDR'];
- }
- return $ip;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement