-
Notifications
You must be signed in to change notification settings - Fork 1
/
classapp.php.eroi7
9899 lines (7702 loc) · 391 KB
/
classapp.php.eroi7
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
$ehcpversion="0.30.9";
# ehcp in launchpad: https://launchpad.net/~ehcp
# last modified by ehcpdeveloper on 2.3.2012 (d-m-y)
/*
* EASY HOSTING CONTROL PANEL MAIN CLASS FILE - ehcp Version 0.30.7 - www.ehcp.net
mail&msn: [email protected]
New ChangeLog (Nearest upper):
2012-3:
* gziping backup option added
* fix db add with "-" in name, (create database db-dene: not work, create database `db-dene`: works)
* fix subdomain issue
* minor fixes (usage&security)
* new options (such as wildcard domains)
* default template is sky
2011-11:
* file ownerships changed to: vsftpd:www-data
* file ownerships are more flexible and adjustable. all ftp/web configs follow those ownerships, when changed in classapp config section.
* one quota bug fixed
* one security fix
2011-08: (ver 0.30)
* new "easy install scripts" added, sqlbuddy etc.
* a clean, "sky" template added, by 7skyhost, thanks
* auto check for ehcp version, if upgrade needed..
* logrotate for all domain done, autom.
* different custom http for different webservers in dhcp db, so, switching webserver while having custom http is not a problem anymore
* code fixes, cleanup
* chive (mysql admin tool) added
* template_reseller added
* password reset improved/fixed
* ftp active/passive bug fixed
2011-05:
* fixed an ftp insert, security
* do not remember all
*
2011-01:
* Roundcube added,
* add domain to different IP on same server.
*
*
2010-11:
* multiserver, apache2+nginx on remote servers,
* some bugfix,
* ported ehcp dir to a new location: /var/www/new/ehcp
*
2010-09:
* nginx is supported directly in ehcp, automatically.
* multiserver concept improved. now, can produce config files for multiple webservers, it will be controlling multiple webservers soon.
* ssl is handled better now, i hope,
2010-03:
* a few fixes, I dont remember all,
* fixmailconfig does fix a few things too,
* ubuntu theme added by [email protected]
* more stable "fixapacheconfig" command
* bulk add email (bulk add domain/hosting already exist)
2010-01:
* Added webmail, pass change plugin in webmail (squirrelmail), by [email protected]
2009-11:
* Added autoreply using only php,ehcp, postfix transport maps, without 3rd party software
* added: function adjustEmailAutoreply
*
2009-09:
* fixmailconfiguration,
* fixapachewithssl # ssl support..
* fixapachenonssl
* default charset for new databases...
2009-06-08:
deleteFtpUserDirect() added
2009-06-07:
$this->showSimilarFunctions($func); function added
function addFtpToThisPaneluser() and similars added,
*
Todo:
* fixmail config içine, tüm domain dizinlerini oluşturan kod eklenecek. ilgili hata: www imapd: chdir dtl-server.com/wake/: No such file or directory
* add ftpuser/subdomain/email/db at single step, a feature request,
* multi server..
* firewall config,
* spamassassin,
* postfix mailbox_size_limit:
user:I was also wondering if you will be adding other webmail clients to the install any time soon I have nocc and v-webmail installed and i added it to the panel as a link
tr: yapilacaklar: son domain de silinince syncdns cortluyor... zira getdomains null donduruyor... neyse ilgilen iste.
this program was initially written in Turkish , a mixture of both is used a bit.
coding naming issues:
turkish-english- naming equalities: (to understand code namings, some of these may already be fixed.. I try to make it understandable.. )
filtre=filter
linkalan=linkfield
linkdosya=linkfile
alanlar=fields
replacealanlar=replacefields
degiskenal=getvariable (through _GET or _POST, defined in config/dbutil.php)
sayi=count
Hata = Error
Hata olustu = Error occured
cerceve=template, border
tablolistele=tablelist, list table,
varsayilan=default
solyazi=lefttext
sagyazi=righttext
this program was initially written in Turkish language; language module is developed later. So, some texts may be left Turkish.Sory.
security issues: (now handled by beforeinputcontrols and afterinputcontrols)
steps to control when doing something:
1- is user active?
2- is user limit exceeded for that action?
3- is user permitted to do that?
4- is user owner of that or authorized?
5- is target entity already exists ? that is, is domain exists, or is panel users exists ?
Kodlama standardi/ mini coding standards within this project:
*1:
* eger sadece True ya da false donduren bir fonksiyon ise,
$success=$success && $s=$this->adddaemonop("syncdomains",'','');
if($s)$this->output.="sync apache info sent to daemon.<br>";
* yok True/false den baska seyler de dondurebiliyorsa, querylerde oldugu gibi ozaman soyle:
$s=$this->executeQuery("insert into ".$this->conf['domainstable']['tablename']." (reseller,panelusername,domainname,homedir,status) values ('".$this->activeuser."','$panelusername','$domainname','$homedir','$status')");
if($s===false) {
$this->errortext('domain add to db failed');
$success=false;
} else $this->output.="Domain Added to db successfully.<br>";
* Yapılacaklar-todo:
* blgsrc:
vatandaş açtığı veritabanının yanında phpmyadmin ikonu olsa
kullanıcı adı ve şifresi girmeden açsa, sonra olabilir
*
* *
* serverplans taranacak,
* wwwserver icin, priority ye gore, in a kayitlari eklenecek, dnse,
* dnsserver icin, in ns ve ns1 in a kayitlari eklenecek..
*
* mailserver icin, in mx kayitlari eklenecek,
* domain.com. in a www1ip
* domain.com. in a www2ip
* www.domain.com. in a www1ip
* www.domain.com. in a www2ip v.b.
*
* domain.com in ns ns1.domain.com
* domain.com in ns ns2.domain.com,
* domain.com in ns ns3.domain.com,
*
* ns1.domain.com. in a dns1ip
* ns2.domain.com. in a dns2ip
* ns3.domain.com. in a dns3ip
*
* For multi server domain/dns/mysql add:
multi server add:
1- add to local ehcp db,
2- add to remote ehcp db,
3- apply changes to remote mysql using syncdns or appropriate action:
a) syncdns or syncdomains, in case a dns/domain op
b) directly add mysql db to remote mysql, if this is a mysql
multi server remove:
1- remove from remote ehcp db,
2- apply changes on remote by syncdns or syncdmoains,
3- remove from local ehcp db.*
*/
# include_once("config/dbutil.php"); # some old routines.. being ported to this class...
date_default_timezone_set('Europa/Istanbul'); # this is mandatory in php 5.3 and up for date commands
error_reporting (E_ALL ^ E_NOTICE);
include_once('config/adodb/adodb.inc.php');
#include_once('class_user.php');
#include_once('config/adodb/adodb-pager.inc.php');
include_once('localutils.php');
@include_once('module.php');
include_once('config/randomstring.php');
# bu harici fonksiyonlar, localutils icine tasinacak..
class Application
{
var $appname = '',$sitename='ehcp', $headers="From: [email protected]";
var $output='', $requirePassword=True, $checkinstall=True,$miscconfig=null;
var $queries=array(), $selecteddomain='',$isreseller=false;
var $wwwuser="www-data"; # these vars should be used are "user related" places, to unify all user settings.. #equivalent: var $wwwowner="vsftpd:www-data";
var $wwwgroup="www-data";
var $ftpuser="vsftpd"; # equivalent: var $ftpowner="vsftpd:www-data";
var $ftpgroup="www-data"; # with this config, ftp user is able to see/delete files written by webserver.
# debuglevel: 4: shows some functions, 3: shows queries
var $debuglevel=0;
var $myversion='';
var $dbhost;
var $dbname;
var $dbusername;
var $dbpass;
var $conn;
var $defaultlanguage="en",$clientip,$referer;
var $currentlanguage='en';
var $status_active="active",$status_passive="passive",$statusActivePassive,$passivefilt,$activefilt,$isDemo=false;
var $emailfrom='[email protected]';
# language strings will be defined in $lang['en']['error1'] in language/en.php or so on...
var $usertable,$dnsemail,$template,$templatefile,$op,$userinfo;
var $dnszonetemplate="dnszonetemplate";
var $dnsnamedconftemplate="dnsnamedconftemplate"; # aynen apache gibi oluturulacak...
var $activeuser,$isloggedin,$globalfilter,$commandline=false,$erroroccured=false;
var $connected_mysql_servers=array();
var $ehcpdir='';
var $tr="<tr class='list'>", $td="<td class='list'>", $th="<th class='list'>";
var $conf=array(
# config section
# yavas yavas conf sistemine gecmek lazim. aslinda kod icinde sabit bilgi kullanmamak lazim. string bile... ama nerdee...
# this is like configuration of many system settings, tablenames etc. by this, changing something is easier, without need to change code..
# apache and dns defs:
'adminname'=>'ehcpdeveloper',
'adminemail'=>'[email protected]',
'wwwbase'=>'/var/www',
'ehcpdir'=>'',
'vhosts'=>'/var/www/vhosts',
'namedbase'=>'/etc/bind',
'dnsip' => '10.0.0.10',
'dnsemail' => 'your.email.here',
# mysql definitions
'mysqlrootuser'=>'root', # this is for db creation.
'mysqlrootpass'=>'12345',
# ehcp db table definitions, this is to make code more db-independent...
'logintable'=>array(
'tablename'=>'panelusers',
'passwordfunction'=>'md5',
'usernamefield'=>'panelusername',
'passwordfield'=>'password'
),
'settingstable2'=>array(
'tablename'=>'settings',
'createtable'=>
"CREATE TABLE IF NOT EXISTS `settings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`group` varchar(20) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT '',
`reseller` varchar(30) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT '',
`panelusername` varchar(30) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT '',
`name` varchar(40) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT '',
`value` varchar(200) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT '',
`longvalue` text CHARACTER SET utf8 COLLATE utf8_turkish_ci,
`comment` varchar(100) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `group` (`group`,`reseller`,`panelusername`,`name`,`value`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci COMMENT='ehcp db - Table for settings of ehcp'"
),
'vpstable'=>array(
'tablename'=>'vps',
'listfields'=>array('vpsname','ip','ram','description','reseller','panelusername','hostip','state','image_template'),
'linkimages'=>array('images/incele.jpg','images/poweron.gif','images/poweroff.gif','images/pause.gif','images/edit2.gif','images/delete1.jpg'),
'linkfiles'=>array('?op=vps&op2=select','?op=vps&op2=start','?op=vps&op2=shutoff','?op=vps&op2=pause','?op=vps&op2=edit','?op=vps&op2=delete'),
'linkfield'=>'vpsname',
'checkfields'=>array(
'addvpscmd'=>'text'
),
'createtable'=>
"CREATE TABLE `vps` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`reseller` varchar(30) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
`panelusername` varchar(30) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
`status` varchar(10) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
`vpsname` varchar(30) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
`description` varchar(100) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
`hostip` varchar(20) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
`ip` varchar(20) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
`netmask` varchar(20) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
`broadcast` varchar(20) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
`gateway` varchar(20) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
`image_template` varchar(100) DEFAULT NULL,
`ram` int(11) DEFAULT NULL,
`cpu` int(11) DEFAULT NULL,
`state` varchar(20) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
`ping` varchar(10) CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
`hdimage` varchar(200) DEFAULT NULL,
`addvpscmd` text CHARACTER SET utf8 COLLATE utf8_turkish_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci COMMENT='ehcp db - list of vps and their properties'"
),
'domainstable'=>array(
'tablename'=>'domains',
'ownerfield'=>'panelusername',
'resellerfield'=>'reseller',
'domainfields'=>array('id','reseller','panelusername','domainname','status','comment'),
'listfields'=>array('id','reseller','panelusername','domainname','webserverips','status','diskquotaused','diskquota'),
'checkfields'=>array(
'serverip'=>'varchar(30)',
'dnsserverips'=>'varchar(200)',
'webserverips'=>'varchar(200)',
'mailserverips'=>'varchar(200)',
'mysqlserverips'=>'varchar(200)',
'host'=>'varchar(30)',
'apachetemplate'=>'text',
'apache2template'=>'text',
'nginxtemplate'=>'text',
'dnstemplate'=>'text',
'aliases'=>'text',
'diskquotaused'=>'int(4)',
'diskquota'=>'int(4)',
'diskquotaovernotified'=>'int(4)',
'diskquotaoversince'=>'date',
'graceperiod'=>'int(4) default 7'
)
),
'domainstable2'=>array(
'tablename'=>'domains',
'listfields'=>array('domainname')
),
'subdomainstable'=>array(
'tablename'=>'subdomains',
'listfields'=>array('reseller','panelusername','subdomain','domainname','homedir','ftpusername','comment'),
'linkimages'=>array('images/delete1.jpg'),
'linkfiles'=>array('?op=delsubdomain'),
'linkfield'=>'id',
'checkfields'=>array(
'ftpusername'=>'varchar(30)',
'password'=>'varchar(20)',
'email'=>'varchar(50)',
'webserverips'=>'varchar(200)'
)
),
'paneluserstable'=> array(
'tablename'=>'panelusers',
'resellerfield'=>'reseller',
'usernamefield'=>'panelusername',
'passwordfield'=>'password',
'listfields'=>array('id','reseller','panelusername','maxdomains','maxemails','quota','maxpanelusers','maxftpusers','maxdbs','name','email'),
'clickimages'=>array('images/edit.gif','images/delete1.jpg'),
'clickfiles'=>array('?op=editpaneluser','?op=deletepaneluser'),
'insertfields'=>array('panelusername',array('password','password'),array('maxdomains','default'=>5),array('maxemails','default'=>20),array('quota','default'=>500),array('maxpanelusers','default'=>5),array('maxftpusers','default'=>5),array('maxdbs','default'=>10),'name','email'),
'insertfieldlabels'=>array('panelusername','Password','maxdomains','maxemails','Quota (Mb)','maxpanelusers','maxftpusers','Max Mysql Databases','Name','Email'),
'mandatoryinsertfields'=>array('panelusername'), # zorunlu insert alanlari
'editfields'=>array('maxdomains','maxemails','quota','maxpanelusers','maxftpusers','maxdbs','name','email'), # edit edildigi zaman görünecek alanlar..
'editlabels'=>array('maxdomains','maxemails','quota (MB)','maxpanelusers','maxftpusers','maxdbs','name','email'), # edit edildigi zaman görünecek alanlar..
'viewfields'=>array('id','panelusername','maxdomains','maxemails','quota','maxpanelusers','maxdbs','name','email'),
'linkfield'=>'id',
'checkfields'=>array(
'comment'=>'varchar(100)'
),
'help'=>'description of this table... ehcp control panel users... '
),
'customstable'=>array( # custom dns and http settings
'tablename'=>'customsettings',
'listfields'=>array('id','domainname','name','comment','value'),
'linkimages'=>array('images/delete1.jpg'),
'linkfiles'=>array('?op=deletecustom'),
'orderby'=>'id',
'linkfield'=>'id',
'checkfields'=>array(
'reseller'=>'varchar(30)',
'panelusername'=>'varchar(30)',
'domainname'=>'varchar(50)',
'webservertype'=>'varchar(30)'
)
),
'emailuserstable'=>array(
'tablename'=>'emailusers', # going to be array as above..
'listfields'=>array('email','quota','domainname'),
'linkimages'=>array('images/delete1.jpg','images/edit.gif'),
'linkfiles'=>array('?op=userop&action=emailuserdelete','?op=editemailuser'),
'linkfield'=>'id',
'ownerfield'=>'panelusername',
'resellerfield'=>'reseller',
# for use with email user logins
'passwordfunction'=>'encrypt',
'usernamefield'=>'email',
'passwordfield'=>'password',
'checkfields'=>array(
'reseller'=>'varchar(30)',
'panelusername'=>'varchar(30)',
'domainname'=>'varchar(50)',
'status'=>'varchar(10)',
'autoreplysubject'=>'varchar(100)',
'autoreplymessage'=>'text'
)
),
'ftpuserstable'=>array(
'tablename'=>'ftpaccounts', # going to be array as above..
'ownerfield'=>'panelusername',
'resellerfield'=>'reseller',
'listfields'=>array('domainname','ftpusername','status','homedir','type'),
'checkfields'=>array(
'type'=>'varchar(10)',
'reseller'=>'varchar(30)',
'panelusername'=>'varchar(30)',
'domainname'=>'varchar(50)',
'homedir'=>'varchar(100)',
'datetime'=>'datetime'
)
),
'operations_table'=>array(
'tablename'=>'operations', # going to be array as above..
'listfields'=>array('id','user','ip','op','status','tarih','try','info','info2','info3','action'),
'checkfields'=>array(
'info'=>'varchar(200)',
'info2'=>'varchar(200)',
'info3'=>'varchar(200)',
'user'=>'varchar(30)',
'ip'=>'varchar(30)'
)
),
'backups_table'=>array(
'tablename'=>'backups',
'listfields'=>array('id','domainname','backupname','filename','date','size','status'),
'linkimages'=>array('images/delete1.gif'),
'linkfiles'=>array('?op=backups&op2=delete&filename='),
'linkfield'=>'filename',
'checkfields'=>array(
'status'=>'varchar(100)',
'domainname'=>'varchar(100)',
'filename'=>'varchar(200)'
)
),
'mysqldbstable'=>array(
'tablename'=>'mysqldb',
'listfields'=>array('domainname','dbname','host'),
'linkimages'=>array('images/delete1.jpg'),
'linkfiles'=>array('?op=domainop&action=deletedb'),
'linkfield'=>'id',
'checkfields'=>array(
'host'=>'varchar(30)',
'reseller'=>'varchar(30)',
'panelusername'=>'varchar(30)',
'domainname'=>'varchar(50)'
)
),
'mysqldbuserstable'=>array(
'tablename'=>'mysqlusers',
'listfields'=>array('domainname','dbname','dbusername','host'),
'linkimages'=>array('images/edit.gif'),
'linkfiles'=>array('?op=dbedituser'),
'linkfield'=>'id',
'checkfields'=>array(
'host'=>'varchar(30)',
'reseller'=>'varchar(30)',
'panelusername'=>'varchar(30)',
'domainname'=>'varchar(50)'
)
),
'serverstable'=>array(
'tablename'=>'servers',
'listfields'=>array('servertype','ip','accessip','mandatory','location'),
'linkimages'=>array('images/edit.gif'),
'linkfiles'=>array('?op=editserver'),
'linkfield'=>'id',
'checkfields'=>array('accessip'=>'varchar(30)')
),
'passwddirectoriestable'=>array(
'tablename'=>'directories',
'listfields'=>array('domainname','username','directory','expire'),
'linkimages'=>array('images/delete1.jpg'),
'linkfiles'=>array('?op=deletedirectory'),
'linkfield'=>'id',
'checkfields'=>array(
'reseller'=>'varchar(30)',
'panelusername'=>'varchar(30)',
'domainname'=>'varchar(50)'
)
),
'emailforwardingstable'=>array(
'tablename'=>'forwardings',
'listfields'=>array('panelusername','domainname','source','destination'),
'linkimages'=>array('images/delete1.jpg'),
'linkfiles'=>array('?op=delemailforwarding'),
'linkfield'=>'id',
'checkfields'=>array(
'reseller'=>'varchar(30)',
'panelusername'=>'varchar(30)',
'domainname'=>'varchar(50)'
)
),
'transporttable'=>array( # for email autoreply
'tablename'=>'transport',
'createtable'=>
"
CREATE TABLE transport (
domainname varchar(128) NOT NULL default '',
transport varchar(128) NOT NULL default '',
UNIQUE KEY domainname (domainname)
) TYPE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci
"
),
'settingstable'=>array(
'tablename'=>'misc',
'checkfields'=>array(
'name'=>'varchar(40)',
'panelusername'=>'varchar(30)'
)
),
'scriptstable'=>array(
'tablename'=>'scripts',
'checkfields'=>array(
'homepage'=>'varchar(50)',
'description'=>'text'
)
),
'daemonopstable'=>'operations',
'hashtable'=>array(
'tablename'=>'hash',
'createtable'=>"
CREATE TABLE IF NOT EXISTS `hash` (
`email` varchar(100) COLLATE utf8_turkish_ci NOT NULL DEFAULT 'NULL',
`hash` varchar(100) COLLATE utf8_turkish_ci DEFAULT NULL,
KEY `email_index` (`email`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci COMMENT='to store password remind hash'
"
)
);
/*
for almost every record:
panelusername: who is the owner of that, who setupd that. cannot be empty.
resellername: who is the reseller of that panelusername. cannot be empty.
domainname: to which domain is that related. empty if not related to domainname
*/
function set_ehcp_dir($dirname){
# extra variables will be removed later, only one should be used.
$this->ehcpdir=$dirname;
$this->mydir=$dirname;
$this->conf['ehcpdir']=$dirname;
}
function Application() {
global $skipUpdateWebstats,$debuglevel;
include('config.php');
$this->set_ehcp_dir(dirname(__FILE__));
$this->vhostsdir=$this->conf['vhosts'];
$this->dbhost=$dbhost;
$this->dbusername=$dbusername;
$this->dbpass=$dbpass;
$this->dbname=$dbname;
$this->conf['mysqlrootpass']=$dbrootpass;
$this->defaultlanguage=$defaultlanguage;
$this->isDemo=$isdemo;
if(!(isset($this->isDemo))) $this->isDemo=False;
$this->statusActivePassive=array("active"=>"active","passive"=>"passive");
if(isset($this->debuglevel)){
#....
}
$debuglevel=$this->debuglevel; # for outer functions using debuglevel
$this->clientip = getenv ("REMOTE_ADDR");
$this->referer = getenv("HTTP_REFERER");
$this->wwwowner=$this->wwwuser.':'.$this->wwwgroup;
$this->ftpowner=$this->ftpuser.':'.$this->ftpgroup;
}
function run() {
$this->debugecho("file:".__FILE__.", Line:".__LINE__.", Function:".__FUNCTION__,4,false);
$this->initialize();
#$this->serverPlan=new serverPlan();
# $this->output.=$this->debug();
global $commandline;
$this->commandline=$commandline;
# this is actual application runner, maps urls to functions..
$this->runOp($this->op);
$this->show();
}
function initialize(){
# burda herhangi class initialization yapilacak.. basta yapilacak isler..
global $commandline,$ehcpversion;
#if(!$commandline)$this->output.="<font size=+2>".$this->appname."<br><br></font>";
$this->myversion=$ehcpversion;
$this->connectTodb();
$this->debugecho("file:".__FILE__.", Line:".__LINE__.", Function:".__FUNCTION__,4,false);
$this->syncConfigs();
$this->passivefilt="status<>'".$this->status_active."' or status is null";
$this->activefilt="status='".$this->status_active."'";
$this->loadLanguage(); # load default en to handle errors in loadconfig,
$this->checkInstall();
$this->loadConfig();
if(!$this->isNoPassOp() and $this->requirePassword ) $this->securitycheck();
$this->loadLanguage(); # load again to activate actual lang in config.
#functions that has to be after securitycheck
#$this->output.=print_r3($this->userconfig);
if($this->isadmin()) {
$this->globalfilter=''; # burasi, securitycheck den sonra olmali. isadmin yoksa calismaz.
} else $this->globalfilter="(reseller='".$this->activeuser."' or panelusername='".$this->activeuser."')";
if(!$this->isadmin()) {
$userinfo=$this->query("select * from ".$this->conf['paneluserstable']['tablename']." where panelusername='$this->activeuser'", "dologin2");
$this->userinfo=$userinfo[0];
if($this->userinfo['maxpanelusers']>0) $this->isreseller=True;
}
$this->loadServerPlan();
$this->url='http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
#$this->check_mysql_connection();
}
function counter_reached($counter,$count){
# can be used to count something...
if(intval($this->miscconfig[$counter])>0) {
$nextval=intval($this->miscconfig[$counter])-1;
$this->setConfigValue($counter,$nextval);
return False; # check sometime,
}
$this->setConfigValue($counter,$count);
return True;
}
function check_ehcp_version(){
global $ehcpversion;
if($this->latest_version<>'') return; # check once
if(!$this->counter_reached('versionwarningcounter',20)) return False; # check 20 login later again.
$this->latest_version=trim(@file_get_contents("http://www.ehcp.net/latest_version.php?ip=".$this->dnsip));
if($this->latest_version<>'' and $this->latest_version<>$ehcpversion) {
$str="Your ehcp version is different($ehcpversion) than latest($this->latest_version) version. Either your ehcp is old, or you are using a new beta/test version. Look at <a target=_blank href='http://ehcp.net/?q=node/153'>here for download and upgrade</a>";
$this->warnings.=$str;
$this->infotoadminemail($str,"ehcp version warning for ".$this->dnsip,false);
}
}
function loadServerPlan(){
$this->singleserverip=$this->conf['dnsip']; # if there is only one server...
#$this->output.=__FUNCTION__.":".$this->singleserverip."<br>";
# more servers will be coded here...
}
function load_module($name){
if(!defined($name.'_file_loaded')) {
$this->echoln2(__FUNCTION__.": Sory, that module file not loaded yet. check code. (php autoload does not work with CLI)");
return False;
}
if(gettype($this->$name)<>'object') $this->$name=new $name($this,$name); # initialize new module, only if not done before.
return True;
}
function call_func_in_module($name,$func,$params=Null){
if(!$this->load_module($name)) return False;
if($params==Null) return $this->$name->$func(); # a function with no args
else return $this->$name->$func($params); # a func with named arguments (named array), as used in many parts of this file
}
function check_module_tables(){
# to be coded later.
}
function runOp($op){ # these are like url to function mappers... maps op variable to some functions in ehcp
global $id,$domainname;
$this->getVariable(array('id','domainname'));
$op=strtolower($op);
$otheroperations=array('advancedsettings');
switch ($op) {
# other
case 'settings' : return $this->settings();break;
case 'adjust_system' : return $this->adjust_system();break;
case 'redirect_domain' : return $this->redirect_domain();break;
case 'information' : return $this->information($id);break;
#multi-server operations:
case 'multiserver_add_domain' : return $this->multiserver_add_domain();break;
case 'new_sync_all' : return $this->new_sync_all();break;
case 'new_sync_domains' : return $this->new_sync_domains();break;
case 'new_sync_dns' : return $this->new_sync_dns();break;
case 'multiserver_add_ftp_user_direct': return $this->gui_multiserver_add_ftp_user_direct();break;
#single-server operations:
case 'bulkaddemail' : return $this->bulkAddEmail();break;
case 'whitelist' : return $this->whitelist();break;
case 'fixmailconfiguration' : return $this->fixMailConfiguration();break;
case 'dofixmailconfiguration' : return $this->addDaemonOp('fixmailconfiguration','','','','fix mail configuration');break;
case 'dofixapacheconfigssl' : return $this->addDaemonOp('fixApacheConfigSsl','','','','fixApacheConfigSsl');break;
case 'dofixapacheconfignonssl' : return $this->addDaemonOp('fixApacheConfigNonSsl','','','','fixApacheConfigNonSsl');break;
case 'rebuild_webserver_configs': return $this->rebuild_webserver_configs();break;
case 'updatediskquota' : return $this->updateDiskQuota();break;
case 'doupdatediskquota' : $this->addDaemonOp('updatediskquota','',$domainname,'','update disk quota');return $this->displayHome();break;
#editing of dns/apache templates for domains, on ehcp db
case 'editdnstemplate' : return $this->editDnsTemplate();break;
case 'editapachetemplate' : return $this->editApacheTemplate();break;
case 'editdomainaliases' : return $this->editDomainAliases();break;
case 'changedomainserverip' : return $this->changedomainserverip();break;
case 'warnings' : break; # this will be written just before show..
case 'bulkadddomain' : return $this->bulkaddDomain();break ;
case 'bulkdeletedomain' : return $this->bulkDeleteDomain();break ;
case 'exportdomain' : return $this->exportDomain();break;
case 'adddnsonlydomain' : return $this->addDnsOnlyDomain();break;
case 'adddnsonlydomainwithpaneluser': return $this->addDnsOnlyDomainWithPaneluser();break;
case 'getselfftpaccount' : return $this->getSelfFtpAccount();break;
case 'adddomaintothispaneluser' : return $this->addDomainToThisPaneluser();break;
case 'dodownloadallscripts' : return $this->doDownloadAllscripts();break;
case 'choosedomaingonextop' : return $this->chooseDomainGoNextOp();break;
case 'getmysqlserver' : return $this->getMysqlServer();break;
case 'emailforwardingsself' : return $this->emailForwardingsSelf();break;
case 'addemailforwardingself' : return $this->addEmailForwardingSelf();break;
case 'cmseditpages' : return $this->cmsEditPages();break;
case 'listservers' : return $this->listServers();break;
case 'addserver' : return $this->addServer();break;
case 'addiptothisserver' : return $this->add_ip_to_this_server();break;
case 'setactiveserverip' : return $this->set_active_server_ip();break;
case 'advancedsettings' : return $this->advancedsettings();break;
case 'delemailforwarding' : return $this->delEmailForwarding();break;
case 'addemailforwarding' : return $this->addEmailForwarding();break;
case 'emailforwardings' : return $this->emailForwardings();break;
case 'addscript' : return $this->addScript();break;
case 'addnewscript' : return $this->addNewScript();break;
case 'suggestnewscript' : return $this->suggestnewscript();break;
case 'listselectdomain' : return $this->listselectdomain();break;
case 'selectdomain' : return $this->selectdomain($id);break;
case 'deselectdomain' : return $this->deselectdomain();break;
case 'otheroperations' : return $this->otheroperations();break;
case 'loadconfig' : return $this->loadConfig();break;
#case 'showconf' : return $this->showConfig();break;
case 'changemypass' : return $this->changeMyPass();break;
# for mysql, stop and start is meaningless, because if mysql cannot run, then, panel also cannot be accessible or this functions do not work.
case 'dorestartmysql' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'mysql','info2'=>'restart')); break;
case 'dostopapache2' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'apache2','info2'=>'stop')); break;
case 'dostartapache2' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'apache2','info2'=>'start')); break;
case 'dorestartapache2' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'apache2','info2'=>'restart')); break;
case 'dostopvsftpd' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'vsftpd','info2'=>'stop')); break;
case 'dostartvsftpd' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'vsftpd','info2'=>'start')); break;
case 'dorestartvsftpd' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'vsftpd','info2'=>'restart')); break;
case 'dostopbind' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'bind9','info2'=>'stop')); break;
case 'dostartbind' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'bind9','info2'=>'start')); break;
case 'dorestartbind' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'bind9','info2'=>'restart')); break;
case 'dostoppostfix' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'postfix','info2'=>'stop')); break;
case 'dostartpostfix' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'postfix','info2'=>'start')); break;
case 'dorestartpostfix' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'service','info'=>'postfix','info2'=>'restart')); break;
case 'donewsyncdomains' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'new_sync_domains')); break;
case 'donewsyncdns' : $this->requireAdmin(); return $this->add_daemon_op(array('op'=>'new_sync_dns')); break;
case 'dosyncdomains' : return $this->addDaemonOp('syncdomains','','','','sync domains');break;
case 'dosyncdns' : return $this->addDaemonOp('syncdns','','','','sync dns');break;
case 'dosyncftp' : return $this->addDaemonOp('syncftp','','','','sync ftp for nonstandard homes');break;
case 'dosyncapacheauth' : return $this->addDaemonOp('syncapacheauth','','','','sync apache auth');break;
case 'options' : return $this->options();
case 'backups' : return $this->backups();break;
case 'dobackup' : return $this->doBackup();break;
case 'dorestore' : return $this->doRestore();break;
case 'listbackups' : return $this->listBackups();break;
# these sync functions are executed in daemon mode.
case 'syncdomains' : return $this->syncDomains();break;
case 'syncftp' : return $this->syncFtp();break;
case 'syncdns' : return $this->syncDns();break;
case 'syncall' : return $this->syncAll();break;
case 'syncapacheauth' : return $this->syncApacheAuth();break;
case 'fixapacheconfigssl' : return $this->fixApacheConfigSsl();break;
case 'fixapacheconfignonssl' : return $this->fixApacheConfigNonSsl();break;
#case 'syncallnew' : return $this->syncallnew();break;
case 'listdomains' : return $this->listDomains();break; # ayni zamanda domain email userlarini da listeler.
case 'subdomains' : return $this->subDomains(); break;
case 'addsubdomain' : return $this->addSubDomain(); break;
case 'addsubdomainwithftp' : return $this->addSubDomainWithFtp(); break;
case 'addsubdirectorywithftp' :return $this->addSubDirectoryWithFtp(); break;
case 'delsubdomain' : return $this->delSubDomain(); break;
case 'editdomain' : return $this->editdomain();
case 'listpassivedomains' : return $this->listDomains('',$this->passivefilt);break;
case 'phpinfo' : return $this->phpinfo();break;
case 'help' : return $this->help();break;
case 'syncpostfix' : return $this->syncpostfix();break;
case 'listemailusers' : return $this->listemailusers();break;
case 'listallemailusers' : return $this->listallemailusers();break;
case 'listpanelusers' : return $this->listpanelusers();break;
case 'resellers' : return $this->resellers();break;
case 'deletepaneluser' : return $this->deletepaneluser();break;
case 'operations' : $this->requireAdmin();$this->listTable('operations','operations_table','');break;
case 'listallftpusers' : return $this->listAllFtpUsers();break;
case 'listftpusersrelatedtodomains': return $this->listAllFtpUsers("domainname<>''");break;
case 'listftpuserswithoutdomain': return $this->listAllFtpUsers("domainname='' or domainname is null");break;
case 'listftpusers' : return $this->listftpusers();break;
case 'sifrehatirlat' : return $this->sifreHatirlat();break;
case 'todolist' : return $this->todolist();break;
case 'adddomain' : return $this->addDomain();break;
case 'adddomaineasy' : return $this->addDomainEasy();break;
case 'adddomaineasyip' : return $this->addDomainEasyip();break;
case 'transferdomain' : return $this->transferDomain(); break;
case 'deletedomain' : return $this->deleteDomain();break;
case 'addemailuser' : return $this->addEmailUser();break;
case 'addftpuser' : return $this->addFtpUser();break;
case 'addftptothispaneluser' : return $this->addFtpToThisPaneluser();break;# added in 7.6.2009
case 'add_ftp_special' : return $this->add_ftp_special();break;
case 'userop' : return $this->userop();break;
case 'domainop' : return $this->domainop();break;
case 'addmysqldb' : return $this->addMysqlDb(); break;
case 'addmysqldbtouser' : return $this->addMysqlDbtoUser(); break;
case 'addpaneluser' : return $this->addPanelUser();break;
case 'editpaneluser' : return $this->editPanelUser();break;
case 'editftpuser' : return $this->editFtpUser();break;
case 'domainsettings' : return $this->domainSettings();break;
case 'logout' : return $this->logout();break;
case 'daemon' : return $this->daemon();break;
case 'test' : return $this->test(); break;
case 'aboutcontactus' : return $this->aboutcontactus();break;
case 'applyforaccount' : return $this->applyforaccount();break;
case 'applyfordomainaccount' : return $this->applyfordomainaccount();break;
case 'applyforftpaccount' : return $this->applyforftpaccount();break;
case 'setconfigvalue2' : return $this->setConfigValue2($id);break;
case 'customhttp' : return $this->customHttpSettings();break;
case 'addcustomhttp' : return $this->addCustomHttp();break;
case 'deletecustom' : return $this->deleteCustomSetting();break;
case 'customdns' : return $this->customDnsSettings();break;
case 'addcustomdns' : return $this->addCustomDns();break;
case 'dbedituser' : return $this->dbEditUser();break;
case 'dbadduser' : return $this->dbAddUser();break;
case 'editemailuser' : # same as below
case 'editemailuserself' : return $this->editEmailUser();break;
case 'editemailuserautoreplyself':
case 'editemailuserautoreply' : return $this->editEmailUserAutoreply();break;
case 'editemailuserpasswordself':
case 'editemailuserpassword' : return $this->editEmailUserPassword();break;
case 'directories' : return $this->directories();break;
case 'listmyalldirectories' : return $this->listMyAllDirectories();break;
case 'adddirectory' : return $this->addDirectory();break;
case 'deletedirectory' : return $this->deleteDirectory();break;
case 'changetemplate' : return $this->changetemplate();break;
case 'addredirect' : return $this->addRedirect();break;
case 'serverstatus' : return $this->serverStatus();break;
case 'setlanguage' : $this->setLanguage($id);$this->displayHome();break;
case 'setdefaultdomain' : $this->setDefaultDomain();$this->displayHome();break;
case 'dologin' : # default anasayfa, same as below:
case '' : $this->displayHome();break;
# virtual machine (vps) opcodes:
case 'vps_home' : return $this->call_func_in_module('Vps_Module','vps_home'); break;
case 'vps' : return $this->call_func_in_module('Vps_Module','vps'); break;
case 'vps_mountimage' : return $this->call_func_in_module('Vps_Module','vps_mountimage'); break;
case 'vps_dismountimage' : return $this->call_func_in_module('Vps_Module','vps_dismountimage'); break;
case 'add_vps' : return $this->call_func_in_module('Vps_Module','add_vps'); break;
default : return $this->errorText("(runop) internal ehcp error: Undefined operation: $op <br> This feature may not be complete");break;
}# switch
return True;
}# func runop
#include_once('modules/module_index.php'); # verdigi hata: Parse error: syntax error, unexpected T_INCLUDE_ONCE, expecting T_FUNCTION in /var/www/new/ehcp/classapp.php on line 1044
function information($id,$link=false){
if($link) return " - <a href=index.php?op=information&id=$id>?</a>";
switch($id){
case 1: $out='The translation of this item is not complete. see languages folder or launchpad translation section';break;
default: $out=' Information id is not provided/wrong. see function '.__FUNCTION__.' in '.__FILE__;break;
}
$this->output.="<br><b>$out</b><br>";
}
function gui_multiserver_add_ftp_user_direct(){
$params=array(
'ftpserver'=>'96.31.91.67',
'panelusername'=>'admin22',
'ftpusername'=>'bvdene',
'ftppassword'=>'1234',
'homedir'=>'/var/www/bvdene',
'domainname'=>'bvdene.com'
);
#$this->output.="Adding ftp for remote:".print_r2($params);
$this->multiserver_add_ftp_user_direct($params);
}
function checkFields($tb,$fields1,$fields2){