info.php 13.5 KB
<?  // Ïîäêëþ÷åíèå
	include_once($_SERVER['DOCUMENT_ROOT']."/account/mods/autorizator_user.php");

	// ============================== 
	// ======== Îáðàáîòêà ===========
	// ==============================

	
	if ((isset($_POST["info"])) && ($_POST["info"] == "ok")) {
        
		// Ñîáèðàåì èíòåðåñû
		if (isset($_POST['form']['interest'])) { 
			$_POST['form']['interest']=implode(":",$_POST['form']['interest']);
		} else { 
            $_POST['form']['interest']='';
        }      
        $birthday=$_POST['form']['year']."-".$_POST['form']['mounth']."-".$_POST['form']['day'];	
        if(trim($_POST['form']['email'])!=''){
		$sql = sprintf("UPDATE zlo_users SET pass=%s, city=%s, address=%s, tel=%s, username=%s, sex=%s, birthday=%s, interest=%s, tel2=%s, email=%s WHERE id='".$_SESSION['user']['id']."' ",
						   GetSQLValueString($_POST['form']['pass'], "text"),
						   GetSQLValueString($_POST['form']['city'], "text"),
						   GetSQLValueString($_POST['form']['address'], "text"),
						   GetSQLValueString($_POST['form']['tel'], "text"),
						   GetSQLValueString($_POST['form']['username'], "text"),
						   GetSQLValueString($_POST['form']['sex'], "text"),
						   GetSQLValueString($birthday, "text"),
						   GetSQLValueString($_POST['form']['interest'], "text"),
						   GetSQLValueString($_POST['form']['tel2'], "text"),
						   GetSQLValueString($_POST['form']['email'], "text"));

		}else{
				$sql = sprintf("UPDATE zlo_users SET pass=%s, city=%s, address=%s, tel=%s, username=%s, sex=%s, birthday=%s, interest=%s, tel2=%s WHERE id='".$_SESSION['user']['id']."' ",
						   GetSQLValueString($_POST['form']['pass'], "text"),
						   GetSQLValueString($_POST['form']['city'], "text"),
						   GetSQLValueString($_POST['form']['address'], "text"),
						   GetSQLValueString($_POST['form']['tel'], "text"),
						   GetSQLValueString($_POST['form']['username'], "text"),
						   GetSQLValueString($_POST['form']['sex'], "text"),
						   GetSQLValueString($birthday, "text"),
						   GetSQLValueString($_POST['form']['interest'], "text"),
						   GetSQLValueString($_POST['form']['tel2'], "text"));
		}
		//echo $sql."-";


if (!@preg_match("/[à-ÿ]/i",$_POST['form']['pass']))
		{
		$result = mysql_query($sql) or die(mysql_error());

        // Îáíîâëÿåì ñåññèþ
        
			$_SESSION['user']['pass']   =$_POST['form']['pass'];
            $_SESSION['user']['name']   =$_POST['form']['username'];
			$_SESSION['user']['tel']    =$_POST['form']['tel'];
			$_SESSION['user']['tel2']   =$_POST['form']['tel2'];
			$_SESSION['user']['address']=$_POST['form']['address'];
			$_SESSION['user']['city']   =$_POST['form']['city'];

		echo "<script language=\"JavaScript\">{ location.href=\"/account/info/?ok\"; self.focus(); } </script>";
		}else echo "<script language=\"JavaScript\">{ location.href=\"/account/info/?error\"; self.focus(); } </script>";
	}

	// ============================== 
	// ========== Âûâîä =============
	// ==============================
	
	$sql = "SELECT * FROM zlo_users as u 
			WHERE u.id=".$_SESSION['user']['id']." ";
	$result = mysql_query($sql) or die(mysql_error());
	if (mysql_affected_rows()!=0) {
		$userInfo=mysql_fetch_assoc($result);
        
if(isset($_GET['ok'])) $datas = "<center><b>Ñïàñèáî! Èçìåíåíèÿ óñïåøíî ñîõðàíåíû</b></center><br/>";
elseif(isset($_GET['error'])) $datas = "<center><b>Îøèáêà! Ïðè ââîäå ïàðîëÿ</b></center><br/>";

	echo'<div class="leftbar2">';
	include_once($_SERVER['DOCUMENT_ROOT']."/account/account_menu.php");
	echo'</div>';
	echo'<div class="content">';    
	echo'<div class="title3"><div class="l"><div class="r"><div class="w">Ëè÷íàÿ èíôîðìàöèÿ</div></div></div></div>';
    echo'<div class="cont_box">';
        echo"
            <div class='info'>
			".$datas."
                <form id='info' action='/account/info/' method='POST'>
               
                    
                        <div class='row2'>
                            <label>ÔÈÎ</label>
                            <input type='text' name='form[username]' class='idle' onblur='this.className=\"idle\"' onfocus='this.className=\"activeField\"' size='60' value='".$userInfo['username']."'>
                        </div>
                        <div class='row2'>
                            <label>Ïîë</label>
                            <select name='form[sex]'>
                                    <option value='0'>[âûáîð]</option>";
                                    
                                if ($userInfo['sex']=='M') {$selected="selected='selected'";} else {$selected='';}
                                    echo"<option value='M' $selected>M</option>";
                                if ($userInfo['sex']=='W') {$selected="selected='selected'";} else {$selected='';}
                                    echo"<option value='W' $selected>Æ</option>";
                                    
                        echo"</select>
                        </div>

                        <div class='row2'>                        
                            <label>Äàòà ðîæäåíèÿ</label>";
                            
                            // ===================== 
                            // === Äàòà ðîæäåíèÿ ===
                            // =====================
    
                            $dateFromDate=ExtractDate($userInfo['birthday']);

                            // äíè
                            echo"<select name='form[day]'>"; 
                                echo"<option value='00'></option>";
                            for ($i=1; $i<31; $i++) {
                                if($i==$dateFromDate[2]) {$selected="selected='selected'";} else {$selected='';}
                                echo"<option value='".AddZeroDate($i)."' $selected>$i</option>";
                            }
                            echo"</select>";
                            
                            // ìåñÿö
                            echo"<select name='form[mounth]'>";
                                echo"<option value='00'></option>";
                            for ($i=1; $i<13; $i++) {
                                if($i==$dateFromDate[1]) {$selected="selected='selected'";} else {$selected='';}
                                echo"<option value='".AddZeroDate($i)."' $selected>".WhatMonth($i)."</option>";
                            }
                            echo"</select>";                          
                            
                            // ãîä
                            echo"<select name='form[year]'>";
                                echo"<option value='0000'></option>";
                            for ($i=(date('Y')-6); $i>(date('Y')-80); $i--) {
                                if($i==$dateFromDate[0]) {$selected="selected='selected'";} else {$selected='';}
                                echo"<option value='$i' $selected>$i</option>";
                            }
                            echo"</select>"; 
                            
if(trim($userInfo['UID'])!='' && trim($userInfo['email'])==""){
	$ccccc = "";
	$iiiddd ="";
}else{
	$ccccc = "disabled='disabled'";
	$iiiddd = " id='email'";
}

                        echo"</div>
                        <div class='row2'>
                            <label>E-mail</label>
                            <input type='text' name='form[email]' class='idle' onblur='this.className=\"idle\"' onfocus='this.className=\"activeField\"' size='60' ".$ccccc." value='".$userInfo['email']."' ".$iiiddd.">	
                        </div>
                        <div class='row2'>
                            <label>Ïàðîëü</label>
                            <input type='text' name='form[pass]' class='idle' onblur='this.className=\"idle\"' onfocus='this.className=\"activeField\"' size='60' value='".$userInfo['pass']."'>	
                        </div>	
                        <div class='row2'>	
                            <label>Òåëåôîí</label>
                            <input type='text' name='form[tel]' class='idle' onblur='this.className=\"idle\"' onfocus='this.className=\"activeField\"' size='60'  value='".$userInfo['tel']."'>
                        </div>
                        <div class='row2'>	
                            <label>Àëüòåðíàòèâíûé òåëåôîí</label>
                            <input type='text' name='form[tel2]' class='idle' onblur='this.className=\"idle\"' onfocus='this.className=\"activeField\"' size='60'  value='".$userInfo['tel2']."'>
                        </div>
                        <div class='row2'>
                            <label>Ãîðîä</label>
                            <input type='text' name='form[city]' class='idle' onblur='this.className=\"idle\"' onfocus='this.className=\"activeField\"' size='60'  value='".$userInfo['city']."'>
                        </div>	                        
                        <div class='row2'>
                            <label>Àäðåñ</label>
                            <textarea name='form[address]' id='address' rows='5' cols='65' class='idle' onblur='this.className=\"idle\"' onfocus='this.className=\"activeField\"' >".$userInfo['address']."</textarea>
                        </div>
					</div>	
					
                        <div class='interest'>	

                            <div class='interest-block'>";

                            // interest
                            $sql2 = "SELECT * FROM zlo_interest ORDER BY `common` DESC";
                            $result2 = mysql_query($sql2) or die(mysql_error());
                            $total=mysql_affected_rows();
                            if ($total!=0) { $i=0; 
                            
                                echo'<div class="title3"><div class="w">Ïîäïèñêà íà ðàññûëêó</div></div>';
                            
                                $col=3; 
                                $perCol=ceil($total/$col);
                                $one=0;$two=0;
                                $j=0;
                                
                                // êîíâåðòèðóåì
                                $interestMass=explode(":",$userInfo['interest']);
                                
                                while ($interest=mysql_fetch_assoc($result2)) { 
 
                                    if($interest['common']==1) { $j++;

                                        if($one==0){
                                            echo"<div class='common'>
                                                    <div class='th'>Oáùèå ðàññûëêè</div>
                                                    <span>Âû áóäåòå ïîëó÷àòü èíôîðìàöèþ î ñêèäêàõ è àêöèÿõ, à òàêæå î ïîñòóïëåíèè íîâîãî òîâàðà</span>";
                                            $one=1;
                                        }
                                        if (in_array($interest['id'], $interestMass)) {$checked="checked='checked'";} else {$checked='';}
                                        echo"<div class='choice'><input type='checkbox' name='form[interest][".$interest['id']."]' $checked value='".$interest['id']."'>".$interest['title']."</div>";
                                    
                                    }
                                
                                    if($interest['common']==0) { $i++;
                                    
                                        if($one==1) {
                                        
                                            echo"</div>
                                                <div class='line'></div>"; $one=2;
                                            
                                        }
                                        
                                        if($two==0) {
                                            echo"<div class='interst'>
                                                    <div class='th'>Èíòåðåñû</div>
                                                    <span>Âû áóäåòå ïîëó÷àòü ðàññûëêó ïî èíòåðåñóþùåé Âàì ãðóïïå òîâàðîâ, à òàêæå ñïåöèàëüíûå ïðåäëîæåíèÿ</span>"; 
                                                    $two=1;
                                        }
                                    
                                        if ($i==1 || $i==$perCol+1 || $i==2*$perCol+1 ) { echo"<div class='column'>"; }

                                            if (in_array($interest['id'], $interestMass)) {$checked="checked='checked'";} else {$checked='';}
                                            echo"<div class='choice'><input type='checkbox' name='form[interest][".$interest['id']."]' $checked value='".$interest['id']."'>".$interest['title']."</div>";
                                        
                                        if ($i==$perCol || $i==2*$perCol || $i==$total-$j) { echo"</div>"; } 
                                    
                                    }
                                }
                                
                                        echo"<div class='both'></div></div>";
                            }
                            
                            echo"</div>"; 
                        echo"<div class='clear'></div>
                        </div>
                        <div class='clear'></div>
                        <div class='line'></div>
                        <div class='row2'>		
                            <label>&nbsp;</label>                    
                            <div class='button' align='center'>
                                <input type='hidden' name='info' value='ok'>
                                <input type='submit' name='button' class='submit5' value='Ñîõðàíèòü'>
                            </div>
                        </div>	
                
                </form>
            </div>
			</div>";
	}	
?>