PageRenderTime 62ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/install/install_functions.inc.php

https://gitlab.com/kingcody/Mods-for-HESK
PHP | 966 lines | 847 code | 72 blank | 47 comment | 32 complexity | c2e2a0e5d59a26608f0108f94f0ca64d MD5 | raw file
  1. <?php
  2. /*******************************************************************************
  3. * Title: Help Desk Software HESK
  4. * Version: 2.6.7 from 18th April 2016
  5. * Author: Klemen Stirn
  6. * Website: http://www.hesk.com
  7. ********************************************************************************
  8. * COPYRIGHT AND TRADEMARK NOTICE
  9. * Copyright 2005-2015 Klemen Stirn. All Rights Reserved.
  10. * HESK is a registered trademark of Klemen Stirn.
  11. * The HESK may be used and modified free of charge by anyone
  12. * AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS REMAIN INTACT.
  13. * By using this code you agree to indemnify Klemen Stirn from any
  14. * liability that might arise from it's use.
  15. * Selling the code for this program, in part or full, without prior
  16. * written consent is expressly forbidden.
  17. * Using this code, in part or full, to create derivate work,
  18. * new scripts or products is expressly forbidden. Obtain permission
  19. * before redistributing this software over the Internet or in
  20. * any other medium. In all cases copyright and header must remain intact.
  21. * This Copyright is in full effect in any country that has International
  22. * Trade Agreements with the United States of America or
  23. * with the European Union.
  24. * Removing any of the copyright notices without purchasing a license
  25. * is expressly forbidden. To remove HESK copyright notice you must purchase
  26. * a license for this script. For more information on how to obtain
  27. * a license please visit the page below:
  28. * https://www.hesk.com/buy.php
  29. *******************************************************************************/
  30. /* Check if this is a valid include */
  31. if (!defined('IN_SCRIPT')) {die('Invalid attempt');}
  32. // We will be installing this HESK version:
  33. define('HESK_NEW_VERSION','2.6.7');
  34. define('MODS_FOR_HESK_NEW_VERSION','2.6.1');
  35. define('REQUIRE_PHP_VERSION','5.0.0');
  36. define('REQUIRE_MYSQL_VERSION','5.0.7');
  37. // Other required files and settings
  38. define('INSTALL',1);
  39. define('HIDE_ONLINE',1);
  40. require(HESK_PATH . 'hesk_settings.inc.php');
  41. $hesk_settings['debug_mode'] = 1;
  42. $hesk_settings['language']='English';
  43. $hesk_settings['languages']=array('English' => array('folder'=>'en','hr'=>'------ Reply above this line ------'));
  44. error_reporting(E_ALL);
  45. require(HESK_PATH . 'inc/common.inc.php');
  46. require(HESK_PATH . 'inc/admin_functions.inc.php');
  47. require(HESK_PATH . 'inc/setup_functions.inc.php');
  48. hesk_load_database_functions();
  49. // Start the session
  50. hesk_session_start();
  51. // ******* FUNCTIONS ******* //
  52. function hesk_iTestDatabaseConnection()
  53. {
  54. global $hesk_settings, $hesklang;
  55. $db_success = 1;
  56. $hesk_settings['db_host'] = hesk_input( hesk_POST('host') );
  57. $hesk_settings['db_name'] = hesk_input( hesk_POST('name') );
  58. $hesk_settings['db_user'] = hesk_input( hesk_POST('user') );
  59. $hesk_settings['db_pass'] = hesk_input( hesk_POST('pass') );
  60. // Allow & in password
  61. $hesk_settings['db_pass'] = str_replace('&amp;', '&', $hesk_settings['db_pass']);
  62. // Use MySQLi extension to connect?
  63. $use_mysqli = function_exists('mysqli_connect') ? true : false;
  64. // Start output buffering
  65. ob_start();
  66. // Connect to database
  67. if ($use_mysqli)
  68. {
  69. // Do we need a special port? Check and connect to the database
  70. if ( strpos($hesk_settings['db_host'], ':') )
  71. {
  72. list($hesk_settings['db_host'], $hesk_settings['db_port']) = explode(':', $hesk_settings['db_host']);
  73. $hesk_db_link = mysqli_connect($hesk_settings['db_host'], $hesk_settings['db_user'], $hesk_settings['db_pass'], $hesk_settings['db_name'], intval($hesk_settings['db_port']) ) or $db_success=0;
  74. }
  75. else
  76. {
  77. $hesk_db_link = mysqli_connect($hesk_settings['db_host'], $hesk_settings['db_user'], $hesk_settings['db_pass'], $hesk_settings['db_name']) or $db_success=0;
  78. }
  79. }
  80. else
  81. {
  82. $hesk_db_link = mysql_connect($hesk_settings['db_host'],$hesk_settings['db_user'], $hesk_settings['db_pass']) or $db_success=0;
  83. // Select database works OK?
  84. if ($db_success == 1 && ! mysql_select_db($hesk_settings['db_name'], $hesk_db_link) )
  85. {
  86. // No, try to create the database
  87. if (function_exists('mysql_create_db') && mysql_create_db($hesk_settings['db_name'], $hesk_db_link))
  88. {
  89. if (mysql_select_db($hesk_settings['db_name'], $hesk_db_link))
  90. {
  91. $db_success = 1;
  92. }
  93. else
  94. {
  95. $db_success = 0;
  96. }
  97. }
  98. else
  99. {
  100. $db_success = 0;
  101. }
  102. }
  103. }
  104. ob_end_clean();
  105. // Any errors?
  106. if ( ! $db_success)
  107. {
  108. global $mysql_log;
  109. $mysql_log = $use_mysqli ? mysqli_connect_error() : mysql_error();
  110. hesk_iDatabase(1);
  111. }
  112. // Check MySQL version
  113. define('MYSQL_VERSION', hesk_dbResult( hesk_dbQuery('SELECT VERSION() AS version') ) );
  114. if ( version_compare(MYSQL_VERSION,REQUIRE_MYSQL_VERSION,'<') )
  115. {
  116. hesk_iDatabase(5);
  117. }
  118. return $hesk_db_link;
  119. } // END hesk_iTestDatabaseConnection()
  120. function hesk_iSaveSettingsFile($set)
  121. {
  122. global $hesk_settings, $hesklang;
  123. $settings_file_content='<?php
  124. // Settings file for HESK ' . $set['hesk_version'] . '
  125. // ==> GENERAL
  126. // --> General settings
  127. $hesk_settings[\'site_title\']=\'' . $set['site_title'] . '\';
  128. $hesk_settings[\'site_url\']=\'' . $set['site_url'] . '\';
  129. $hesk_settings[\'webmaster_mail\']=\'' . $set['webmaster_mail'] . '\';
  130. $hesk_settings[\'noreply_mail\']=\'' . $set['noreply_mail'] . '\';
  131. $hesk_settings[\'noreply_name\']=\'' . $set['noreply_name'] . '\';
  132. // --> Language settings
  133. $hesk_settings[\'can_sel_lang\']=' . $set['can_sel_lang'] . ';
  134. $hesk_settings[\'language\']=\'' . $set['language'] . '\';
  135. $hesk_settings[\'languages\']=array(
  136. \'English\' => array(\'folder\'=>\'en\',\'hr\'=>\'------ Reply above this line ------\'),
  137. );
  138. // --> Database settings
  139. $hesk_settings[\'db_host\']=\'' . $set['db_host'] . '\';
  140. $hesk_settings[\'db_name\']=\'' . $set['db_name'] . '\';
  141. $hesk_settings[\'db_user\']=\'' . $set['db_user'] . '\';
  142. $hesk_settings[\'db_pass\']=\'' . $set['db_pass'] . '\';
  143. $hesk_settings[\'db_pfix\']=\'' . $set['db_pfix'] . '\';
  144. $hesk_settings[\'db_vrsn\']=' . $set['db_vrsn'] . ';
  145. // ==> HELP DESK
  146. // --> Help desk settings
  147. $hesk_settings[\'hesk_title\']=\'' . $set['hesk_title'] . '\';
  148. $hesk_settings[\'hesk_url\']=\'' . $set['hesk_url'] . '\';
  149. $hesk_settings[\'admin_dir\']=\'' . $set['admin_dir'] . '\';
  150. $hesk_settings[\'attach_dir\']=\'' . $set['attach_dir'] . '\';
  151. $hesk_settings[\'max_listings\']=' . $set['max_listings'] . ';
  152. $hesk_settings[\'print_font_size\']=' . $set['print_font_size'] . ';
  153. $hesk_settings[\'autoclose\']=' . $set['autoclose'] . ';
  154. $hesk_settings[\'max_open\']=' . $set['max_open'] . ';
  155. $hesk_settings[\'new_top\']=' . $set['new_top'] . ';
  156. $hesk_settings[\'reply_top\']=' . $set['reply_top'] . ';
  157. // --> Features
  158. $hesk_settings[\'autologin\']=' . $set['autologin'] . ';
  159. $hesk_settings[\'autoassign\']=' . $set['autoassign'] . ';
  160. $hesk_settings[\'custclose\']=' . $set['custclose'] . ';
  161. $hesk_settings[\'custopen\']=' . $set['custopen'] . ';
  162. $hesk_settings[\'rating\']=' . $set['rating'] . ';
  163. $hesk_settings[\'cust_urgency\']=' . $set['cust_urgency'] . ';
  164. $hesk_settings[\'sequential\']=' . $set['sequential'] . ';
  165. $hesk_settings[\'time_worked\']=' . $set['time_worked'] . ';
  166. $hesk_settings[\'spam_notice\']=' . $set['spam_notice'] . ';
  167. $hesk_settings[\'list_users\']=' . $set['list_users'] . ';
  168. $hesk_settings[\'debug_mode\']=' . $set['debug_mode'] . ';
  169. $hesk_settings[\'short_link\']=' . $set['short_link'] . ';
  170. $hesk_settings[\'select_cat\']=' . $set['select_cat'] . ';
  171. $hesk_settings[\'select_pri\']=' . $set['select_pri'] . ';
  172. // --> SPAM Prevention
  173. $hesk_settings[\'secimg_use\']=' . $set['secimg_use'] . ';
  174. $hesk_settings[\'secimg_sum\']=\'' . $set['secimg_sum'] . '\';
  175. $hesk_settings[\'recaptcha_use\']=' . $set['recaptcha_use'] . ';
  176. $hesk_settings[\'recaptcha_public_key\']=\'' . $set['recaptcha_public_key'] . '\';
  177. $hesk_settings[\'recaptcha_private_key\']=\'' . $set['recaptcha_private_key'] . '\';
  178. $hesk_settings[\'question_use\']=' . $set['question_use'] . ';
  179. $hesk_settings[\'question_ask\']=\'' . $set['question_ask'] . '\';
  180. $hesk_settings[\'question_ans\']=\'' . $set['question_ans'] . '\';
  181. // --> Security
  182. $hesk_settings[\'attempt_limit\']=' . $set['attempt_limit'] . ';
  183. $hesk_settings[\'attempt_banmin\']=' . $set['attempt_banmin'] . ';
  184. $hesk_settings[\'reset_pass\']=' . $set['reset_pass'] . ';
  185. $hesk_settings[\'email_view_ticket\']=' . $set['email_view_ticket'] . ';
  186. // --> Attachments
  187. $hesk_settings[\'attachments\']=array (
  188. \'use\' => ' . $set['attachments']['use'] . ',
  189. \'max_number\' => ' . $set['attachments']['max_number'] . ',
  190. \'max_size\' => ' . $set['attachments']['max_size'] . ',
  191. \'allowed_types\' => array(\'' . implode('\',\'',$set['attachments']['allowed_types']) . '\')
  192. );
  193. // ==> KNOWLEDGEBASE
  194. // --> Knowledgebase settings
  195. $hesk_settings[\'kb_enable\']=' . $set['kb_enable'] . ';
  196. $hesk_settings[\'kb_wysiwyg\']=' . $set['kb_wysiwyg'] . ';
  197. $hesk_settings[\'kb_search\']=' . $set['kb_search'] . ';
  198. $hesk_settings[\'kb_search_limit\']=' . $set['kb_search_limit'] . ';
  199. $hesk_settings[\'kb_views\']=' . $set['kb_views'] . ';
  200. $hesk_settings[\'kb_date\']=' . $set['kb_date'] . ';
  201. $hesk_settings[\'kb_recommendanswers\']=' . $set['kb_recommendanswers'] . ';
  202. $hesk_settings[\'kb_rating\']=' . $set['kb_rating'] . ';
  203. $hesk_settings[\'kb_substrart\']=' . $set['kb_substrart'] . ';
  204. $hesk_settings[\'kb_cols\']=' . $set['kb_cols'] . ';
  205. $hesk_settings[\'kb_numshow\']=' . $set['kb_numshow'] . ';
  206. $hesk_settings[\'kb_popart\']=' . $set['kb_popart'] . ';
  207. $hesk_settings[\'kb_latest\']=' . $set['kb_latest'] . ';
  208. $hesk_settings[\'kb_index_popart\']=' . $set['kb_index_popart'] . ';
  209. $hesk_settings[\'kb_index_latest\']=' . $set['kb_index_latest'] . ';
  210. $hesk_settings[\'kb_related\']=' . $set['kb_related'] . ';
  211. // ==> EMAIL
  212. // --> Email sending
  213. $hesk_settings[\'smtp\']=' . $set['smtp'] . ';
  214. $hesk_settings[\'smtp_host_name\']=\'' . $set['smtp_host_name'] . '\';
  215. $hesk_settings[\'smtp_host_port\']=' . $set['smtp_host_port'] . ';
  216. $hesk_settings[\'smtp_timeout\']=' . $set['smtp_timeout'] . ';
  217. $hesk_settings[\'smtp_ssl\']=' . $set['smtp_ssl'] . ';
  218. $hesk_settings[\'smtp_tls\']=' . $set['smtp_tls'] . ';
  219. $hesk_settings[\'smtp_user\']=\'' . $set['smtp_user'] . '\';
  220. $hesk_settings[\'smtp_password\']=\'' . $set['smtp_password'] . '\';
  221. // --> Email piping
  222. $hesk_settings[\'email_piping\']=' . $set['email_piping'] . ';
  223. // --> POP3 Fetching
  224. $hesk_settings[\'pop3\']=' . $set['pop3'] . ';
  225. $hesk_settings[\'pop3_job_wait\']=' . $set['pop3_job_wait'] . ';
  226. $hesk_settings[\'pop3_host_name\']=\'' . $set['pop3_host_name'] . '\';
  227. $hesk_settings[\'pop3_host_port\']=' . $set['pop3_host_port'] . ';
  228. $hesk_settings[\'pop3_tls\']=' . $set['pop3_tls'] . ';
  229. $hesk_settings[\'pop3_keep\']=' . $set['pop3_keep'] . ';
  230. $hesk_settings[\'pop3_user\']=\'' . $set['pop3_user'] . '\';
  231. $hesk_settings[\'pop3_password\']=\'' . $set['pop3_password'] . '\';
  232. // --> Email loops
  233. $hesk_settings[\'loop_hits\']=' . $set['loop_hits'] . ';
  234. $hesk_settings[\'loop_time\']=' . $set['loop_time'] . ';
  235. // --> Detect email typos
  236. $hesk_settings[\'detect_typos\']=' . $set['detect_typos'] . ';
  237. $hesk_settings[\'email_providers\']=array(' . $set['email_providers'] . ');
  238. // --> Notify customer when
  239. $hesk_settings[\'notify_new\']=' . $set['notify_new'] . ';
  240. $hesk_settings[\'notify_skip_spam\']=' . $set['notify_skip_spam'] . ';
  241. $hesk_settings[\'notify_spam_tags\']=array(' . $set['notify_spam_tags'] . ');
  242. $hesk_settings[\'notify_closed\']=' . $set['notify_closed'] . ';
  243. // --> Other
  244. $hesk_settings[\'strip_quoted\']=' . $set['strip_quoted'] . ';
  245. $hesk_settings[\'eml_req_msg\']=' . $set['eml_req_msg'] . ';
  246. $hesk_settings[\'save_embedded\']=' . $set['save_embedded'] . ';
  247. $hesk_settings[\'multi_eml\']=' . $set['multi_eml'] . ';
  248. $hesk_settings[\'confirm_email\']=' . $set['confirm_email'] . ';
  249. $hesk_settings[\'open_only\']=' . $set['open_only'] . ';
  250. // ==> TICKET LIST
  251. $hesk_settings[\'ticket_list\']=array(\'' . implode('\',\'',$set['ticket_list']) . '\');
  252. // --> Other
  253. $hesk_settings[\'submittedformat\']=\'' . $set['submittedformat'] . '\';
  254. $hesk_settings[\'updatedformat\']=\'' . $set['updatedformat'] . '\';
  255. // ==> MISC
  256. // --> Date & Time
  257. $hesk_settings[\'diff_hours\']=' . $set['diff_hours'] . ';
  258. $hesk_settings[\'diff_minutes\']=' . $set['diff_minutes'] . ';
  259. $hesk_settings[\'daylight\']=' . $set['daylight'] . ';
  260. $hesk_settings[\'timeformat\']=\'' . $set['timeformat'] . '\';
  261. // --> Other
  262. $hesk_settings[\'ip_whois\']=\'' . $set['ip_whois'] . '\';
  263. $hesk_settings[\'maintenance_mode\']=' . $set['maintenance_mode'] . ';
  264. $hesk_settings[\'alink\']=' . $set['alink'] . ';
  265. $hesk_settings[\'submit_notice\']=' . $set['submit_notice'] . ';
  266. $hesk_settings[\'online\']=' . $set['online'] . ';
  267. $hesk_settings[\'online_min\']=' . $set['online_min'] . ';
  268. $hesk_settings[\'check_updates\']=' . $set['check_updates'] . ';
  269. // ==> CUSTOM FIELDS
  270. $hesk_settings[\'custom_fields\']=array (
  271. ';
  272. for ($i=1;$i<=20;$i++) {
  273. $settings_file_content.='\'custom'.$i.'\'=>array(\'use\'=>'.$set['custom_fields']['custom'.$i]['use'].',\'place\'=>'.$set['custom_fields']['custom'.$i]['place'].',\'type\'=>\''.$set['custom_fields']['custom'.$i]['type'].'\',\'req\'=>'.$set['custom_fields']['custom'.$i]['req'].',\'name\'=>\''.$set['custom_fields']['custom'.$i]['name'].'\',\'maxlen\'=>'.$set['custom_fields']['custom'.$i]['maxlen'].',\'value\'=>\''.$set['custom_fields']['custom'.$i]['value'].'\')';
  274. if ($i!=20) {$settings_file_content.=',
  275. ';}
  276. }
  277. $settings_file_content.='
  278. );
  279. #############################
  280. # DO NOT EDIT BELOW #
  281. #############################
  282. $hesk_settings[\'hesk_version\']=\'' . $set['hesk_version'] . '\';
  283. if ($hesk_settings[\'debug_mode\'])
  284. {
  285. error_reporting(E_ALL);
  286. }
  287. else
  288. {
  289. error_reporting(0);
  290. }
  291. if (!defined(\'IN_SCRIPT\')) {die(\'Invalid attempt!\');}';
  292. // Write to the settings file
  293. if ( ! file_put_contents(HESK_PATH . 'hesk_settings.inc.php', $settings_file_content) )
  294. {
  295. hesk_error($hesklang['err_openset']);
  296. }
  297. return true;
  298. } // END hesk_iSaveSettingsFile()
  299. function hesk_iDatabase($problem=0)
  300. {
  301. global $hesk_settings, $hesk_db_link, $mysql_log;
  302. hesk_iHeader();
  303. ?>
  304. <br />
  305. <div class="col-md-4">
  306. <div class="panel panel-default">
  307. <div class="panel-heading">
  308. <p>Summary</p>
  309. </div>
  310. <div class="panel-body">
  311. <p style="padding: 10px;">To complete setup HESK needs to connect to your database. You can get this information from your hosting control panel.</p>
  312. </div>
  313. </div>
  314. </div>
  315. <div class="col-md-8">
  316. <div class="alert alert-warning"><strong>3. Database Settings</strong></div>
  317. <form role="form" action="<?php echo INSTALL_PAGE; ?>" method="post">
  318. <div class="h3">Database Settings</div>
  319. <div class="footerWithBorder blankSpace"></div>
  320. <?php
  321. if ($problem == 1)
  322. {
  323. echo '<div class="alert alert-danger">';
  324. echo '<br /><br />Double-check all the information below. Contact your hosting company for the correct information to use!<br /><br /><b>MySQL said:</b> '.$mysql_log.'</p>', 'Database connection failed';
  325. echo '</div>';
  326. }
  327. elseif ($problem == 2)
  328. {
  329. echo '<div class="alert alert-danger">';
  330. echo '<b>Database tables already exist!</b><br /><br />
  331. HESK database tables with <b>'.$hesk_settings['db_pfix'].'</b> prefix already exist in this database!<br /><br />
  332. To upgrade an existing HESK installation select <a href="index.php">Update existing install</a> instead.<br /><br />
  333. To install a new copy of HESK in use a unique table prefix.';
  334. echo '</div>';
  335. }
  336. elseif ($problem == 3)
  337. {
  338. echo '<div class="alert alert-danger">';
  339. echo '<b>Old database tables not found!</b><br /><br />
  340. HESK database tables have not been found in this database!<br /><br />
  341. To install HESK use the <a href="index.php">New install</a> option instead.';
  342. echo '</div>';
  343. }
  344. elseif ($problem == 4)
  345. {
  346. echo '<div class="alert alert-danger">';
  347. echo '<b>Version '.HESK_NEW_VERSION.' tables already exist!</b><br /><br />
  348. Your database seems to be compatible with HESK version '.HESK_NEW_VERSION.'<br /><br />
  349. To install a new copy of HESK use the <a href="index.php">New install</a> option instead.';
  350. echo '</div>';
  351. }
  352. elseif ($problem == 5)
  353. {
  354. hesk_show_error('MySQL version <b>'.REQUIRE_MYSQL_VERSION.'+</b> required, you are using: <b>' . MYSQL_VERSION . '</b><br /><br />
  355. You are using and old and insecure MySQL version with known bugs, security issues and outdated functionality.<br /><br />
  356. Ask your hosting company to update your MySQL version.');
  357. }
  358. ?>
  359. <div class="form-group">
  360. <label for="host">Database Host</label>
  361. <input type="text" class="form-control" name="host" id="host" placeholder="ex. localhost">
  362. </div>
  363. <div class="form-group">
  364. <label for="name">Database Name</label>
  365. <input type="text" class="form-control" name="name" id="name" placeholder="ex. hesk">
  366. </div>
  367. <div class="form-group">
  368. <label for="user">Database User</label>
  369. <input type="text" class="form-control" name="user" id="user" placeholder="ex. root">
  370. </div>
  371. <div class="form-group">
  372. <label for="pass">Database User's Password</label>
  373. <input type="password" class="form-control" name="pass" id="pass" placeholder="Password">
  374. </div>
  375. <?php
  376. if (INSTALL_PAGE == 'install.php')
  377. {
  378. ?>
  379. <div class="form-group">
  380. <label for="pfix">Table Prefix</label>
  381. <input type="text" class="form-control" name="pfix" id="pfix" placeholder="ex. hesk_">
  382. </div>
  383. <br>
  384. <div class="h3">HESK Login Details</div>
  385. <div class="h6">Username and password you will use to login into HESK administration.</div>
  386. <div class="footerWithBorder blankSpace"></div>
  387. <div class="form-group">
  388. <label for="admin_user">Choose a Username</label>
  389. <input type="text" class="form-control" placeholder="Username" name="admin_user" value="<?php echo isset($_SESSION['admin_user']) ? stripslashes($_SESSION['admin_user']) : 'Administrator'; ?>" size="40" autocomplete="off" />
  390. </div>
  391. <div class="form-group">
  392. <label for="admin_pass">Choose a Password</label>
  393. <input type="text" class="form-control" placeholder="Password" name="admin_pass" id="admin_pass" value="<?php echo isset($_SESSION['admin_pass']) ? stripslashes($_SESSION['admin_pass']) : ''; ?>" size="40" autocomplete="off" />
  394. </div>
  395. <?php
  396. }
  397. ?>
  398. <p align="center"><input type="hidden" name="dbtest" value="1" /><button type="submit" class="btn btn-default btn-lg">Continue</button></p>
  399. </form>
  400. <?php
  401. hesk_iFooter();
  402. } // End hesk_iDatabase()
  403. function hesk_iCheckSetup()
  404. {
  405. global $hesk_settings;
  406. $correct_these = array();
  407. // 1. PHP 5+ required
  408. if ( function_exists('version_compare') && version_compare(PHP_VERSION,REQUIRE_PHP_VERSION,'<') )
  409. {
  410. $correct_these[] = '
  411. PHP version <b>'.REQUIRE_PHP_VERSION.'+</b> required, you are using: <b>' . PHP_VERSION . '</b><br /><br />
  412. You are using and old and insecure PHP version with known bugs, security issues and outdated functionality.<br /><br />
  413. Ask your hosting company to update your PHP version.
  414. ';
  415. }
  416. // 2. File hesk_settings.inc.php must be writable
  417. if ( ! is__writable(HESK_PATH . 'hesk_settings.inc.php') )
  418. {
  419. // -> try to CHMOD it
  420. if ( function_exists('chmod') )
  421. {
  422. @chmod(HESK_PATH . 'hesk_settings.inc.php', 0666);
  423. }
  424. // -> test again
  425. if ( ! is__writable(HESK_PATH . 'hesk_settings.inc.php') )
  426. {
  427. $correct_these[] = '
  428. File <b>hesk_settings.inc.php</b> is not writable by PHP.<br /><br />
  429. Make sure PHP has permission to write to file <b>hesk_settings.inc.php</b><br /><br />
  430. &raquo; on <b>Linux</b> servers <a href="http://www.phpjunkyard.com/tutorials/ftp-chmod-tutorial.php">CHMOD</a> this file to 666 (rw-rw-rw-)<br />
  431. &raquo; on <b>Windows</b> servers allow Internet Guest Account to modify the file<br />
  432. &raquo; contact your hosting company for help with setting up file permissions.
  433. ';
  434. }
  435. }
  436. // 3. Folder attachments must exist
  437. $hesk_settings['attach_dir_name'] = isset($hesk_settings['attach_dir']) ? $hesk_settings['attach_dir'] : 'attachments';
  438. $hesk_settings['attach_dir'] = HESK_PATH . $hesk_settings['attach_dir_name'];
  439. // -> Try to create it
  440. if ( ! file_exists($hesk_settings['attach_dir']) )
  441. {
  442. @mkdir($hesk_settings['attach_dir'], 0755);
  443. }
  444. // -> Is the folder now there?
  445. if ( is_dir($hesk_settings['attach_dir']) )
  446. {
  447. // -> Is it writable?
  448. if ( ! is__writable($hesk_settings['attach_dir']) )
  449. {
  450. // -> try to CHMOD it
  451. @chmod($hesk_settings['attach_dir'], 0777);
  452. // -> test again
  453. if ( ! is__writable($hesk_settings['attach_dir']) )
  454. {
  455. $correct_these[] = '
  456. Folder <b>' . $hesk_settings['attach_dir_name'] . '</b> is not writable by PHP.<br /><br />
  457. Make sure PHP has permission to write to folder <b>' . $hesk_settings['attach_dir_name'] . '</b><br /><br />
  458. &raquo; on <b>Linux</b> servers <a href="http://www.phpjunkyard.com/tutorials/ftp-chmod-tutorial.php">CHMOD</a> this folder to 777 (rwxrwxrwx)<br />
  459. &raquo; on <b>Windows</b> servers allow Internet Guest Account to modify the folder<br />
  460. &raquo; contact your hosting company for help with setting up folder permissions.
  461. ';
  462. }
  463. }
  464. }
  465. else
  466. {
  467. $correct_these[] = '
  468. Folder <b>' . $hesk_settings['attach_dir_name'] . '</b> is missing.<br /><br />
  469. Create a folder called <b>' . $hesk_settings['attach_dir_name'] . '</b> inside your main HESK folder.<br /><br />
  470. ';
  471. }
  472. // 4. MySQL must be available
  473. if ( ! function_exists('mysql_connect') && ! function_exists('mysqli_connect') )
  474. {
  475. $correct_these[] = '
  476. MySQL is disabled.<br /><br />
  477. HESK requires MySQL to be installed and enabled.<br /><br />
  478. Ask your hosting company to enable MySQL for PHP.
  479. ';
  480. }
  481. // 5. Can we use GD library?
  482. $GD_LIB = ( extension_loaded('gd') && function_exists('gd_info') ) ? true : false;
  483. // 6. Make sure old files are deleted
  484. $old_files = array(
  485. // pre-0.93 *.inc files
  486. 'hesk_settings.inc','hesk.sql','inc/common.inc','inc/database.inc','inc/footer.inc','inc/header.inc',
  487. 'inc/print_tickets.inc','inc/show_admin_nav.inc','inc/show_search_form.inc','install.php','update.php',
  488. // pre-2.0 files
  489. 'admin.php','admin_change_status.php','admin_main.php','admin_move_category','admin_reply_ticket.php',
  490. 'admin_settings.php','admin_settings_save.php','admin_ticket.php','archive.php',
  491. 'delete_tickets.php','find_tickets.php','manage_canned.php','manage_categories.php',
  492. 'manage_users.php','profile.php','show_tickets.php',
  493. // pre-2.1 files
  494. 'emails/','language/english.php',
  495. // pre-2.3 files
  496. 'secimg.inc.php',
  497. // pre-2.4 files
  498. 'hesk_style_v23.css','help_files/','TreeMenu.js',
  499. // malicious files that were found on some websites illegally redistributing HESK
  500. 'inc/tiny_mce/utils/r00t10.php', 'language/en/help_files/r00t10.php',
  501. // pre-2.5 files
  502. 'hesk_style_v24.css', 'hesk_javascript_v24.js',
  503. // pre-2.6 files
  504. 'hesk_style_v25.css', 'hesk_javascript_v25.js',
  505. );
  506. sort($old_files);
  507. $still_exist = array();
  508. foreach ($old_files as $f)
  509. {
  510. if (file_exists(HESK_PATH . $f))
  511. {
  512. $still_exist[] = $f;
  513. }
  514. }
  515. if ( count($still_exist) )
  516. {
  517. $correct_these[] = '
  518. Outdated files and folders<br /><br />
  519. For security reasons please delete these legacy files and folders:<br />
  520. <ul><li><b>'.implode('</b></li><li><b>',$still_exist).'</b></li></ul>
  521. ';
  522. }
  523. // Do we have any errors?
  524. if ( count($correct_these) )
  525. {
  526. hesk_iHeader();
  527. ?>
  528. &nbsp;
  529. <div style="margin-left:40px;margin-right:40px">
  530. <?php
  531. foreach ($correct_these as $correct_this)
  532. {
  533. hesk_show_error($correct_this);
  534. echo "&nbsp;";
  535. }
  536. ?>
  537. </div>
  538. <form method="post" action="<?php echo INSTALL_PAGE; ?>">
  539. <p align="center"><input type="submit" value="Click here to test again" class="btn btn-default" /></p>
  540. </form>
  541. <p>&nbsp;</p>
  542. <?php
  543. hesk_iFooter();
  544. }
  545. // If all tests were successful, we can continue to the next step
  546. $_SESSION['set_attachments'] = 1;
  547. $_SESSION['set_captcha'] = $GD_LIB ? 1 : 0;
  548. $_SESSION['use_spamq'] = $GD_LIB ? 0 : 1;
  549. $_SESSION['step'] = 3;
  550. // When updating, first try saved MySQL info
  551. if (INSTALL_PAGE == 'update.php')
  552. {
  553. header('Location: ' . INSTALL_PAGE);
  554. }
  555. else
  556. {
  557. hesk_iDatabase();
  558. }
  559. exit();
  560. } ?></div></div> <!-- End hesk_iCheckSetup() -->
  561. <?php
  562. function hesk_iStart()
  563. {
  564. global $hesk_settings;
  565. // Set this session variable to check later if sessions are working
  566. $_SESSION['works'] = true;
  567. hesk_iHeader();
  568. ?>
  569. <div class="row">
  570. <div class="col-md-4">
  571. <div class="panel panel-default">
  572. <div class="panel-heading">
  573. <p>Summary</p>
  574. </div>
  575. <div class="panel-body">
  576. <ul>
  577. <li>The script is provided &quot;as is&quot;, without any warranty. Use at your own risk.<br />&nbsp;</li>
  578. <li>HESK is a registered trademark, using the term HESK requires permission.<br />&nbsp;</li>
  579. <li>Do not redistribute this script without express written permission<br />&nbsp;</li>
  580. <li>If you wish to remove the &quot;Powered by&quot; links a <a href="https://www.hesk.com/buy.php" target="_blank">license is required</a>.</li>
  581. </ul>
  582. </div>
  583. </div>
  584. </div>
  585. <div class="col-md-8">
  586. <div class="alert alert-warning"><strong>1. License Agreement</strong></div>
  587. <b>The entire agreement:</b>
  588. <div class="agreementBox">
  589. <strong>HESK License Agreement</strong><br/>
  590. The &quot;script&quot; is all files included with the HESK distribution archive as well as all files produced as a result of the installation scripts. Klemen Stirn (&quot;Author&quot;,&quot;HESK&quot;) is the author and copyrights owner of the script. The &quot;Licensee&quot; (&quot;you&quot;) is the person downloading or using the Licensed version of script. &quot;User&quot; is any person using or viewing the script with their HTML browser.
  591. &quot;Powered by&quot; link is herein defined as an anchor link pointing to HESK website and/or script webpage, usually located at the bottom of the script and visible to users of the script without looking into source code.
  592. &quot;Copyright headers&quot; is a written copyright notice located in script source code and normally not visible to users.
  593. This License may be modified by the Author at any time. The new version of the License becomes valid when published on HESK website. You are encouraged to regularly check back for License updates.
  594. THIS SCRIPT IS PROVIDED &quot;AS IS&quot; AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLEMEN STIRN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SCRIPT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  595. Using this code, in part or full, to create derivative work, new scripts or products is expressly forbidden. Obtain permission before redistributing this software over the Internet or in any other medium.
  596. REMOVING POWERED BY LINKS
  597. You are not allowed to remove or in any way edit the &quot;Powered by&quot; links in this script without purchasing a License. You can purchase a License at
  598. https://www.hesk.com/buy.php
  599. If you remove the Powered by links without purchasing a License and paying the licensee fee, you are in a direct violation of European Union and International copyright laws. Your License to use the scripts is immediately terminated and you must delete all copies of the entire program from your web server. Klemen Stirn may, at any time, terminate this License agreement if Klemen Stirn determines, that this License agreement has been breached.
  600. Under no circumstance is the removal of copyright headers from the script source code permitted.
  601. TRADEMARK POLICY
  602. HESK is a US and EU registered trademark of Klemen Stirn. Certain usages of the Trademark are fine and no specific permission from the author is needed:
  603. - there is no commercial intent behind the use
  604. - what you are referring to is in fact HESK. If someone is confused into thinking that what isn't HESK is in fact HESK, you are probably doing something wrong
  605. - there is no suggestion (through words or appearance) that your project is approved, sponsored, or affiliated with HESK or its related projects unless it actually has been approved by and is accountable to the author
  606. Permission from the author is necessary to use the HESK trademark under any circumstances other than those specifically permitted above. These include:
  607. - any commercial use
  608. - use on or in relation to a software product that includes or is built on top of a product supplied by author, if there is any commercial intent associated with that product
  609. - use in a domain name or URL
  610. - use for merchandising purposes, e.g. on t-shirts and the like
  611. - use of a name which includes the letters HESK in relation to computer hardware or software.
  612. - services relating to any of the above
  613. If you wish to have permission for any of the uses above or for any other use which is not specifically referred to in this policy, please contact me and I'll let you know as soon as possible if your proposed use is permissible. Note that due to the volume of mail I receive, it may take some time to process your request. Permission may only be granted subject to certain conditions and these may include the requirement that you enter into an agreement with me to maintain the quality of the product and/or service which you intend to supply at a prescribed level.
  614. While there may be exceptions, it is very unlikely that I will approve Trademark use in the following cases:
  615. - use of a Trademark in a company name
  616. - use of a Trademark in a domain name which has a commercial intent. The commercial intent can range from promotion of a company or product, to collecting revenue generated by advertising
  617. - the calling of any software or product by the name HESK (or another related Trademark), unless that software or product is a substantially unmodified HESK product
  618. - use in combination with any other marks or logos. This include use of a Trademark in a manner that creates a "combined mark," or use that integrates other wording with the Trademark in a way that the public may think of the use as a new mark (for example Club HESK or HESKBooks, or in a way that by use of special fonts or presentation with nearby words or images conveys an impression that the two are tied in some way)
  619. - use in combination with any product or service which is presented as being Certified or Official or formally associated with me or my products or services
  620. - use in a way which implies an endorsement where that doesn't exist, or which attempts to unfairly or confusingly capitalise on the goodwill or brand of the project
  621. - use of a Trademark in a manner that disparages HESK and is not clearly third-party parody
  622. - on or in relation to a software product which constitutes a substantially modified version of a product supplied by HESK.com, that is to say with material changes to the code, or services relating to such a product
  623. - in a title or metatag of a web page whose sole intention or result is to influence search engine rankings or result listings, rather than for discussion, development or advocacy of the Trademarks
  624. OTHER
  625. This License Agreement is governed by the laws of Slovenia, European Union. Both the Licensee and Klemen Stirn submit to the jurisdiction of the courts of Slovenia, European Union. Both the Licensee and Klemen Stirn agree to commence any litigation that may arise hereunder in the courts located in Slovenia.
  626. If any provision hereof shall be held illegal, invalid or unenforceable, in whole or in part, such provision shall be modified to the minimum extent necessary to make it legal, valid and enforceable, and the legality, validity and enforceability of all other provisions of this Agreement shall not be affected thereby. No delay or failure by either party to exercise or enforce at any time any right or provision hereof shall be considered a waiver thereof or of such party's right thereafter to exercise or enforce each and every right and provision of this Agreement.
  627. </div>
  628. </div>
  629. </div>
  630. <br />
  631. <br />
  632. <form method="post" action="<?php echo INSTALL_PAGE; ?>" name="license" onsubmit="return hesk_checkAgree()">
  633. <div align="center">
  634. <p align="center">
  635. <a class="btn btn-default btn-lg" href="#" onclick="javascript:parent.location='index.php'" role="button">Cancel</a>
  636. <button type="submit" class="btn btn-default btn-lg">Continue</button>
  637. <p><b>By clicking continue, you agree to the license agreement and all the terms incorporated therein.</b></p>
  638. <input type="hidden" name="agree" value="YES" />
  639. </p>
  640. <p>&nbsp;</p>
  641. </div>
  642. </form>
  643. <?php
  644. hesk_iFooter();
  645. } // End hesk_iStart()
  646. function hesk_iHeader()
  647. {
  648. global $hesk_settings;
  649. $steps = array(
  650. 1 => '1. License agreement',
  651. 2 => '2. Check setup',
  652. 3 => '3. Database settings',
  653. 4 => '4. Setup database tables'
  654. );
  655. ?>
  656. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  657. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  658. <head>
  659. <title>HESK <?php echo HESK_NEW_VERSION; ?> Setup</title>
  660. <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  661. <link href="../hesk_style.css?<?php echo HESK_NEW_VERSION; ?>" type="text/css" rel="stylesheet" />
  662. <link rel="stylesheet" href="../css/bootstrap.css">
  663. <link rel="stylesheet" href="../css/bootstrap-theme.css">
  664. <link href="../css/hesk_newStyle.css" type="text/css" rel="stylesheet" />
  665. <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  666. <script src="../js/jquery-1.10.2.min.js"></script>
  667. <script language="Javascript" type="text/javascript" src="../hesk_javascript.js?<?php echo HESK_NEW_VERSION; ?>"></script>
  668. <script language="Javascript" type="text/javascript" src="../js/bootstrap.min.js"></script>
  669. <!-- Include all compiled plugins (below), or include individual files as needed -->
  670. <script src="../js/bootstrap.min.js"></script>
  671. </head>
  672. <body>
  673. <div class="enclosing">
  674. <div class="headersm">HESK <?php echo HESK_NEW_VERSION; ?> Setup</div>
  675. <?php
  676. if ( isset($_SESSION['step']) )
  677. {
  678. $_SESSION['step'] = intval($_SESSION['step']);
  679. ?>
  680. <ol class="breadcrumb">
  681. <?php
  682. foreach ($steps as $number => $description)
  683. {
  684. if ($number == $_SESSION['step']) //Active step
  685. {
  686. $steps[$number] = '<li>' . $steps[$number] . '</li>';
  687. }
  688. else //Already passed through or not yet there
  689. {
  690. $steps[$number] = '<li class="active">' . $steps[$number] . '</li>';
  691. }
  692. }
  693. echo implode($steps);
  694. ?>
  695. </ol>
  696. <br />
  697. <?php
  698. }
  699. else
  700. {
  701. echo '<div class="installWarning"><div class="alert alert-warning"><strong>Note: </strong><a href="../docs/index.html">Read installation guide</a> before using this setup script!</div></div>';
  702. }
  703. } // End hesk_iHeader()
  704. function hesk_iFooter()
  705. {
  706. global $hesk_settings;
  707. ?>
  708. <p style="text-align:center"><span class="smaller">&nbsp;<br />Powered by <a href="http://www.hesk.com" class="smaller" title="Free PHP Help Desk Software">Help Desk Software</a> <b>HESK</b>, brought to you by <a href="https://www.sysaid.com/?utm_source=Hesk&utm_medium=cpc&utm_campaign=HeskProduct_To_HP">SysAid</a></span></p>
  709. </div>
  710. </body>
  711. </html>
  712. <?php
  713. exit();
  714. } // End hesk_iFooter()
  715. function hesk_iSessionError()
  716. {
  717. hesk_session_stop();
  718. hesk_iHeader();
  719. ?>
  720. <br />
  721. <div class="error">
  722. <img src="<?php echo HESK_PATH; ?>img/error.png" width="16" height="16" border="0" alt="" style="vertical-align:text-bottom" />
  723. <b>Error:</b> PHP sessions not working!<br /><br />Note that this is a server configuration issue, not a HESK issue.<br /><br />Please contact your hosting company and ask them to verify why PHP sessions aren't working on your server!
  724. </div>
  725. <br />
  726. <form method="get" action="<?php echo INSTALL_PAGE; ?>">
  727. <p align="center"><input type="submit" value="&laquo; Start over" class="orangebutton" onmouseover="hesk_btn(this,'orangebuttonover');" onmouseout="hesk_btn(this,'orangebutton');" /></p>
  728. </form>
  729. <?php
  730. hesk_iFooter();
  731. } // END hesk_iSessionError()
  732. function hesk_compareVariable($k,$v)
  733. {
  734. global $hesk_settings;
  735. if (is_array($v))
  736. {
  737. foreach ($v as $sub_k => $sub_v)
  738. {
  739. $v[$k] = hesk_compareVariable($sub_k,$sub_v);
  740. }
  741. }
  742. if (isset($hesk_settings[$k]))
  743. {
  744. return $hesk_settings[$k];
  745. }
  746. else
  747. {
  748. return $v;
  749. }
  750. } // END hesk_compareVariable()
  751. function is__writable($path)
  752. {
  753. //will work in despite of Windows ACLs bug
  754. //NOTE: use a trailing slash for folders!!!
  755. //see http://bugs.php.net/bug.php?id=27609
  756. //see http://bugs.php.net/bug.php?id=30931
  757. if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
  758. return is__writable($path.uniqid(mt_rand()).'.tmp');
  759. else if (is_dir($path))
  760. return is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
  761. // check tmp file for read/write capabilities
  762. $rm = file_exists($path);
  763. $f = @fopen($path, 'a');
  764. if ($f===false)
  765. return false;
  766. fclose($f);
  767. if (!$rm)
  768. unlink($path);
  769. return true;
  770. } // END is__writable()