@@ -34,13 +34,17 @@ discard block |
||
| 34 | 34 | $query = isset($options['query']) ? |
| 35 | 35 | array_filter($options['query']) : array(); |
| 36 | 36 | |
| 37 | - if (sizeof($query)==0) return null; |
|
| 37 | + if (sizeof($query)==0) { |
|
| 38 | + return null; |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | 41 | $body = isset($options['body']) ? |
| 40 | 42 | array_filter($options['body']) : null; |
| 41 | 43 | |
| 42 | 44 | $fname = isset($body['strFilename']) ? $body['strFilename'] : ''; |
| 43 | - if ($fname=='') return null; |
|
| 45 | + if ($fname=='') { |
|
| 46 | + return null; |
|
| 47 | + } |
|
| 44 | 48 | |
| 45 | 49 | $rpath = realpath($fname); |
| 46 | 50 | |
@@ -110,7 +114,9 @@ discard block |
||
| 110 | 114 | } |
| 111 | 115 | |
| 112 | 116 | if (isset($options['HTTPHEADERS'])) { |
| 113 | - foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header; |
|
| 117 | + foreach ($options['HTTPHEADERS'] As $header) { |
|
| 118 | + $headers[]=$header; |
|
| 119 | + } |
|
| 114 | 120 | } |
| 115 | 121 | //self::simplePrint($headers); die(""); |
| 116 | 122 | $ch = curl_init(); |
@@ -123,7 +129,9 @@ discard block |
||
| 123 | 129 | //self::simplePrint($headers); die(""); |
| 124 | 130 | $baseUrl=self::getBaseUrl(); |
| 125 | 131 | |
| 126 | - if (strpos($url,'move_route_destination')>0) $baseUrl='https://www.route4me.com'; |
|
| 132 | + if (strpos($url,'move_route_destination')>0) { |
|
| 133 | + $baseUrl='https://www.route4me.com'; |
|
| 134 | + } |
|
| 127 | 135 | $curlOpts = arraY( |
| 128 | 136 | CURLOPT_URL => $baseUrl. $url, |
| 129 | 137 | CURLOPT_RETURNTRANSFER => true, |
@@ -199,14 +207,16 @@ discard block |
||
| 199 | 207 | if (200 == $code) { |
| 200 | 208 | if ($isxml) { |
| 201 | 209 | $json = $jxml; |
| 202 | - } else $json = json_decode($result, true); |
|
| 210 | + } else { |
|
| 211 | + $json = json_decode($result, true); |
|
| 212 | + } |
|
| 203 | 213 | //var_dump($json); die(""); |
| 204 | 214 | if (isset($json['errors'])) { |
| 205 | 215 | throw new ApiError(implode(', ', $json['errors'])); |
| 206 | 216 | } else { |
| 207 | 217 | return $json; |
| 208 | 218 | } |
| 209 | - } elseif (409 == $code) { |
|
| 219 | + } elseif (409 == $code) { |
|
| 210 | 220 | |
| 211 | 221 | //throw new ApiError('Wrong API key'); |
| 212 | 222 | } else { |
@@ -288,7 +298,9 @@ discard block |
||
| 288 | 298 | |
| 289 | 299 | if ($isxml) { |
| 290 | 300 | $json = $jxml; |
| 291 | - } else $json = json_decode($result, true); |
|
| 301 | + } else { |
|
| 302 | + $json = json_decode($result, true); |
|
| 303 | + } |
|
| 292 | 304 | |
| 293 | 305 | |
| 294 | 306 | if (200 == $code) { |
@@ -189,18 +189,26 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | public static function validateLatitude($lat) |
| 191 | 191 | { |
| 192 | - if (!is_numeric($lat)) return false; |
|
| 192 | + if (!is_numeric($lat)) { |
|
| 193 | + return false; |
|
| 194 | + } |
|
| 193 | 195 | |
| 194 | - if ($lat>90 || $lat<-90) return false; |
|
| 196 | + if ($lat>90 || $lat<-90) { |
|
| 197 | + return false; |
|
| 198 | + } |
|
| 195 | 199 | |
| 196 | 200 | return true; |
| 197 | 201 | } |
| 198 | 202 | |
| 199 | 203 | public static function validateLongitude($lng) |
| 200 | 204 | { |
| 201 | - if (!is_numeric($lng)) return false; |
|
| 205 | + if (!is_numeric($lng)) { |
|
| 206 | + return false; |
|
| 207 | + } |
|
| 202 | 208 | |
| 203 | - if ($lng>180 || $lng<-180) return false; |
|
| 209 | + if ($lng>180 || $lng<-180) { |
|
| 210 | + return false; |
|
| 211 | + } |
|
| 204 | 212 | |
| 205 | 213 | return true; |
| 206 | 214 | } |
@@ -231,8 +239,9 @@ discard block |
||
| 231 | 239 | array_push($results['fail'],"$iRow --> Wrong cached_lat"); |
| 232 | 240 | $iRow++; |
| 233 | 241 | continue; |
| 242 | + } else { |
|
| 243 | + $cached_lat=doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
| 234 | 244 | } |
| 235 | - else $cached_lat=doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
| 236 | 245 | |
| 237 | 246 | $cached_lng=0.000; |
| 238 | 247 | |
@@ -240,8 +249,9 @@ discard block |
||
| 240 | 249 | array_push($results['fail'],"$iRow --> Wrong cached_lng"); |
| 241 | 250 | $iRow++; |
| 242 | 251 | continue; |
| 252 | + } else { |
|
| 253 | + $cached_lng=doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
| 243 | 254 | } |
| 244 | - else $cached_lng=doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
| 245 | 255 | |
| 246 | 256 | |
| 247 | 257 | |
@@ -263,10 +273,18 @@ discard block |
||
| 263 | 273 | |
| 264 | 274 | $address=$rows[$ordersFieldsMapping['address_1']]; |
| 265 | 275 | |
| 266 | - if (isset($ordersFieldsMapping['order_city'])) $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
| 267 | - if (isset($ordersFieldsMapping['order_state_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
| 268 | - if (isset($ordersFieldsMapping['order_zip_code'])) $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
| 269 | - if (isset($ordersFieldsMapping['order_country_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
| 276 | + if (isset($ordersFieldsMapping['order_city'])) { |
|
| 277 | + $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
| 278 | + } |
|
| 279 | + if (isset($ordersFieldsMapping['order_state_id'])) { |
|
| 280 | + $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
| 281 | + } |
|
| 282 | + if (isset($ordersFieldsMapping['order_zip_code'])) { |
|
| 283 | + $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
| 284 | + } |
|
| 285 | + if (isset($ordersFieldsMapping['order_country_id'])) { |
|
| 286 | + $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
| 287 | + } |
|
| 270 | 288 | |
| 271 | 289 | echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
| 272 | 290 | |
@@ -298,8 +316,7 @@ discard block |
||
| 298 | 316 | $orderResults = $order->addOrder($orderParameters); |
| 299 | 317 | |
| 300 | 318 | array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
| 301 | - } |
|
| 302 | - else { |
|
| 319 | + } else { |
|
| 303 | 320 | array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
| 304 | 321 | } |
| 305 | 322 | |
@@ -196,35 +196,52 @@ discard block |
||
| 196 | 196 | { |
| 197 | 197 | $schedMmodes=array("daily","weekly","monthly","annually"); |
| 198 | 198 | |
| 199 | - if (in_array($scheduleMode, $schedMmodes)) return TRUE; else return FALSE; |
|
| 199 | + if (in_array($scheduleMode, $schedMmodes)) { |
|
| 200 | + return TRUE; |
|
| 201 | + } else { |
|
| 202 | + return FALSE; |
|
| 203 | + } |
|
| 200 | 204 | } |
| 201 | 205 | |
| 202 | 206 | public static function validateScheduleEnable($scheduleEnabled) |
| 203 | 207 | { |
| 204 | 208 | $schedEnambles=array(TRUE,FALSE); |
| 205 | 209 | |
| 206 | - if (in_array($scheduleEnabled, $schedEnambles)) return TRUE; else return FALSE; |
|
| 210 | + if (in_array($scheduleEnabled, $schedEnambles)) { |
|
| 211 | + return TRUE; |
|
| 212 | + } else { |
|
| 213 | + return FALSE; |
|
| 214 | + } |
|
| 207 | 215 | } |
| 208 | 216 | |
| 209 | 217 | public static function validateScheduleEvery($scheduleEvery) |
| 210 | 218 | { |
| 211 | - if (is_numeric($scheduleEvery)) return TRUE; else return FALSE; |
|
| 219 | + if (is_numeric($scheduleEvery)) { |
|
| 220 | + return TRUE; |
|
| 221 | + } else { |
|
| 222 | + return FALSE; |
|
| 223 | + } |
|
| 212 | 224 | } |
| 213 | 225 | |
| 214 | 226 | public static function validateScheduleWeekDays($scheduleWeekDays) |
| 215 | 227 | { |
| 216 | 228 | $weekdays = explode(',', $scheduleWeekDays); |
| 217 | 229 | |
| 218 | - if (sizeof($weekdays)<1) return FALSE; |
|
| 230 | + if (sizeof($weekdays)<1) { |
|
| 231 | + return FALSE; |
|
| 232 | + } |
|
| 219 | 233 | |
| 220 | 234 | $isValid=TRUE; |
| 221 | 235 | |
| 222 | 236 | for ($i=0; $i < sizeof($weekdays); $i++) { |
| 223 | 237 | if (is_numeric($weekdays[$i])) { |
| 224 | 238 | $wday=intval($weekdays[$i]); |
| 225 | - if ($wday<1 || $wday>7) $isValid=FALSE; |
|
| 239 | + if ($wday<1 || $wday>7) { |
|
| 240 | + $isValid=FALSE; |
|
| 241 | + } |
|
| 242 | + } else { |
|
| 243 | + $isValid=FALSE; |
|
| 226 | 244 | } |
| 227 | - else $isValid=FALSE; |
|
| 228 | 245 | } |
| 229 | 246 | //echo $scheduleWeekDays.' --- '. $isValid."<br>"; |
| 230 | 247 | return $isValid; |
@@ -234,23 +251,32 @@ discard block |
||
| 234 | 251 | { |
| 235 | 252 | $schedMonthlyMmodes=array("dates","nth"); |
| 236 | 253 | |
| 237 | - if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) return TRUE; else return FALSE; |
|
| 254 | + if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
| 255 | + return TRUE; |
|
| 256 | + } else { |
|
| 257 | + return FALSE; |
|
| 258 | + } |
|
| 238 | 259 | } |
| 239 | 260 | |
| 240 | 261 | public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
| 241 | 262 | { |
| 242 | 263 | $monthlyDates = explode(',', $scheduleMonthlyDates); |
| 243 | 264 | |
| 244 | - if (sizeof($monthlyDates)<1) return FALSE; |
|
| 265 | + if (sizeof($monthlyDates)<1) { |
|
| 266 | + return FALSE; |
|
| 267 | + } |
|
| 245 | 268 | |
| 246 | 269 | $isValid=TRUE; |
| 247 | 270 | |
| 248 | 271 | for ($i=0; $i < sizeof($monthlyDates); $i++) { |
| 249 | 272 | if (is_numeric($monthlyDates[$i])) { |
| 250 | 273 | $mday=intval($monthlyDates[$i]); |
| 251 | - if ($mday<1 || $mday>31) $isValid=FALSE; |
|
| 274 | + if ($mday<1 || $mday>31) { |
|
| 275 | + $isValid=FALSE; |
|
| 276 | + } |
|
| 277 | + } else { |
|
| 278 | + $isValid=FALSE; |
|
| 252 | 279 | } |
| 253 | - else $isValid=FALSE; |
|
| 254 | 280 | } |
| 255 | 281 | |
| 256 | 282 | return $isValid; |
@@ -258,18 +284,30 @@ discard block |
||
| 258 | 284 | |
| 259 | 285 | public static function validateScheduleNthN($scheduleNthN) |
| 260 | 286 | { |
| 261 | - if (!is_numeric($scheduleNthN)) return FALSE; |
|
| 287 | + if (!is_numeric($scheduleNthN)) { |
|
| 288 | + return FALSE; |
|
| 289 | + } |
|
| 262 | 290 | |
| 263 | 291 | $schedNthNs=array(1,2,3,4,5,-1); |
| 264 | - if (in_array($scheduleNthN, $schedNthNs)) return TRUE; else return FALSE; |
|
| 292 | + if (in_array($scheduleNthN, $schedNthNs)) { |
|
| 293 | + return TRUE; |
|
| 294 | + } else { |
|
| 295 | + return FALSE; |
|
| 296 | + } |
|
| 265 | 297 | } |
| 266 | 298 | |
| 267 | 299 | public static function validateScheduleNthWhat($scheduleNthWhat) |
| 268 | 300 | { |
| 269 | - if (!is_numeric($scheduleNthWhat)) return FALSE; |
|
| 301 | + if (!is_numeric($scheduleNthWhat)) { |
|
| 302 | + return FALSE; |
|
| 303 | + } |
|
| 270 | 304 | |
| 271 | 305 | $schedNthWhats=array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
| 272 | - if (in_array($scheduleNthWhat, $schedNthWhats)) return TRUE; else return FALSE; |
|
| 306 | + if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
| 307 | + return TRUE; |
|
| 308 | + } else { |
|
| 309 | + return FALSE; |
|
| 310 | + } |
|
| 273 | 311 | } |
| 274 | 312 | |
| 275 | 313 | /* Function adds the locations (with/without schedule) from the CSV file. |
@@ -301,16 +339,13 @@ discard block |
||
| 301 | 339 | if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
| 302 | 340 | $schedule='"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
| 303 | 341 | $mode=$rows[$locationsFieldsMapping['schedule_mode']]; |
| 304 | - } |
|
| 305 | - else {array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); $schedule="";} |
|
| 306 | - } |
|
| 307 | - else {array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); $schedule="";} |
|
| 342 | + } else {array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); $schedule="";} |
|
| 343 | + } else {array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); $schedule="";} |
|
| 308 | 344 | |
| 309 | 345 | if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
| 310 | 346 | if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
| 311 | 347 | $schedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
| 312 | - } |
|
| 313 | - else {array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set "); $schedule="";} |
|
| 348 | + } else {array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set "); $schedule="";} |
|
| 314 | 349 | } |
| 315 | 350 | |
| 316 | 351 | if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
@@ -320,8 +355,7 @@ discard block |
||
| 320 | 355 | $schedule=trim($schedule,','); |
| 321 | 356 | $schedule.='}'; |
| 322 | 357 | } |
| 323 | - } |
|
| 324 | - else {array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); $schedule=""; } |
|
| 358 | + } else {array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); $schedule=""; } |
|
| 325 | 359 | } |
| 326 | 360 | |
| 327 | 361 | if ($mode!='daily') { |
@@ -330,10 +364,8 @@ discard block |
||
| 330 | 364 | if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
| 331 | 365 | if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
| 332 | 366 | $schedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
| 333 | - } |
|
| 334 | - else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $schedule="";} |
|
| 335 | - } |
|
| 336 | - else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $schedule="";} |
|
| 367 | + } else {array_push($results['fail'],"$iRow --> Wrong weekdays"); $schedule="";} |
|
| 368 | + } else {array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); $schedule="";} |
|
| 337 | 369 | break; |
| 338 | 370 | case 'monthly': |
| 339 | 371 | $monthlyMode=""; |
@@ -341,10 +373,8 @@ discard block |
||
| 341 | 373 | if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
| 342 | 374 | $monthlyMode=$rows[$locationsFieldsMapping['monthly_mode']]; |
| 343 | 375 | $schedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
| 344 | - } |
|
| 345 | - else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $schedule="";} |
|
| 346 | - } |
|
| 347 | - else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $schedule="";} |
|
| 376 | + } else {array_push($results['fail'],"$iRow --> Wrong monthly mode"); $schedule="";} |
|
| 377 | + } else {array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); $schedule="";} |
|
| 348 | 378 | |
| 349 | 379 | if ($monthlyMode!="") { |
| 350 | 380 | switch ($monthlyMode) { |
@@ -352,27 +382,22 @@ discard block |
||
| 352 | 382 | if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
| 353 | 383 | if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
| 354 | 384 | $schedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
| 355 | - } |
|
| 356 | - else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $schedule="";} |
|
| 385 | + } else {array_push($results['fail'],"$iRow --> Wrong monthly dates"); $schedule="";} |
|
| 357 | 386 | } |
| 358 | 387 | break; |
| 359 | 388 | case 'nth': |
| 360 | 389 | if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
| 361 | 390 | if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
| 362 | 391 | $schedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
| 363 | - } |
|
| 364 | - else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $schedule="";} |
|
| 365 | - } |
|
| 366 | - else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $schedule="";} |
|
| 392 | + } else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); $schedule="";} |
|
| 393 | + } else {array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); $schedule="";} |
|
| 367 | 394 | |
| 368 | 395 | if ($schedule!="") { |
| 369 | 396 | if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
| 370 | 397 | if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
| 371 | 398 | $schedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
| 372 | - } |
|
| 373 | - else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $schedule="";} |
|
| 374 | - } |
|
| 375 | - else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $schedule="";} |
|
| 399 | + } else {array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); $schedule="";} |
|
| 400 | + } else {array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); $schedule="";} |
|
| 376 | 401 | } |
| 377 | 402 | |
| 378 | 403 | break; |