/var/www/hkosl.com/imusiccircle/fastpaypal.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
<?php
    
include('_init.php');

    if (
$_POST) {
        
$time $_POST['time'];;
        
$instrument $_POST['instrument'];;
        
$level       $_POST['level'];
        
$tutor       $_POST['tutor'];
        
$coupon_code strtoupper($_POST['code']);
        if (
$_SESSION["is_student"] == 1) {
            if (
$time && $instrument && $level && $tutor) {
                unset(
$order_data);

                
$sql        "select id from tutor_charge where tutormain_id = '" aes_crypt($tutor2) . "' and mas_instrument = '" aes_crypt($instrument2) . "' and deleted = 0";
                
$parameters = array();
                
$row        bind_pdo($sql$parameters"selectone");

                
$sql              "select charge_" aes_crypt($time2) . "min as fee from tutor_expectcharge where type = 'tfee' and  charge_id = '" $row['id'] . "' and deleted = 0";
                
$row_expectcharge bind_pdo($sql$parameters"selectone");

                
$sql         "select count(*)+1 as maxcount from `order`";
                
$parameters  = array();
                
$row_orderno bind_pdo($sql$parameters"selectone");

                
$sql            "select name_en from master_type_code where id = ? and typeid = 'INSTRUMENT' LIMIT 1";
                
$parameters     = array(aes_crypt($instrument2));
                
$row_instrument bind_pdo($sql$parameters"selectone");

                
$order_data['id']                = $row_orderno['maxcount'];
                
$order_data['order_type']        = 'try';
                
$invoiceNo                       'OT' date('ymd') . sprintf("%06d"$order_data['id']);
                
$order_data['order_no']          = $invoiceNo;
                
$order_data['studentmain_id']    = $_SESSION['student_login'];
                
$order_data['tutormain_id']      = aes_crypt($tutor2);
                
$order_data['job_id']            = 0;
                
$order_data['course_venus']      = 0;
                
$order_data['level']             = aes_crypt($level2);
                
$order_data['mas_instrument']    = aes_crypt($instrument2);
                
$order_data['mas_residencecode'] = 0;
                
$order_data['course_count']      = 2;
                
$order_data['course_length']     = aes_crypt($time2);
                
$order_data['fee']               = $row_expectcharge['fee'];
                
$fee                             $row_expectcharge['fee'] * 2;
                if (
$coupon_code) {
                    
//hardcode for fixed price to $X
                    
if ((strtoupper($coupon_code) == "INKY20" || strtoupper($coupon_code) == "IMC$20")) {
                        
$amount 20;
                    } else {
                        
$sql        "select id,discount_type,number from coupon where coupon_code = ? and status = ? and limit_type = ?";
                        
$parameters = array($coupon_code1'try');
                        
$row_coupon bind_pdo($sql$parameters"selectone");
                        if (
$row_coupon['id']) {
                            
$order_data['coupon_code'] = $coupon_code;
                            if (
$row_coupon['discount_type'] == 'rate') {
                                
$order_data['coupon_fee'] = $fee - ($fee * ($row_coupon['number'] / 100));
                            } else if (
$row_coupon['discount_type'] == 'cash') {
                                
$order_data['coupon_fee'] = $fee - ($fee $row_coupon['number']);
                            }
                            
$amount $fee $order_data['coupon_fee'];
                        }
                    }


                } else {
                    
$amount $fee;
                }
                
$order_data['total_fee']  = $row_expectcharge['fee'] * 2;
                
$order_data['extra_fee']  = 0;
                
$order_data['from_type']  = 'student';
                
$order_data['lastupdate'] = date('Y-m-d H:i:s');
                
$order_data['createdate'] = date('Y-m-d H:i:s');
                
$order_data['status']     = 'approved';
                
$sql                      mysql_install($order_data'order''add');
                
$arraykey                 array_keys($order_data);
                unset(
$parameters);
                for (
$i 0$i count($arraykey); $i++) {
                    
$parameters[$i] = $order_data[$arraykey[$i]];
                }
                
bind_pdo($sql$parameters);
                
$shipping_price 0;
                
//$amount         = intval($row['total_fee']) - intval($row['coupon_fee']);
                //$invoiceNo      = $row['order_no'];
                //$amount = 0.1;
                
$extra_url    EXTRA_URL;
                
$paypal_url   PAYPAL_URL;
                
$paypal_array = array('cmd'           => '_xclick',
                                      
'upload'        => '1',
                                      
'custom'        => $order_data['id'],
                                      
'invoice'       => $invoiceNo,
                                      
'business'      => PAYPAL_BUSINESS,
                                      
'item_name'     => $row_instrument['name_en'] . ' - Course Fee',
                    
//'item_name'        =>'a',
                                      
'item_number'   => $invoiceNo,
                                      
'currency_code' => 'HKD',
                                      
'shipping'      => $shipping_price,
                                      
'no_shipping'   => 1,
                                      
'amount'        => $amount,
                    
//'image_url'        =>$GLOBALS['site_info']['full_path'].'images/logo.png',
                                      
'return'        => 'http://' $_SERVER['HTTP_HOST'] . '/' $extra_url 'webadmin/order_form.php?id=' $row['id'],
                                      
'notify_url'    => 'http://' $_SERVER['HTTP_HOST'] . '/' $extra_url 'paypal_notify.php',
                                      
'cancel_return' => 'http://' $_SERVER['HTTP_HOST'] . '/' $extra_url 'webadmin/order_form.php?id=' $row['id']
                );
                
$array        = array();
                foreach (
$paypal_array as $name => $data) {
                    
$array[] = $name '=' urlencode($data);
                }
                
$path $paypal_url '?' implode('&'$array);
                @
header("Location: {$path}");
                echo 
"<script language='JavaScript'>window.location='{$path}'</script>";
                exit();
            }
        } else {
            if (
$time && $instrument && $level && $tutor) {

                
$sql        "select id from tutor_charge where tutormain_id = '" aes_crypt($tutor2) . "' and mas_instrument = '" aes_crypt($instrument2) . "' and deleted = 0";
                
$parameters = array();
                
$row        bind_pdo($sql$parameters"selectone");

                
$sql        "select id,nickname,tutor_no from tutor_main where id = '" aes_crypt($tutor2) . "' and deleted = 0";
                
$parameters = array();
                
$row_tutor  bind_pdo($sql$parameters"selectone");

                
$sql              "select charge_" aes_crypt($time2) . "min as fee from tutor_expectcharge where type = 'tfee' and  charge_id = '" $row['id'] . "' and deleted = 0";
                
$row_expectcharge bind_pdo($sql$parameters"selectone");

                
$sql            "select name_en,name_cn from master_type_code where id = ? and typeid = 'INSTRUMENT' LIMIT 1";
                
$parameters     = array(aes_crypt($instrument2));
                
$row_instrument bind_pdo($sql$parameters"selectone");

                if (
aes_crypt($level2) == 1) {
                    
$levelname '1 - 2';
                } else if (
aes_crypt($level2) == 2) {
                    
$levelname '3 - 5';
                } else {
                    
$levelname '6級或以上';
                }

                
$msg '上課時數: ' aes_crypt($time2) . '分鐘<br>
                    樂器: ' 
$row_instrument['name_cn'] . '<br>
                    級別: ' 
$levelname '<br>
                    期望導師: <a href="../profile.php?id=' 
$row_tutor['id'] . '">' $row_tutor['nickname'] . ' ( ' $row_tutor['tutor_no'] . ' )</a><br>
                    電郵: ' 
$_POST['email'] . '<br>
                    電話: ' 
$_POST['tel'];
                unset(
$data);
                
$data['type']       = 'fasttry';
                
$data['msg']        = $msg;
                
$data['lastupdate'] = date('Y-m-d H:i:s');
                
$data['status']     = 1;
                
$data['deleted']    = 0;
                
$sql                mysql_install($data'admin_msg''add');
                
$arraykey           array_keys($data);
                unset(
$parameters);
                for (
$i 0$i count($arraykey); $i++) {
                    
$parameters[$i] = $data[$arraykey[$i]];
                }
                
bind_pdo($sql$parameters);

                
$path                    $_SERVER['HTTP_REFERER'];
                
$_SESSION['profile_msg'] = true;
                @
header("Location: {$path}");
                echo 
"<script language='JavaScript'>window.location='{$path}'</script>";
                exit();
            }
        }
    }
    exit();
?>