This repository has been archived by the owner on Nov 17, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPostAd.php
171 lines (144 loc) · 3.91 KB
/
PostAd.php
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
session_start();
require_once 'Buisness/dbconfig.php';
require_once 'Buisness/Images.cls.php';
require_once 'Buisness/Ad.cls.php';
require_once 'Buisness/Payement.cls.php';
/*
if(!isset($selectedPayement)){
$selectedPayement = new Payement();
}
*/
echo $_SESSION["language"];
if (isset($_SESSION["id"])){
echo $_SESSION["id"];
}
else {
echo "Please login first";
}
if(isset($_GET["subCategory"])){
$subCat = $_GET["subCategory"];
}
if(isset($_POST["pay"])){
$payement = new Payement();
$payement->setPk_pay_id($_POST["pay"]);
$payement = $payement->find($connectionId);
$ad = new Ad();
$ad->setAd_description($_POST["description"]);
//$ad->setAd_price($_POST["price"]);
$ad->setAd_reg_date(date("Y/m/d"));
//$ad->setAd_exp_date(date("Y/m/d") + $payement->getPay_duration());
$ad->setAd_tit($_POST["title"]);
$ad->setFk_mem_id($_SESSION["id"]);
$ad->setFk_pay_id($payement->getPk_pay_id());
$ad->setFk_subCat_id($subCat);
$ad->setLanguage($_SESSION["language"]);
$newId = $ad->create($connectionId);
echo $newId;
}
//session_start() - Démarre une nouvelle session ou reprend une session existante
/*
if(isset($_POST["post"])){
echo Payement::header();
echo $selectedPayement;
echo Payement::footer();
$ad = new Ad();
$ad->setAd_description($_POST["description"]);
$ad->setAd_price($_POST["price"]);
$ad->setAd_reg_date(date("Y/m/d"));
$ad->setAd_exp_date();
$ad->setAd_tit($_POST["title"]);
$ad->setFk_mem_id($_SESSION["id"]);
$ad->setFk_pay_id($_POST["pay"]);
$ad->setFk_subCat_id($subCat);
$ad->setLanguage($_SESSION["language"]);
$ad->create($connectionId);
}
*/
if(isset($_FILES["images"]) && isset($newId)){
//echo implode(',', $_FILES["images"]);
//Créer un dossier 'fichiers/1/'
if (!is_uploaded_file($_FILES["images"]['tmp_name'])){echo "Image Upload Failed error // " . $_FILES["images"]['error'];}
if(isset($_SESSION["id"])){
$sessionId = $_SESSION["id"];
}
//if issue it falls into id 0 which does not exist
else{$sessionId = 0;}
$path = 'Images/'.$sessionId.'/';
//echo $path;
if(is_dir($path)){}
else{
mkdir($path , 0777, true);
}
// mkdir($path , 0777, true);
//Créer un identifiant difficile à deviner
$nom = md5(uniqid(rand(), true));
$extension = pathinfo($_FILES["images"]['name'],PATHINFO_EXTENSION);
//echo $path.$nom.".jpg";
//echo $extension;
//echo "File uploaded ".$_FILES["images"]['tmp_name'];
move_uploaded_file($_FILES["images"]['tmp_name'], $path.$nom.'.'.$extension);
$image = new Images();
$image->setImagePath($path.$nom.'.'.$extension);
$image->setFk_ad_id($newId);
$image->create($connectionId);
}
?>
<form method="post" enctype="multipart/form-data">
<link rel="stylesheet" type="text/css" href="css/PostAd.css"/>
<table>
<tr>
<td>Title</td>
<td>
<input type="text" name="title"/>
</td>
</tr>
<tr>
<td>Description</td>
<td>
<input type="text" name="description"/>
</td>
</tr>
<tr>
<td>Price</td>
<td><td>
</tr>
<tr>
<td>Images</td>
<td><input type="file" name="images"><td>
</tr>
<tr>
<td>Ad Type</td>
<td >
<?php
$payement = new Payement();
$payements = $payement->getAll($connectionId);
foreach($payements as $element){
?>
<div class="payement">
<table>
<th>
<tr>
<td></td>
</tr>
<tr>
<td>Package(<?php echo $element->getPk_pay_id()?>)<br/><hr/><br/> <?php echo $element->getPay_duration()?> Days</td>
</tr>
<tr>
<td><?php echo $element->getPay_amount()?>$</td>
</tr>
<tr>
<td><?php echo $element->getPay_pictures_amount()?> Images</td>
</tr>
<tr>
<td><input type="submit" name="pay" value="<?php echo $element->getPk_pay_id()?>"></td>
</tr>
</th>
</table>
</div>
<?php }?>
</td>
</tr>
</table>
<!-- <input type="submit" name="post" value="Post Ad"/> -->
</form>