Jump to content

ionik

Members
  • Posts

    187
  • Joined

  • Last visited

Posts posted by ionik

  1. fiqured out the problem.....seems to be a bug with MySQL....

    if you try to get the value of a table where its name is the same as what your looking for will result in an error...?

    hence

    username = "username" results in an error

    but

    username = "name" works fine....strange

  2. $sql = 'SELECT userid FROM '.USER_TABLE.' WHERE password = "'.$encrypted_pass.'" AND username = "'.$username.'"';
    
    // SELECT userid FROM users WHERE password = "md5" AND username = "UserName"
    
    // that the sql that is shown when the script is run 
    
    if( $db->query($sql) )
    

     

    for some reason i keep getting the error

     

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

     

    if i take out AND username = "'.$username.'"

     

    it will work...but if i take out

     

    password = "'.$encrypted_pass.'" AND

     

    get that error again cant fiqure this one out....

  3. Ok why doesnt the file upload? It doesnt give any errors execpt the die_message error at the end and i cant fiqure out the problem heres the function,

    all the constants are defined when the script is run and the AVATAR_UPLOAD_DIR = 'includes/uploads/avatars/' and i've made it so when the file is uploaded it will be given a random name from my session_id_create() function so names will be d0951a6f.gif ETC, this is ran on my localhost server on my pc....so permissions is not the problem and if i use my test file and simply use move_uploaded_file() it works....

     

    function upload_profile_image($name, $type)
    {
    global $db,$udata;
    if(!$_POST['form'])
    {
    	die_message(USER_MESSAGE, 'Unauthorized');
    }
    if(empty($_FILES))
    {
    	die_message(USER_MESSAGE, 'No file was selected to upload');
    }
    // Information about uploading file
    $info = getimagesize($_FILES[$name]['tmp_name']);
    
    $allowed_ext_array = explode(',', ALLOWED_IMAGE_TYPES);
    
    foreach($allowed_ext_array as $allowed_ext)
    {
    	$strlen = strlen($allowed_ext) - 6;
    	$names .= ' '.substr($allowed_ext, '6', $strlen);
    }
    
    if(!in_array($_FILES[$name]['type'], $allowed_ext_array))
    {
    	die_message(USER_MESSAGE, 'Sorry, you are only allowed to upload '.$names.' file types');
    }
    
    $max_size = iif($type == 'avatar', ALLOWED_AVATAR_SIZE, ALLOWED_PICTURE_SIZE);
    $max_width = iif($type == 'avatar', MAX_AVATAR_WIDTH, MAX_PICTURE_WIDTH);
    $max_height = iif($type == 'avatar', MAX_AVATAR_HEIGHT, MAX_PICTURE_HEIGHT);
    $upload_dir = iif($type == 'avatar', AVATAR_UPLOAD_DIR, PICTURES_UPLOAD_DIR);
    
    
    if($info[0] > $max_width)
    {
    	die_message(USER_MESSAGE, 'Sorry avatars are only allowed a maximum width of '.$max_width);
    }
    
    if($info[1] > $max_height)
    {
    	die_message(USER_MESSAGE, 'Sorry avatars are only allowed a maximum height of '.$max_height);
    }
    
    if($_FILES[$name]['size'] > $max_size)
    {
    	$size = $max_size * 100;
    	die_message(USER_MESSAGE, 'Sorry avatars are only allowed a maximum size of '.$size.' kb');
    }
    
    $file_type = substr($_FILES[$name]['type'], 6, strlen($_FILES[$name]['type']) - 6);
    
    $name = substr(session_id_create(), 0,  . '.' . $file_type;
    
    $named = $upload_dir . $name;
    
    if(move_uploaded_file($_FILES[$name]['tmp_name'], $named))
    {
    	$table = iif($type == 'avatar', 'avatar', 'picture');
    	die_message(USER_MESSAGE, 'File has been uploaded and saved');
    }
    else 
    {
    	die_message(USER_MESSAGE, 'Failed to upload file please try again <a href="#" onclick="javascript:history.go(-1)"');
    }
    
    }
    

  4. Why don't you track their time in a DB instead of a Cookie?  I know I would delete any tracking cookies on my PC.

     

    simple....reduce the number of queries needed when a page loads.....if i stored it in the db i would need a minimum of 2 queries ran just to get the info

  5. Ok what i have is a session management script that handles user sessions store infromation in database and sets cookies for the current session

    what i've run into is everytime a logged in user refreshes or visits a new page it updates the cookie information to set the lastactivity timestamp of the user

    the problem i've run into is if the user has chosen to remain logged in their next visit when i re-set the userdata cookie the expiration time will be reset also and the is no way to determain if the user has chosen to remain logged in....

    So is there any way to get the times that the cookie will expire or time until a cookie expires?

  6. Hey i cant seem to find anything on this and lost the code i developed long ago for this and my memory isnt to good on it.

    What I'm trying to do is make a 2 functions one will read text a user inputs and find if there are any opening html  tags and there atrr. If it finds html opening tags it will compare them to an array of html tags allowed to be used by the user and if not remove the unwanted tags leaving the text inside of them. And the other function will find closing html tags and compare them to the ones that are allready opened and get the text that is within the html tags and prepare it for output. Here is an example of what it would be.

    $text = '<span color="red">This text is red</span> This text is outside html tags';
    //it will take the code and make these variables
    $opentags = 1;
    $closetags = 1;
    $parsetext = 'This text is outside html tags';
    $parseabledata = 'This text is red';
    $opentags = array('span color="red"');
    $closetags = array('span');
    

×
×
  • 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.