-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabundatrade_pugin.php
executable file
·1006 lines (862 loc) · 44.3 KB
/
abundatrade_pugin.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* @package abundatrade_plugin
* @version 1.8.02
* @author Robert Landers ([email protected])
*/
/*
Plugin Name: Abundatrade Plugin
Plugin URI: http://wordpress.org/extend/plugins/abundatrade-plugin/
Description: Earn extra income for your site via the Abundatrade affiliate program!
Author: withinboredom
Version: 1.8.02
Author URI: http://withinboredom.info
*/
if (!defined("WP_CONTENT_DIR")) exit();
class abundatrade_withinboredom {
/**
*
* @var array The active folders
*/
private $folders;
/**
*
* @var array The settings
*/
public $settings;
/**
* Get all our folders and return them
*/
public function getFolders($folders )
{
return array_merge_recursive($this->folders, $folders);
}
/**
* Applies the configuration of the plugin
* @var array $config The config that is to be edited
* @return array The new config
*/
public function applyConfig($config) {
$config['tabs'] = array(
0 => array( 'Settings', 'tabs__settings_withinboredom'),
1 => array('About', 'tabs__about_withinboredom'),
2 => array('Support', 'tabs__support_withinboredom'),
);
$config['help'] = array(
// The tab to display on
'0' => array(
// The title content of the help menu
0 => array('Overview', "Basic settings for the Abundatrade Calculator."),
1 => array('Help', 'Enter your affiliate id and the location of your thank you page')
)
);
$config['config'] = array(
'settings' => true,
'page_title' => 'Abundatrade',
'button_title' => 'Abundatrade',
'slug' => 'abundatrade',
'shortcodes' => array(
'abundatrade'
),
);
return $config;
}
public function validate_required($name) {
if(isset($_REQUEST[$name]) && $_REQUEST[$name] == "") {
return false;
}
return true;
}
public function is_ssl() {
if(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) {
return 'https://';
}
return 'http://';
}
public function get_value($name) {
if(isset($_REQUEST[$name])) {
return $_REQUEST[$name];
}
return "";
}
public function isIE() {
preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches);
$use_labels = false;
if (count($matches)>1){
//Then we're using IE
$version = $matches[1];
$use_labels = true;
switch(true){
case ($version<=8):
//IE 8 or under!
$use_labels = true;
break;
case ($version==9):
//IE9!
$use_labels = true;
break;
case ($version == 10):
$use_labels = false;
default:
//You get the idea
}
}
return $use_labels;
}
public function gadget($atts) {
$closediv = "</div>";
$gad_cat = '';
$red = "style='border: 1px solid red'";
$all_valid = false;
$show_all = "style='display:none'";
$use_labels = $this->isIE();
if (isset($atts['gad_cat'])) {
$this->export = array('gad_cat' => $atts['gad_cat']);
}
if(isset($_REQUEST['gad_cat'])) {
if ($_REQUEST['gad_cat'] == -1) {
$gad_cat = $red;
}
$all_valid = true;
}
if(!$this->validate_required('my_name')) {
$name = $red;
$all_valid = false;
}
else {
}
if(!$this->validate_required('email')) {
$email = $red;
$all_valid = false;
}
else {
}
if(!$this->validate_required('address_street')) {
$address_street = $red;
$all_valid = false;
}
else {
}
if(!$this->validate_required('address_city')) {
$address_city = $red;
$all_valid = false;
}
else {
}
if(!$this->validate_required('address_state')) {
$address_state = $red;
$all_valid = false;
}
else {
}
if(!$this->validate_required('address_zip')) {
$address_zip = $red;
$all_valid = false;
}
else {
}
$dvd = array(
'-1' => 'Select Your Free CD and DVD',
'-2' => 'No Thank You',
'-3' => '-- DVDs --',
'Austin Powers in Goldmember' => 'Austin Powers in Goldmember',
'Barbershop 2: Back in Business (Special Edition)' => 'Barbershop 2: Back in Business (Special Edition)',
'Batman Begins (Single-Disc Widescreen Edition)' => 'Batman Begins (Single-Disc Widescreen Edition)',
'Superman Returns (Widescreen Edition)' => 'Superman Returns (Widescreen Edition)',
'King Kong (Widescreen Edition)' => 'King Kong (Widescreen Edition)',
'The Clique' => 'The Clique',
'Blade' => 'Blade',
'The Lord of the Rings: The Fellowship of the Ring (Two-Disc Widescreen Theatrical Edition)' => 'The Lord of the Rings: The Fellowship of the Ring (Two-Disc Widescreen Theatrical Edition)',
'The Matrix Reloaded (Full Screen Edition)' => 'The Matrix Reloaded (Full Screen Edition)',
'Welcome to Nanalan - Favorites' => 'Welcome to Nanalan - Favorites',
'-4' => '-- CDs --',
'Christina Aguilera -- Christina Aguilera' => 'Christina Aguilera -- Christina Aguilera',
'Our Time in Eden -- 10,000 Maniacs' => 'Our Time in Eden -- 10,000 Maniacs',
'Backstreet Boys -- Backstreet Boys' => 'Backstreet Boys -- Backstreet Boys',
'Rock Spectacle -- Barenaked Ladies' => 'Rock Spectacle -- Barenaked Ladies',
'Four -- Blues Traveler' => 'Four -- Blues Traveler',
'New Beginning -- Tracy Chapman' => 'New Beginning -- Tracy Chapman',
'Voice of an Angel -- Charlotte Church' => 'Voice of an Angel -- Charlotte Church',
'Recovering the Satellites -- Counting Crows' => 'Recovering the Satellites -- Counting Crows',
'Falling Into You -- Celine Dion' => 'Falling Into You -- Celine Dion',
'Yes I Am -- Melissa Etheridge' => 'Yes I Am -- Melissa Etheridge',
'New Miserable Experience -- Gin Blossoms' => 'New Miserable Experience -- Gin Blossoms',
'Cracked Rear View -- Hootie & The Blowfish' => 'Cracked Rear View -- Hootie & The Blowfish',
'Pieces of You -- Jewel' => 'Pieces of You -- Jewel',
'Ingenue -- KD Lang' => 'Ingenue -- KD Lang',
'Why I Sing the Blues -- BB King' => 'Why I Sing the Blues -- BB King',
'Throwing Copper -- Live.' => 'Throwing Copper -- Live.',
'Ray of Light -- Madonna' => 'Ray of Light -- Madonna',
'Jagged Little Pill -- Alanis Morissette' => 'Jagged Little Pill -- Alanis Morissette',
'Monster -- R.E.M.' => 'Monster -- R.E.M.',
'Mirrorball -- Sarah McLachlan' => 'Mirrorball -- Sarah McLachlan',
'Seal -- Seal' => 'Seal -- Seal',
'Titanic: Music from the Motion Picture Soundtrack' => 'Titanic: Music from the Motion Picture Soundtrack',
'Baby One More Time -- Britney Spears' => 'Baby One More Time -- Britney Spears',
'The Woman in Me -- Shania Twain' => 'The Woman in Me -- Shania Twain',
'Motown Love Songs -- Various Artists' => 'Motown Love Songs -- Various Artists',
'Reggae Hits, Vol. 36 -- Various Artists' => 'Reggae Hits, Vol. 36 -- Various Artists'
);
if ($all_valid) {
$display = "<h1 id='finalize'><img src='" . $this->is_ssl() . "abundatrade.com/recommerce/wp-content/plugins/abundatrade_plugin/images/spinner.gif' /> Please wait while we finalize your quote</h1>";
}
else {
$display = "<form method='get' action='#'><input type='hidden' id='is_gadget' name='gadget' value='true'/><input type='hidden' name='unknown' value='false'><div id='abundatrade_gadget'>";
$display .= "<h1 id='finalize' style='display:none'></h1>";
$display .= "<div class='category_selector select_container'><div id='category_selection' $gad_cat class='selection sel_center'>This form requires javascript. Please use a javascript enabled browser";
$display .= $closediv . $closediv;
$display .= "<div class='large_container' style='display:none' id='large_container_div'><div id='manufacturer_selection' class='selection sel_left'>";
$display .= $closediv;
$display .= "<div id='carrier_selection' class='selection sel_left'>";
$display .= $closediv;
$display .= "<div id='device_selection' class='selection sel_left'>";
$display .= $closediv;
$display .= "<div id='condition_selection' class='selection sel_left'>";
$display .= $closediv . $closediv;
$display .= "<div class='quote_display select_container' id='quote_container_div' style='display:none'><div id='quote' class='quote_center'>";
$display .= $closediv . $closediv;
$display .= "<div class='description_container'><div id='description' class='box_center'>";
$display .= "<p id='desc_desc'>Tell us more about your gadget including complete model #, make, etc...</p>";
$display .= "<textarea name='description_entry' " . ($use_labels ? "rows='10'" : "") . "></textarea>";
$display .= $closediv . $closediv;
$display .= "<div id='master_container_contact' $show_all>";
$display .= "<div class='contact_form_container'><div class='contact_form_thirds'>";
if ($use_labels) {
$display .= "<label for='my_name'>Your name*</label><br>";
}
$display .= "<input $name type='text' placeholder='Your name*' name='my_name' value='" . $this->get_value("my_name") . "' /><span class='required'>*</span>";
$display .= $closediv;
$display .= "<div class='contact_form_thirds'>";
if ($use_labels) {
$display .= "<label for='email'>Your Email*</label><br>";
}
$display .= "<input $email type='text' placeholder='Your email*' name='email' value='" . $this->get_value("email") . "'/><span class='required'>*</span>";
$display .= $closediv;
$display .= "<div class='contact_form_thirds'>";
if ($use_labels) {
$display .= "<label for='phone'>Your phone #</label><br>";
}
$display .= "<input $phone type='text' placeholder='Your phone #' name='phone' value = '" . $this->get_value("phone") . "'/>";
$display .= $closediv . $closediv;
$display .= "<div class='contact_form_container'><div class='contact_form_thirds' style='width:49%'>";
if ($use_labels) {
$display .= "<label for='address_street'>Address*</label><br>";
}
$display .= "<input $address_street type='text' placeholder='Address*' name='address_street' value='" . $this->get_value("address_street") . "'/><span class='required'>*</span>";
$display .= $closediv;
$display .= "<div class='contact_form_thirds' style='width:49%'>";
if ($use_labels) {
$display .= "<label for='address_street_two'>Address Line 2</label><br>";
}
$display .= "<input $address_street_two type='text' placeholder='Address Line 2' name='address_street_two' value='" . $this->get_value("address_street_two") . "'/>";
$display .= $closediv . $closediv;
$display .= "<div class='contact_form_container'><div class='contact_form_thirds'>";
if ($use_labels) {
$display .= "<label for='address_city'>City*</label><br>";
}
$display .= "<input $address_city type='text' placeholder='City*' name='address_city' value='" . $this->get_value("address_city") . "'/><span class='required'>*</span>";
$display .= $closediv;
$display .= "<div class='contact_form_thirds'>";
if ($use_labels) {
$display .= "<label for='address_state'>State*</label><br>";
}
$display .= "<input $address_state type='text' placeholder='State*' name='address_state' value='" . $this->get_value("address_state") . "'/><span class='required'>*</span>";
$display .= $closediv;
$display .= "<div class='contact_form_thirds'>";
if ($use_labels) {
$display .= "<label for='address_zip'>Zip Code*</label><br>";
}
$display .= "<input $address_zip type='text' placeholder='Zip Code*' name='address_zip' value='" . $this->get_value("address_zip") . "'/><span class='required'>*</span>";
$display .= $closediv . $closediv;
$display .= "<div style='height:auto;' class='contact_form_container'><div class='contact_form_thirds'></div><div class='contact_form_thirds'>";
$display .= "<select name='dvd' id='choose_dvd' onChange='changeFree()' style='width:90%'>";
foreach ($dvd as $value => $text) {
$display .= "<option " . (isset($_REQUEST['dvd']) && $_REQUEST['dvd'] == htmlentities($value) ? "selected" : "") . " value='" . htmlentities($value) . "'>" . htmlentities($text) . "</option>";
}
$display .= "</select>";
$display .= $closediv . $closediv;
$display .= "<div class='contact_form_container'><div class='contact_form_thirds'></div><div class='contact_form_thirds'>";
$display .= "<input disabled='disabled' type='submit' value='Submit to Make Your Cash'/>";
$display .= $closediv . $closediv . $closediv;
$display .= "</form>";
$display .= $closediv;
}
if (!isset($this->export)) {
$this->export = array();
}
$display .= "<script type='text/javascript'> /* <![CDATA[ */ var abundacalc_gad = " . json_encode($this->export) . ";/* ]]> */</script>";
if (true) {
return $display;
}
else return "";
}
public function shortcode($atts) {
if (!isset($atts['gadget_only'])) $atts['gadget_only'] = false;
if (!isset($atts['a'])) {
$affid = $this->settings->Affiliate_ID;
}
else {
$affid = $atts['a'];
}
if ($atts['gadget_only']) {
$hide = ' display: none;';
$gadget_state = ' ';
}
else {
$hide = ' ';
$gadget_state = ' display: none;';
}
$display = '<div id="abundatrade">';
$top = '<noscript><h1>Javascript is required for the calculator to work -- please enable it before continuing!</h1></noscript>
<div id="top_input_section" class="calc_content_wrap calc_color1 calcbg1" style="'.$hide.'">
<div id="search_results_list"></div>
<form id="abundaInput" class="abundaInput" style="margin-top: 6px;" onsubmit="return false;" method="post" >
<input id="item_num" value="1" name="item_num" type="hidden"/>
<input id="a" value="' . $affid . '" type="hidden"/>
<div class="input_container">
</div>
<div class="input_container">'
.($this->isIE() ?
'<div class="label">Barcode, Title or Artist</div>'
: '').
'<div'.($this->isIE() ? '' : ' style="min-width:150px; width:100%;"').' class="product_holder">
<input'.($this->isIE() ? '' : ' style="min-width:150px; width:100%;"').' placeholder="UPC, ISBN, EAN, ASIN, Title or Artist" class="center validate[\'required\',\'length[3,25]\']" id="product_code" name="product_code" onkeyup="return; doSearch();" onblur="clean_product_code(this)" type="text"/>
</div>
</div>
<div class="input_container" style="width:200px;">
<div class="label"> Quantity </div>
<div class="qty_holder">
<input class="center validate[\'required\',\'digit[1,20]\']" id="product_qty" name="product_qty" value="1" type="text"/>
</div>
</div>
<div class="submit_holder">
<input class="btn1 right btn_link1 btnbg1" value="+ Add Item" type="submit"/>
</div>';
$bulk_button = '
<div id="bulk_button" class="calcbg1" style="'.$hide.'">
<p class="abunda_text2 calc_color1"><a href="#" onclick="transform_into_full_calc(\'gadget\');" class="calc_linkS1" >Add a gadget</a><a href="#" onclick="return bulk_open();" style="float:right; margin-right:20px;" class="calc_linkS1">Bulk Upload</a>
</p>
</div>';
$switch_back = '
<div id="switch_back_button" class="calcbg1" style="'.$gadget_state.'">
<p class="abunda_text2 calc_color1">Can\'t find your gadget? <a href="' . $this->is_ssl() . 'abundatrade.com/recommerce/custom-quote-top-cash-gadgets" class="calc_linkS1">Get a custom quote</a>
<a href="#" class="calc_linkS1" style="float:right; margin-right:20px;" onclick="transform_into_full_calc(\'main\');">Switch back to regular items</a></p>
</div>';
$bulk = '
<div id="bulk" class="calcbg1">
<div id="bulk_help" class="abunda_text calc_color1">You can cut and paste directly from popular office programs<br/> like Excel and Word.</div>
<div id="bulk_text_holder"><textarea placeholder="02454352525998" cols=20 rows=10 id="bulk_upload" name="bulk_upload"></textarea></div>
<div id="bulk_button_holder"><a href="#" class="likebutton" onclick="return bulk_close_window();">Go back</a>
<a href="#" class="likebutton" onclick="bulk_submit_items();">Submit List</a></div>
<p class="calcbg1 bottomcurve"> </p>
</div>';
$second = '
<div id="second_content" class="calc_content_wrap calcbg2 calc_color2" style="'.$hide.'">
<div class="second_content_sec1">
<label class="calc_color2">Total Items:</label>
<div id="total_item_count">0</div>
</div>
<div class="second_content_sec2">
<label class="calc_color2">Pre-Valuation Total:</label>
<div id="total_prevaluation">$0.00</div>
</div>
<!--<div class="second_content_sec4">
<a id="submitList" class="btnbg2 btn_link2" onclick="submit_the_list(this);">Get a quote</a>
</div>-->
<!--<div class="second_content_sec4">
<a id="BeatAll" class="btnbg3 btn_link3" onClick="BeatAll()">Beat All</a>
</div>-->
</div>';
$endform = "</form></div>";
$endtop = "</div>";
$supershow = "<a id='super_show' href='#' onclick='toggle_show(); return false;'>Show all zero value items</a>";
$endAll = "</div>";
$table_head = '<table cellspacing="0" bgcolor="#fff" cellpadding="0" id="abundaCalcTblTop" class="abundaCalcTbl" style="'.$hide.'">
<thead>
<tr>
<th style="display:none;" class="calcbg3 calc_color3">UPC</th>
<th colspan="2" class="calcbg3 calc_color3" width="638px" style="text-align:left;">Product Details</th>
<th class="calcbg3 calc_color3" style="padding-right:40px">Qty</th>
<!--<th class="calcbg3 calc_color3">Offers</th>-->
<th id="TheBestOffer" class="calcbg3 calc_color3 txtright" style="padding-right:44px">Offer</th>
<th class="calcbg3 calc_color3"><a class="calc_linkS3" onclick="clear_session()">Start Over</a></th>
<th style="display: none;">ID</th>
</tr>
</thead>
';
$table_body = '
<tbody id="abundaCalcBody_request">
</tbody>
<!--<tfoot>
<tr>
<th class="calcbg2 calc_color2 thxpad"> </th>
<th class="calcbg2 calc_color2"> </th>
<th class="calcbg2 calc_color2 txtright" colspan="2"> </th>
<th class="calcbg2 calc_color2 txtright"> </th>
<th colspan="2" class="calcbg2 center"> </th>
</tr>
</tfoot>-->
<tbody id="abundaCalcBody_process">
<tr><td colspan="6" id="ready2go" class="center">Did you know, you can use your smart phone, tablet or Kindle Fire as a scanner? <a href="http://abundatrade.com/abundascan-mobile-app.php" title="Click here to download the app">Click here to download the app</a></td></tr>
</tbody>
<tbody >
<tr class="response">
</tbody>
</table>';
$very_bottom = '
<div id="very_bottom" style="'.$hide.'" class="calcbg2 bottomcurve"><div style="" class="second_content_sec4">
<a id="submitList" class="likebutton" onclick="submit_the_list(this);">Continue</a>
</div></div>'
;
$gadget_begin = '<div id="gadget_abundatrade" style="'.$gadget_state.'" class="calc_content_wrap calc_color1 calcbg1 bottomcurve">';
$gadget_manufacturer = '<input type="hidden" value="'. (isset($atts["manufacturer"]) ? $atts["manufacturer"] : '') . '" id="gadget_manufacturer"/>';
$gadget_category = '<input type="hidden" value="' . (isset($atts["category"]) ? $atts["category"] : '') . '" id="gadget_category"/>';
$gadget_selector =
'<form id="abundaGadgetInput" class="abundaInput" style="margin-top: 6px;" onsubmit="return false;" method="post" >
<div id="new_gad_cat" class="gadget_holder">
<div class="abundaGadget_cat" onclick="setNewCat(1);">
<img src="' . $this->folders['PluginUrl'] . '/images/icons/cats/gadgets_icon01.jpg" />
<p>iPhone</p>
</div>
<div class="abundaGadget_cat" onclick="setNewCat(2);">
<img src="' . $this->folders['PluginUrl'] . '/images/icons/cats/gadgets_icon02.jpg" />
<p>Tablet</p>
</div>
<div class="abundaGadget_cat" onclick="setNewCat(3);">
<img src="' . $this->folders['PluginUrl'] . '/images/icons/cats/gadgets_icon03.jpg" />
<p>iPod Classic</p>
</div>
<div class="abundaGadget_cat" onclick="setNewCat(4);">
<img src="' . $this->folders['PluginUrl'] . '/images/icons/cats/gadgets_icon04.jpg" />
<p>iPod Touch</p>
</div>
<div class="abundaGadget_cat" onclick="setNewCat(5);">
<img src="' . $this->folders['PluginUrl'] . '/images/icons/cats/gadgets_icon05.jpg" />
<p>iPod Nano</p>
</div>
<div class="abundaGadget_cat" onclick="setNewCat(6);">
<img src="' . $this->folders['PluginUrl'] . '/images/icons/cats/gadgets_icon06.jpg" />
<p>Blackberry</p>
</div>
<div class="abundaGadget_cat" onclick="setNewCat(7);">
<img src="' . $this->folders['PluginUrl'] . '/images/icons/cats/gadgets_icon07.jpg" />
<p>Android</p>
</div>
<div class="abundaGadget_cat" onclick="setNewCat(8);">
<img src="' . $this->folders['PluginUrl'] . '/images/icons/cats/gadgets_icon08.jpg" />
<p>eReader</p>
</div>
<div class="abundaGadget_cat" onclick="setNewCat(9);">
<img src="' . $this->folders['PluginUrl'] . '/images/icons/cats/gadgets_icon09.png" />
<p>Mac Book</p>
</div>
<!-- <div class="abundaGadget_cat" onclick="setNewCat(10);">
<img src="' . $this->folders['PluginUrl'] . '/images/icons/cats/gadgets_icon10.jpg" />
<p>Game Consoles</p>
</div> -->
</div>';
$gadget_selector .= '<div id="new_gad_man" class="gadget_holder" style="display:none;">
<div id="man_content" style="display:none;"></div>
<div id="man_loader" style="width:30%; margin:auto; background-color:white; transition:background-color 1s ease 0;">
<div style="width:16px; margin:auto;">
<img src="' . $this->folders['PluginUrl'] . '/images/spinner.gif" />
</div>
<p style="text-align:center;">Loading Manufacturers</p>
</div>
</div>
<div id="new_gad_dev" class="gadget_holder" style="display:none;">
<div id="dev_content" style="display:none;"></div>
<div id="dev_loader" style="width:30%; margin:auto; background-color:white; transition:background-color 1s ease 0;">
<div style="width:16px; margin:auto;">
<img src="' . $this->folders['PluginUrl'] . '/images/spinner.gif" />
</div>
<p style="text-align:center;">Loading Devices</p>
</div>
</div>
<div id="new_gad_car" class="gadget_holder" style="display:none;">
<div id="car_content" style="display:none;"></div>
<div id="car_loader" style="width:30%; margin:auto; background-color:white; transition:background-color 1s ease 0;">
<div style="width:16px; margin:auto;">
<img src="' . $this->folders['PluginUrl'] . '/images/spinner.gif" />
</div>
<p style="text-align:center;">Loading Carriers</p>
</div>
</div>
<div id="new_gad" class="gadget_holder" style="display:none;">
<div class="gad_big_pict">
<img src="" />
</div>
<div class="gad_details">
<p>Details go here</p>
<select>
<option>Select your condition</option>
</select>
</div>
<div id="gad_adder" style="display:inline-block" class="submit_holder">
<input class="btn1 right btn_link1 btnbg1" value="+ Add" type="submit"/>
</div>
</div>
</form>';
$status = "<div id=\"login_status_abundatrade\"></div>";
$newtop = "<div id='top_input_section' class='calchead'><form id='abundaInput' onsubmit='return false;' method='post'>
<div class='searchby'><img src='" . $this->folders['PluginUrl'] . "/css/images/searchby.png'/></div>
<div class='upcetc'>
<input id='a' value='$affid' type='hidden'/>
<input id='product_code' " . (isset($_POST['product_id']) ? "value='{$_POST['product_id']}'" : "") . " name='product_code' onkeyup='return; doSearch();' onblur='clean_product_code(this);' autocomplete='off' placeholder='UPC,ASIN,ISBN,Title, or Artist' type='text' class='upcinputbox'/></div>
<div class='quantitybox'>
<div class='quantitylabel'>
<span style='margin-right:10px;'>QTY.</span>
<input id='product_qty' name='product_qty' value='1' type='text' class='quantityinputbox'/>
</div></div>
<div class='addbuttonbox'>
<input type='submit' class='likebutton' value='+ Add '/>
</div>
<div class='bulkuploadbox'>
<a href='#' onclick='return bulk_open()'>Bulk Upload</a>
<br/>
<a href='#' onclick='transform_into_full_calc(\"gadget\");'>Add a Gadget</a>
</div>
<div class='prevaluationbox'>
Pre-valuation total: <span id='total_prevaluation' class='valuationtotal'>$0.00</span>
<br/>
Item Total: <span id='total_item_count' class='itemtotal'>0</span>
</div>
<div class='clear'></div>
</form>
</div>";
$display .= $status;
$display .= $bulk;
$display .= "<div id='calc_follow' style='position:relative'>";
$display .= $gadget_begin;
$display .= $gadget_selector;
$display .= $endtop;
$display .= $newtop;
//$display .= $top;
//$display .= $endform;
//$display .= $bulk_button;
//$display .= $switch_back;
//$display .= $second;
$display .= $table_head;
$display .= "</table></div><table id='abundaCalcTbl' class='abundaCalcTbl'>";
$display .= $table_body;
$display .= $very_bottom;
$display .= $endAll;
return $display;
}
/**
* Retuns a pointer to the settings object
*/
public function getSettings() {
return array(&$this->settings);
}
public function doshortcode($atts) {
$display = apply_filters("abundatrade(shortcode(abundatrade))", $atts);
return $display;
}
public function dogadgets($atts) {
$display = apply_filters("abundatrade(shortcode(gadgets))", $atts);
return $display;
}
public function addScripts() {
if (file_exists($this->folders['UploadsDir']['basedir'] . '/abundatrade/themes/' . $this->settings->Theme . '.css')) {
wp_register_style("abundatrade_classic", $this->folders['UploadsDir']['baseurl'] . '/abundatrade/themes/' . $this->settings->Theme . '.css');
}
else if (file_exists($this->folders['PluginDir'] . '/themes/' . $this->settings->Theme . '.css')) {
wp_register_style("abundatrade_classic", $this->folders['PluginUrl'] . '/themes/' . $this->settings->Theme . '.css');
}
else {
wp_register_style("abundatrade_classic", $this->folders['PluginUrl'] . '/themes/classic.css');
}
if (file_exists($this->folders['UploadsDir']['basedir'] . '/abundatrade/themes/' . $this->settings->Theme . '-prompt.css')) {
wp_register_style("abundatrade_prompt_classic", $this->folders['UploadsDir']['baseurl'] . '/abundatrade/themes/' . $this->settings->Theme . '-prompt.css');
}
else if (file_exists($this->folders['PluginDir'] . '/themes/' . $this->settings->Theme . '-prompt.css')) {
wp_register_style("abundatrade_prompt_classic", $this->folders['PluginUrl'] . '/themes/' . $this->settings->Theme . '-prompt.css');
}
else {
wp_register_style("abundatrade_prompt_classic", $this->folders['PluginUrl'] . '/themes/classic-prompt.css');
}
wp_register_style("abundatrade_jsui", $this->folders['PluginUrl'] . '/css/jquery-ui-1.10.3.custom.css');
wp_register_style("abundatrade_qtip", $this->folders['PluginUrl'] . '/css/jquery.qtip.css');
wp_register_style("abunda_gadgets", $this->folders['PluginUrl'] . '/themes/gadget.css');
wp_register_script("abundatrade_md5", $this->folders['PluginUrl'] . '/js/MD5.js');
wp_register_script("abundatrade_remote", $this->folders['PluginUrl'] . '/js/remote.js', array('jquery','abundatrade_md5', 'jquery-ui-autocomplete'));
wp_register_script("abundatrade_impromptu", $this->folders['PluginUrl'] . '/js/jquery-impromptu.4.0.min.js', array('jquery'));
wp_register_script("abundatrade_register", $this->folders['PluginUrl'] . '/js/register.js', array('jquery', 'abundatrade_remote'));
wp_register_script("abundatrade_gadgets", $this->folders['PluginUrl'] . '/js/abunda_gadgets_short.js', array('jquery'));
wp_register_script("abundatrade_qtip_js", $this->folders['PluginUrl'] . '/js/jquery.qtip.js', array('jquery'));
wp_register_script("abundatrade_perm_prod", $this->folders['PluginUrl'] . '/js/perm_prods.js', array('jquery'));
wp_register_script("abundatrade_animate_shadow", $this->folders['PluginUrl'] . '/js/jquery.animate-shadow-min.js', array('jquery'));
wp_enqueue_style("abundatrade_jsui");
wp_enqueue_style("abundatrade_qtip");
wp_enqueue_style("abundatrade_classic");
wp_enqueue_style("abundatrade_prompt_classic");
wp_enqueue_style("abunda_gadgets");
wp_enqueue_script("abundatrade_qtip_js");
wp_enqueue_script("abundatrade_md5");
wp_enqueue_script("abundatrade_remote");
wp_enqueue_script("abundatrade_impromptu");
wp_enqueue_script("abundatrade_register");
wp_enqueue_script("abundatrade_gadgets");
wp_enqueue_script("abundatrade_perm_prod");
wp_enqueue_script("abundatrade_animate_shadow");
if (!isset($this->export)) {
$this->export = array();
}
$abundacalc = array('server' => 'abundatrade.com',
'bulk' => 'stable.abundatrade.com',
'url' => $this->folders['PluginUrl'],
'export' => $this->export,
'search_for' => (isset($_POST['product_id']) ? $_POST['product_id'] : ""),
'thanks' => $this->settings->Thank_you_page);
if (isset($_REQUEST['upload_id']) && $_REQUEST['upload_id'] != '') {
$abundacalc['upload_id'] = $_REQUEST['upload_id'];
}
wp_localize_script('abundatrade_remote','abundacalc',$abundacalc);
}
/**
* Creates a map structure
*/
function __construct() {
$this->BuildFolderList();
add_filter("abundatrade(getFolders)", array(&$this, "getFolders"), 1);
add_filter("abundatrade(applyConfig)", array(&$this, "applyConfig"), 1);
add_filter("abundatrade(shortcode(abundatrade))", array(&$this, "shortcode"), 1);
add_filter("abundatrade(shortcode(gadgets))", array(&$this, "gadget"), 1);
//////////////////// shortcode defs
add_shortcode("abundatrade", array($this, "doshortcode"));
add_shortcode("abundagadgets", array($this, "dogadgets"));
add_shortcode("user", array($this, "doprofile"));
add_shortcode("is_logged_in", array($this, "is_logged_in"));
add_shortcode("save_button", array($this, "save_button"));
add_shortcode("goto_next_if_saved", array($this, "next_address"));
add_shortcode("show_valuations", array($this, "show_valuations"));
add_shortcode("valuations_page", array($this, "valuations_page"));
add_shortcode("previous_page", array($this, "previous_page"));
add_shortcode("next_page", array($this, "next_page"));
add_filter("abundatrade(settings)", array($this, "getSettings"), 200, 0);
add_action("wp_enqueue_scripts", array($this, "addScripts"));
spl_autoload_register(array($this, "autoload"));
$skel = new skel__skel();
//load settings last for updates
$this->settings = new skel__settings();
}
public $current_page = 0;
public function set_page() {
if (isset($_REQUEST['val_page']) && is_numeric($_REQUEST['val_page'])) {
$this->current_page = $_REQUEST['val_page'];
}
}
public function previous_page($atts) {
$this->set_page();
$next = $atts['next'];
$page = $this->current_page;
$page -= 1;
$page = ($page < 0 ? 0 : $page);
return "$next?val_page=$page";
}
public function next_page($atts) {
$this->set_page();
$next = $atts['next'];
$page = $this->current_page;
$page += 1;
$page = ($page < 0 ? 0 : $page);
return "$next?val_page=$page";
}
public function valuations_page($atts) {
$this->set_page();
return $this->current_page + 1;
}
public function get_customer_valuations($limit = 10) {
$db = new TradeDB();
$page = $this->current_page * $limit;
$query = "select completed, accepted, created_date > now() - interval '14 days' as editable, valuation_id, status, num_items, initial_total_string, reviewed_total_string, accepted_total_string, status_id from valuation_details where customer_id = :id and num_items > 0 and archived = 'f' limit :limit offset :page";
$statement = $db->db()->prepare($query);
$result = $statement->execute(array('id' => $_SESSION['user']['customer_id'], 'limit' => $limit, 'page' => $page));
$this->valuation = $result->fetchAll();
if (count($valuation) <= $limit) $this->last_page = true;
$this->total_pages = count($valuation);
}
public function GetStatus($valuation) {
$display_status = substr($valuation['status'], 0, strpos($valuation['status'], ' '));
if ($valuation['accepted'] == 't') {
$display_status = 'Accepted';
}
if ($valuation['completed'] == 't') {
$display_status = 'Complete';
}
return $display_status;
}
public function GenerateTotal($valuation) {
switch ($this->GetTrueStatusId($valuation)) {
case 1:
case 2:
case 8:
case 9:
return $valuation['initial_total_string'];
case 3:
case 4:
case 6:
case 7:
return $valuation['reviewed_total_string'];
case 5:
return $valuation['accepted_total_string'];
}
}
function GetTrueStatusId($valuation) {
$status_id = $valuation['status_id'];
if ($valuation['accepted'] == 't') {
$status_id = 5;
}
if ($valuation['completed'] == 't') {
$status_id = 5;
}
return $status_id;
}
public function GenerateActions($valuation) {
switch ($this->GetTrueStatusId($valuation)) {
case 1:
if ($valuation['editable'] == 't') {
return array('html' => "<option value='1'>Edit</option><option value='2'>Mark as Sent</option><option value='3'>Mark as Cancelled</option>", 'allowed' => array( 1, 2, 3));
}
return array('html' => "<option value='2'>Mark as Sent</option><option value='3'>Mark as Cancelled</option>", 'allowed' => array(2, 3));
case 4:
case 6:
case 7:
return array('html' => "<option value='4'>Accept Payment</option>", 'allowed' => array(4));
case 8:
return array('html' => "<option value='5'>Unmark as Sent</option>", 'allowed' => array(5));
case 9:
return array('html' => "<option value='6'>Unmark as Cancelled</option>", 'allowed' => array(6));
default:
return array('html' => '', 'allowed' => array());
}
}
public function DisplayValuations($valuation) {
$display_status = $this->GetStatus($valuation);
$display_total = $this->GenerateTotal($valuation);
$actions = $this->GenerateActions($valuation);
$r = "<tr>";
$r .= "<td>";
$r .= $valuation['valuation_id'];
$r .= "</td>";
$r .= "<td>";
$r .= $display_status;
$r .= "</td>";
$r .= "<td>";
$r .= $valuation['num_items'];
$r .= "</td>";
$r .= "<td>";
$r .= $display_total;
$r .= "</td>";
$r .= "<td>";
$r .= "<select id='sel{$valuation['valuation_id']}' onchange='update_status({$valuation['valuation_id']}, \"{$_SESSION['my_nonce']}\"); return false;' name='do_action'><option value='0'>Action</option>" . $actions['html'] . "</select>";
$r .= "</td>";
$r .= "</tr>";
return $r;
}
public function show_valuations($atts) {
$this->set_page();
$this->get_customer_valuations();
$r = "";
$_SESSION['my_nonce'] = md5(time());
foreach($this->valuation as $row_num => $valuation) {
$r .= $this->DisplayValuations($valuation);
}
$_SESSION['check_nonce'] = $_SESSION['my_nonce'];
return $r;
}
public function next_address($atts) {
$edit_address = "#";
$next_address = "#";
$check_var = "Edit";
$name = "save_button";
if(isset($atts['edit_address'])) {
$edit_address = $atts['edit_address'];
}
if(isset($atts['next_address'])) {
$next_address = $atts['next_address'];
}
if(isset($atts['name'])) {
$name = $atts['name'];
}
if(isset($atts['check_var'])) {
$check_var = $atts['check_var'];
}
if(isset($_REQUEST[$name]) && $_REQUEST[$name] == $check_var) {
return $next_address;
}
return $edit_address;
}
public function save_button($atts) {
$save_text = "Save";
$edit_text = "Edit";
$name = "save_button";
if(isset($atts['name'])) {
$name = $atts['name'];
}
if(isset($atts['save_text'])) {
$save_text = $atts['save_text'];
}
if(isset($atts['edit_text'])) {
$edit_text = $atts['edit_text'];
}
if (isset($_REQUEST['save_button']) && $_REQUEST['save_button'] == $edit_text) {
$text = $save_text;
}
else {
$text = $edit_text;
}
return "<input type='submit' name='$name' value='$text' />";
}
public function doprofile($atts) {
require_once("/var/www/trade/config.php");
$edit_on = "Edit Info";
$save_on = "Save Info";
$class = (isset($atts['class']) ? $atts['class'] : '');
if (isset($atts['no_save']) && $atts['no_save'] == true) {
return $_SESSION['user'][$atts['user']];
}
if (isset($_POST['save_button']) && $_POST['save_button'] == $edit_on) {
return "<input type='text' value='{$_SESSION['user'][$atts['user']]}' name='{$atts['user']}' />";
}
if (isset($_POST['save_button']) && $_POST['save_button'] == $save_on) {
return $_POST[$atts['user']];
}
return $_SESSION['user'][$atts['user']];
}
public function is_logged_in() {
if (isset($_SESSION['user'])) {
return "My Account";
}
return "Log In";
}
/**
* Autoloads all classes as required to only load in what we need
* @var string $classname The name of the class to load
*/
static public function autoload($classname) {
$file = str_replace("__", "/", $classname);
$folders = apply_filters("abundatrade(getFolders)", array());
if (file_exists($folders['PluginDir'] . $file . ".php"))
include_once($folders['PluginDir'] . $file . ".php");
//else
//echo "<pre>file no exists: " . $folders['PluginDir'] . $file . ".php\n</pre>";
}
/**
* Builds a list of folders for later distribution so we can find ourselves
* call with apply_filters("abundatrade(getFolders", array());
*/
private function BuildFolderList() {
$config = $this->applyConfig(array());
$this->folders = array();
$this->folders['UploadsDir'] = wp_upload_dir();
$this->folders['PluginDir'] = plugin_dir_path(__FILE__);
$this->folders['PluginUrl'] = plugins_url('', __FILE__);
$this->folders['PluginAdmin'] = admin_url() . 'options-general.php?page=' . $config['config']['slug'];
$this->folders['Basename'] = plugin_basename(__FILE__);
}