· 11 years ago · Aug 30, 2015, 06:10 AM
1<?php
2include('class/mysql_crud.php');
3
4$db = new Database();
5$db->connect();
6
7$action = $_POST['action'];
8
9switch ($action) {
10
11 // case "register":
12 // $customer_email = $_POST['customer_email'];
13 // $customer_password = $_POST['customer_password'];
14 // $now = date("Y-m-d H:i:s");
15 // $customer_loginattempt = '0';
16 // $detailcustomer_fname = $_POST['detailcustomer_fname'];
17 // $detailcustomer_country = $_POST['detailcustomer_country'];
18 // $detailcustomer_city = $_POST['detailcustomer_city'];
19 // $detailcustomer_address = $_POST['detailcustomer_address'];
20 // $detailcustomer_phone1 = $_POST['detailcustomer_phone1'];
21 // $detailcustomer_phone2 = $_POST['detailcustomer_phone2'];
22 // $detailcustomer_lineid = $_POST['detailcustomer_lineid'];
23 // //$detailcustomer_image = $_POST['detailcustomer_image'];
24 // $cardnumber_bank = $_POST['cardnumber_bank'];
25 // $cardnumber_accountname = $_POST['cardnumber_accountname'];
26 // $cardnumber_rek = $_POST['cardnumber_rek'];
27
28 // $db->insert('mst_customer',array('customer_email'=>$customer_email,'customer_password'=>md5($customer_password), 'customer_loginattempt'=>$customer_loginattempt,
29 // 'customer_status'=>'active','customer_createdate'=>$now,'customer_updatedate'=>$now)); // Table name, column names and respective values
30 // $res = $db->thisResult_();
31 // if ($res == 1)
32 // {
33
34 // $target_dir = "uploads/";
35 // $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
36 // list($namefile, $ext) = explode(".", basename($_FILES["fileToUpload"]["name"]));
37 // $target_file1 = $target_dir . date("YmdHis"). "." . $ext;
38 // $uploadOk = 1;
39 // $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
40 // // Check if image file is a actual image or fake image
41 // $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
42 // if($check !== false) {
43 // //echo "File is an image - " . $check["mime"] . ".";
44 // $uploadOk = 1;
45 // } else {
46 // //echo "File is not an image.";
47 // $uploadOk = 0;
48 // }
49 // if ($_FILES["fileToUpload"]["size"] > 500000) {
50 // //echo "Sorry, your file is too large.";
51 // $uploadOk = 0;
52 // }
53 // // Allow certain file formats
54 // if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
55 // && $imageFileType != "gif" ) {
56 // //echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
57 // $uploadOk = 0;
58 // }
59 // if ($uploadOk == 0) {
60 // //echo "Sorry, your file was not uploaded.";
61 // // if everything is ok, try to upload file
62 // $temp_image = '';
63 // } else {
64 // if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file1)) {
65 // //echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
66 // $temp_image = date("YmdHis"). "." .$ext;
67 // } else {
68 // //echo "Sorry, there was an error uploading your file.";
69 // $temp_image = '';
70 // }
71 // }
72
73 // $db->insert('mst_detailcustomer',array('customer_email'=>$customer_email,'detailcustomer_fname'=>$detailcustomer_fname, 'detailcustomer_country'=>$detailcustomer_country,
74 // 'detailcustomer_city'=>$detailcustomer_city,'detailcustomer_address'=>$detailcustomer_address,'detailcustomer_phone1'=>$detailcustomer_phone1,
75 // 'detailcustomer_phone2'=>$detailcustomer_phone2,'detailcustomer_lineid'=>$detailcustomer_lineid,'detailcustomer_image'=>$temp_image
76 // )); // Table name, column names and respective values
77 // $res2 = $db->thisResult_();
78
79
80 // if ($res2 == 1)
81 // {
82 // $db->insert('mst_cardnumber',array('customer_email'=>$customer_email,'cardnumber_bank'=>$cardnumber_bank, 'cardnumber_accountname'=>$cardnumber_accountname,
83 // 'cardnumber_rek'=>'cardnumber_rek','cardnumber_status'=>'active',
84 // 'cardnumber_createdate'=>$now,'cardnumber_updatedate'=>$now
85 // )); // Table name, column names and respective values
86 // $res3 = $db->thisResult_();
87
88 // include('class/function_live.php');
89 // $fu_dec = new api();
90 // $ver2 = $fu_dec->encrypt_decrypt('encrypt', $customer_email);
91 // $ver = substr($ver2, 0, 50);
92 // $db->insert('mst_verification',array('verification_email'=>$customer_email,'verification_code'=>$ver,
93 // 'verification_status'=>'not approved')); // Table name, column names and respective values
94 // $res4 = $db->thisResult_();
95
96 // if ($res == 1)
97 // {
98 // require_once "mail/Mail.php";
99 // //setup email
100 // $from = '<noreply@cakramarkets.com>';
101 // $to = '<'.$customer_email.'>';
102 // $subject = 'Your Account In Cakramarkets';
103 // $body = "Hi,\n\nCongrats Your Account Register Successfully, \n\nDetail Your Account :\n\n name : ".$detailcustomer_fname." \n\n password : ".$customer_password." \n\n Country : ".$detailcustomer_country." \n\n Your Verification Code : http://cakramarkets.com/cabdem/verification_email/index.php?code=".$ver."&email=".$customer_email." \n\n Thank your for registration. \n\n Best Regards,";
104
105 // $headers = array(
106 // 'From' => $from,
107 // 'To' => $to,
108 // 'Subject' => $subject
109 // );
110
111 // $smtp = Mail::factory('smtp', array(
112 // 'host' => 'ssl://server167.web-hosting.com',
113 // 'port' => '465',
114 // 'auth' => true,
115 // 'username' => 'noreply@cakramarkets.com',
116 // 'password' => 'dadakan123'
117 // ));
118
119 // $mail = $smtp->send($to, $headers, $body);
120
121 // if (PEAR::isError($mail)) {
122 // $arr = array('result' => 'Successfully Create Account', 'Email Status' => $mail->getMessage());
123 // } else {
124 // $arr = array('result' => 'Successfully Create Account', 'Email Status' => 'Successfully Send email');
125 // }
126 // // echo json_encode($arr);
127 // header ("location:cabinet_login.php?suc=Anda Telah Berhasil Melakukan Register Akun");
128 // }else
129 // {
130 // $arr = array('result' => 'Failed Create Account', 'Error Code' => 'Cardnumber');
131 // echo json_encode($arr);
132 // header ("location:cabinet_register.php?err=Akun Bank Telah Terdaftar");
133 // }
134
135 // }else {
136 // $arr = array('result' => 'Fileailed Create Account', 'Error Code' => 'Detail Customer');
137 // echo json_encode($arr);
138 // header ("location:cabinet_register.php?err=Email Telah Terdaftar");
139 // }
140
141 // }
142 // else
143 // {
144 // $arr = array('result' => 'Failed Create Account', 'Error Code' => 'Failed');
145 // echo json_encode($arr);
146 // header ("location:cabinet_register.php?err=Gagal Melakukan Registrasi");
147 // }
148
149 // break;
150
151 case "register":
152 $customer_email = $_POST['customer_email'];
153 $customer_password = $_POST['customer_password'];
154 $now = date("Y-m-d H:i:s");
155 $customer_loginattempt = '0';
156 $detailcustomer_fname = $_POST['detailcustomer_fname'];
157 $detailcustomer_country = $_POST['detailcustomer_country'];
158 $detailcustomer_city = $_POST['detailcustomer_city'];
159 $detailcustomer_address = $_POST['detailcustomer_address'];
160 $detailcustomer_phone1 = $_POST['detailcustomer_phone1'];
161 $detailcustomer_phone2 = $_POST['detailcustomer_phone2'];
162 $detailcustomer_lineid = $_POST['detailcustomer_lineid'];
163 //$detailcustomer_image = $_POST['detailcustomer_image'];
164 $cardnumber_bank = $_POST['cardnumber_bank'];
165 $cardnumber_accountname = $_POST['cardnumber_accountname'];
166 $cardnumber_rek = $_POST['cardnumber_rek'];
167
168 // require_once('recaptchalib.php');
169 // $privatekey = "6LdevAsTAAAAAOulMPkT8MgHlPkhUoAXFPyjQlC_";
170 // $resp = recaptcha_check_answer ($privatekey,
171 // $_SERVER["REMOTE_ADDR"],
172 // $_POST["recaptcha_challenge_field"],
173 // $_POST["recaptcha_response_field"]);
174
175 // if (!$resp->is_valid) {
176 // // What happens when the CAPTCHA was entered incorrectly
177 // //die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
178 // //"(reCAPTCHA said: " . $resp->error . ")");
179 // $arr = array('result' => 'Failed Login To Web', 'Error Code' => $resp->error);
180 // echo json_encode($arr);
181 // } else {
182
183 $db->insert('mst_customer',array('customer_email'=>$customer_email,'customer_password'=>md5($customer_password), 'customer_loginattempt'=>$customer_loginattempt,
184 'customer_status'=>'not active','customer_createdate'=>$now,'customer_updatedate'=>$now)); // Table name, column names and respective values
185 $res = $db->thisResult_();
186 if ($res == 1)
187 {
188
189 $target_dir = "uploads/";
190 $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
191 list($namefile, $ext) = explode(".", basename($_FILES["fileToUpload"]["name"]));
192 $target_file1 = $target_dir . date("YmdHis"). "." . $ext;
193 $uploadOk = 1;
194 $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
195 // Check if image file is a actual image or fake image
196 $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
197 if($check !== false) {
198 //echo "File is an image - " . $check["mime"] . ".";
199 $uploadOk = 1;
200 } else {
201 //echo "File is not an image.";
202 $uploadOk = 0;
203 }
204 if ($_FILES["fileToUpload"]["size"] > 500000) {
205 //echo "Sorry, your file is too large.";
206 $uploadOk = 0;
207 }
208 // Allow certain file formats
209 if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
210 && $imageFileType != "gif" ) {
211 //echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
212 $uploadOk = 0;
213 }
214 if ($uploadOk == 0) {
215 //echo "Sorry, your file was not uploaded.";
216 // if everything is ok, try to upload file
217 $temp_image = '';
218 } else {
219 if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file1)) {
220 //echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
221 $temp_image = date("YmdHis"). "." .$ext;
222 } else {
223 //echo "Sorry, there was an error uploading your file.";
224 $temp_image = '';
225 }
226 }
227
228 $db->insert('mst_detailcustomer',array('customer_email'=>$customer_email,'detailcustomer_fname'=>$detailcustomer_fname, 'detailcustomer_country'=>$detailcustomer_country,
229 'detailcustomer_city'=>$detailcustomer_city,'detailcustomer_address'=>$detailcustomer_address,'detailcustomer_phone1'=>$detailcustomer_phone1,
230 'detailcustomer_phone2'=>$detailcustomer_phone2,'detailcustomer_lineid'=>$detailcustomer_lineid,'detailcustomer_image'=>$temp_image
231 )); // Table name, column names and respective values
232 $res2 = $db->thisResult_();
233 if ($res2 == 1)
234 {
235 $db->insert('mst_cardnumber',array('customer_email'=>$customer_email,'cardnumber_bank'=>$cardnumber_bank, 'cardnumber_accountname'=>$cardnumber_accountname,
236 'cardnumber_rek'=>'cardnumber_rek','cardnumber_status'=>'active',
237 'cardnumber_createdate'=>$now,'cardnumber_updatedate'=>$now
238 )); // Table name, column names and respective values
239 $res3 = $db->thisResult_();
240
241 include('class/function_live.php');
242 $fu_dec = new api();
243 $ver = $fu_dec->encrypt_decrypt('encrypt', $customer_email);
244 $db->insert('mst_verification',array('verification_email'=>$customer_email,'verification_code'=>$ver,
245 'verification_status'=>'not approved')); // Table name, column names and respective values
246 $res4 = $db->thisResult_();
247
248 if ($res == 1)
249 {
250 require_once "mail/Mail.php";
251 //setup email
252 $from = '<noreply@cakramarkets.com>';
253 $to = '<'.$customer_email.'>';
254 $subject = 'Your Account In Forex';
255 $body = "Hi,\n\nCongrats Your Account Register Successfully, \n\nDetail Your Account :\n\n name : ".$detailcustomer_fname." \n\n password : ".$customer_password." \n\n Country : ".$detailcustomer_country." \n\n Your Verification Code : http:\\localhost\cakramarkets\verification\index.php?code=".$ver." \n\n Thank your for registration. \n\n Best Regards,";
256
257 $headers = array(
258 'From' => $from,
259 'To' => $to,
260 'Subject' => $subject
261 );
262
263 $smtp = Mail::factory('smtp', array(
264 'host' => 'ssl://server167.web-hosting.com',
265 'port' => '465',
266 'auth' => true,
267 'username' => 'noreply@cakramarkets.com',
268 'password' => 'dadakan123'
269 ));
270
271 $mail = $smtp->send($to, $headers, $body);
272
273 if (PEAR::isError($mail)) {
274 $arr = array('result' => 'Successfully Create Account', 'Email Status' => $mail->getMessage());
275 } else {
276 $arr = array('result' => 'Successfully Create Account', 'Email Status' => 'Successfully Send email');
277 }
278 // echo json_encode($arr);
279 header ("location:cabinet_login.php?suc=Successfully Create Account");
280 }else
281 {
282 $arr = array('result' => 'Failed Create Account', 'Error Code' => 'Cardnumber');
283 echo json_encode($arr);
284 header ("location:cabinet_register.php?err=Bank Account Number already registered");
285 }
286
287 }else {
288 $arr = array('result' => 'Fileailed Create Account', 'Error Code' => 'Detail Customer');
289 echo json_encode($arr);
290 header ("location:cabinet_register.php?err=Email Already Registered");
291 }
292
293 }
294 else
295 {
296 $arr = array('result' => 'Failed Create Account', 'Error Code' => 'Failed');
297 echo json_encode($arr);
298 header ("location:cabinet_register.php?err=Failed registration");
299 }
300 }
301 break;
302 case "reqdeposit":
303
304 $customer_email = $_POST['customer_email'];
305 $account_mt4id = $_POST['account_mt4id'];
306 $reqdeposit_bank = $_POST['reqdeposit_bank'];
307 $reqdeposit_accountname = $_POST['reqdeposit_accountname'];
308 $reqdeposit_accountnumber = $_POST['reqdeposit_accountnumber'];
309 $reqdeposit_nominal = $_POST['reqdeposit_nominal'];
310 $code = date("YmdHis"). '-reqdeposit';
311 $db->insert('mst_reqdeposit',array('customer_email'=>$customer_email,'account_mt4id'=>$account_mt4id, 'reqdeposit_bank'=>$reqdeposit_bank,
312 'reqdeposit_accountname'=>$reqdeposit_accountname,'reqdeposit_accountnumber'=>$reqdeposit_accountnumber,'reqdeposit_approval'=>'N'
313 , 'reqdeposit_approvalby'=>'', 'reqdeposit_code'=>$code, 'reqdeposit_nominal' =>$reqdeposit_nominal)); // Table name, column names and respective values
314 $res = $db->thisResult_();
315
316 if ($res == 1)
317 {
318 $arr = array('result' => 'Successfully Request Deposit', 'Error Code' => '');
319 // echo json_encode($arr);
320 header("location:feedback/ADfeedback.php?suc=Anda Telah Berhasil melakukan Request deposit");
321 }
322 else
323 {
324 $arr = array('result' => 'Failed Request Deposit', 'Error Code' => 'req deposit');
325 // echo json_encode($arr);
326 header("location:feedback/ADfeedback.php?err=Anda Telah gagal melakukan Request deposit");
327 }
328
329 break;
330 case "reqwitdraw":
331
332 $customer_email = $_POST['customer_email'];
333 $account_mt4id = $_POST['account_mt4id'];
334 $cardnumber_id = $_POST['cardnumber_id'];
335 $reqwithdraw_ammount = $_POST['reqwithdraw_ammount'];
336
337 $code = date("YmdHis"). '-reqwitdraw';
338
339 $target_dir = "uploads/";
340 $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
341 list($namefile, $ext) = explode(".", basename($_FILES["fileToUpload"]["name"]));
342 $target_file1 = $target_dir . date("YmdHis"). "." . $ext;
343 $uploadOk = 1;
344 $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
345 // Check if image file is a actual image or fake image
346 $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
347 if($check !== false) {
348 //echo "File is an image - " . $check["mime"] . ".";
349 $uploadOk = 1;
350 } else {
351 //echo "File is not an image.";
352 $uploadOk = 0;
353 }
354 if ($_FILES["fileToUpload"]["size"] > 500000) {
355 //echo "Sorry, your file is too large.";
356 $uploadOk = 0;
357 }
358 // Allow certain file formats
359 if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
360 && $imageFileType != "gif" ) {
361 //echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
362 $uploadOk = 0;
363 }
364 if ($uploadOk == 0) {
365 $arr = array('result' => 'Failed Request Witdraw', 'Error Code' => 'Please Check File Type and File Size, file upload must be image and size maksimum 5 mb');
366 echo json_encode($arr);
367 // if everything is ok, try to upload file
368 $temp_image = '';
369 } else {
370 if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file1)) {
371 $temp_image = date("YmdHis"). "." .$ext;
372 $db->insert('mst_reqwitdraw',array('customer_email'=>$customer_email,'account_mt4id'=>$account_mt4id, 'cardnumber_id'=>$cardnumber_id,
373 'reqwithdraw_ammount'=>$reqwithdraw_ammount,'reqwithdraw_screenshoot'=>$temp_image,'reqwithdraw_approval'=>'N'
374 , 'reqwithdraw_approvalby'=>'', 'reqwithdraw_code'=>$code)); // Table name, column names and respective values
375 $res = $db->thisResult_();
376
377 if ($res == 1)
378 {
379 $arr = array('result' => 'Successfully Request Witdraw', 'Error Code' => '');
380 // echo json_encode($arr);
381 header("location:feedback/AWfeedback.php?suc=Anda Telah Berhasil melakukan Request Withdraw");
382 }
383 else
384 {
385 $arr = array('result' => 'Failed Request Witdraw', 'Error Code' => 'Failed Insert to database');
386 // echo json_encode($arr);
387 header("location:feedback/AWfeedback.php?suc=Anda Telah Gagal melakukan Request Withdraw");
388 }
389
390 } else {
391 //echo "Sorry, there was an error uploading your file.";
392 $arr = array('result' => 'Failed Request Witdraw', 'Error Code' => 'Sorry, there was an error uploading your file.');
393 // echo json_encode($arr);
394 header("location:feedback/AWfeedback.php?suc=Anda Telah Gagal melakukan Request Withdraw");
395 }
396 }
397
398 break;
399
400case "reqaccount":
401
402 $customer_email = $_POST['customer_email'];
403 $account_type = $_POST['account_type'];
404 $account_mode = $_POST['account_mode'];
405
406 $db->insert('mst_account',array('customer_email'=>$customer_email,'account_type'=>$account_type, 'account_mt4id'=>'',
407 'account_approval'=>'N', 'account_approvalby'=>'N', 'account_mode'=>$account_mode)); // Table name, column names and respective values
408 $res = $db->thisResult_();
409
410 if ($res == 1)
411 {
412 $arr = array('result' => 'Successfully Request Deposit', 'Error Code' => '');
413 // echo json_encode($arr);
414 header("location:feedback/ARfeedback.php?suc=Anda Telah Berhasil melakukan Request Akun");
415 }
416 else
417 {
418 $arr = array('result' => 'Failed Request Deposit', 'Error Code' => 'req deposit');
419 header("location:feedback/ARfeedback.php?err=Gagal melakukan Request Akun'");
420 }
421
422 break;
423case "approve_account":
424 $account_id = $_POST['account_id'];
425 $account_approvalby = $_POST['account_approvalby']; //gunakan session admin yang login
426 //$customer_email = "maulanaoktofitriadi@gmail.com";
427 $customer_email = $_POST['customer_email'];
428 //create a database connection
429 mysql_connect("localhost","root","") or die("Error:".mysql_error());
430 //select your database
431 mysql_select_db("mst_cakra");
432 //create the query
433 $result_qry = mysql_query("select a.*, b.account_mode from mst_detailcustomer as a left outer join mst_account as b on b.customer_email =
434 a.customer_email where a.customer_email = '".$customer_email."' and b.account_id = '".$account_id."' Limit 1");
435
436 include('class/encrypt.php');
437 $fu_dec = new encrypt();
438 //return the array and loop through each row
439 while ($row = mysql_fetch_array($result_qry))
440 {
441 $name = $row['detailcustomer_fname'];
442 $country = $row['detailcustomer_country'];
443 $state = $row['detailcustomer_city'];
444 $city = $row['detailcustomer_city'];
445 $address = $row['detailcustomer_address'];
446 $password2 = $fu_dec->encrypt_decrypt('encrypt', $row['detailcustomer_fname']);
447 $password = substr($password2, 0, 8);
448 $phone = $row['detailcustomer_phone2'];
449 $account_mode = $row['account_mode'];
450 }
451
452
453 if ($account_mode == "live")
454 {
455 include('class/function_live.php');
456 $message = "action=createaccount&name=".$name."&email=".$customer_email."&group=CKRSTPUSD-000&leverage=100&country=".$country."&state=".$state."&address=".$address."&phone=".$phone."&city=".$city."&enable=168626701&password_investor=".$password."&password=".$password."&request_password=".$password."&hash=0\0 ";
457
458 }else
459 {
460 include('class/function.php');
461 $message = "action=createaccount&name=".$name."&email=".$customer_email."&group=demoCKRUSD-000&leverage=100&country=".$country."&state=".$state."&address=".$address."&phone=".$phone."&city=".$city."&enable=168626701&password_investor=".$password."&password=".$password."&request_password=".$password."&hash=0\0 ";
462
463 }
464
465 $fu = new api();
466 $fu->send_api($message);
467 $urlhitapi = $fu->thisResult_();
468 $urlresult = $fu->thisResult_api();
469 $ipaddr = $_SERVER['REMOTE_ADDR'];
470 if($fu->thisResult_bool() == true)
471 {
472 $string = preg_replace('/\.$/', '', $fu->thisResult_api());
473 $max_str = strlen($string);
474 $string = substr($string, 3, $max_str - 3);
475 $db->insert('mst_loghitapi',array('loghitapi_type'=>'Approval Account','loghitapi_refcode'=>$account_id, 'loghitapi_urlhit'=>$urlhitapi,
476 'loghitapi_urlrespon'=>$urlresult,'loghitapi_ipaddress'=>$ipaddr,'loghitapi_macaddress'=>''));
477 parse_str($string);
478 if ($result != 1)
479 {
480 $arr = array('result' => 'Failed Approval Account', 'Error Code' => 'Invalid Parameter API');
481 // echo json_encode($arr);
482 header ("location:admin_conaccount.php?err=Invalid Parameter API");
483 }else{
484 $db->update('mst_account',array('account_approval'=>"Y",'account_approvalby'=>$account_approvalby, 'account_mt4id'=>$login)
485 ,'account_id="'.$account_id.'"'); // Table name, column names and values, WHERE conditions
486 $res = $db->thisResult_();
487
488 require_once "mail/Mail.php";
489 //setup email
490 $from = '<noreply@cakramarkets.com>';
491 $to = '<'.$customer_email.'>';
492 $subject = 'Your MT4 Account In Cakramarkets';
493 //$password_decrypt = $fu->encrypt_decrypt("decrypt", $decpassword);
494 $body = "Hi,\n\nCongrats Your Account Actived Successfully, \n\nDetail Your Account Mt4 :\n\n LoginID = ".$login." \n \n Password Mt4 = ".$password." \n\n Thank your for registration. \n\n Best Regards,";
495
496 $headers = array(
497 'From' => $from,
498 'To' => $to,
499 'Subject' => $subject
500 );
501
502 $smtp = Mail::factory('smtp', array(
503 'host' => 'ssl://server167.web-hosting.com',
504 'port' => '465',
505 'auth' => true,
506 'username' => 'noreply@cakramarkets.com',
507 'password' => 'dadakan123'
508 ));
509
510 $mail = $smtp->send($to, $headers, $body);
511
512 if (PEAR::isError($mail)) {
513 //$arr = array('result' => 'Successfully Create Account', 'Email Status' => $mail->getMessage());
514 } else {
515 //$arr = array('result' => 'Successfully Create Account', 'Email Status' => 'Successfully Send email');
516 }
517 //echo json_encode($arr);
518
519 if ($res == 1)
520 {
521 $arr = array('result' => 'Successfully Approval Account', 'Error Code' => '');
522 // echo json_encode($arr);
523 header ("location:admin_conaccount.php?suc=Account Approved");
524 }
525 else
526 {
527 $arr = array('result' => 'Failed Approval Account', 'Error Code' => 'Cannot insert to database');
528 // echo json_encode($arr);
529 header ("location:admin_conaccount.php?err=Cannot Insert To Database");
530 }
531 }
532 }
533 else
534 {
535 $arr = array('result' => 'Failed Approval Account', 'Error Code' => 'Sorry, cannot accsess API');
536 // echo json_encode($arr);
537 header ("location:admin_conaccount.php?err=Cannot Access API");
538 }
539
540 break;
541
542case "approve_deposit":
543 $reqdeposit_id = $_POST['reqdeposit_id'];
544 $reqdeposit_approvalby = $_POST['reqdeposit_approvalby']; //gunakan session admin yang login
545 mysql_connect("localhost","root","") or die("Error:".mysql_error());
546 //select your database
547 mysql_select_db("mst_cakra");
548 //create the query
549 $result_qry = mysql_query("select a.*, b.account_mode from mst_reqdeposit as a left outer join mst_account as b on b.account_mt4id = a.account_mt4id where a.reqdeposit_id = '".$reqdeposit_id."' Limit 1");
550
551 //return the array and loop through each row
552 while ($row = mysql_fetch_array($result_qry))
553 {
554 $account_mt4id = $row['account_mt4id'];
555 $reqdeposit_nominal = $row['reqdeposit_nominal'];
556 $reqdeposit_code = $row['reqdeposit_code'];
557 $customer_email2 = $row['customer_email'];
558 $customer_email = rtrim($customer_email2);
559 $account_mode = $row['account_mode'];
560 }
561
562 if ($account_mode == "live")
563 {
564 include('class/function_live.php');
565 }else
566 {
567 include('class/function.php');
568 }
569 $fu = new api();
570 $message = "action=changebalance&login=".$account_mt4id."&value=".$reqdeposit_nominal."&comment=ok";
571 //echo $message;
572 $fu->send_api($message);
573 $urlhitapi = $fu->thisResult_();
574 $urlresult = $fu->thisResult_api();
575 $ipaddr = $_SERVER['REMOTE_ADDR'];
576 if($fu->thisResult_bool() == true)
577 {
578 $string = preg_replace('/\.$/', '', $fu->thisResult_api());
579 $max_str = strlen($string);
580 $string = substr($string, 3, $max_str - 4);
581 $db->insert('mst_loghitapi',array('loghitapi_type'=>'Approval Deposit','loghitapi_refcode'=>$reqdeposit_code, 'loghitapi_urlhit'=>$urlhitapi,
582 'loghitapi_urlrespon'=>$urlresult,'loghitapi_ipaddress'=>$ipaddr,'loghitapi_macaddress'=>''));
583
584 parse_str($string);
585 if ($result != 1)
586 {
587 $arr = array('result' => 'Failed Approval Deposit', 'Error Code' => 'Invalid Parameter API');
588 header ("location:admin_condeposit.php?err=Invalid Parameter API");
589 }else{
590 $db->update('mst_reqdeposit',array('reqdeposit_approval'=>"Y",'reqdeposit_approvalby'=>$reqdeposit_approvalby, 'account_mt4id'=>$account_mt4id)
591 , 'reqdeposit_code="'.$reqdeposit_code.'"'); // Table name, column names and values, WHERE conditions
592 $res = $db->thisResult_();
593
594 require_once "mail/Mail.php";
595 //setup email
596 $from = '<noreply@cakramarkets.com>';
597 $to = '<'.$customer_email.'>';
598 $subject = 'Your MT4 Account Successfully Deposit';
599 //$password_decrypt = $fu->encrypt_decrypt("decrypt", $decpassword);
600 $body = "Hi,\n\nCongrats Your Account MT4 ( ".$account_mt4id.") Successfully Deposit, \n\nDetail Your Transaction Mt4 :\n\n LoginID = ".$account_mt4id." \n \n Nominal = ".$reqdeposit_nominal." \n\n Requesst Code = ".$reqdeposit_code." \n\n Thank your.. \n\n Best Regards,";
601
602 $headers = array(
603 'From' => $from,
604 'To' => $to,
605 'Subject' => $subject
606 );
607
608 $smtp = Mail::factory('smtp', array(
609 'host' => 'ssl://server167.web-hosting.com',
610 'port' => '465',
611 'auth' => true,
612 'username' => 'noreply@cakramarkets.com',
613 'password' => 'dadakan123'
614 ));
615
616 $mail = $smtp->send($to, $headers, $body);
617
618 if (PEAR::isError($mail)) {
619 //$arr = array('result' => 'Successfully Create Account', 'Email Status' => $mail->getMessage());
620 } else {
621 //$arr = array('result' => 'Successfully Create Account', 'Email Status' => 'Successfully Send email');
622 }
623 //echo json_encode($arr);
624
625
626 if ($res == 1)
627 {
628 $arr = array('result' => 'Successfully Approval Deposit', 'Error Code' => '');
629 // echo json_encode($arr);
630 header ("location:admin_condeposit.php?suc=Deposit Approved");
631 }
632 else
633 {
634 $arr = array('result' => 'Failed Approval Deposit', 'Error Code' => 'Cannot insert to database');
635 // echo json_encode($arr);
636 header ("location:admin_condeposit.php?err=Cannot Insert to Database");
637 }
638 }
639 }
640 else
641 {
642 $arr = array('result' => 'Failed Approval Deposit', 'Error Code' => 'Sorry, cannot accsess API');
643 // echo json_encode($arr);
644 header ("location:admin_condeposit.php?err=Cannot Access API");
645 }
646
647break;
648
649case "approve_wit":
650 $reqwithdraw_id = $_POST['reqwithdraw_id'];
651 $reqwithdraw_approvalby = $_POST['reqwithdraw_approvalby']; //gunakan session admin yang login
652 mysql_connect("localhost","root","") or die("Error:".mysql_error());
653 //select your database
654 mysql_select_db("mst_cakra");
655 //create the query
656 $result_qry = mysql_query("select a.*, b.account_mode from mst_reqwitdraw as a left outer join mst_account as b
657 on b.account_mt4id = a.account_mt4id where a.reqwithdraw_id = '".$reqwithdraw_id."' Limit 1");
658
659 //return the array and loop through each row
660 while ($row = mysql_fetch_array($result_qry))
661 {
662 $account_mt4id = $row['account_mt4id'];
663 $reqwithdraw_ammount = $row['reqwithdraw_ammount'];
664 $reqwithdraw_code = $row['reqwithdraw_code'];
665 $customer_email2 = $row['customer_email'];
666 $customer_email = rtrim($customer_email2);
667 $account_mode = $row['account_mode'];
668 }
669
670 if ($account_mode == "live")
671 {
672 include('class/function_live.php');
673 }else
674 {
675 include('class/function.php');
676 }
677 $fu = new api();
678 $message = "action=changebalance&login=".$account_mt4id."&value=-".$reqwithdraw_ammount."&comment=ok";
679 //echo $message;
680 $fu->send_api($message);
681 $urlhitapi = $fu->thisResult_();
682 $urlresult = $fu->thisResult_api();
683 $ipaddr = $_SERVER['REMOTE_ADDR'];
684 if($fu->thisResult_bool() == true)
685 {
686 $string = preg_replace('/\.$/', '', $fu->thisResult_api());
687 $max_str = strlen($string);
688 $string = substr($string, 3, $max_str - 4);
689 $db->insert('mst_loghitapi',array('loghitapi_type'=>'Approval Witdraw','loghitapi_refcode'=>$reqwithdraw_code, 'loghitapi_urlhit'=>$urlhitapi,
690 'loghitapi_urlrespon'=>$urlresult,'loghitapi_ipaddress'=>$ipaddr,'loghitapi_macaddress'=>''));
691 parse_str($string);
692 if ($result != 1)
693 {
694 $arr = array('result' => 'Failed Approval Witdraw', 'Error Code' => 'Invalid Parameter API');
695 header ("location:admin_conwithdrawal.php?err=Invalid Parameter API");
696 }else{
697 $db->update('mst_reqwitdraw',array('reqwithdraw_approval'=>"Y",'reqwithdraw_approvalby'=>$reqwithdraw_approvalby, 'account_mt4id'=>$account_mt4id)
698 , 'reqwithdraw_code="'.$reqwithdraw_code.'"'); // Table name, column names and values, WHERE conditions
699 $res = $db->thisResult_();
700
701 require_once "mail/Mail.php";
702 //setup email
703 $from = '<noreply@cakramarkets.com>';
704 $to = '<'.$customer_email.'>';
705 $subject = 'Your MT4 Account Successfully Withdrawal';
706 //$password_decrypt = $fu->encrypt_decrypt("decrypt", $decpassword);
707 $body = "Hi,\n\nCongrats Your Account MT4 ( ".$account_mt4id.") Successfully Withdrawal, \n\nDetail Your Transaction Mt4 :\n\n LoginID = ".$account_mt4id." \n \n Nominal = ".$reqwithdraw_ammount." \n\n Requesst Code = ".$reqwithdraw_code." \n\n Thank your.. \n\n Best Regards,";
708
709 $headers = array(
710 'From' => $from,
711 'To' => $to,
712 'Subject' => $subject
713 );
714
715 $smtp = Mail::factory('smtp', array(
716 'host' => 'ssl://server167.web-hosting.com',
717 'port' => '465',
718 'auth' => true,
719 'username' => 'noreply@cakramarkets.com',
720 'password' => 'dadakan123'
721 ));
722
723 $mail = $smtp->send($to, $headers, $body);
724
725 if (PEAR::isError($mail)) {
726 //$arr = array('result' => 'Successfully Create Account', 'Email Status' => $mail->getMessage());
727 } else {
728 //$arr = array('result' => 'Successfully Create Account', 'Email Status' => 'Successfully Send email');
729 }
730 //echo json_encode($arr);
731
732 if ($res == 1)
733 {
734 $arr = array('result' => 'Successfully Approval Witdraw', 'Error Code' => '');
735 // echo json_encode($arr);
736 header ("location:admin_conwithdrawal.php?suc=Withdrawal Approved");
737 }
738 else
739 {
740 $arr = array('result' => 'Failed Approval Witdraw', 'Error Code' => 'Cannot insert to database');
741 // echo json_encode($arr);
742 header ("location:admin_conwithdrawal.php?err=Cannot Insert To Database");
743 }
744 }
745 }
746 else
747 {
748 $arr = array('result' => 'Failed Approval Witdraw', 'Error Code' => 'Sorry, cannot accsess API');
749 // echo json_encode($arr);
750 header ("location:admin_conwithdrawal.php?err=Cannot Access API");
751 }
752
753break;
754
755case "transfer":
756
757 $customer_email = $_POST['customer_email'];
758 $transfer_mt4idfrom = $_POST['transfer_mt4idfrom'];
759 $transfer_mt4idto = $_POST['transfer_mt4idto'];
760 $transfer_nominal = $_POST['transfer_nominal'];
761 $code = 'TFR-'. date("YmdHis");
762 mysql_connect("localhost","root","") or die("Error:".mysql_error());
763 //checking account mode
764 mysql_select_db("mst_cakra");
765 $result_qry = mysql_query("select * from mst_account where account_mt4id = '".$transfer_mt4idfrom."' and customer_email = '".$customer_email."' Limit 1");
766 while ($row = mysql_fetch_array($result_qry))
767 {
768 $from_mode = $row['account_mode'];
769 }
770 $num_rows = mysql_num_rows($result_qry);
771 $result_qry2 = mysql_query("select * from mst_account where account_mt4id = '".$transfer_mt4idto."' and customer_email = '".$customer_email."' Limit 1");
772 while ($row2 = mysql_fetch_array($result_qry2))
773 {
774 $to_mode = $row2['account_mode'];
775 }
776 $num_rows2 = mysql_num_rows($result_qry2);
777
778 if (($from_mode != $to_mode ) || ($num_rows == 0) || ($num_rows2 == 0))
779 {
780 $arr = array('result' => 'Failed Transfer Balance', 'Error Code' => 'Sorry Your Account Do not Match mode');
781 echo json_encode($arr);
782 }
783 else{
784
785 if ($to_mode == "live")
786 {
787 include('class/function_live.php');
788 }else
789 {
790 include('class/function.php');
791 }
792 $fu = new api();
793 $message = "action=getaccountbalance&login=".$transfer_mt4idfrom." ";
794 $fu->send_api($message);
795 $urlhitapi = $fu->thisResult_();
796 $urlresult = $fu->thisResult_api();
797
798
799 if($fu->thisResult_bool() == true)
800 {
801 $string = preg_replace('/\.$/', '', $fu->thisResult_api());
802 $max_str = strlen($string);
803 $string = substr($string, 3, $max_str - 4);
804 $db->insert('mst_loghitapi',array('loghitapi_type'=>'Transfer Balance','loghitapi_refcode'=>$code, 'loghitapi_urlhit'=>$urlhitapi,
805 'loghitapi_urlrespon'=>$urlresult,'loghitapi_ipaddress'=>'','loghitapi_macaddress'=>''));
806
807 parse_str($string);
808 if ($result != 1)
809 {
810 $arr = array('result' => 'Failed Transfer Balance', 'Error Code' => 'Invalid Parameter API');
811 echo json_encode($arr);
812 //header ("location:condeposit.php?err=Invalid Parameter API");
813 }else{
814
815 if($balance < $transfer_nominal)
816 {
817 $arr = array('result' => 'Failed Transfer Balance', 'Error Code' => 'Request Transfer more less then nominal');
818 echo json_encode($arr);
819 }
820 else
821 {
822 $fu2 = new api();
823 $message2 = "action=transferbalance&receiver_logins=".$transfer_mt4idto."&receiver_comment=ok&from_logins=".$transfer_mt4idfrom."&from_comment=ok&amount=".$transfer_nominal."";
824 $fu2->send_api($message2);
825 $urlhitapi = $fu2->thisResult_();
826 $urlresult = $fu2->thisResult_api();
827
828 $string = preg_replace('/\.$/', '', $fu2->thisResult_api());
829 $max_str = strlen($string);
830 $string = substr($string, 3, $max_str - 4);
831 $db->insert('mst_loghitapi',array('loghitapi_type'=>'Transfer Balance','loghitapi_refcode'=>$code, 'loghitapi_urlhit'=>$urlhitapi,
832 'loghitapi_urlrespon'=>$urlresult,'loghitapi_ipaddress'=>'','loghitapi_macaddress'=>''));
833
834 parse_str($string);
835 echo $urlhitapi;
836 echo "</br>";
837 echo $urlresult;
838 echo "</br>";
839
840 if($fu->thisResult_bool() == true)
841 {
842
843 if ($result != 1)
844 {
845 $arr = array('result' => 'Failed Transfer Balance', 'Error Code' => 'Invalid Parameter API');
846 echo json_encode($arr);
847 //header ("location:condeposit.php?err=Invalid Parameter API");
848 }else{
849
850 $db->insert('mst_transfer',array('transfer_code'=>$code,'transfer_email'=>$customer_email,
851 'transfer_mt4idfrom'=>$transfer_mt4idfrom, 'transfer_mt4idto'=>$transfer_mt4idto, 'transfer_nominal'=>$transfer_nominal)); // Table name, column names and respective values
852 $res = $db->thisResult_();
853
854 if ($res == 1)
855 {
856 $arr = array('result' => 'Successfully Transfer Balance', 'Error Code' => '');
857 echo json_encode($arr);
858 //header ("location:condeposit.php?suc=Deposit Approved");
859 }
860 else
861 {
862 $arr = array('result' => 'Failed Transfer Balance', 'Error Code' => 'Cannot insert to database');
863 echo json_encode($arr);
864 //header ("location:condeposit.php?err=Cannot Insert to Database");
865 }
866
867 }
868 }
869 else
870 {
871 $arr = array('result' => 'Failed Transfer Balance', 'Error Code' => 'Failed Request From Server');
872 echo json_encode($arr);
873 }
874
875 }
876
877 }
878 }
879 else
880 {
881 $arr = array('result' => 'Failed Transfer Balance', 'Error Code' => 'Sorry, cannot accsess API');
882 echo json_encode($arr);
883 //header ("location:conaccount.php?err=Cannot Access API");
884 }
885 }
886
887 break;
888
889 case "test_api":
890 include('class/function.php');
891 $from = strtotime('2015-08-01');
892 $to = strtotime('2015-09-01');
893 $message = "action=getbalancesoperations&login=2090018771&from=1438387200&to=1439769600";
894 $fu = new api();
895 $fu->send_api($message);
896 //list($url, $result_api) = explode("#", $fu->thisResult_());
897 $string = preg_replace('/\.$/', '', $fu->thisResult_api()); //Remove dot at end if exists
898 //$string = $fu->thisResult_api(); //Remove dot at end if exists
899 $array = explode('&', $string); //split string into array seperated by ', '
900 parse_str($string);
901 $cart[] = array('login' => $login,'size' => $size);
902 $max_str = strlen($size);
903 //echo substr($size, 4, $max_str - 4);
904 //echo $max_str;
905 //echo explode(" ",substr($size, 4, $max_str - 4));
906 //echo "<br />". $size;
907 $array = explode(' ', substr($size, 4, $max_str - 4)); //split string into array seperated by ', '
908 $text = substr($size, 4, $max_str - 4);
909 $vegetables = explode("\n", $text);
910
911 //for($a=0; $a<=count($vegetables); $a++)
912 //{
913 $a = 1;
914 $values = [5];
915 foreach($vegetables as $value) //loop over values
916 {
917 list($ticket, $profit, $open_time, $comment) = explode(";", $value);
918
919 $nyoy2[] = array($a=>array
920 (
921 "ticket" => $ticket,
922 "profit" => $profit,
923 "open_time" => $open_time,
924 "comment" => $comment
925 ));
926 $a = $a + 1;
927 }
928
929 //}
930
931 echo json_encode( $nyoy2 );
932
933 //var_dump($vegetables);
934 //echo json_encode( $data );
935 //echo "<br />";
936 //echo $fu->thisResult_api();
937 break;
938
939 default:
940 echo "Please input the command";
941}
942
943
944//$data = $db->escapeString("name5@email.com"); // Escape any input before insert
945//$db->insert('CRUDClass',array('name'=>'Name 5','email'=>$data)); // Table name, column names and respective values
946//$res = $db->getResult();
947//print_r($res);
948?>