Jump to content

Altec

Members
  • Posts

    91
  • Joined

  • Last visited

    Never

About Altec

  • Birthday 07/01/1993

Contact Methods

  • AIM
    smashingaltoids
  • MSN
    htmlpro@q.com
  • Website URL
    http://www.phreakyourgeek.com/

Profile Information

  • Gender
    Male
  • Location
    Colorado

Altec's Achievements

Member

Member (2/5)

0

Reputation

  1. Don't forget to mark the thread as solved.
  2. You need to use the relative path, not absolute: "./irf_marquee"
  3. Are you talking about a plugboard? http://www.plugboard.org/
  4. I've started redesigning my site and I started working on a more robust (haha) error handler, more so than I usually do. I'm trying to distinguish between the different error levels using switch(). This is what I have: function error_handler($error_lvl,$error_msg,$error_file,$error_line) { switch($error_lvl) { case E_USER_NOTICE: $level = 'Notice'; break; case E_USER_WARNING: $level = 'Warning'; break; case E_USER_ERROR: $level = 'Error'; break; default: $level = 'Unknown: '.$error_lvl; } $date = '['.date('d/m/y H:i P').'] '; $pad = floor((strlen($date) / 2)); $error_msg = preg_replace('/ \[<a.*>\]/i','',$error_msg); $error = $date.$level."\n"; $error .= str_repeat(' ',$pad).wordwrap('Message: '.$error_msg,75,"\n".str_repeat(' ',$pad+9))."\n"; $error .= str_repeat(' ',$pad).wordwrap('File: '.$error_file,75,"\n".str_repeat(' ',$pad+6))."\n"; $error .= str_repeat(' ',$pad).wordwrap('Line: '.$error_line,75,"\n".str_repeat(' ',$pad+6))."\n\n"; echo '<div class="fatal_error">Uh Oh! Something terrible has happened! We\'ve dispatched our in-house monkey to take a look at things.</div></body></html>'; @file_put_contents('../pyg.log.txt',$error,FILE_APPEND); exit; } I'm initiating the error like so: $db_handle = @mysql_connect('localhost','root','notmypassword'); if( !$db_handle ) { trigger_error('MySQL: '.mysql_error(),E_USER_ERROR); } Obviously I'm passing a bad password to mysql_connect. Anyway, I trigger the error at E_USER_ERROR which should return a value of 256 (caught by case E_USER_ERROR) but instead returns E_ERROR (integer value 2), as shown in the log: [28/02/10 03:28 -06:00] Unknown: 2 Message: mysql_connect(): Access denied for user 'root'@'localhost' (using password: YES) File: /home/root/public_html/projects/inc/init.php Line: 5 Custom error handlers should NOT handle E_ERROR level errors as they are initiated before script execution: What's going on? Is it a problem with my PHP configuration?
  5. Actually, I started MyBB development a while after that post and the development standards drastically changed my personal style. The actual MyBB code is actually pretty clean, although a majority of it goes against their own development standards.
  6. Use a hook system. Have a class that is called in key areas of the script execution that runs "hooked" functions. For example, you could do: $plugins->hook('hook_name','function_name'); And have something like: $plugins->run('hook_name');
  7. Thanks. I hope people don't kill me too much.
  8. haha, from what I remember it wasn't anything special; just experimentation. I'll hit up the archives of the forum I was on at that time and see if I can find what the hell I was doing. haha, I'll be sure to tailor my practices just for you. Thanks everyone!
  9. A torrent file is not plain text, it's in a special format. I think there is a PHP class to parse them but I can't remember the name of it. Also, just a quick FYI, seeders and leachers are not listed in the torrent file. It simply holds a session hash that the torrent client sends to the tracker. The tracker is what responds to the torrent client with the seeders and leachers list.
  10. I found this short article on the subject: http://ditio.net/2008/09/07/detecting-search-engine-bots-with-php/ Obviously you'll need to do some research on which bots use what names, but the premise is the same. EDIT: Looks like Cardale hit the jackpot.
  11. Google is your friend. http://www.toosweettobesour.com/2009/03/10/calculating-daylight-savings-time-boundary-in-php/
  12. Hello everyone, I've never formally introduced myself, and what with this new style and all I figured I'd take the opportunity and say hello. I've been a forum stalker for a while now and have only posted when my other communities draw a blank. First, my name is Steven. I'm a 16 year old self-taught web developer from Colorado, USA. I have 5 years with (X)HTML and CSS, and almost 5 with PHP. I never really succeed at getting a decent site up and maintaining it, so I generally let my server sit around and do nothing but store random files for me. I've most recently become addicted to MyBB development, and I've been wasting a fair amount of hours developing plugins and other random stuff for it. I have OCD and will probably rewrite your code if you have horrendous code practices, even if I have nothing to contribute. I'm a pretty big Grammar Nazi as well. I hope I'll fit in somewhere here. With all due respect, Steven
  13. I'm having a bit of bad luck with sessions. In the past they have worked fine for me, but this time around I'm having terrible luck. Basically, I made the crappiest login system ever. I'm using sessions to store three bits of information: 1) metadata which consists of the username, password, and salt; 2) database row id; 3) username. Here is my code to login/out the user: <?php /** * Copyright 2009 Steven */ session_start(); session_regenerate_id(); define('IN_VOCAB',true); require('init.php'); // Get POST values foreach( $_POST as $key => $value ) { $$key = clean($value,true); } switch( $_SERVER['QUERY_STRING'] ) { case 'login': // MD5 password $password = md5($password); // Validate user exists $user_val_query = $db->query("SELECT * FROM `users` WHERE `username`='{$username}' AND `password`='{$password}' LIMIT 1"); if( mysql_num_rows($user_val_query) > 0 ) { // User exists; set sessions $salt = substr(md5(date('F')),; $user = mysql_fetch_assoc($user_val_query); $_SESSION['steven_vocab.user.meta'] = $username.$password.$salt; $_SESSION['steven_vocab.user.id'] = $user['id']; $_SESSION['steven_vocab.user.name'] = $user['username']; // Logged in echo message('You have been successfully logged in as '.$username.'!','success'); echo '<a href="',$site_url,'">Go to main site</a>.'; show('footer.php'); } else { fatal_error('Incorrect username and/or password. <a href="'.$site_url.'">Please try again</a>.'); } break; case 'logout': // Make sure user is logged in require($sys_inc_path.'user_check.php'); // Unset session vars unset($_SESSION['steven_vocab.user.meta'],$_SESSION['steven_vocab.user.id'],$_SESSION['steven_vocab.user.name']); echo message('You have been successfully logged out.','success'); echo '<a href="',$site_url,'">Go to main site</a>.'; show('footer.php'); break; default: fatal_error('Invalid request.'); } ?> And here is my code to check and validate the user: <?php /** * Copyright 2009 Steven */ if( !defined('IN_VOCAB') ) { echo 'Direct access to this file is not allowed.'; exit; } // Check for session if( !isset($_SESSION['steven_vocab.user.meta']) || !isset($_SESSION['steven_vocab.user.id']) || !isset($_SESSION['steven_vocab.user.name']) ) { show('login_form.html',null,true); } // Session exists; validate $salt = substr(md5(date('F')),; $id = $_SESSION['steven_vocab.user.id']; $meta = $_SESSION['steven_vocab.user.meta']; $user_info_query = $db->query("SELECT * FROM `users` WHERE `id`='{$id}' LIMIT 1"); if( mysql_num_rows($user_info_query) > 0 ) { // User exists, check username and password $user = mysql_fetch_assoc($user_info_query); if( ($user['username'].$user['password'].$salt) != $meta ) { // User invalid; unset session and exit unset($_SESSION['steven_vocab.user.meta'],$_SESSION['steven_vocab.user.id'],$_SESSION['steven_vocab.user.name']); fatal_error('Invalid session metadata. <a href="'.$site_url.'">Please login again</a>.'); } } else { // User invalid; unset session and exit unset($_SESSION['steven_vocab.user.meta'],$_SESSION['steven_vocab.user.id'],$_SESSION['steven_vocab.user.name']); fatal_error('User cannot be found. <a href="'.$site_url.'">Please login again</a>.'); } // The user is logged in and validated; check IP address $user_ip = $_SERVER['REMOTE_ADDR']; $check_ip_query = $db->query("SELECT `ip` FROM `users` WHERE `id`='{$user['id']}' LIMIT 1"); if( mysql_num_rows($check_ip_query) > 0 ) { $stored_ip = mysql_result($check_ip_query,0,'ip'); // Check if empty if( empty($stored_ip) ) { // Update IP $ip_update_query = $db->query("UPDATE `users` SET `ip`='{$user_ip}' WHERE `id`='{$user['id']}' LIMIT 1"); } else { // Check if current IP is same if( $stored_ip != $user_ip ) { // Send me a text and log it $ip_log_data = time().' - Username "'.$user['username'].'" accessed site from IP "'.$user_ip.'" while stored IP is "'.$stored_ip.'" : ID'.$user['id']; file_put_contents($sys_inc_path_admin.'ip_log.txt',$ip_log_data."\n\n",FILE_APPEND); @mail('5555555555@vtext.com','IP Confliction: Vocab',$ip_log_data); } } } // Output info $username = $_SESSION['steven_vocab.user.name']; echo '<div id="user_meta">Welcome back, ',$username,'!<br />» <a href="',$site_url,'user.php?logout">Logout</a> «</div>'; ?> When I log in, everything runs smoothly and it works perfectly. I can log in as anyone and I always have the proper access level, etc. However, when anyone else tries to log in, he or she gets the Invalid metadata message (check code). I've been swapping code in and out all day and nothing seems to fix their problems, except it works fine for me. Can anyone see anything blatantly obvious in the above code?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.