/
model.classes.php
5122 lines (4801 loc) · 137 KB
/
model.classes.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
include_once('utility.simpledom.php');
include_once('utility.functions.php');
$HIS_MATCH_TYPES=array(
'processing'=>'processing',
'operation'=>'operation',
'action'=>'action',
'output'=>'output'
);
$HIS_HFPVC_TYPES=array(
'allow-alphanum'=>'allow alphanumeric characters',
'allow-space'=>'allow spaces',
'allow-num'=>'allow numbers',
'allow-alpha'=>'allow alphabetic characters',
'allow-special'=>'allow the following special characters:',
'disallowed-str'=>'disallowed string',
'match-regex'=>'must match regular expression'
);
$HIS_ACTION_TYPES=array(
'his-hf'=>'HIS Function + postback printed output to here',
'cur-as-key'=>'use current value as adjacent dictionary key',
'cur-as-val'=>'use current value as adjacent dictionary value',
'key-and-val'=>'set adjacent dictionary key and value',
'clear-adj'=>'clear adjacent dictionary',
'buffer'=>'set adjacent dictionary key "[BUFFER]"s value equal to preceding sub-processings outputs',
'php-code'=>'PHP Code'
);
$HIS_JOB_STATUS=array(
'new'=>'new',
'running'=>'running',
'paused'=>'paused',
'done'=>'done',
'failed'=>'failed'
);
$HIS_JOB_TYPES=array(
'batch-shell-script'=>'Batch/Shell Script'
);
$HIS_OUTPUT_TYPES=array(
'print-value'=>'Print value (default if none is selected)',
'http-connection'=>'HTTP connection',
'database-connection'=>'Database connection',
'file-storage-connection'=>'File storage connection',
'message-queue-connection'=>'Message Queue connection',
'send-email'=>'Send E-Mail'
);
$HIS_PROCESSING_TYPES=array(
'filter-regex'=>'needs further filtering - use regular expression',
'filter-split-string'=>'needs further filtering - split using string delimiter',
'filter-split-regex'=>'needs further filtering - split using regular expression',
'filter-xpath'=>'needs further filtering - use xpath expression',
'filter-string-formatter'=>'needs further filtering - use string format specifier',
);
$HIS_CONDITIONS=array(
'perfectly'=>'working perfectly',
'partially-raw'=>'data is still partially raw (contains HTML), needs further adjustment',
'reported-not-working'=>'reported as not working',
'might-not-be-working'=>'might not be working',
'not-working'=>'not working',
'being-worked-on'=>'being worked on',
'not-being-worked-on'=>'not being worked on',
'too-difficult-to-fix'=>'too difficult to fix',
'target-using-obfuscation'=>'target is using obfuscation',
'no-hf_resources-available'=>'no resources available',
'needs-to-be-checked-by-qa'=>'needs to be checked by QA',
'just-an-idea'=>'just an idea - do not do yet',
'automatic-failure-detection'=>'Automatic Function Failure Detection - Broken Functions'
);
$HIS_OPERATION_TYPES=array(
'read-non-html'=>'read as text, non-html',
'urlencode'=>'urlencode',
'double-urlencode'=>'double urlencode',
'urldecode'=>'urldecode',
'treat-as-integer'=>'treat as integer',
'treat-as-float'=>'treat as floating point number',
'double-urldecode'=>'double urldecode',
'keywdreppass'=>'keyword replacement pass',
'prepend-and-append'=>'prepend and append',
'replace'=>'replace',
'erase'=>'erase (set equal to "")',
'prepend-and-append-file'=>'prepend and append file contents',
'replace-using-regex'=>'replace using regular expression',
'format-with-string-specifier'=>'format with string specifier',
'html-entities'=>'encode ALL possible < HTML characters into applicable HTML entities (&lt;)',
'html-entity-decode'=>'decode ALL possible &lt; characters into applicable HTML characters (<)',
'trim'=>'trim',
'htmlspecialchars'=>'htmlspecialchars (UTF-8 encoded, XML+Quotes, < converts to &lt;)',
'htmlspecialchars-decode'=>'htmlspecialchars-decode (XML+Quotes, &lt; converts to <)',
'strtoupper'=>'Convert to upper case',
'strtolower'=>'Convert to lower case',
'base64-encode'=>'Encode as base64',
'base64-decode'=>'Decode base64'
);
$HIS_IRESOURCE_TYPES=array(
'remote-wget'=>'HTML Raw (Remote wget)',
'remote-imacros'=>'HTML DOM (Remote iMacros)',
'remote-imacros-simple'=>'HTML Simple DOM (Remote iMacros)',
'remote-win-batch'=>'Windows Batch File (Remote)',// (inc. local folder svn, git, imap, wget, iMacros, WinSCP references)',
'remote-shell'=>'Linux/Unix Shell Script (Remote)',
'remote-cygwin'=>'Cygwin (Remote)',
'remote-text'=>'Text',
'remote-sftp'=>'SFTP (Remote)',
'remote-ftp'=>'FTP (Remote)',
'remote-scp'=>'SCP (Remote)',
'remote-winscp'=>'WinSCP (Remote)',
'remote-ssh'=>'SSH (Remote)',
'remote-torrent'=>'Torrent (Remote)',
'remote-awk'=>'awk/gawk (Remote)',
'remote-ttsraw'=>'Text to Speech [Festival TTS Linux] - Raw Text to Speak (Remote)',
'remote-ttsurl-reference'=>'Text to Speech [Festival TTS Linux] - URL Containing Text (Remote)',
'remote-cvs'=>'CVS Checkout (Remote)',
'remote-upload'=>'Per-Instance File Upload (Remote)',
'remote-imap'=>'E-Mail Read through IMAP Connection (Remote)',//(Example: imap[s]://user:pass@example-server.com:999/Inbox/NOT SEEN)',
'remote-email-outgoing'=>'E-Mail - Outgoing (Remote)',
'remote-mysql'=>'MySQL Database Connection/Function (Remote)',
'remote-imacros-download'=>'Web Browsing Session File Download (Remote iMacros)',
'remote-phone-call-outgoing-twilio'=>'Phone Call - Outgoing (Remote)',
'remote-phone-call-incoming-twilio'=>'Phone Call - Incoming (Remote)',
'remote-faxin-godaddy-fax-outgoing'=>'Fax - Outgoing (Remote)',
'remote-faxout-godaddy-fax-incoming'=>'Fax - Incoming (Remote)',
'remote-smsout-twilio'=>'SMS - Outgoing (Remote)',
'remote-smsin-twilio'=>'SMS - Incoming (Remote)',
'remote-snailmail-postalmethods'=>'Snail Mail - Outgoing (Remote)',
'remote-his-hf'=>'Human Intelligence System Function (Remote)',
'remote-hit-amazon'=>'Amazon Human Intelligence Task (Remote)',
'remote-py2.3'=>'Compile & Run: Python 2.3 Script',
'remote-py2.4'=>'Compile & Run: Python 2.4 Script',
'remote-py2.5'=>'Compile & Run: Python 2.5 Script',
'remote-py2.6'=>'Compile & Run: Python 2.6 Script',
'remote-py2.7'=>'Compile & Run: Python 2.7 Script',
'remote-py3.0'=>'Compile & Run: Python 3.0 Script',
'remote-py3.1'=>'Compile & Run: Python 3.1 Script',
'remote-py3.2'=>'Compile & Run: Python 3.2 Script',
'remote-perl5.12'=>'Compile & Run: Perl 5.12 Script',
'remote-perl'=>'Compile & Run: Perl 5.12 Script',
'remote-vb.net-vbnc'=>'Compile & Run: Visual Basic.NET 2008',
'remote-c#.net'=>'Compile & Run: C#.NET 2008',
'remote-gcc'=>'Compile & Run: C (compiled with gcc)',
'remote-g++'=>'Compile & Run: C++ (compiled with g++)',
'remote-java6'=>'Compile & Run: Java 6',
'remote-java7'=>'Compile & Run: Java 7',
'remote-java'=>'Compile & Run: Java (Java7)',
'remote-php5.4'=>'Compile & Run: PHP 5.4 Script',
'remote-php5'=>'Compile & Run: PHP 5 Script',
'remote-php'=>'Compile & Run: PHP Script (PHP5)',
'remote-assy32-nasm-linux-32-intel'=>'Compile & Run: Assembly (nasm, linux x86, Intel)',
'remote-assy64-nasm-linux-64'=>'Compile & Run: Assembly (nasm, linux x64)',
'remote-TeX'=>'TeX',
'remote-matlab'=>'MATLAB',
'remote-sage'=>'Sage',
'remote-fortran'=>'Fortran',
'remote-ampl'=>'AMPL',
'remote-r'=>'R',
'remote-vbscript'=>'VBScript',
'remote-lisp'=>'Lisp',
'remote-haskell'=>'Haskell',
'remote-prolog'=>'Prolog',
'remote-ruby'=>'Ruby',
'remote-tcl'=>'Tcl',
'remote-scheme'=>'Scheme',
'remote-smalltalk'=>'Smalltalk',
'remote-dart'=>'Dart',
'remote-winbatch'=>'Winbatch',
'remote-libxslt'=>'libxslt (Remote)',
'remote-xslfo'=>'XSL-FO (Remote)',
'remote-helium'=>'Helium Scraper Custom Template Export (Remote Helium Scraper)',
);
$HIS_IRESOURCE_EXAMPLES=array(
'remote-wget'=>'http://google.com',
'remote-imacros'=>'VERSION BUILD=7511734
TAB T=1
TAB CLOSEALLOTHERS
SET !EXTRACT_TEST_POPUP NO
SET !ENCRYPTION NO
URL GOTO=http://battlelog.battlefield.com/bf3/gate/
TAG POS=1 TYPE=LABEL FORM=ID:gate-form ATTR=TXT:Origin*<SP>Account<SP>E-mail
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:gate-form ATTR=ID:gate-form-email CONTENT={login}
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:gate-form ATTR=ID:gate-form-password CONTENT={pw}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:gate-form ATTR=VALUE:Sign<SP>in
TAG POS=1 TYPE=A ATTR=CLASS:main-loggedin-leftcolumn-active-soldier-name
WAIT SECONDS=5
TAG POS=1 TYPE=HTML ATTR=* EXTRACT=HTM
TAG POS=1 TYPE=A ATTR=CLASS:base-no-ajax
SAVEAS TYPE=EXTRACT FOLDER={JOB_FOLDER} FILE=*',
'remote-imacros-simple'=>'http://google.com',
'remote-win-batch'=>'echo "HI";<br/>ipconfig /all',
'remote-shell'=>'echo "HI";ifconfig',
'remote-cygwin'=>'gcc hello.c -o hello.exe
./hello.exe',
'remote-text'=>'hello world',
'remote-sftp'=>'SFTP (Remote)',
'remote-ftp'=>'FTP (Remote)',
'remote-scp'=>'SCP (Remote)',
'remote-winscp'=>'WinSCP (Remote)',
'remote-ssh'=>'SSH (Remote)',
'remote-torrent'=>'Torrent (Remote)',
'remote-awk'=>'awk/gawk (Remote)',
'remote-tts-raw'=>'This is hello world in spoken language.',
'remote-tts-reference'=>'http://example.com/path/to/your/readable/spoken-text-file.txt',
'remote-cvs'=>'CVS Checkout (Remote)',
'remote-upload'=>'Per-Instance File Upload (Remote)',
'remote-imap'=>'E-Mail Read through IMAP Connection (Remote)',//(Example: imap[s]://user:pass@example-server.com:999/Inbox/NOT SEEN)',
'remote-email-outgoing'=>'E-Mail - Outgoing (Remote)',
'remote-mysql'=>'MySQL Database Connection/Function (Remote)',
'remote-imacros-download'=>'Web Browsing Session File Download (Remote iMacros)',
'remote-twilio-phone-call-outgoing'=>'Phone Call - Outgoing (Remote)',
'remote-twilio-phone-call-incoming'=>'Phone Call - Incoming (Remote)',
'remote-godaddy-fax-outgoing'=>'Fax - Outgoing (Remote)',
'remote-godaddy-fax-incoming'=>'Fax - Incoming (Remote)',
'remote-twilio-sms-outgoing'=>'SMS - Outgoing (Remote)',
'remote-twilio-sms-incoming'=>'SMS - Incoming (Remote)',
'remote-postalmethods-snail-mail'=>'Snail Mail - Outgoing (Remote)',
'remote-amazon-hit'=>'Amazon Human Intelligence Task (Remote)',
'remote-his-hf'=>'http://your-website.com/his/s=facebook,list,friends&user=me@me.com&pass=test',
'remote-py-2.3'=>'print "hello world"
for i in range(1,11):
print str(i)',
'remote-py-2.4'=>'print "hello world"
for i in range(1,11):
print str(i)',
'remote-py-2.5'=>'print "hello world"
for i in range(1,11):
print str(i)',
'remote-py-2.6'=>'print "hello world"
for i in range(1,11):
print str(i)',
'remote-py-2.7'=>'print "hello world"
for i in range(1,11):
print str(i)',
'remote-py-3.0'=>'Compile & Run: Python 3.0 Script',
'remote-py-3.1'=>'Compile & Run: Python 3.1 Script',
'remote-py-3.2'=>'Compile & Run: Python 3.2 Script',
'remote-perl-5.12'=>'print "hello world\\n";',
'remote-perl'=>'print "hello world\\n";',
'remote-vb.net-vbnc'=>'Console.WriteLine("Hello world")
For x = 0 to 10
Console.WriteLine(x)
Next x',
'remote-c#.net'=>'class HelloWorld
{
static void Main()
{
System.Console.WriteLine("Hello world");
}
}',
'remote-gcc'=>'#include <stdio.h>
int main()
{
printf("hello world\\n");
return 0;
}',
'remote-g++'=>'#include <iostream>
int main()
{
std::cout << "Hello World!\\n";
return 0;
}',
'remote-java6'=>'public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("hello world");
}
}',
'remote-java7'=>'public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("hello world");
}
}',
'remote-java'=>'public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("hello world");
}
}',
'remote-php5.4'=>'echo "hello world";
for ($i=0;$i<10;$i++)
{
echo $i."\\n";
}',
'remote-php5'=>'echo "hello world";
for ($i=0;$i<10;$i++)
{
echo $i."\\n";
}',
'remote-php'=>'echo "hello world";
for ($i=0;$i<10;$i++)
{
echo $i."\\n";
}',
'remote-assembly-nasm-linux-32-intel'=>'section .data
msg db "hello world",0x0a
len equ $-msg
section .text
global _start
_start:
mov ebx,0x01
mov ecx,msg
mov edx,len
mov eax,0x04
int 0x80
mov ebx,0x00
mov eax,0x01
int 0x80
',
'remote-assembly-nasm-linux-64'=>'; 64-bit Hello World in Linux NASM
global _start ; global entry point for ld
section .text
_start:
; sys_write(stdout,message,length)
mov rax,1 ; sys_write
mov rdi, 1 ; stdout
mov rsi, message ; message address
mov rdx, length ; message string length
syscall
; sys_exit(return_code)
mov rax, 60 ; sys_exit
mov rdi, 0 ; return 0 (success)
section .data
message: db \'hello, world!\',0x0A ; message and newline
length: equ $-message ; NASM definition pseudo-instruction
',
'remote-tex'=>'\\documentclass{article}
\\begin{document}
hello world
\\end{document}',
'remote-matlab'=>'MATLAB',
'remote-sage'=>'Sage',
'remote-fortran'=>'Fortran',
'remote-ampl'=>'AMPL',
'remote-r'=>'R',
'remote-vbscript'=>'VBScript',
'remote-lisp'=>'(print "hello world")',
'remote-haskell'=>'module Main where
main = putStrLn "hello, world"',
'remote-prolog'=>'Prolog',
'remote-ruby'=>'puts "hello world"
for i in 1..10
puts i
end
(1..10).each { |i|
puts i
}
',
'remote-tcl'=>'Tcl',
'remote-scheme'=>'(display "hello world")
(newline)',
'remote-smalltalk'=>'Transscript show:\'hello world\';cr',
'remote-dart'=>'Dart',
'remote-winbatch'=>'Winbatch',
'remote-libxslt'=>'libxslt (Remote)',
'remote-xslfo'=>'XSL-FO (Remote)',
'remote-helium'=>'Helium Scraper Custom Template Export (Remote Helium Scraper)',
);
$HIS_WAIT_TYPES=array(
"0" => "Respond instantly to GET/POST requests (see \"Output Expressions\" page)",
"1" => "Respond to GET/POST requests when HIS Function finishes processing",
);
$HIS_MIME_TYPES=array(
'text/xml'=>'xml',
'text/plain'=>'txt',
'text/csv'=>'csv',
'text/tab-separated-values'=>'tsv',
'text/css'=>'css',
'text/html'=>'html',
'text/vcard'=>'vcard',
'application/x-www-form-urlencoded'=>'form',
'application/x-dvi'=>'dvi',
'application/x-latex'=>'tex',
'application/x-font-ttf'=>'ttf',
'application/x-shockwave-flash'=>'swf',
'application/x-stuffit'=>'sit',
'application/x-rar-compressed'=>'rar',
'application/x-tar'=>'tar',
'text/x-gwt-rpc'=>'xgr',
'application/x-javascript'=>'js',
'text/x-jquery-tmpl'=>'js',
'application/vnd.oasis.opendocument.text'=>'',
'application/vnd.oasis.opendocument.spreadsheet'=>'',
'application/vnd.oasis.opendocument.presentation'=>'',
'application/vnd.oasis.opendocument.graphics'=>'',
'application/vnd.ms-excel'=>'xls',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'=>'',
'application/vnd.ms-powerpoint'=>'ppt',
'application/vnd.openxmlformats-officedocument.presentationml.presentation'=>'',
'application/msword'=>'doc',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'=>'',
'application/vnd.mozilla.xul+xml'=>'',
'application/vnd.google-earth.kml+xml'=>'',
'multipart/mixed'=>'',
'multipart/alternative'=>'',
'multipart/related'=>'',
'multipart/form-data'=>'',
'multipart/signed'=>'',
'multipart/encrypted'=>'enc',
'model/example'=>'',
'model/iges'=>'iges',
'model/mesh'=>'mesh',
'model/vrml'=>'vrml',
'model/x3d+binary'=>'',
'model/x3d+vrml'=>'',
'model/x3d+xml'=>'',
'message/http'=>'',
'message/imdn+xml'=>'',
'message/partial'=>'',
'message/rfc822'=>'',
'image/svg+xml'=>'svg',
'image/gif'=>'gif',
'image/jpeg'=>'jpg',
'image/pjpeg'=>'pjpg',
'image/png'=>'png',
'image/tiff'=>'tiff',
'image/vnd.microsoft.icon'=>'ico',
'application/atom+xml'=>'atom',
'application/ecmascript'=>'ecma',
'application/EDI-X12'=>'edx',
'application/EDIFACT'=>'edi',
'application/json'=>'json',
'application/javascript'=>'js',
'application/octet-stream'=>'oct',
'application/ogg'=>'ogg',
'application/pdf'=>'pdf',
'application/postscript'=>'ps',
'application/rss+xml'=>'rss',
'application/soap+xml'=>'soap',
'application/font-woff'=>'fwf',
'application/xhtml+xml'=>'html',
'application/xml-dtd'=>'dtd',
'application/xop+xml'=>'xop',
'application/zip'=>'zip',
'application/x-gzip'=>'gz',
'audio/mpeg3'=>'mp3',
'audio/x-mpeg-3'=>'mp3',
'audio/mpeg'=>'mpg',
'audio/wav'=>'wav'
);
$STATIC=array();
global $STATIC;
$STATIC['match_types']=$HIS_MATCH_TYPES;
$STATIC['hfpvc_types']=$HIS_HFPVC_TYPES;
$STATIC['action_types']=$HIS_ACTION_TYPES;
$STATIC['job_status']=$HIS_JOB_STATUS;
$STATIC['job_types']=$HIS_JOB_TYPES;
$STATIC['output_types']=$HIS_OUTPUT_TYPES;
$STATIC['processing_types']=$HIS_PROCESSING_TYPES;
$STATIC['conditions']=$HIS_CONDITIONS;
$STATIC['operation_types']=$HIS_OPERATION_TYPES;
$STATIC['hf_resource_types']=$HIS_IRESOURCE_TYPES;
$STATIC['hf_resource_examples']=$HIS_IRESOURCE_EXAMPLES;
$STATIC['mime_types']=$HIS_MIME_TYPES;
$STATIC['wait_types']=$HIS_WAIT_TYPES;
// SET STATIC['languages'] and more...
include("translation.php");
$BIN_DIR=__dir__;
$PATH_SEPERATOR="/";
if ( strpos(php_uname('s'),"nux")===false)
{
$PATH_SEPERATOR="\\";
}
$settings_file=($BIN_DIR.$PATH_SEPERATOR."his-config.php");
if ( !file_exists($settings_file) )
{
$settings_file=(dirname($BIN_DIR).$PATH_SEPERATOR."his-config.php");
}
if ( file_exists($settings_file) )
{
include_once($settings_file);
}
else
{
if ( PHP_SAPI !== 'cli' && strpos($_SERVER['REQUEST_URI'],"install.php")===false)
{
include("view.menu.public.php");
include("view.public.php");
exit;
}
}
$APP=array();
$APP['db']=false;
$APP['fs']=false;
$APP['ms']=false;
include_once("model.database.php");
if ( file_exists($settings_file) )
{
include_once($settings_file);
$GLOBALS['settings']=$settings;
include_once("model.storage.php");
$db = new Settings_Database_Adapter($settings);
$db=$db->database;
$db->debug=false;
$APP['db']=$db;
if (!$db->connect())
{
include("templates/existsmessage.php");
exit;
}
include_once("model.storage.php");
$fs = new Settings_Storage_Adapter($settings);
$fs=$fs->storage;
$APP['fs']=$fs;
if (!$fs->connect())
{
include("templates/existsmessage.php");
exit;
}
include_once("model.message.php");
$ms = new Settings_Message_Adapter($settings);
$ms=$ms->messenger;
$APP['ms']=$ms;
}
/// SERVICES
$services_file=$BIN_DIR.$PATH_SEPERATOR."services.xml";
$service_doc = xmlToArray( simplexml_load_file($services_file) );
$services=array();
foreach ($service_doc as $services_list)
{
foreach ($services_list as $service)
{
$new_service=new Service($service);
$services[]=$new_service;
}
}
//$GLOBALS['settings']=$settings;
$APP['services']=$services;
$GLOBALS['APP']=$APP;
global $APP;
class his
{
public $obj_key_type='hash';
public $obj_version;
public function __construct()
{
global $software_version;
$this->obj_version = $software_version;
}
public function create_from_xml_array($data)
{
$this->fromobjectxml($data);
}
public function rcreate($props,$mode_raw=false)
{
$this->create($props,$mode_raw);
}
public function member_value_array()
{
$retval=array();
$localprops="";
$member_list=$this->member_list($this);
foreach ($member_list as $member)
{
$retval[$member]=$this->$member;
}
return $retval;
}
public function fromobjectxml($data)
{
// data is an array'd xml
$localprops="";
$member_list=$this->member_list($this);
foreach ($member_list as $member)
{
if ( isset($data['@attributes'][$member]) )
{
//echo "setting $member equal to ".($data['@attributes'][$member]);
//echo "<br/>";
if ($member!="str_file")
{
$this->$member = html_entity_decode($data['@attributes'][$member],ENT_XML1,"UTF-8");
}
else
{
$this->$member = base64_decode($data['@attributes'][$member]);
}
}
else
{
if (is_array($data) && array_key_exists($member,$data['@attributes']))
{
if ( strpos($member,"int_")===0)
{
$this->$member="0";
}
else
{
$this->$member="";
}
}
else
{
//echo "unable to find $member";
//echo "<br/>";
//print_r($data);
}
}
}
}
public function toobjectxml()
{
$localprops="";
$member_list=$this->member_list($this);
foreach ($member_list as $member)
{
$member_val = $this->$member;
$member_vals= toxmlvalue($this->$member);
//$member_val = htmlentities($this->$member, ENT_DISALLOWED|ENT_XML1, "UTF-8");
$localprops=$localprops." $member='".$member_val."'";
}
$retval="<".get_class($this).$localprops.">";
//$retval = $retval.var_export($this,true);
$retval=$retval."</".get_class($this).">\n";
//echo $retval;
return $retval;
}
public function send($queue,$data)
{
global $APP;
$queue_name=$APP['ms']->queue_prefix."".get_class($this)."_".$queue;
//echo "sending data to queue: ".$queue_name;
$APP['ms']->send_message($queue_name,$data);
}
public function receive($queue)
{
global $APP;
return $APP['ms']->read_message($APP['ms']->queue_prefix."".get_class($this)."_".$queue);
}
public function toxml()
{
$localprops="";
$member_list=$this->member_list($this);
foreach ($member_list as $member)
{
if ($member=="id_user") continue;
if ($member=="id_resource") continue;
if (strpos($member,"id_hf")===0) continue;
if ($member=="id") continue;
if ($member=="id_expr") continue;
if (strpos($member,"str_")===0) continue;
$localprops=$localprops." $member='".toxmlvalue($this->$member)."'";
}
if (!$this->obj_inherited)
{
$retval="<".get_class($this).$localprops.">";
$retval=$retval."</".get_class($this).">\n";
}
return $retval;
}
public $obj_debug=false;
public function build($obj_build_exclude=array())
{
global $APP;
//echo "BUILDING...\n";
$member_list=$this->member_list($this);
foreach ($member_list as $member)
{
if ( strpos( $member, "str_")!==FALSE )
{
$obj_prop=str_replace("str_","obj_",$member);
//echo "building $obj_prop\n";
$this->$obj_prop=new strings();
$hash_id=$this->$member;
$this->$obj_prop->get_from_hashrange( $hash_id );
if ($this->$obj_prop->id=='undefined' || in_array($obj_prop,$obj_build_exclude) )
{
//echo "SKIPPING $obj_prop";
$this->$obj_prop=false;
}
else
{
$this->$obj_prop->build($obj_build_exclude);
}
}
}
}
public function create_raw($props)
{
$this->create($props,true);
}
public function set($props)
{
$props=$this->remove_non_members($props);
foreach ($props as $prop_key=>$prop_value)
{
$this->$prop_key=$prop_value."";
}
}
public function delete()
{
global $APP;
$member_list=$this->member_list($this);
$first_member=$member_list[0];
$select_conditions=array();
$select_condition=new SelectComparison();
$select_condition->field=$first_member;
$select_condition->comparison="EQUAL";
$select_condition->value=$this->$first_member;
$select_conditions[]=$select_condition;
if ($this->obj_key_type=="hashrange")
{
$second_member=$member_list[1];
$select_condition=new SelectComparison();
$select_condition->field=$second_member;
$select_condition->comparison="EQUAL";
$select_condition->value=$this->$second_member;
$select_conditions[]=$select_condition;
}
foreach ($member_list as $each_member)
{
if (strpos($each_member,"str_")===0)
{
$obj_member = str_replace("str_","obj_",$each_member);
if ( isset($this->$obj_member) && $this->$obj_member)
{
$this->$obj_member->delete();
}
}
}
if ($this->obj_debug)
{
$APP['db']->debug=true;
}
$APP['db']->delete(get_class($this),$select_conditions);
}
public function create($props,$mode_raw=false)
{
global $APP;
if ($this->obj_debug)
{
//echo "before remove";
//print_r($props);
}
$props=$this->remove_non_members($props);
if ($this->obj_debug)
{
//echo "after remove";
//print_r($props);
}
$props_keys=array_keys($props);
for($i=0;$i<count($props_keys);$i++)
{
$prop_key=$props_keys[$i];
if ( strlen(trim($prop_key))==0)
{
continue;
}
$prop_val=$props[$props_keys[$i]];
if (!$mode_raw)
{
$prop_val=$this->special_storage($prop_key,$prop_val);
$props[$prop_key]=$prop_val;
}
}
if ($this->obj_debug)
{
echo "<pre>";
echo "CREATE()<br/>";
//echo "PROPS:<br/>";
//print_r($props);
$APP['db']->debug=true;
}
$APP['db']->insert(get_class($this),$props);
foreach ($props as $prop_key=>$prop_val)
{
//$prop_val=str_replace("'","\'",$prop_val); // "'
$this->$prop_key=$prop_val."";
} // end foreach
if ($this->obj_debug)
{
print_r($this);
}
} // end function
public function hash_to_expression_tree($hash,$do_substitutions=true)
{
if ($hash=="undefined") return;
if ( !isset($this->obj_expression) )
{
// $this->obj_expression=new stdClass();
$this->obj_expression=new strings();
$this->obj_expression->get_from_hashrange($hash);
$this->obj_expression->build();
}
if ( isset($this->obj_hf_parameters) && isset($this->obj_expression) && isset($this->obj_expression->body) )
{
if ($do_substitutions)
{
$this->obj_expression->value=replace_hf_parameters($this->obj_expression->body,$this->obj_hf_parameters);
}
else
{
if ( isset($this->obj_expression) )
{
if ( isset($this->obj_expression->body) )
{
$this->obj_expression->value=$this->obj_expression->body;
}
}
else
{
}
//$this->obj_expression->value=$this->obj_expression->body;
}
}
if ( isset($this->obj_expression) && !is_bool($this->obj_expression) && get_class($this->obj_expression)=="strings" )
{
$this->obj_expression->obj_match_customs=array();
$match_custom=new match_custom();
$all_customs = $match_custom->get_from_hashrange($hash);
if ( $all_customs )
{
foreach ( $all_customs as $each_custom )
{
$a_custom= new match_custom();
$a_custom->set( $each_custom );
$a_custom->build();
$this->obj_expression->obj_match_customs[$a_custom->idx_key]=$a_custom;
}
} // end if
$this->obj_expression->obj_match_entries=array();
$match_entry=new match_entry();
$all_entries = $match_entry->get_from_hashrange($hash);
if ( $all_entries )
{
foreach ( $all_entries as $each_entry )
{
$a_entry= new match_entry();
$a_entry->set( $each_entry );
$a_entry->build();
$this->obj_expression->obj_match_entries[$a_entry->idx_id]=$a_entry;
}
usort($this->obj_expression->obj_match_entries, "mesort");
} // end if
}
} // end function
public function special_storage($prop_key,$prop_val)
{
global $APP;
if ( strpos($prop_key,"str_") !== FALSE )
{
if ($this->obj_debug)
{
echo "In Special_storage function() for prop: $prop_key<br/><br/>";
}
$content_mime_type="text/plain";
$content_extension="txt";
$original_content_extension = $content_extension;
$sha1_string=sha1(microtime().$prop_key.$prop_val.rand(3,5));
$keyname=$GLOBALS['settings'][$APP['fs']->kind]['paths']['strings']['@attributes']['value']."/".$sha1_string.".".$content_extension;
$bucket_name=$GLOBALS['settings'][$APP['fs']->kind][$APP['fs']->bucket_syntax()]['@attributes']['value'];
$content_detection_info = get_mime_and_extension($prop_val);
// GIVES MIME TYPE, EXTENSION
$content_mime_type = $content_detection_info[0];
$content_extension = $content_detection_info[1];
if ( !stringEndsWith($keyname,$content_extension) )
{
$keyname = str_lreplace($original_content_extension,$content_extension,$keyname);
}
$APP['fs']->create_object(false,$bucket_name,$keyname,$prop_val,$content_mime_type);
$string_url=$APP['fs']->key_url($bucket_name,$keyname);
$sha1_string2=sha1($prop_key.microtime().$prop_val.rand(1,20));
$props_string=array();
$props_string['id']=$sha1_string2;
$props_string['val']=$string_url;
$new_string=new strings();
$new_string->create($props_string);
$prop_val=$sha1_string2;
} // end if
return $prop_val;
} // end function
public function update_raw($props)
{
$this->update($props,true);
}
public function remove_non_members($props)
{
$member_list=$this->member_list($this);
$props_keys=array_keys($props);
foreach ($props_keys as $prop_key)
{
$found_member=false;
foreach ($member_list as $member)
{
if ($prop_key==$member)
{
$found_member=true;
break;
}
}
if (!$found_member)
{
unset($props[$prop_key]);
}
}
return $props;
}
public function update($new_props,$mode_raw=false)
{
global $APP;
if ( !is_array($new_props) )
{
echo "model.classes.php Update() function expects array as input";
}
if ($this->obj_debug)
{
echo "UPDATE called in class ".get_class($this);
print_r($new_props);
$APP['db']->debug=true;
}
$bucket_name=$GLOBALS['settings'][$APP['fs']->kind][$APP['fs']->bucket_syntax()]['@attributes']['value'];
$member_list=$this->member_list($this);
$first_member=$member_list[0];
$second_member="";
if (!$mode_raw)
{
$new_props_keys=array_keys($new_props);
for ($i=0;$i<count($new_props_keys);$i++)
{
$new_props[$new_props_keys[$i]]=$this->special_storage($new_props_keys[$i],$new_props[$new_props_keys[$i]]);
}
}
$select_conditions=array();
$select_condition=new SelectComparison();
$select_condition->field=$first_member;
$select_condition->comparison="EQUAL";
$select_condition->value=$this->$first_member;
$select_conditions[]=$select_condition;
if ($this->obj_key_type=="hashrange")
{
$second_member=$member_list[1];
$select_condition=new SelectComparison();