Jump to content

cherri8

Members
  • Posts

    43
  • Joined

  • Last visited

Posts posted by cherri8

  1. hi when i get postbacks from the outside like mediumpath which is an offerwall, my database doesnt update or select member's info. i didnt use the exact postback below but it's the same idea. it's an example from that site.

    if(!empty($_POST)){
    	
    	define('EvolutionScript', 1);
    	define('ROOTPATH',dirname(__FILE__).'/');
    	define('INCLUDES',ROOTPATH.'includes/');
    	require(INCLUDES.'core.php');
    	require_once INCLUDES.'global.php';
    
    	$user_id = isset($_POST['user_id']) ? $_POST['user_id'] : null;
    	$transId = isset($_POST['transId']) ? $_POST['transId'] : null;
    	$reward = isset($_POST['reward']) ? $_POST['reward'] : null;
    	$currency = isset($_POST['currency']) ? $_POST['currency'] : null;
    	$signature = isset($_POST['signature']) ? $_POST['signature'] : null;
    	$status = isset($_POST['status']) ? $_POST['status'] : null;
    	$userIp = isset($_POST['userIp']) ? $_POST['userIp'] : null;
    	$campaign_id = isset($_POST['campaign_id']) ? $_POST['campaign_id'] : null;
    	$country = isset($_POST['country']) ? $_POST['country'] : null;
    
    	$secret = "[YOUR_WEBSITE/APP_SECRET_KEY]"; // check your app info at www.mediumpath.com
    
    	$user_id = isset($_POST['user_id']) ? $_POST['user_id'] : null;
    	$transId = isset($_POST['transId']) ? $_POST['transId'] : null;
    	$reward = isset($_POST['reward']) ? $_POST['reward'] : null;
    	$signature = isset($_POST['signature']) ? $_POST['signature'] : null;
    
    	if(md5($user_id.$transId.$reward.$secret) != $signature){
    		print_r($_POST);
    		exit;
    	}else{
    		$insert = array(
    						'user_id' => $user_id,
    						'transId' => $transId,
    						'reward' => $reward,
    						'currency' => $currency,
    						'signature' => $signature,
    						'status' => $status,
    						'userIp' => $userIp,
    						'campaign_id' => $campaign_id,
    						'country' => $country,
    						);
    		$insertdb = $db->insert("mediumpathipn", $insert);
    		$orderid = $db->lastInsertId();
    
    		$user_info = $db->fetchRow("SELECT * FROM members WHERE id={$user_id}");
    		if(!empty($user_info)){
    			$set = array(
    						'money' => $user_info['money']+$reward,
    						);
    			$upd = $db->update("members", $set, "id = {$user_id}");
    		}
    	}
    }else{
    echo "ERROR: No key founds";
    exit;
    }

     

  2. I was just trying to tell you that if there were more questions in the part that I didn't understand that you should rephrase them. The part I didn't understand looked like superfluous information about the first question.
    HI During my third comment I understood what you meant by that.I should have been more clear.Both you and Don E answer all my questions perfectly.You all help me allot.Thanks
  3. Well I'm sorry. If it will help I'll avoid trying to help you in the future.
    Ok.Thanks It is alright if I don't receive your help anymore :).Im fine if others will do the same.For my last comment I wasnt saying that people who use wth or wtf are being rude or offensive but It only depends on how those statements are used and in what situation. If I explain further I might confuse you.I usually get made fun of about the way I write on the net.Good bye and thanks allot for your help. Sorry if you think I offended you.
  4. WTH = what the heck, I didn't understand the rest of your post except the part about the if/elseif/else.
    I already know what wth means but i didnt know if you were trying to be rude to me.Wth or wtf is suppose to be offensive statements but i guess everyone doesn't know so nevermind.
  5. The number of if/elseif/else nests shouldn't be a problem. I didn't understand WTH the rest of your question was about, maybe I missed the prequel.
    Thanks but I don't know why the bold part was even necessary since I get that.you don't understand anything I wrote.It is hard to tell if you are trying to offend me?........
  6. hi, I have a question about the code below which has always been on my mind.Is there a limit to how many times I use the elseif(condition) ?.the site only mentions that several blocks of code can be executed but i don't know the amount of code that can't be used.first i'll use the if statement to check if user inputs are empty and in the else statement it would contain more condition statements: in the if(condition) and elseif(condition) i will validate(for these conditions it would show true that there has been an error like for example: the users didn't use a proper email address) user inputs and in the else im plan to put user input in database( since the other conditions aren't true it would be safe to enter user data in database).thanks if (condition){code to be executed if condition is true;}elseif (condition){code to be executed if condition is true;}else{code to be executed if condition is false;}

  7. session_set_save_handler() makes session safer when it stores data in database. in shared host the session data is stored in flat files usualy. and all of user/ other sites hosted on that server use same sources. so it is not safer that if that one is compromised your session data will be compromised. saving in db will make it more secure. but that does not makes secure from stealing session id from any user as justsomeguy already stated. you dont have to use session_regenerate_id() unless you want to regenrate id explicitly. when you star a session it checks that any of session cookie or propogated session id is there are not. if its there it resumes to it else it genrate new one. if you want to check against ip and user agent you have to store it in database. there is callback for reading session data in session_set_save_handler() in that function you have to check the ip an user agent and session id combo. when it matches make the data read. same with write callback. you should check the link jsg posted to get the idea. when you use to check integrety of session using $_SESSION['PREV_REMOTEADDR'] here it already read the data from the current activated session. you have to do the checking before it read. that is what for session_set_save_handler() for. it let you customize session behaviour
    Thanks you all. Thanks Birbal :I wanted to make my own codes for session_set_save_handler() when I use it to understand it more instead of using the ones that are already made on the net. I notice that most people only use mysql_real_escape_string in handler which wouldn't be enough to filter stuff. It would be more work for me to think of which filters to use for every session data which is one of the reasons why I wanted to use session_set_save_handler() later because im in a rush to finish site for important reasons lol. I already know that I have to use this to filter session id: if ((preg_match('/[^a-zA-Z0-9-,]/i', $sessid ))!==TRUE). If I don't use the handler I did plan to make a mysql query at the login page to put the session id+user agent in database.After i will get ip from database that was put there during signup than put session id+user agent+ip in session at login page.yah it sounds like allot of work my way and confusing too lol.It seems that with session_set_save_handler() I don't have to do a mysql query every time to put session data in database.
  8. Checking like that and regenerating the ID wouldn't necessarily protect the session. If someone gets a session ID from someone else and puts it in a cookie, the server will look that up and find all of the correct data in the session. If you want to make sure people don't steal other sessions then you should store unique values like the user's IP address and user agent string and compare those each time to make sure they match for the same session. That's still not perfect, but people would at least need to be on the same IP and have the same user agent string in order to steal it.
    Thanks.So far i already have $_SESSION['ipcheck'] = true;(when ip is already found in database) and $_SESSION['logincheck'] = true;(when password and username is found in database).I'll use this code below that i found on wiki that has user agent.ill change up some stuff in code.The user agent stuff is new to me s i had to google it.if (strpos($_SERVER['HTTP_REFERER'], 'https://DiD/') !== 0 || isset($_GET['LOGOUT']) || $_SERVER['REMOTE_ADDR'] !== $_SESSION['PREV_REMOTEADDR'] || $_SERVER['HTTP_USER_AGENT'] !== $_SESSION['PREV_USERAGENT']) session_destroy(); session_regenerate_id(); // generate a new session identifier $_SESSION['PREV_USERAGENT'] = $_SERVER['HTTP_USER_AGENT'];$_SESSION['PREV_REMOTEADDR'] = $_SERVER['REMOTE_ADDR'];
  9. If you're talking about the session save handler, you can use that to store your session data in a database or somewhere else instead of the default file handling for sessions. There are some examples here that use classes to handle the session functions: http://www.php.net/m...ave-handler.php I'm not sure how regenerating the ID relates to using a custom session handler. You don't need to use a custom handler, you would only do that if you want to use a way to save sessions other than the defaults. It depends where the log is, if it's the system log then it's fine, otherwise it's preferable to use an error log that is not publicly accessible. I prefer to always write errors to a log file, regardless of who is accessing it. Error logging is especially important for ajax development where you may not even see the output of the script. error_reporting(E_ALL);ini_set('error_log', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'error.log');ini_set('html_errors', 0);ini_set('log_errors', 1);ini_set('display_errors', 0); That will set PHP to report all errors in a file called error.log in the same directory as the script. Like I said, it's preferable to save the error log in a location that people can't open it from a browser.
    Thanks for help :Happy: . I thought that the session set safe handler was also use to prevent people's session ID from being stolen. I'll only use the session regenerate Id and not the session set safe handler. I'll just use the defaults. If I put error in files ,I'll store them in the private directory on server that is above the public directorys.
  10. Hi, Session set safe handing is abit confusing for me to use now even though i can get the codes on the net.I will not be able to store sessions in database without the session set safe handler.if I always change session id when users login than i shouldnt have to use session set safe handler? is this code alone good enough to use to change id? .i got the code from wikipedia : //accept only SIDs generated on my serverif (!isset($_SESSION['SERVER_GENERATED_SID'])) { session_destroy(); // destroy all data in session}session_regenerate_id(); // new sid$_SESSION['SERVER_GENERATED_SID'] = true; Are errors safe in the error log on server? and is this code that i got at php.net good enough to use for error logging? my purpose is to not display errors to people. /* 00.00.00.00 is replace with the site owner ip address.*/// Report all PHP errorserror_reporting(-1);if($_SERVER['REMOTE_ADDR']=="00.00.00.00"){ini_set('display_errors','On');}else{ini_set('display_errors','Off');}

  11. Very nice color combo.I like the navigation bar ,it is something i dont really see on websites.In the box called slide one i was expecting to see pics but i guess you plan to put them in later.in my opinion i wouldnt have put contact form with address on the home page but instead interesting info about company and etc.

×
×
  • Create New...