Esempio n. 1
0
function teamphoto_update(){
	global $wpdb;
	
	$data = $_POST;
	
	$member_id = $data['ID'];
	unset($data['action'],$data['submit'],$data['ID'],$data['file_upload']);
	
	$teamphotoClass = new teamphoto();
	$member_data = clean_post($data);
	$teamphotoClass->_teamphoto_ID = $member_id;
	$update_id = $teamphotoClass->update($member_data);
	
	$report=array();
	if(is_numeric($update_id)){
		
		$report['text'] = "Changes Successfully saved.";
		$report['class'] = 'updated';
		$report['photo'] = $data['sport'];
		//save image
		$photo = $data['photo'];
		$sport = $data['sport'];
		//photo uploaded temporary
		$is_temp_img = strpos($photo,'_temp');
		if($is_temp_img === false ){
			#no changes on photo
		}else{
			//$teamphotoClass->update($member_data);
			$ext = pathinfo($photo, PATHINFO_EXTENSION);
			$_filename = $update_id .'.'. $ext;
			//save- photo
			$return_filename = teamphoto::savephoto(TEAMPHOTO_UPLOAD_DIR . $photo,$sport,'','',$_filename,150);
			$return_thumb = teamphoto::savephoto(TEAMPHOTO_UPLOAD_DIR . $photo,$sport,'/thumb','',$_filename,80);
			
			#remove the temp file
			if(file_exists(TEAMPHOTO_UPLOAD_DIR . $photo)){
				unlink(TEAMPHOTO_UPLOAD_DIR . $photo);
			}
			
			#save the changes on Database
			$update_field = array(
				'photo' => $return_filename,
				'photo_min' => $return_thumb
			);
			$teamphotoClass->update($update_field,$update_id);
			$report['text'] .= " <b>Logo updated.</b>";
			$report['photo'] = $return_filename;
		}
		$report['ID'] = $update_id;
		$teamphotoClass->add_logs($update_id,'Update Team Info -'.  $data['team']);
		
	}else{
		$report['text'] =  'Error: '.$wpdb->last_error;
		$report['class'] = 'error';
	}
	echo json_encode($report);
	exit;
	
}
Esempio n. 2
0
 function updateProc()
 {
     $config = array(array('field' => 'user_name', 'label' => '*', 'rules' => 'trim|required|min_length[3]|xss_clean'), array('field' => 'user_email', 'label' => '*', 'rules' => 'trim|required|valid_email'), array('field' => 'user_phone', 'label' => '*', 'rules' => 'trim|required|numeric'));
     $this->form_validation->set_error_delimiters('<div class="text-error">', '</div>');
     $this->form_validation->set_rules($config);
     if ($this->form_validation->run() == FALSE) {
         $this->index();
     } else {
         $id = $this->session->userdata('user_id');
         $data = array('user_name' => clean_post(strtoupper($this->input->post('user_name', TRUE))), 'user_email' => clean_post(strtolower($this->input->post('user_email', TRUE))), 'user_phone' => clean_post($this->input->post('user_phone', TRUE)), 'user_phone2' => clean_post($this->input->post('user_phone2', TRUE)), 'date_modified' => date('Y-m-d H:i:s'), 'modifiedby' => $this->session->userdata('user_id'));
         $result = $this->Mod_profile->update($id, $data);
         if ($result === TRUE) {
             $this->session->set_flashdata('success', 'Profile successfully updated.');
         } else {
             $this->session->set_flashdata('error', config_item('save_failed'));
         }
         redirect('profile', 'refresh');
     }
 }
// Check if all the required data are passed
if (!isset($_POST['id_salarie'], $_POST['prenom'], $_POST['nom'], $_POST['adresse'], $_POST['cp'], $_POST['ville'], $_POST['tel'], $_POST['email'])) {
    $_SESSION['fortitudo_messages'][] = array('type' => 'error', 'content' => 'Mauvais usage du formulaire.');
} elseif (empty($_POST['prenom']) || empty($_POST['nom']) || empty($_POST['adresse']) || empty($_POST['cp']) && empty($_POST['ville']) || empty($_POST['tel']) || empty($_POST['email']) || empty($_POST['id_salarie'])) {
    $_SESSION['fortitudo_messages'][] = array('type' => 'error', 'content' => 'Tous les champs ne sont pas rempli.');
} elseif (!is_numeric($_POST['id_salarie'])) {
    $_SESSION['fortitudo_messages'][] = array('type' => 'error', 'content' => 'L\'identifiant du client n\'est pas un nombre.');
} elseif (!is_numeric($_POST['cp'])) {
    $_SESSION['fortitudo_messages'][] = array('type' => 'error', 'content' => 'Le code postal n\'est pas un nombre.');
} elseif (!is_numeric($_POST['tel'])) {
    $_SESSION['fortitudo_messages'][] = array('type' => 'error', 'content' => 'Le numéro de téléphone n\'est pas un nombre.');
} elseif (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
    $_SESSION['fortitudo_messages'][] = array('type' => 'error', 'content' => 'L\'e-mail rentré n\'est pas valide');
} else {
    // Firstly, clean the $_POST data
    $_POST = clean_post($_POST);
    // Then update the t_personne informations
    $query_update_t_personne = $slim->pdo->prepare('UPDATE ' . $config['db_prefix'] . 'T_Personne
            SET adresse = :adresse,
            code_postal = :cp,
            ville = :ville,
            telephone = :tel,
            mail = :email
            WHERE id_personne = :idp');
    // Again, bind the POST data to the prepare() variables
    $query_update_t_personne->bindParam(':idp', $_POST['id_salarie']);
    $query_update_t_personne->bindParam(':adresse', $_POST['adresse']);
    $query_update_t_personne->bindParam(':cp', $_POST['cp']);
    $query_update_t_personne->bindParam(':ville', $_POST['ville']);
    $query_update_t_personne->bindParam(':tel', $_POST['tel']);
    $query_update_t_personne->bindParam(':email', $_POST['email']);
} else {
    $arr = array('error' => 1);
    echo json_encode($arr);
}
?>

<?php 
if (isset($_POST['B']) && !empty($_POST['B']) && !empty($_POST['G'])) {
    include_once 'db.php';
    $id = clean_post($_POST['B']);
    // Google ID
    $email = clean_post($_POST['G']);
    // Email ID
    $name = clean_post($_POST['ha']);
    // Name
    $profile_pic = clean_post($_POST['wc']);
    //Profile Pic URL
    //check if Google ID already exits
    $stmt = $db->prepare("SELECT * FROM tbl_gusers WHERE fld_google_id=:id");
    $stmt->execute(array(':id' => $id));
    $check_user = $stmt->fetchAll(PDO::FETCH_ASSOC);
    if (!$check_user) {
        //new user - we need to insert a record
        $time = time();
        $insert_user_query = $db->prepare("INSERT INTO tbl_gusers(fld_user_name,fld_user_email,fld_google_id,fld_user_doj) VALUES(:name,:email,:google_id,:doj)");
        $insert_user_query->execute(array(':name' => $name, ':email' => $email, ':google_id' => $id, ':doj' => $time));
        echo json_encode($_POST);
    } else {
        //update the user details
        $update_user_query = $db->prepare("UPDATE tbl_gusers SET fld_user_name=?, fld_user_email=? WHERE fld_google_id=?");
        $update_user_query->execute(array($name, $email, $id));