Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
magic_quote problem.. and help me add HASH.... [URGENT!!!!]
Old 06-12-2009, 12:39 AM magic_quote problem.. and help me add HASH.... [URGENT!!!!]
Junior Talker

Posts: 2
Trades: 0
Besides that i have problem with magic_quote..

when i post Jingle's Bells
it will show :Jingle\\\'s Bells
so anyone have any idea?

----------------------------------------------------------------------------
and anyone have a code for [register page , reset password , comfimation mail?]
or help me edit this...just only help me implemed HASH.. you ca use MD5/SHA1

PHP Code:
if($_POST['create_account']){
    if(!
$_POST['accept_terms']) $smarty->assign("error_terms"err_accept_terms);
    else if(!
$_POST['username']) $smarty->assign("error_username"err_choose_username);
    else if(!
preg_match('/^[a-zA-Z0-9]+$/'$_POST['username'])) $smarty->assign("error_username_chars"err_username_chars);
    else if(
user_exists($_POST['username'])) $smarty->assign("error_username"err_account_exists);
    else if(!
$_POST['pass1'] || $_POST['pass1'] != $_POST['pass2']) $smarty->assign("error_pass"err_password_mismatch);
    else if(!
email_ok($_POST['email'])) $smarty->assign("error_email"err_email_incorrect);
    else if(
$_POST['code1'] != $_POST['code2']) $smarty->assign("error_code"err_invalid_code);
    else if(
email_exists($_POST['email'])) $smarty->assign("error_email"err_email_exists);
    else {
        if(
$_POST['visible']) $visible 1; else $visible 0;
        
$db = new database;
        
$db->dblink();
        
$id $db->db_insert("users""time, username, pass, email, visible"time().", '{$_POST['username']}', '{$_POST['pass1']}', '{$_POST['email']}', $visible");
        if(
$id) {
            
$rec $db->get_rec("users""*""id=$id");
            
$_SESSION['user'] = new user($rec);

            
//confirmation email
            
$msg str_replace("#username"$_SESSION['user']->usernameconfirmation_mail);
            
$msg str_replace("#link"$base_href."welcome/".encrypt($_SESSION['user']->username."###".$_SESSION['user']->pass), $msg);
            
mail($_SESSION['user']->emailconfirmation_subject$msg"From: Admin<".CONTACT_MAIL.">");

            
$files get_files('sample_photos');
            
$file $files[0];
            
$old "sample_photos/$file";

            
$parts explode("."$file);
            
$last count($parts) - 1;
            
$ext $parts[$last];

            
$filename $_SESSION['user']->id.".".$ext;
            
$new "profile_images/$filename";
            if(
copy($old$new)) $db->db_update("users""avatar='$filename'""id={$_SESSION['user']->id}");
            
copy($new"avatars/$filename");
            
resize_picture(2525"avatars/$filename"$ext);

            
//confirmation email
            //$msg = str_replace("#username", $_SESSION['user']->username, confirmation_mail);
            //$msg = str_replace("#link", $base_href."welcome/".encrypt($_SESSION['user']->username."###".$_SESSION['user']->pass), $msg);
            //mail($_SESSION['user']->email, confirmation_subject, $msg, "From: Admin<".CONTACT_MAIL.">");
            
unset($_SESSION['user']);
            
$page "welcome_info";
        } else 
$error err_create_account;
    }
    if(
$page != "welcome_info") {
        
$page "home";
        
$smarty->assign("error"$error);
        
$smarty->assign("reg"1);
    }
//login a user
if($_POST['login']){
    
$result $db->get_recs("users""*""(username='{$_POST['user']}' or email='{$_POST['user']}') and pass='{$_POST['pass']}' and new=0");
    
$how_many $db->count_recs($result);
    if(
$how_many != 0) {
        
$rec $db->fetch_objects($result);
        
$_SESSION['user'] = new user($rec[0]);
        
$_SESSION['user_id'] = $_SESSION['user']->id;
        if(
$_POST['remember_me']){
            
setcookie("login_user"$_SESSION['user']->usernametime() + 86400 60);
            
setcookie("login_pass"$_SESSION['user']->passtime() + 86400 60);
        }
        unset(
$_SESSION['logged_out']);
        
header("Location: profile/{$_SESSION['user']->username}");
    } else {
        
$result $db->get_recs("users""*""(username='{$_POST['user']}' or email='{$_POST['user']}') and pass='{$_POST['pass']}' and new=1");
        
$how_many $db->count_recs($result);
        if(
$how_many != 0){
            
//confirmation email
            
$recs $db->fetch_objects($result);
            if(
is_array($recs)) foreach($recs as $rec){
                
$u = new user($rec);
                
$msg str_replace("#username"$u->usernameconfirmation_mail);
                
$msg str_replace("#link"$base_href."welcome/".encrypt($u->username."###".$u->pass), $msg);
                
mail($u->emailconfirmation_subject$msg"From: Admin<".CONTACT_MAIL.">");
                
$smarty->assign("login_error"err_account_inactive);
            } else 
$smarty->assign("login_error"err_login_incorrect);
        } else 
$smarty->assign("login_error"err_login_incorrect);
    }
}

//check if the user is logged in
if($_SESSION['user']){
    
$rec $db->get_rec("users""id""username='{$_SESSION['user']->username}'");
    if(
$rec->id != $_SESSION['user_id']) $_SESSION['user_id'] = $rec->id;
} else {
    
//if not logged in but remembered in cookies
    
if($_COOKIE['login_user'] && $_COOKIE['login_pass'] && !$_SESSION['logged_out']){
        
$rec $db->get_rec("users""*""(username='{$_COOKIE['login_user']}' or email='{$_COOKIE['login_user']}') and pass='{$_COOKIE['login_pass']}'");
        if(
$rec$_SESSION['user'] = new user($rec);
        
header("Location: profile/{$_SESSION['user']->username}");
    }
    
$code random_string(5);
    
$smarty->assign("code"$code);

xDragonZ is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to magic_quote problem.. and help me add HASH.... [URGENT!!!!]
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22399 seconds with 12 queries