-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathacc_update.php
More file actions
87 lines (63 loc) · 1.97 KB
/
acc_update.php
File metadata and controls
87 lines (63 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* @author kem parson
* @copyright 2016
*/
$id=$_POST['id'];
$email=$_POST['email'];
require_once ($_SERVER['DOCUMENT_ROOT'] .'/app/Mage.php');
Mage::app('default');
umask(0);
Mage::init();
Mage::getSingleton('core/session', array('name' =>'frontend'));
$customer = Mage::getModel("customer/customer");
$customer->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
$customer->loadByEmail($email);
$mage_id=$customer->getId();
if($mage_id==$id){
// create each post as a function
$errors ='false';
$file=$_FILES['info_image'];
$ending = '.' . strtolower(end(explode(".", $file['name'])));
$allowedtypes = array(
'tiff' => 'image/tiff',
'jpg' => 'image/jpg',
'png' => 'image/png',
'gif' => 'image/gif',
);
$ext = in_array(str_replace('.','',$ending), array_keys($allowedtypes));
if ($ext === false):
$ret['error'] = 'Only .tiff, .jpg, .png .gif files are supported.';
$errors="true";
endif;
if (in_array($ending,array_keys($allowedtypes))) {
$ret['error'] = 'Only .tiff, .jpg, .png .gif files are supported.';
$errors="true";
}
if (($file["size"] > 200000)) {
$ret['error'] = 'maximum fize size exceeded ';
$errors="true";
}
if (!is_numeric($file["size"])) {
$ret['error'] = 'Size of file is not a number.';
$errors="true";
}
if ($file["error"] > 0) {
$ret['error'] = $file["error"];
$errors="true";
}
if ($errors=='false'):
$sourcePath = $file['tmp_name'];
$filename="$id.jpg";
$targetPath = "customerpic/".$filename;
move_uploaded_file($sourcePath, $targetPath);
$ret['sucess']='true';
$ret['path']= $targetPath;
endif;
}//id mach email
else{
$ret['error']="Id and Email do not match please to login customer";
}
$result=json_encode($ret) ;
echo $result;
?>