Mine sisusse
Otsi siit
  • Rohkem valikuid...
Otsi tulemusi mis sisaldab...
Otsi tulemusi...

Abi oleks vaja natuke

Soovitatud postitused

Külaline misterx

Mees, sa annad pikast koodist väikse jupi ja loodad, et sul parandatakse see ära, kui sa ei ütle isegi milline error on või mida see koodijupp tegema peaks.

Jaga seda postitust


Postituse link
Share on other sites
Author of the topic Postitas
<?php

if(file_exists("classes/class_ABtest.php"))

include_once( "classes/class_ABtest.php" );

elseif(file_exists("../classes/class_ABtest.php"))

include_once( "../classes/class_ABtest.php" );

 

// lets keep all login tasks in 1 place

class login{

var $user=FALSE;

var $mysql=FALSE;

 

function login($simple=0){

global $mysql, $SETTINGS, $usememcache, $fmmemcache, $fmmemcachetime;;

if (empty($cachetime)) $cachetime=$fmmemcachetime;

$this->mysql=$mysql;

 

// make sure we get proxied ip JIC

if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){

$ip = preg_replace("![^0-9\.\_]!", "", $_SERVER['HTTP_X_FORWARDED_FOR']);

}else{

$ip = preg_replace("![^0-9\.\_]!", "", $_SERVER['REMOTE_ADDR']);

}

 

$ua = md5($_SERVER['HTTP_USER_AGENT']);

$themd5p = $_COOKIE['pmp'];

$themd5 = $_COOKIE['pm'];

 

if ( (isset($_POST['login']) || $_POST[action]=='login') && isset($_POST['username']) && isset($_POST['password'])){

$this->newlogin($simple);

}

 

$query="SELECT * FROM users WHERE password='{$themd5p}' and sessionkey='{$themd5}' and last_ip='{$ip}' and last_useragent='{$ua}'";

$check_login = $this->mysql->fetch( $this->mysql->query( $query ) );

 

if (empty($check_login)){

// lets save the requested path for redirect later

if (!$simple){ // make sure we do not remember the ajax calls

if (empty($_SESSION['REQUEST_URI'])){

$_SESSION['REQUEST_URI']=$_SERVER['REQUEST_URI'];

}

}

return false;

}

 

if ($this->isfrozenbanned($check_login, 1)) return false;

 

if ($usememcache){

$last_active=$fmmemcache->get("{$SETTINGS['iden']}_last_active_{$check_login['id']}");

if (!empty($last_active)){

$check_login['last_active']=$last_active;

}

 

if (!isset($_SESSION['showinactive']) && !isset($_REQUEST['inactive'])){

if (!$simple){

$fmmemcache->set("{$SETTINGS['iden']}_last_active_{$check_login['id']}", time(), false, 15*60); // 15 min, so only 'active' players are in cache...

}

}

}

 

$this->user=$check_login;

 

// make sure players don;t try to work around captchas by logging out...

if (!isset($_SESSION['action_count']) && !empty($check_login['action_count'])){

$_SESSION['action_count'] = $check_login['action_count'];

}

if (empty($_SESSION['imgvar']) && !empty($check_login['captcha'])){

$_SESSION['imgvar']=$check_login['captcha'];

}

 

 

if( $_GET[on] == "logout" ){

$this->logout();

}

 

$pages_to_skip = array("search");

 

 

if (!$simple){

# DIVERSECG

# Added to try to prevent duping, if they are hitting the site faster than 1 second,

# than the time will be the same, so if they are, lets wait up to 2 seconds before

# continuing processing. We will also increment counters for the user to keep track.

#

$pages_to_skip = array("gpanel","train","point_shop","slot_machine","higher_lower");

$actions_to_skip = array("use");

 

$forceUpdate=0;

$hammer_stops_daily=$fmmemcache->get("{$SETTINGS['id']}_hammer_stops_daily_{$check_login['id']}");

if ($hammer_stops_daily === FALSE) $hammer_stops_daily=$check_login['hammer_stops_daily'];

 

if ($hammer_stops_daily == '5000'){

$message="You are hammering the site a bit much. This is a warning too slow down a little. You will get one more warning then a 24 hour freeze.";

$forceUpdate=1;

add_event($message, 'unknown', $check_login['id']);

$curenttime = time();

$this->mysql->query( "insert into hammer_log set user_id =$check_login[id],hammer_stops = '5000', time='$curenttime' ");

}

 

else if ($hammer_stops_daily == '7500'){

$message="This is your second warning. You are hammering the site a bit much. This is a warning to slow down a little. You will be frozen for 24 hours if you keep going as you are.";

$forceUpdate=1;

add_event($message, 'unknown', $check_login['id']);

$curenttime = time();

$this->mysql->query( "insert into hammer_log set user_id =$check_login[id],hammer_stops = '7500', time='$curenttime' ");

}

 

else if ($hammer_stops_daily >= 10000){

$msg='You have clicked to fast to often and the security system has auto froze you for 24 hours. You were warned to slow down.';

unset($data);

$data['hammer_stops_daily']=0;

$data['old_user_level']='user_level';

$data['user_level']=4;

$data['frozen_days']=1;

$data['frozen_reason']=$msg;

$rawvars=array('old_user_level');

$this->update($data,$rawvars);

$curenttime = time();

$this->mysql->query( "insert into hammer_log set user_id =$check_login[id],hammer_stops = '10000', time='$curenttime' ");

header("Location: /index.php");

return;

}

 

if (time()-$check_login['last_active']

$forceUpdate = 1;

}

 

if ( $forceUpdate == 1 ){

if ($usememcache){

$fmmemcache->set("{$SETTINGS['iden']}_hammer_stops_daily_{$check_login['id']}", ++$hammer_stops_daily, false, 15*60); // 15 min, so only 'active' players are in cache...

}else{

unset($data);

$data['hammer_stops']='if(hammer_stops is null,1,hammer_stops+1)';

$data['hammer_stops_daily']='if(hammer_stops_daily is null,1,hammer_stops_daily+1)';

$rawvars=array('hammer_stops','hammer_stops_daily');

$this->update($data,$rawvars);

$check_login['hammer_stops_daily'] = ++$hammer_stops_daily;

}

}

}

 

 

$USER = $check_login;

 

unset($data);

 

if (!isset($_SESSION['showinactive']) && !isset($_REQUEST['inactive'])){

if (!$usememcache){

// DIVERSECG don't need last active down to the second.. 10 seconds will do...

if ($USER['last_active']

$data['last_active'] = time();

}

}else{

// lets update DB every 5 min..

$last_db_update=$fmmemcache->get("{$SETTINGS['iden']}_last_active_db_{$check_login['id']}");

if (intval($last_db_update)

$fmmemcache->set("{$SETTINGS['iden']}_last_active_db_{$check_login['id']}", time(), false, 15*60); // 15 min, so only 'active' players are in cache...

$data['last_active'] = time();

$data['action_count'] = $_SESSION['action_count'];

}

}

}

 

if ($check_login['last_ip'] != $ip){

// we do not want to update these if simple, like ajax call

$data['last_ip'] = $ip;

}

if ($check_login['last_ip2'] != $_SERVER['HTTP_X_FORWARDED_FOR']){

$data['last_ip2'] = $_SERVER['HTTP_X_FORWARDED_FOR'];

}

if (!$simple){

if(count($_POST)) {

$data['last_post_at'] = microtime(1);

$data['last_post_contents'] = md5(serialize($_POST));

}

}

 

// 1000 just to make sure it is a time stamp value and not something else...

if ($USER['hospital'] > 0 && $USER['hospital']

if ($USER['hospital'] > 1000){

$data['hospital']=0;

$data['hp']=$USER['hp_max'];

}else{

// old style, make new

$data['hospital']=strtotime("+{$USER['hospital']} min");

}

$count_hospital = $this->mysql->fetch( $this->mysql->query( "select count(*) from users where hospital > ".time() ) );

$this->mysql->query( "update game_settings set hospital_count = '$count_hospital[0]'" );

$SETTINGS['hospital_count']=$count_hospital;

}

if ($USER['prison'] > 0 && $USER['prison']

if ($USER['prison'] > 1000){

$data['prison']=0;

}else{

// old style, make new

$data['prison']=strtotime("+{$USER['prison']} min");

}

$count_prison = $this->mysql->fetch( $this->mysql->query( "select count(*) from users where prison > ".time() ) );

$this->mysql->query( "update game_settings set prison_count = '$count_prison[0]'" );

$SETTINGS['prison_count']=$count_prison;

}

 

if ($USER['hp'] > $USER['hp_max']){

$data['hp'] = $USER['hp_max'];

}

if ($USER['nerve'] > $USER['nerve_max']){

$data['nerve'] = $USER['nerve_max'];

}

if ($USER['energy'] > $USER['energy_max']){

$data['energy'] = $USER['energy_max'];

}

if ($USER['awake'] > $USER['awake_max']){

$data['awake'] = $USER['awake_max'];

}

 

$rawvars=array('surf_count','money');

if (count($data) > 0) $this->update($data,$rawvars);

}

 

function newlogin(){

// make sure we get proxied ip JIC

if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){

$ip = preg_replace("![^0-9\.\_]!", "", $_SERVER['HTTP_X_FORWARDED_FOR']);

}else{

$ip = preg_replace("![^0-9\.\_]!", "", $_SERVER['REMOTE_ADDR']);

}

 

$login_name=mysql_real_escape_string(strtolower($_POST['username']));

$password=md5($_POST['password']);

$query="SELECT * FROM users WHERE login_name='{$login_name}' AND password='{$password}'";

$check_login = $this->mysql->fetch( $this->mysql->query( $query ) );

 

// if failed, lets see if inactive

if (empty($check_login)){

$query="SELECT * FROM inactive_users WHERE login_name='{$login_name}' AND password='{$password}'";

$inactive_login = $this->mysql->fetch( $this->mysql->query( $query ) );

}

 

if (!empty($inactive_login)){

// inactive database should match active DB,

unset($data);

$query="DESCRIBE users";

$struc = $this->mysql->fetch( $this->mysql->query( $query ) );

// dump($struc);

// exit;

 

}

 

if (empty($check_login)){

$_SESSION['loginmessages']="

Invalid Login

";

return false;

}

 

if ($this->isfrozenbanned($check_login)) return false;

 

$key = "PM" . rand(100000, 999999) . chr(rand(65,90));

 

$expire = ($_POST['rememberme'] == "true" ? time()+(86400*30) : time()+86400);

// If remember me is set keep it alive for 30 days, otherwise just 24 hours.

 

setcookie("pmp", md5($_POST['password']), $expire);

setcookie("pm", $key, $expire);

if ($_POST['rememberme'] == "true"){

setcookie("u", $_POST['username'], $expire);

}else{

setcookie("u", '', time()-3600);

}

 

$this->user=$check_login;

 

unset($data);

$data['last_active']=time();

$data['sessionkey']=$key;

$data['last_ip'] = $ip;

$data['last_useragent']=md5($_SERVER['HTTP_USER_AGENT']);

$this->update($data);

 

if ($_SESSION['ABobj']){

$ABtest = unserialize($_SESSION['ABobj']);

$ABtest->removeABTestEntry();

}

 

if (isset($_POST['ajax'])){

echo 1;

exit;

}

if (!empty($_SESSION['REQUEST_URI'])){

header("Location: {$_SESSION['REQUEST_URI']}");

}else{

header("Location: /");

}

unset($_SESSION['REQUEST_URI']);

exit;

}

 

function isfrozenbanned($check_login,$noipcheck=0){

// $noipcheck is to prevent the extra DB lookup on every page request

 

// make sure we get proxied ip JIC

if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){

$ip = preg_replace("![^0-9\.\_]!", "", $_SERVER['HTTP_X_FORWARDED_FOR']);

}else{

$ip = preg_replace("![^0-9\.\_]!", "", $_SERVER['REMOTE_ADDR']);

}

 

if ($check_login['user_level']==4){

$_SESSION['loginmessages']="

Frozen

";

$_SESSION['loginmessages'].="Your account has been frozen for {$check_login['frozen_days']} days due to breaking rules.

 

";

$_SESSION['loginmessages'].="

Reason:

";

$_SESSION['loginmessages'].=(empty($check_login['frozen_reason']))?'Unknown':$check_login['frozen_reason'];

$_SESSION['loginmessages'].="

 

For additional information, go to our Support Site to file a ticket.

 

";

return true;

}

 

$checkip=array();

if ($noipcheck==0){

if (isset($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])){

$proxied_IP = $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'];

$checkip = $this->mysql->fetch( $this->mysql->query( "select * from banned where user_id='{$check_login['id']}' OR ip = '$ip' or ip = '$proxied_IP'" ) );

}else{

$checkip = $this->mysql->fetch( $this->mysql->query( "select * from banned where user_id='{$check_login['id']}' OR ip = '$ip'" ) );

}

}

 

if ($check_login['user_level']==5){

$_SESSION['loginmessages']="

Banned

";

$_SESSION['loginmessages'].="Your account has been banned due to breaking rules.

 

";

$_SESSION['loginmessages'].="

Reason:

";

$_SESSION['loginmessages'].=($checkip['user_id'] != $check_login['id'] || empty($checkip['reason']))?'Unknown':$checkip['reason'];

$_SESSION['loginmessages'].="

 

For additional information, go to our Support Site to file a ticket.

 

";

return true;

}

 

if ($checkip['ip'] == $ip && !empty($ip)){

$_SESSION['loginmessages']="

Banned IP

";

$_SESSION['loginmessages'].="The IP address you are on has been banned from the website.

 

";

$_SESSION['loginmessages'].="

 

For additional information, go to our Support Site to file a ticket.

 

";

return true;

}

 

return false;

}

 

function logout(){

global $SETTINGS,$fmmemcache,$usememcache;

 

if ($usememcache){

$fmmemcache->delete("{$SETTINGS['iden']}_last_active_{$this->user['id']}");

}

 

$key = "PM";

$key .= mt_rand( 100000, 999999 );

$key .= chr( mt_rand( 65,90) );

unset($data);

$data['last_active'] = time();

$data['sessionkey'] = $key;

// make sure players don;t try to work around captchas by logging out...

$data['action_count'] = $_SESSION['action_count'];

if (!empty($_SESSION['imgvar'])) $data['captcha'] = $_SESSION['imgvar'];

$this->update($data);

session_unset();

session_destroy();

 

header("Location: /");

exit;

}

private function update($data,$rawvars=''){

if (empty($this->user['id'])) return;

if (count($data) == 0) return;

$this->mysql->update('users', $data, "id='{$this->user['id']}'", false, $rawvars, 1);

$noupdate=array('surf_count','money','last_post_at','last_post_contents');

foreach (array_keys($data) as $key){

// lets update all selected user vars with info we just updated to avoid a DB hit

if (!in_array($key,$noupdate)){

$this->user[$key]=$data[$key];

}

}

}

}

?>

loodan et sobib saate äkki aidata mind

Jaga seda postitust


Postituse link
Share on other sites

Veadeade on get() funktsioonis.. nagu on olemas pilt sellest. function get() otsi üles..

 

Veateade: http://vahvel.net/attachment.php?attachmentid=1802&d=1350729856

Te ei näe, et esimeses postituses oli see juba mainitud?!..

 

 

näita seda funktsiooni koodi.. function get() ..

Muudetud liikme paksmatu'i poolt

Jaga seda postitust


Postituse link
Share on other sites

Kommentaari lisamiseks loo konto või logi sisse

Kommenteerimiseks peate olema liige

Loo konto

Liituge meie kommuuni uue kontoga. See on lihtne!

Loo uus konto

Logi sisse

On juba konto? Logi sisse siit.

Logi sisse nüüd

×
×
  • Loo uus...

Oluline informatsioon

Selle veebisaidi paremaks muutmiseks oleme teie seadmesse paigutanud küpsised . Võite kohandada oma küpsiste seadeid , vastasel juhul eeldame, et te olete küpsiste kasutamisega nõus kui jätkate veebisaidil sirvimist.. Palun lugege läbi Kasutustingimused ja Privaatsuspoliitika.