1<?php 2/** 3 * Group-Office 4 * 5 * Copyright Intermesh BV. 6 * This file is part of Group-Office. You should have received a copy of the 7 * Group-Office license along with Group-Office. See the file /LICENSE.TXT 8 * 9 * If you have questions write an e-mail to info@intermesh.nl 10 * 11 * @license AGPL/Proprietary http://www.group-office.com/LICENSE.TXT 12 * @link http://www.group-office.com 13 * @copyright Copyright Intermesh BV 14 * @version $Id: Number.php 7962 2011-08-24 14:48:45Z mschering $ 15 * @author Merijn Schering <mschering@intermesh.nl> 16 * @package GO.base 17 */ 18 19/** 20 * Main configuration 21 * 22 * This class holds the main configuration options of Group-Office 23 * Don't modify this file. The values defined here are just default values. 24 * They are overwritten by the configuration options in /config.php or 25 * /etc/groupoffice/{HOSTNAME}/config.php 26 * 27 * To edit these options use install.php. 28 * 29 * All options can also be found at: 30 * 31 * http://www.group-office.com/wiki/Configuration_file 32 * 33 * 34 * @license AGPL/Proprietary http://www.group-office.com/LICENSE.TXT 35 * @link http://www.group-office.com 36 * @author Merijn Schering <mschering@intermesh.nl> 37 * @version $Id: config.class.inc.php 7687 2011-06-23 12:00:34Z mschering $ 38 * @copyright Copyright Intermesh BV. 39 * @package GO.base 40 */ 41 42 43namespace GO\Base; 44 45use GO\Base\Model\Group; 46 47 48class Config extends Observable{ 49#FRAMEWORK VARIABLES 50 51/** 52 * This can be set to clear the payment method field when an order is duplicated. 53 * By default it is set to true, so then the field will be cleared in the duplicate item. 54 * When set to false, the value of the original will be copied to the duplicated version. 55 * 56 * @deprecated 57 * @var boolean 58 */ 59var $billing_clear_payment_method_on_duplicate = true; 60 61/** 62 * Enable this Group-Office installation? 63 * 64 * @deprecated Block non admin logins 65 * @var StringHelper 66 * @access public 67 */ 68 var $enabled = true; 69 70 /** 71 * Enable sending system emails with an email account from the email module 72 * Needs to be the id of the wanted mail account 73 * 74 * @deprecated Used in tickets now but perhaps create settings there if needed. 75 * 76 * @var int 77 */ 78 var $smtp_account_id = false; 79 80 /** 81 * Enable Smime for outgoing system emails. 82 * Note: this only works when a mailaccount is used to send the system emails 83 * (Please see: $smtp_account_id) 84 * 85 * @depcreated Do we need this? 86 * @var boolean 87 */ 88 var $smtp_account_smime_sign = false; 89 90 /** 91 * The password that is needed to sign the Smime certificate for outgoing system emails 92 * Note: this is only needed when a mailaccount is used to send the system emails 93 * (Please see: $smtp_account_id) 94 * and when $smtp_account_smime_sign is set to true 95 * 96 * @var StringHelper 97 */ 98 var $smtp_account_smime_password = ""; 99 100 /** 101 * 102 * @deprecated We'll cache the headers 103 * 104 * @var Set the client side sort of imap to receive all messages with the DATE or R_DATE flag. 105 * If set to false (Default) then it will use the sort key 'ARRIVAL' 106 * Usually done when client_side_sort is used in combination with an Microsoft Exchange Server. 107 */ 108 var $imap_sort_on_date = false; 109 110 /** 111 * The Group-Office server ID 112 * 113 * @var StringHelper 114 * @access public 115 */ 116 var $id = 'groupoffice'; 117 118 /** 119 * Enable debugging mode. This will log much info to 120 * /home/groupoffice/log/debug.log and will use uncompressed javascripts. 121 * You can also enable this as admin in Group-Office by pressing CTRL+F7. 122 * 123 * @deprecated Is in system settings 124 * @var bool 125 * @access public 126 */ 127 var $debug = false; 128 129 130 /** 131 * Enable display_errors = on for php 132 * 133 * @deprecated Never diplay errors 134 * @var boolean 135 */ 136 public $debug_display_errors=false; 137 138 139// /** 140// * Only log debug messages for this remote IP address. 141// * 142// * @var string 143// * @access public 144// */ 145// var $debug_log_remote_ip = ""; 146 147 148 /** 149 * Just enable the debug log. 150 * 151 * @deprecated 152 * @var bool 153 */ 154 var $debug_log = false; 155 156 157 158 159 160 /** 161 * Set the number of days the database log will contain until it will be dumped to a CSV file on disk. 162 * The log module must be installed. 163 * 164 * @deprecated Should be in log module settings 165 * @var int 166 */ 167 var $log_max_days=14; 168 169 /** 170 * Enable FirePhp 171 * 172 * @deprecated 173 * @var bool 174 * @access public 175 */ 176 var $firephp = false; 177 178 /** 179 * Info log location. Disabled when left empty. 180 * 181 * @deprecated move to new module 182 * @var bool 183 */ 184 var $info_log = ""; 185 186// /** 187// * Output errors in debug mode 188// * 189// * @var bool 190// * @access public 191// */ 192// var $debug_display_errors=true; 193 194// /** 195// * Enable syslog 196// * 197// * @var bool 198// * @access public 199// */ 200// 201// var $log = false; 202 203 204 205 206 207 208 /** 209 * Default VAT percentage 210 * 211 * @deprecated Should move to billing 212 * @var StringHelper 213 * @access public 214 */ 215 var $default_vat = 21; 216 217 218 /** 219 * Default currency 220 * 221 * @var StringHelper 222 * @access public 223 */ 224 public function getdefault_currency() { 225 return \go\core\model\Settings::get()->defaultCurrency; 226 } 227 228 /** 229 * Default date format 230 * 231 * @deprecated is in system settings 232 * @var StringHelper 233 * @access public 234 */ 235 public function getDefault_date_format() { 236 $df = \go\core\model\Settings::get()->defaultDateFormat; 237 return $df[0].$df[2].$df[4]; 238 } 239 240 241 242 /** 243 * Default date separator 244 * 245 * @deprecated is in system settings 246 * @var StringHelper 247 * @access public 248 */ 249 public function getdefault_date_separator() { 250 $df = \go\core\model\Settings::get()->defaultDateFormat; 251 return $df[1]; 252 } 253 254 /** 255 * Default time format 256 * 257 * @var StringHelper 258 * @access public 259 */ 260 261 public function getdefault_time_format() { 262 return \go\core\model\Settings::get()->defaultTimeFormat; 263 } 264 265 /** 266 * Default name formatting and sorting. Can be last_name or first_name 267 * 268 * @deprecated Should move to address book 269 * @var StringHelper 270 * @access public 271 */ 272 var $default_sort_name = "displayName"; 273 274 275 /** 276 * Default first day of the week 0=sunday 1=monday 277 * 278 * @deprecated Should move to address book 279 * @var StringHelper 280 * @access public 281 */ 282 public function getDefault_first_weekday() { 283 return \go\core\model\Settings::get()->defaultFirstWeekday; 284 } 285 286 /** 287 * Default decimal separator for numbers 288 * 289 * @var StringHelper 290 * @access public 291 */ 292 public function getdefault_decimal_separator() { 293 return \go\core\model\Settings::get()->defaultDecimalSeparator; 294 } 295 296 /** 297 * Default thousands separator for numbers 298 * 299 * @var StringHelper 300 * @access public 301 */ 302 public function getdefault_thousands_separator() { 303 return \go\core\model\Settings::get()->defaultThousandSeparator; 304 } 305 306 /** 307 * Default list separator for import and export 308 * 309 * @var StringHelper 310 * @access public 311 */ 312 public function getdefault_list_separator() { 313 return \go\core\model\Settings::get()->defaultListSeparator; 314 } 315 316 /** 317 * Default text separator for import and export 318 * 319 * @var StringHelper 320 * @access public 321 */ 322 public function getdefault_text_separator() { 323 return \go\core\model\Settings::get()->defaultTextSeparator; 324 } 325 326 public function getdefault_timezone() { 327 return \go\core\model\Settings::get()->defaultTimezone; 328 } 329 330 /** 331 * Default theme 332 * 333 * @var StringHelper 334 * @access public 335 */ 336 var $theme = 'Paper'; 337 338 /** 339 * Default theme 340 * 341 * @var StringHelper 342 * @access public 343 */ 344 var $defaultView = 'Extjs3'; 345 346 /** 347 * Enable theme switching by users 348 * 349 * @var bool 350 * @access public 351 */ 352 var $allow_themes = true; 353 354 /** 355 * Enable password changing by users 356 * 357 * @var bool 358 * @access public 359 */ 360 var $allow_password_change = true; 361 362 /** 363 * Enable profile editing by every user through the settings dialog 364 * 365 * @var bool 366 * @access public 367 */ 368 var $allow_profile_edit = true; 369 370 /** 371 * Hide disabled users in select lists. 372 * 373 * @var bool 374 */ 375 var $hide_disabled_users = true; 376 377// /** 378// * Enable user registration by everyone 379// * 380// * @var bool 381// * @access public 382// */ 383// var $allow_registration = false; 384 385 386 /** 387 * The maximum number of MB a new Group-Office user will be able to use. 388 * This can be changed per user after creating it. 389 * Empty means unlimited disk space (Option is NOT yet released) 390 * 391 * @var int 392 */ 393 var $default_diskquota = 1000; 394 395 396 /** 397 * Allow e-mail address more then once 398 * 399 * @var bool 400 * @access public 401 */ 402 var $allow_duplicate_email = false; 403 404 405 /** 406 * The default font to be used in the generated PDF files. 407 * @var StringHelper 408 */ 409 public $tcpdf_font = "freesans"; 410 411 /** 412 * Disable filesystem syncing from the web interface 413 * 414 * @var boolean 415 */ 416 public $files_disable_filesystem_sync=false; 417 418 /** 419 * Enable spell checker 420 * 421 * Warning: It has known issues with corrupting the HTML! 422 * 423 * @var boolean 424 */ 425 public $spell_check_enabled = false; 426// /** 427// * Grant read permissions for these modules to new self-registered users. 428// * Module names are separated by a comma. 429// * 430// * @var string 431// * @access public 432// */ 433// var $register_modules_read = ''; 434// 435// /** 436// * Grant write permissions for these modules to new self-registered users. 437// * Module names are separated by a comma. 438// * 439// * @var string 440// * @access public 441// */ 442// var $register_modules_write = ''; 443 444 /** 445 * Comma separated list of allowed modules. Leave empty to allow all modules. 446 * 447 * @var StringHelper 448 * @access public 449 */ 450 var $allowed_modules = ''; 451 452 453 /** 454 * Add self-registered users to these user groups 455 * Group names are separated by a comma. 456 * 457 * @var StringHelper 458 * @access public 459 */ 460 var $register_user_groups = ''; 461 462 /** 463 * Self-registered users will be visible to these user groups 464 * Group names are separated by a comma. 465 * 466 * @var StringHelper 467 * @access public 468 */ 469 var $register_visible_user_groups = "GROUP_EVERYONE"; 470 471 /** 472 * Relative hostname with slash on both start and end 473 * 474 * use go\core\model\Settings:URL 475 * 476 * @deprecated since 6.3 477 * 478 * @var StringHelper 479 * @access public 480 */ 481 var $host = '/groupoffice/'; 482 483 /** 484 * Set Access-Control-Allow-Origin: * header for example. 485 * 486 * @var StringHelper 487 */ 488 var $extra_headers=array(); 489 490// /** 491// * Useful to force https://your.host:433 or something like that 492// * 493// * @var bool 494// * @access public 495// */ 496// 497// var $force_login_url = false; 498 499 /** 500 * Force an HTTPS connection in the main /index.php 501 * 502 * @var boolean 503 */ 504 var $force_ssl=false; 505 506 /** 507 * The path to the root of Group-Office with trailing slash. 508 * 509 * @deprecated Auto detected 510 * 511 * @var StringHelper 512 * @access public 513 */ 514 var $root_path = ''; 515 516 /** 517 * The path to store temporary files with trailing slash. 518 * 519 * @var StringHelper 520 * @access public 521 */ 522 var $tmpdir = '/tmp/groupoffice/'; 523 524 /** 525 * The maximum number of users 526 * 527 * @var int 528 * @access public 529 */ 530 var $max_users = 0; 531 532 /** 533 * If set, user queries will only return this maximum number of users. 534 * Useful in large environments where you don't want users to scroll through all, 535 * 536 * @var int 537 */ 538 var $limit_usersearch=0; 539 540 /** 541 * The maximum number KB this Group-Office installation may use. 0 will allow unlimited usage of disk space. 542 * 543 * @var int 544 * @access public 545 */ 546 var $quota = 0; 547 548 549 #database configuration 550 /** 551 * The database type to use. Currently only MySQL is supported 552 * 553 * @var StringHelper 554 * @access public 555 */ 556 var $db_type = 'mysql'; 557 /** 558 * The host of the database 559 * 560 * @var StringHelper 561 * @access public 562 */ 563 var $db_host = ''; 564 /** 565 * The name of the database 566 * 567 * @var StringHelper 568 * @access public 569 */ 570 var $db_name = ''; 571 /** 572 * The username to connect to the database 573 * 574 * @var StringHelper 575 * @access public 576 */ 577 var $db_user = ''; 578 /** 579 * The password to connect to the database 580 * 581 * @var StringHelper 582 * @access public 583 */ 584 var $db_pass = ''; 585 586 /** 587 * Specifies the port number to attempt to connect to the MySQL server. 588 * 589 * @var StringHelper 590 * @access public 591 */ 592 var $db_port = 3306; 593 594 /** 595 * Specifies the socket or named pipe that should be used. 596 * 597 * @var StringHelper 598 * @access public 599 */ 600 var $db_socket = ''; 601 602 /** 603 * Specifies the charset that needs to be used for the database. 604 * 605 * @var StringHelper 606 * @access public 607 */ 608 var $db_charset = "'utf8mb4' COLLATE 'utf8mb4_unicode_ci'"; 609 610 /** 611 * 612 * Useful in clustering mode. Defaults to "1". Set to the number of clustered 613 * nodes. 614 * 615 * @var StringHelper 616 * @access public 617 */ 618 619 var $db_auto_increment_increment=1; 620 621 /** 622 * 623 * Give each node an incremented number. 624 * 625 * @var StringHelper 626 * @access public 627 */ 628 629 var $db_auto_increment_offset=1; 630 631 632 633 #FILE BROWSER VARIABLES 634 635 /** 636 * The path to the location where the files of the file browser module are stored 637 * 638 * This path should NEVER be inside the document root of the webserver 639 * this directory should be writable by apache. Also choose a partition that 640 * has enough diskspace. 641 * 642 * @var StringHelper 643 * @access public 644 */ 645 var $file_storage_path = '/home/groupoffice/'; 646 647 648 /** 649 * Convert non ASCII characters to ASCII codes when uploaded to Group-Office. 650 * Useful for Windows servers that don't support UTF8. 651 * 652 * @var boolean 653 */ 654 public $convert_utf8_filenames_to_ascii=false; 655 656 /** 657 * The maximum file size the filebrowser attempts to upload. Be aware that 658 * the php.ini file must be set accordingly (http://www.php.net). 659 * 660 * @var StringHelper 661 * @access public 662 */ 663 var $max_file_size = 1000 * 1024 * 1024; 664 665 /** 666 * The maximum file size of an image to be allowed for thumbnailing in MBs 667 * 668 * @var integer 669 * @access public 670 */ 671 var $max_thumbnail_size = 10; 672 673 /** 674 * Maximum number of old file versions to keep 675 * -1 will disable versioning. 0 will keep an infinite number of versions (Be careful!). 676 * 677 * @var int 678 */ 679 public $max_file_versions = 3; 680 681 682 #email variables 683 /** 684 * The E-mail mailer type to use. Valid options are: smtp, qmail, sendmail, mail 685 * 686 * @var int 687 * @access public 688 */ 689 690 691 /** 692 * The Swift mailer component auto detects the domain you are connecting from. 693 * In some cases it fails and uses an invalid IPv6 IP like ::1. You can 694 * override it here. 695 * 696 * @var StringHelper 697 * @access public 698 */ 699 var $smtp_local_domain = ''; 700 701 702 /** 703 * A special Swift preference to escape dots. For some buggy SMTP servers this 704 * is necessary. 705 * 706 * @var boolean 707 */ 708 var $swift_qp_dot_escape=false; 709 710 711 /** 712 * Set to true to prevent users from changing their e-mail aliases in the email module. 713 * 714 * @var boolean 715 */ 716 var $email_disable_aliases=false; 717 718 719 /** 720 * We stumbled upon a dovecot server that crashed when sending a command 721 * using LIST-EXTENDED. With this option we can workaround that issue. 722 * 723 * @var StringHelper 724 */ 725 var $disable_imap_capabilities=""; 726 727 /** 728 * A comma separated list of smtp server IP addresses that you 729 * want to restrict. 730 * 731 * eg. '213.207.103.219:10,127.0.0.1:10'; 732 * 733 * Will restrict those IP's to 10 e-mails per day. 734 * 735 * @var unknown_type 736 */ 737 738 var $restrict_smtp_hosts = ''; 739 740 /** 741 * The maximum summed size of e-mail attachments in a message in bytes 742 * Group-Office will accept. 743 * 744 * @var int 745 * @access public 746 */ 747 var $max_attachment_size = 50 * 1024 * 1024; 748 749 750 //External programs 751 752 /** 753 * Command to create ZIP archive 754 * @var StringHelper 755 * @access public 756 */ 757 var $cmd_zip = '/usr/local/bin/zip'; 758 759 /** 760 * Command to unpack ZIP archive 761 * @var StringHelper 762 * @access public 763 */ 764 var $cmd_unzip = '/usr/bin/unzip'; 765 766 /** 767 * Command to control TAR archives 768 * @var StringHelper 769 * @access public 770 */ 771 var $cmd_tar = '/usr/bin/tar'; 772 773 /** 774 * Command to set system passwords. Used by passwd.users.class.inc. 775 * SUDO must be set up! 776 * 777 * @var StringHelper 778 * @access public 779 */ 780 var $cmd_chpasswd = '/usr/bin/passwd'; 781 782 /** 783 * Command to SUDO 784 * @var StringHelper 785 * @access public 786 */ 787 var $cmd_sudo = '/usr/local/bin/sudo'; 788 789 /** 790 * Command to convert xml to wbxml 791 * 792 * @var StringHelper 793 * @access public 794 */ 795 var $cmd_xml2wbxml = '/usr/local/bin/xml2wbxml'; 796 797 /** 798 * Command to convert wbxml to xml 799 * 800 * @var StringHelper 801 * @access public 802 */ 803 var $cmd_wbxml2xml = '/usr/local/bin/wbxml2xml'; 804 805 /** 806 * Command to unpack winmail.dat files 807 * 808 * @var StringHelper 809 * @access public 810 */ 811 var $cmd_tnef = '/usr/local/bin/tnef'; 812 813 /** 814 * Command to execute the php command line interface 815 * 816 * @var StringHelper 817 * @access public 818 */ 819 var $cmd_php = 'php'; 820 821 822 /** 823 * Length of the password generated when a user uses the lost password option 824 * 825 * @var int 826 */ 827 var $default_password_length=6; 828 829 /** 830 * Required length of passwords. 831 * 832 * @var boolean 833 */ 834 var $password_validate=true; 835 836 /** 837 * Required length of passwords. 838 * 839 * @var int 840 */ 841 var $password_min_length=6; 842 843 /** 844 * Require an uppercase char 845 * 846 * @var boolean 847 */ 848 var $password_require_uc=true; 849 850 /** 851 * Require a lowercase char 852 * 853 * @var boolean 854 */ 855 var $password_require_lc=true; 856 857 /** 858 * Require numbers 859 * 860 * @var boolean 861 */ 862 var $password_require_num=true; 863 864 /** 865 * Require a special char 866 * 867 * @var boolean 868 */ 869 var $password_require_sc=true; 870 871 /** 872 * Required unique chars 873 * 874 * @var int 875 */ 876 var $password_require_uniq=3; 877 878 /** 879 * Automatically log a user out after n seconds of inactivity 880 * 881 * @var int 882 */ 883 var $session_inactivity_timeout = 0; 884 885 /** 886 * Callto: link template 887 */ 888 889 var $callto_template='tel://{phone}'; 890 891 /** 892 * Open a new new window when a phone number is clicked 893 * 894 * @var bool 895 */ 896 var $callto_open_window = false; 897 898 /** 899 * Disable security check for cross domain forgeries 900 * 901 * @var <type> 902 */ 903 904 var $disable_security_token_check=false; 905 906 /** 907 * The number of items displayed in the navigation panels (Calendars, addressbooks etc.) 908 * Don't set this number too high because it may slow the browser and server down. 909 * 910 * @var type 911 */ 912 913 var $nav_page_size=50; 914 915 916 /** 917 * If you are behind a proxy you can set it here for all CURL operations Group-Office performs. 918 * 919 * This curl function will be used: 920 * curl_setopt($ch, CURLOPT_PROXY, "http://proxy.com:8080"); 921 * 922 * @var StringHelper 923 */ 924 var $curl_proxy=""; 925 926 927 var $calendar_tasklist_show = 0; 928 929 930// /** 931// * Enable logging of slow requests 932// * 933// * @var boolean 934// */ 935// public $log_slow_requests=false; 936// 937// /** 938// * Slow request time in seconds 939// * 940// * @var float 941// */ 942// public $log_slow_requests_trigger=1; 943// 944// /** 945// * Path of the log file 946// * 947// * @var string 948// */ 949// public $log_slow_requests_file="/home/groupoffice/slow-requests.log"; 950 951 /*////////////////////////////////////////////////////////////////////////////// 952 ////////// Variables that are not touched by the installer ///////////// 953 //////////////////////////////////////////////////////////////////////////////*/ 954 955 956 957 /** 958 * Enable zlib compression for faster downloading of scripts and css 959 * 960 * @var StringHelper 961 * @access public 962 */ 963 var $zlib_compress = true; 964 965 /** 966 * Default list page size 967 * 968 * @var int 969 */ 970 var $default_max_rows_list = 30; 971 972 /** 973 * Product name. If changed all Group-Office references will disappear. 974 * @var StringHelper 975 */ 976 977 var $product_name='GroupOffice'; 978 979 980 /* The permissions mode to use when creating files 981 * 982 * @var string 983 * @access public 984 */ 985 var $file_create_mode = '0644'; 986 987 /* The permissions mode to use when creating folders 988 * 989 * @var string 990 * @access public 991 */ 992 var $folder_create_mode = '0755'; 993 994 /* New files and folders will be chown'd to this group. 995 * 996 * @var string 997 * @access public 998 */ 999 var $file_change_group = ''; 1000 1001 /*//////////////////////////////////////////////// 1002 * Variables below this should not be changed 1003 *//////////////////////////////////////////////// 1004 1005 #group configuration 1006 /** 1007 * The administrator user group ID 1008 * 1009 * @var StringHelper 1010 * @access public 1011 */ 1012 var $group_root = '1'; 1013 /** 1014 * The everyone user group ID 1015 * 1016 * @var StringHelper 1017 * @access public 1018 */ 1019 var $group_everyone = '2'; 1020 1021 /** 1022 * The internal user group ID 1023 * 1024 * @var StringHelper 1025 * @access public 1026 */ 1027 var $group_internal = '3'; 1028 1029 /** 1030 * Date formats to be used. Only Y, m and d are supported. 1031 * 1032 * @var StringHelper 1033 * @access public 1034 */ 1035 var $date_formats = array( 1036 'dmY', 1037 'mdY', 1038 'Ymd' 1039 ); 1040 1041 /** 1042 * Date separators to be used. 1043 * 1044 * @var StringHelper 1045 * @access public 1046 */ 1047 1048 var $date_separators = array( 1049 '-', 1050 '.', 1051 '/' 1052 ); 1053 /** 1054 * Time formats to be used. 1055 * 1056 * @var StringHelper 1057 * @access public 1058 */ 1059 var $time_formats = array( 1060 'H:i', 1061 'h:i a' 1062 ); 1063 1064 /** 1065 * Relative path to the modules directory with no slash at start and end 1066 * 1067 * @var StringHelper 1068 * @access private 1069 */ 1070 var $module_path = 'modules'; 1071 /** 1072 * Relative URL to the administrator directory with no slash at start and end 1073 * 1074 * @var StringHelper 1075 * @access private 1076 */ 1077 1078 var $configuration_url = 'configuration'; 1079 1080 1081 /** 1082 * The link or e-mail address in menu help -> support. 1083 * 1084 * No menu item is generated if left empty. 1085 * 1086 * @var StringHelper 1087 * @access public 1088 */ 1089 var $support_link = 'https://www.group-office.com/support/'; 1090 1091 /** 1092 * The link or e-mail address in menu help -> report bug. 1093 * 1094 * No menu item is generated if left empty. 1095 * 1096 * @var StringHelper 1097 * @access public 1098 */ 1099 var $report_bug_link = 'http://sourceforge.net/tracker/?group_id=76359&atid=547651'; 1100 1101 /** 1102 * Relative path to the classes directory with no slash at start and end 1103 * 1104 * @var StringHelper 1105 * @access private 1106 */ 1107 var $class_path = 'classes'; 1108 /** 1109 * Relative path to the controls directory with no slash at start and end 1110 * 1111 * @var StringHelper 1112 * @access private 1113 */ 1114 var $control_path = 'controls'; 1115 /** 1116 * Relative URL to the controls directory with no slash at start and end 1117 * 1118 * @var StringHelper 1119 * @access private 1120 */ 1121 var $control_url = 'controls'; 1122 /** 1123 * Relative path to the themes directory with no slash at start and end 1124 * 1125 * @var StringHelper 1126 * @access private 1127 */ 1128 var $theme_path = 'themes'; 1129 1130 /** 1131 * Relative URL to the themes directory with no slash at start and end 1132 * 1133 * @var StringHelper 1134 * @access private 1135 */ 1136 var $theme_url = 'themes'; 1137 1138 /** 1139 * Relative path to the language directory with no slash at start and end 1140 * 1141 * @var StringHelper 1142 * @access private 1143 */ 1144 var $language_path = 'language'; 1145 1146 /** 1147 * Original tmpdir. The user_id is appended (/tmp/1/) to the normal tmpdir. 1148 * In some cases you don't want that. 1149 * 1150 * @var StringHelper 1151 * @access public 1152 */ 1153 var $orig_tmpdir = ''; 1154 1155 /** 1156 * Path with trailing slash where cached scripts are generated. 1157 * Defaults to $this->tmpdir/cache/ 1158 * 1159 * @var StringHelper 1160 */ 1161 var $cachefolder=''; 1162 1163 /** 1164 * Database object 1165 * 1166 * @var object 1167 * @access private 1168 */ 1169 var $db; 1170 1171 /** 1172 * The amount of seconds before Group-Office will check for new mail or 1173 * other notifications. 1174 * 1175 * @var int 1176 */ 1177 var $checker_interval=120; 1178 1179 1180 /** 1181 * Full URL to the Group-Office assets folder with trailing slash 1182 * 1183 * @var StringHelper 1184 * @access public 1185 */ 1186 var $assets_url = ''; 1187 1188 /** 1189 * Full Path to the Group-Office assets folder with trailing slash 1190 * 1191 * @var StringHelper 1192 * @access public 1193 */ 1194 var $assets_path = ''; 1195 1196 /** 1197 * Enables the quicklink option in the message panel of an email message. 1198 * [] Link email conversation to contact 1199 * [] Link email conversation to company 1200 * 1201 * @var Boolean 1202 */ 1203 var $allow_quicklink = true; 1204 1205 1206 /** 1207 * Automatically opens the file select dialog when opening the upload dialog. 1208 * 1209 * @var boolean 1210 */ 1211 public $upload_quickselect = true; 1212 1213 /** 1214 * EXPERIMENTAL! Minifies JS and CSS on the fly. 1215 * Doesn't seem to make much difference when gzip is used. 1216 * 1217 * @var boolean 1218 */ 1219 public $minify = false; 1220 1221 /** 1222 * Allow creation of tickets without the need of specify an email-address 1223 * 1224 * @var boolean 1225 */ 1226 public $tickets_no_email_required = false; 1227 1228 /** 1229 * Enable encoding of the special characters in the phone number of the callto links 1230 * Defaults to false. 1231 * 1232 * @var boolean 1233 */ 1234 public $encode_callto_link = false; 1235 1236 /** 1237 * Show the addressbook property in the files tree 1238 * Defaults to true 1239 * 1240 * @var boolean 1241 */ 1242 public $files_show_addressbooks = true; 1243 1244 /** 1245 * Show the projects property in the files tree 1246 * Defaults to true 1247 * 1248 * @var boolean 1249 */ 1250 public $files_show_projects = true; 1251 1252 /** 1253 * The maximum filesize of files that may be zipped. 1254 * Defaults to 256MB 1255 * 1256 * @var int 1257 */ 1258 public $zip_max_file_size = 256000000; 1259 1260 /** 1261 * Show the "remember login" checkbox on the login form 1262 * 1263 * @var boolean 1264 */ 1265 public $remember_login = true; 1266 1267 /** 1268 * The amount of days before a password change is forced to the user 1269 * When set to 0, this function is disabled 1270 * 1271 * @var int 1272 */ 1273 public $force_password_change = 0; 1274 1275 /** 1276 * Let Group-Office check if you are already logged in on an other location. 1277 * When enabled (true), you can only be logged in to one location. (sync will still work) 1278 * 1279 * @var boolean 1280 */ 1281 public $use_single_login = false; 1282 1283 1284 /** 1285 * This set the swift email body to base64 1286 * 1287 * //Override qupted-prinatble encdoding with base64 because it uses much less memory on larger bodies. See also: 1288 * //https://github.com/swiftmailer/swiftmailer/issues/356 1289 * 1290 * @var bool 1291 */ 1292 public $swift_email_body_force_to_base64 = false; 1293 1294 1295 /** 1296 * Will link the event to every participants except for the organizer 1297 * 1298 * WARNING: This caused major slowdown with lots of participants 1299 * @var bool 1300 */ 1301 var $calendar_autolink_participants = false; 1302 1303 /** 1304 * Stores the original values that are stored in the config.php file. 1305 * So without the modifications that this class adds to it. 1306 * 1307 * @var array 1308 */ 1309 private $_original_config = array(); 1310 1311 /** 1312 * Get a value from the original config.php file. 1313 * These are the values that are set in the file and not processed by this class 1314 * 1315 * @param string $key 1316 * @return string 1317 */ 1318 public function getOriginalValue($key){ 1319 1320 if(!isset($this->_original_config[$key])){ 1321 return null; 1322 } 1323 1324 return $this->_original_config[$key]; 1325 } 1326 1327 //ignore errors 1328 public function __get($name) { 1329 1330 if(method_exists($this, "get" . $name)) { 1331 return $this->{"get" . $name}(); 1332 } 1333 1334 return null; 1335 } 1336 1337 public function __isset($name) { 1338 if(method_exists($this, "get" . $name)) { 1339 $var = $this->{"get" . $name}(); 1340 return isset($var); 1341 } 1342 1343 return false; 1344 } 1345 1346 private function getGlobalConfig() { 1347 $globalConfigFile = '/etc/groupoffice/globalconfig.inc.php'; 1348 try { 1349 if (file_exists($globalConfigFile)) { 1350 require($globalConfigFile); 1351 } 1352 }catch(\Exception $e) { 1353 //ignore open_basedir error 1354 } 1355 1356 return $config ?? []; 1357 } 1358 1359 private function getInstanceConfig() { 1360 $config_file = $this->get_config_file(); 1361 1362 if($config_file) 1363 include($config_file); 1364 1365 $config['configPath'] = $config_file; 1366 1367 return $config; 1368 } 1369 1370 1371 1372 /** 1373 * Constructor. Initialises all public variables. 1374 * 1375 * @access public 1376 * @return void 1377 */ 1378 function __construct() { 1379 $config = array(); 1380 1381 $this->root_path = str_replace('\\','/',dirname(dirname(dirname(__FILE__)))).'/'; 1382 1383 $config = array_merge($this->getGlobalConfig(), $this->getInstanceConfig()); 1384 1385 //auto host 1386 if(empty($config['host'])) { 1387 $config['host'] = dirname($_SERVER['SCRIPT_NAME']); 1388 } 1389 $config['host'] = trim($config['host'], '/'); 1390 $config['host'] = empty($config['host']) ? '/' : '/' . $config['host'] . '/'; 1391 $config['root_path'] = \go\core\Environment::get()->getInstallFolder()->getPath() . '/'; 1392 1393 $this->_original_config = $config; 1394 1395 foreach($config as $key=>$value) { 1396 if(!method_exists($this, "get".$key)) { 1397 $this->$key=$value; 1398 } 1399 } 1400 1401 $this->file_storage_path = rtrim($this->file_storage_path, '/').'/'; 1402 $this->tmpdir = rtrim($this->tmpdir, '/').'/'; 1403 1404// if($this->info_log=="") 1405// $this->info_log =$this->file_storage_path.'log/info.log'; 1406 1407 //this can be used in some cases where you don't want the dynamically 1408 //determined full URL. This is done in set_full_url below. 1409 //$this->orig_full_url = $this->full_url; 1410 1411 $this->orig_tmpdir=$this->tmpdir; 1412 1413 if(empty($this->db_user)) { 1414 //Detect some default values for installation if root_path is not set yet 1415 $this->host = dirname($_SERVER['SCRIPT_NAME']); 1416 $basename = basename($this->host); 1417 while($basename=='install' || $basename == 'api') { 1418 $this->host = dirname($this->host); 1419 $basename = basename($this->host); 1420 } 1421 1422 if(substr($this->host,-1) != '/') { 1423 $this->host .= '/'; 1424 } 1425 1426 $this->db_host='localhost'; 1427 1428 if(Util\Common::isWindows()) { 1429 $this->file_storage_path = substr($this->root_path,0,3).'groupoffice/'; 1430 $this->tmpdir=substr($this->root_path,0,3).'temp'; 1431 1432 $this->cmd_zip=$this->root_path.'controls/win32/zip.exe'; 1433 $this->cmd_unzip=$this->root_path.'controls/win32/unzip.exe'; 1434 $this->cmd_xml2wbxml=$this->root_path.'controls/win32/libwbxml/xml2wbxml.exe'; 1435 $this->cmd_wbxml2xml=$this->root_path.'controls/win32/libwbxml/wbxml2xml.exe'; 1436 1437 $this->convert_utf8_filenames_to_ascii=true; 1438 } 1439 1440 if(empty($config['tmpdir']) && function_exists('sys_get_temp_dir')) { 1441 $this->tmpdir = rtrim(str_replace('\\','/', sys_get_temp_dir()),'/').'/groupoffice/'; 1442 } 1443 1444 } 1445 1446// // path to classes 1447// $this->class_path = $this->root_path.$this->class_path.'/'; 1448// 1449// // path to themes 1450// $this->theme_path = $this->root_path.$this->theme_path.'/'; 1451// 1452// // URL to themes 1453// $this->theme_url = $this->host.$this->theme_url.'/'; 1454// 1455// // path to controls 1456// $this->control_path = $this->root_path.$this->control_path.'/'; 1457// 1458// // url to controls 1459// $this->control_url = $this->host.$this->control_url.'/'; 1460// 1461// // path to modules 1462// $this->module_path = $this->root_path.$this->module_path.'/'; 1463// 1464// // url to user configuration apps 1465// $this->configuration_url = $this->host.$this->configuration_url.'/'; 1466 1467 1468 if($this->debug) 1469 $this->debug_log=true; 1470 1471// if($this->debug_log){// || $this->log_slow_requests) { 1472// 1473// list ($usec, $sec) = explode(" ", microtime()); 1474// $this->loadstart = ((float) $usec + (float) $sec); 1475// 1476//// $dat = getrusage(); 1477//// define('PHP_TUSAGE', microtime(true)); 1478//// define('PHP_RUSAGE', $dat["ru_utime.tv_sec"]*1e6+$dat["ru_utime.tv_usec"]); 1479// } 1480 1481// if(is_string($this->file_create_mode)) { 1482// $this->file_create_mode=octdec($this->file_create_mode); 1483// } 1484// 1485// if(is_string($this->folder_create_mode)) { 1486// $this->folder_create_mode=octdec($this->folder_create_mode); 1487// } 1488 1489 if($this->debug_log) { 1490 $this->log=true; 1491 } 1492 1493 //$this->set_full_url(); 1494 1495 if(!$this->support_link && $this->isProVersion()){ 1496 $this->support_link = "https://www.group-office.com/support"; 1497 } 1498 1499 } 1500 1501 /** 1502 * The no-reply e-mail which will be used to send system messages 1503 * Check if the noreply_email variable is set in the config.php file. 1504 * If it is not set, then use noreply@ {webmaster_email domain name} 1505 * When the webmaster email is not set, then this will be noreply@example.com 1506 * 1507 * @return StringHelper 1508 */ 1509 public function getNoreply_email(){ 1510 1511 $wmdomain = 'example.com'; 1512 1513 if(!empty($this->webmaster_email)){ 1514 $extractedEmail = explode('@',$this->webmaster_email); 1515 if(isset($extractedEmail[1])) 1516 $wmdomain = $extractedEmail[1]; 1517 } 1518 1519 return 'noreply@'.$wmdomain; 1520 } 1521 1522 public function getVersion() { 1523 return go()->getVersion(); 1524 } 1525 1526 public function getMtime() { 1527 return go()->getVersion(); 1528 } 1529 1530 public function getTitle() { 1531 return go()->getSettings()->title; 1532 } 1533 1534 public function getlanguage() { 1535 return go()->getSettings()->language; 1536 } 1537 1538 public function getwebmaster_email() { 1539 return go()->getSettings()->systemEmail; 1540 } 1541 1542 public function getsmtp_server() { 1543 return go()->getSettings()->smtpHost; 1544 } 1545 1546 public function getsmtp_port() { 1547 return go()->getSettings()->smtpPort; 1548 } 1549 1550 public function getsmtp_username() { 1551 return go()->getSettings()->smtpUsername; 1552 } 1553 1554 public function getsmtp_password() { 1555 return go()->getSettings()->decryptSmtpPassword(); 1556 } 1557 1558 public function getsmtp_encryption() { 1559 return go()->getSettings()->smtpEncryption; 1560 } 1561 1562 public function getdebug_email() { 1563 return !empty(go()->getConfig()['debugEmail']) ? go()->getConfig()['debugEmail'] : null; 1564 } 1565 1566 public function gepassword_min_length() { 1567 return go()->getSettings()->passwordMinLength; 1568 } 1569 1570 public function getlogin_message() { 1571 return go()->getSettings()->loginMessageEnabled ? go()->getSettings()->loginMessage : null; 1572 } 1573 1574 public function getfull_url() { 1575 return rtrim(go()->getSettings()->URL, '/') . '/'; 1576 } 1577 1578 public function getorig_full_url() { 1579 return rtrim(go()->getSettings()->URL, '/') . '/'; 1580 } 1581 1582 public function getMajorVersion(){ 1583 return substr($this->version,0,3);; 1584 } 1585 1586 /** 1587 * Get the temporary files folder. 1588 * 1589 * @return Fs\Folder 1590 */ 1591 public function getTempFolder($autoCreate=true){ 1592 $user_id = \GO::user() ? \GO::user()->id : 0; 1593 1594 $path = $this->orig_tmpdir; 1595 1596 if(PHP_SAPI=='cli'){ 1597 $path .= 'cli/'; 1598 } 1599 $path .= $user_id; 1600 1601 $folder = new Fs\Folder($path); 1602 1603 if($autoCreate) 1604 $folder->create(0777); 1605 1606 return $folder; 1607 } 1608 1609 /** 1610 * Get the cache folder for cached scripts. 1611 * 1612 * @return \Fs\Folder 1613 */ 1614 public function getCacheFolder($autoCreate=true){ 1615 1616 if(empty($this->cachefolder)){ 1617 $this->cachefolder=$this->file_storage_path.'cache/'; 1618 } 1619 1620 $folder = new Fs\Folder($this->cachefolder); 1621 1622 if($autoCreate) 1623 $folder->create(0777); 1624 return $folder; 1625 } 1626 1627 /** 1628 * Check if the pro package is available. 1629 * 1630 * @return boolean 1631 */ 1632 public function isProVersion(){ 1633 return is_dir($this->root_path.'modules/professional'); 1634 } 1635 1636 1637 1638// function __destruct() { 1639// if($this->debug_log) { 1640// //\GO::debug('Performed '.$GLOBALS['query_count'].' database queries', $this); 1641// 1642// \GO::debug('Page load took: '.(Util\Date::getmicrotime()-$this->loadstart).'ms', $this); 1643// \GO::debug('Peak memory usage:'.round(memory_get_peak_usage()/1048576,2).'MB', $this); 1644// 1645// } 1646//// $this->_logSlowRequest(); 1647// } 1648 1649// private function _logSlowRequest(){ 1650// if($this->log_slow_requests){ 1651// $time = Util\Date::getmicrotime()-$this->loadstart; 1652// if($time>$this->log_slow_requests_trigger){ 1653// 1654// $logStr = "URI: "; 1655// 1656// if(isset($_SERVER['HTTP_HOST'])) 1657// $logStr .= $_SERVER['HTTP_HOST']; 1658// 1659// if(isset($_SERVER['REQUEST_URI'])) 1660// $logStr .= $_SERVER['REQUEST_URI']; 1661// 1662// $logStr .= '; '; 1663// 1664// $logStr .= 'r: '.\GO::router()->getControllerRoute().';'; 1665// 1666// $logStr .= 'time: '.$time.';'."\n"; 1667// 1668// 1669// file_put_contents($this->log_slow_requests_file, $logStr,FILE_APPEND); 1670// } 1671// } 1672// } 1673 1674 function use_zlib_compression(){ 1675 1676 if(!isset($this->zlib_support_tested)){ 1677 $this->zlib_support_tested=true; 1678 $this->zlib_compress=$this->zlib_compress && extension_loaded('zlib') && !ini_get('zlib.output_compression'); 1679 } 1680 return $this->zlib_compress; 1681 } 1682 1683 1684 public function getCompleteDateFormat(){ 1685 return $this->default_date_format[0]. 1686 $this->default_date_separator. 1687 $this->default_date_format[1]. 1688 $this->default_date_separator. 1689 $this->default_date_format[2]; 1690 } 1691 1692 /** 1693 * Get's the location of a configuration file. 1694 * Group-Office searches two locations: 1695 * 1. /etc/Group-Office/APACHE SERVER NAME/subdir/to/groupoffice/config.php 1696 * 2. /path/to/groupoffice/config.php 1697 * 1698 * The first location is more secure because the sensitive information is kept 1699 * outside the document root. 1700 * 1701 * @return StringHelper Path to configuration file 1702 */ 1703 1704 public function get_config_file() { 1705 return \go\core\App::findConfigFile(); 1706 } 1707 1708 /** 1709 * Sets Full URL to reach Group-Office with slash on end 1710 * 1711 * This function checks wether or not Group-Office runs on a 1712 * default http or https port and stores the full url in a variable 1713 */ 1714 public function set_full_url() { 1715 //full_url may be configured permanent in config.php. If not then 1716 //autodetect it and put it in the session. It can be used by wordpress for 1717 //example. 1718 1719 //this used to use HTTP_HOST but that is a client controlled value which can be manipulated and is unsafe. 1720 if(empty($this->full_url)){ 1721 if(isset($_SERVER["SERVER_NAME"])) { 1722 if(!isset($_SESSION['GO_SESSION']['full_url']) && isset($_SERVER["SERVER_NAME"])) { 1723 $https = (isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on" || $_SERVER["HTTPS"] == "1")) || !empty($_SERVER["HTTP_X_SSL_REQUEST"]); 1724 $_SESSION['GO_SESSION']['full_url'] = 'http'; 1725 if ($https) { 1726 $_SESSION['GO_SESSION']['full_url'] .= "s"; 1727 } 1728 $_SESSION['GO_SESSION']['full_url'] .= "://".$_SERVER["SERVER_NAME"]; 1729 if ((!$https && $_SERVER["SERVER_PORT"] != "80") || ($https && $_SERVER["SERVER_PORT"] != "443")) 1730 $_SESSION['GO_SESSION']['full_url'] .= ":".$_SERVER["SERVER_PORT"]; 1731 1732 $_SESSION['GO_SESSION']['full_url'] .= $this->host; 1733 } 1734 $this->full_url=$_SESSION['GO_SESSION']['full_url']; 1735 }else 1736 { 1737 $_SESSION['GO_SESSION']['full_url']=$this->full_url; 1738 } 1739 if(empty($this->orig_full_url)) 1740 $this->orig_full_url=$this->full_url; 1741 } 1742 } 1743 1744 1745 /** 1746 * Gets a custom saved setting from the database 1747 * 1748 * @param StringHelper $name Configuration key name 1749 * @param integer $user_id Id of the user you want to get a setting from - defaults to 0 for the default setting, 1750 * @param mixed $default The default value that will be returned when the setting cannot be found 1751 * 1752 * @return mixed Configuration value 1753 */ 1754 public function get_setting($name, $user_id=0,$default=null) { 1755 $attributes['name']=$name; 1756 $attributes['user_id']=$user_id; 1757 1758 $setting = Model\Setting::model()->findSingleByAttributes($attributes); 1759 if ($setting) { 1760 return $setting->value; 1761 } 1762 return $default; 1763 } 1764 1765 /** 1766 * Get multiple settings at once 1767 * @param array $keys 1768 * @param int $user_id Optional leave empty for global settings 1769 * 1770 * @return array Key value array('setting name'=>'value'); 1771 */ 1772 public function getSettings($keys, $user_id=0){ 1773 $findParams = Db\FindParams::newInstance()->select(); 1774 1775 $findParams->getCriteria() 1776 ->addCondition('user_id', $user_id) 1777 ->addInCondition('name', $keys); 1778 1779 $stmt = Model\Setting::model()->find($findParams); 1780 1781 $return = array(); 1782 foreach($keys as $key){ 1783 $return[$key]=null; 1784 } 1785 1786 foreach($stmt as $setting){ 1787 $return[$setting->name]=$setting->value; 1788 } 1789 1790 return $return; 1791 } 1792 1793 /** 1794 * Get all settings with the same key for the settings table 1795 * @param string $name the key of the setting 1796 * @return array all settings in user_id value pairs 1797 * 1798 public function get_settings($name) { 1799 $params = Db\FindParams::newInstance()->select('*'); 1800 $params->getCriteria()->addCondition('name',$name); 1801 return Model\Setting::model()->find($params)->fetchAll(); 1802 } 1803 * 1804 */ 1805 1806 /** 1807 * Saves a custom setting to the database 1808 * 1809 * @param StringHelper $name Configuration key name 1810 * @param StringHelper $value Configuration key value 1811 * @param integer $user_id Id of user you want to load the setting for 1812 * defaults to 0 for the default setting (not user specific) 1813 * @return bool Returns true on succes 1814 */ 1815 public function save_setting( $name, $value, $user_id=0) { 1816 1817 $attributes['name']=$name; 1818 $attributes['user_id']=$user_id; 1819 1820 $setting = Model\Setting::model()->findSingleByAttributes($attributes); 1821 if(!$setting){ 1822 $setting = new Model\Setting(); 1823 $setting->setAttributes($attributes); 1824 } 1825 1826 $setting->value=$value; 1827 return $setting->save(); 1828 } 1829 1830 /** 1831 * Deletes a custom setting from the database 1832 * 1833 * @param StringHelper $name Configuration key name 1834 * @params integer $user_id The is of the user you want to delete a setting from 1835 * defaults to 0 for the default setting, 1836 * if set to false settings for every user inclusing default will be deleted 1837 * @access public 1838 * @return bool Returns true on succes 1839 */ 1840 function delete_setting( $name , $user_id=0) { 1841 $attributes['name']=$name; 1842 if($user_id!==false) 1843 $attributes['user_id']=$user_id; 1844 1845 $setting = Model\Setting::model()->findSingleByAttributes($attributes); 1846 return $setting ? $setting->delete() : true; 1847 } 1848 1849 1850 1851 /** 1852 * Save the current configuraton to the config.php file. 1853 * 1854 * @return boolean 1855 */ 1856 public function save($extraConfig=array()) { 1857 1858 $values = get_object_vars(\GO::config()); 1859 $config=array(); 1860 1861 require($this->get_config_file()); 1862 1863 foreach($values as $key=>$value) 1864 { 1865 if($key == 'full_url') 1866 break; 1867 1868 if(!is_object($value)) 1869 { 1870 $config[$key]=$value; 1871 } 1872 } 1873 $config = array_merge($config, $extraConfig); 1874 1875 return Util\ConfigEditor::save(new Fs\File(\GO::config()->get_config_file()), $config); 1876 } 1877} 1878