BxDolStudioTools.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950
  1. <?php
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinStudio Dolphin Studio
  7. * @{
  8. */
  9. defined('BX_DOL') or die('hack attempt');
  10. require_once('./../inc/classes/BxDolIO.php');
  11. // TODO: consider rewriting installer
  12. class BxDolAdminTools extends BxDolIO {
  13. var $sTroubledElements;
  14. var $aInstallDirs;
  15. var $aInstallFiles;
  16. var $aFlashDirs;
  17. var $aFlashFiles;
  18. var $aPostInstallPermDirs;
  19. var $aPostInstallPermFiles;
  20. function BxDolAdminTools() {
  21. parent::BxDolIO();
  22. $this->sTroubledElements = '';
  23. $this->aInstallDirs = array(
  24. 'cache',
  25. 'cache_public',
  26. 'tmp',
  27. 'plugins/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer',
  28. 'plugins/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer/HTML',
  29. 'plugins/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer/CSS',
  30. 'plugins/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer/Test',
  31. 'plugins/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer/URI',
  32. );
  33. $this->aInstallFiles = array(
  34. );
  35. $this->aFlashDirs = array(
  36. );
  37. $this->aFlashFiles = array(
  38. );
  39. $this->aPostInstallPermDirs = array(
  40. );
  41. $this->aPostInstallPermFiles = array(
  42. );
  43. }
  44. function GenCommonCode() {
  45. $sAdditionDir = (isAdmin()==true) ? BX_DOL_URL_ROOT : '../';
  46. $sMasterSwPic = $sAdditionDir . 'media/images/master_nav.gif';
  47. $sRet = <<<EOF
  48. <style type="text/css">
  49. div.hidden {
  50. display:none;
  51. }
  52. .left_side_sw_caption {
  53. float:left;
  54. text-align:justify;
  55. width:515px;
  56. }
  57. .right_side_sw_caption {
  58. float:right;
  59. width:60px;
  60. }
  61. tr.head td {
  62. background-color:#FFFFFF;
  63. font-weight:bold;
  64. height:17px;
  65. padding:5px;
  66. text-align:center;
  67. font-size:13px;
  68. border-color:silver;
  69. }
  70. tr.cont td {
  71. height:15px;
  72. padding:2px 5px;
  73. font-size:13px;
  74. border-color:silver;
  75. }
  76. .install_table {
  77. background-color: silver;
  78. border-width:0px;
  79. }
  80. span.unwritable {
  81. color:red;
  82. font-weight:bold;
  83. margin-right:5px;
  84. }
  85. span.writable {
  86. color:green;
  87. font-weight:bold;
  88. margin-right:5px;
  89. }
  90. span.desired {
  91. font-weight:bold;
  92. margin-right:5px;
  93. }
  94. .install_table tr.even {
  95. background-color:#EDE9E9;
  96. }
  97. .install_table tr.odd {
  98. background-color:#FFF;
  99. }
  100. .install_table tr:hover{
  101. background-color:#DDD;
  102. }
  103. #btn-alls-on {
  104. background:transparent url({$sMasterSwPic}) no-repeat scroll -0px -0px;
  105. width:25px;
  106. height:21px;
  107. }
  108. #btn-alls-off {
  109. background:transparent url({$sMasterSwPic}) no-repeat scroll -0px -20px;
  110. width:25px;
  111. height:21px;
  112. }
  113. #btn-troubled-on {
  114. background:transparent url({$sMasterSwPic}) no-repeat scroll -24px -20px;
  115. width:25px;
  116. height:21px;
  117. }
  118. #btn-troubled-off {
  119. background:transparent url({$sMasterSwPic}) no-repeat scroll -24px -0px;
  120. width:25px;
  121. height:21px;
  122. }
  123. tr.head td.left_aligned {
  124. text-align:left;
  125. font-weight:bold;
  126. }
  127. </style>
  128. EOF;
  129. return $sRet;
  130. }
  131. function GenPermTable() {
  132. $sDirsC = function_exists('_t') ? _t('_adm_admtools_Directories') : 'Directories';
  133. $sFilesC = function_exists('_t') ? _t('_adm_admtools_Files') : 'Files';
  134. $sElementsC = function_exists('_t') ? _t('_adm_admtools_Elements') : 'Elements';
  135. $sFlashC = function_exists('_t') ? _t('_adm_admtools_Flash') : 'Flash';
  136. $sCurrentLevelC = function_exists('_t') ? _t('_adm_admtools_Current_level') : 'Current level';
  137. $sDesiredLevelC = function_exists('_t') ? _t('_adm_admtools_Desired_level') : 'Desired level';
  138. $sBadFilesC = function_exists('_t') ? _t('_adm_admtools_Bad_files') : 'Next files and directories have inappropriate permissions';
  139. $sShowOnlyBadC = function_exists('_t') ? _t('_adm_admtools_Only_bad_files') : 'Show only troubled files and directories with inappropriate permissions';
  140. $sShowAllC = function_exists('_t') ? _t('_adm_admtools_Show_all_files') : 'Show all files and directories';
  141. $sDescriptionC = function_exists('_t') ? _t('_adm_admtools_Perm_description') : 'Dolphin needs special access for certain files and directories. Please, change permissions as specified in the chart below. Helpful info about permissions is <a href="http://www.boonex.com/trac/dolphin/wiki/DetailedInstall#Permissions" target="_blank">available here</a>.';
  142. $this->sTroubledElements = '';
  143. $sInstallDirs = $this->GenArrElemPerm($this->aInstallDirs, 1);
  144. $sFlashDirs = $this->GenArrElemPerm($this->aFlashDirs, 1);
  145. $sInstallFiles = $this->GenArrElemPerm($this->aInstallFiles, 2);
  146. $sFlashFiles = $this->GenArrElemPerm($this->aFlashFiles, 2);
  147. $sAdditionDir = (isAdmin()==true) ? BX_DOL_URL_ROOT : '../';
  148. $sLeftAddEl = (isAdmin()==true) ? '<div class="left_side_sw_caption">'.$sDescriptionC.'</div>' : '';
  149. $sSpacerPic = $sAdditionDir . 'media/images/spacer.gif';
  150. $sRet = <<<EOF
  151. <script type="text/javascript">
  152. <!--
  153. function callSwitcher(){
  154. $('table.install_table tr:not(.troubled)').toggle();
  155. }
  156. function switchToTroubled(viewType) {
  157. if (viewType == 'A') {
  158. $("#btn-alls-off").attr("id", "btn-alls-on");
  159. $("#btn-troubled-on").attr("id", "btn-troubled-off");
  160. $('table.install_table tr:not(.troubled)').show();
  161. } else if (viewType == 'T') {
  162. $("#btn-alls-on").attr("id", "btn-alls-off");
  163. $("#btn-troubled-off").attr("id", "btn-troubled-on");
  164. $('table.install_table tr:not(.troubled)').hide();
  165. }
  166. return false;
  167. }
  168. -->
  169. </script>
  170. <table width="100%" cellspacing="1" cellpadding="0" class="install_table">
  171. <tr class="head troubled">
  172. <td colspan="3" style="text-align:center;">
  173. {$sLeftAddEl}
  174. <div class="right_side_sw_caption">
  175. <a onclick="return switchToTroubled('A')" href="#"><img id="btn-alls-on" src="{$sSpacerPic}" alt="{$sShowAllC}" title="{$sShowAllC}" /></a>
  176. <a onclick="return switchToTroubled('T')" href="#"><img id="btn-troubled-off" src="{$sSpacerPic}" alt="{$sShowOnlyBadC}" title="{$sShowOnlyBadC}" /></a>
  177. </div>
  178. <div class="clear_both"></div>
  179. </td>
  180. </tr>
  181. <tr class="head">
  182. <td colspan="3" style="text-align:center;" class="normal_td">{$sDirsC}</td>
  183. </tr>
  184. <tr class="head">
  185. <td>{$sDirsC}</td>
  186. <td>{$sCurrentLevelC}</td>
  187. <td>{$sDesiredLevelC}</td>
  188. </tr>
  189. {$sInstallDirs}
  190. <tr class="head">
  191. <td>{$sFlashC} {$sDirsC}</td>
  192. <td>{$sCurrentLevelC}</td>
  193. <td>{$sDesiredLevelC}</td>
  194. </tr>
  195. {$sFlashDirs}
  196. <tr class="head">
  197. <td colspan="3" style="text-align:center;">{$sFilesC}</td>
  198. </tr>
  199. <tr class="head">
  200. <td>{$sFilesC}</td>
  201. <td>{$sCurrentLevelC}</td>
  202. <td>{$sDesiredLevelC}</td>
  203. </tr>
  204. {$sInstallFiles}
  205. <tr class="head">
  206. <td>{$sFlashC} {$sFilesC}</td>
  207. <td>{$sCurrentLevelC}</td>
  208. <td>{$sDesiredLevelC}</td>
  209. </tr>
  210. {$sFlashFiles}
  211. <tr class="head troubled">
  212. <td colspan="3" style="text-align:center;">{$sBadFilesC}</td>
  213. </tr>
  214. <tr class="head troubled">
  215. <td>{$sElementsC}</td>
  216. <td>{$sCurrentLevelC}</td>
  217. <td>{$sDesiredLevelC}</td>
  218. </tr>
  219. {$this->sTroubledElements}
  220. </table>
  221. EOF;
  222. return $sRet;
  223. }
  224. function GenArrElemPerm($aElements, $iType) { //$iType: 1 - folder, 2 - file
  225. if (!is_array($aElements) || empty($aElements))
  226. return '';
  227. $sWritableC = function_exists('_t') ? _t('_adm_admtools_Writable') : 'Writable';
  228. $sNonWritableC = function_exists('_t') ? _t('_adm_admtools_Non_Writable') : 'Non-Writable';
  229. $sNotExistsC = function_exists('_t') ? _t('_adm_admtools_Not_Exists') : 'Not Exists';
  230. $sExecutableC = function_exists('_t') ? _t('_adm_admtools_Executable') : 'Executable';
  231. $sNonExecutableC = function_exists('_t') ? _t('_adm_admtools_Non_Executable') : 'Non-Executable';
  232. $iType = ($iType==1) ? 1 : 2;
  233. $sElements = '';
  234. $i = 0;
  235. foreach ($aElements as $sCurElement) {
  236. $iCurType = $iType;
  237. $sAwaitedPerm = ($iCurType==1) ? $sWritableC : $sWritableC;
  238. $sElemCntStyle = ($i%2==0) ? 'even' : 'odd' ;
  239. $bAccessible = ($iCurType==1) ? self::isWritable($sCurElement) : self::isWritable($sCurElement);
  240. if ($sCurElement == 'flash/modules/global/app/ffmpeg.exe') {
  241. $sAwaitedPerm = $sExecutableC;
  242. $bAccessible = self::isExecutable($sCurElement);
  243. }
  244. if ($bAccessible) {
  245. $sResultPerm = ($iCurType==1) ? $sWritableC : $sWritableC;
  246. if ($sCurElement == 'flash/modules/global/app/ffmpeg.exe') {
  247. $sResultPerm = $sExecutableC;
  248. }
  249. $sElements .= <<<EOF
  250. <tr class="cont {$sElemCntStyle}">
  251. <td>{$sCurElement}</td>
  252. <td class="span">
  253. <span class="writable">{$sResultPerm}</span>
  254. </td>
  255. <td class="span">
  256. <span class="desired">{$sAwaitedPerm}</span>
  257. </td>
  258. </tr>
  259. EOF;
  260. } else {
  261. $sPerm = self::getPermissions($sCurElement);
  262. $sResultPerm = '';
  263. if ($sPerm==false) {
  264. $sResultPerm = $sNotExistsC;
  265. } else {
  266. $sResultPerm = ($iCurType==1) ? $sNonWritableC : $sNonWritableC;
  267. }
  268. if ($sCurElement == 'flash/modules/global/app/ffmpeg.exe') {
  269. $sResultPerm = $sNonExecutableC;
  270. }
  271. $sPerm = '';
  272. $sElements .= <<<EOF
  273. <tr class="cont {$sElemCntStyle}">
  274. <td>{$sCurElement}</td>
  275. <td class="span">
  276. <span class="unwritable">{$sPerm} {$sResultPerm}</span>
  277. </td>
  278. <td class="span">
  279. <span class="desired">{$sAwaitedPerm}</span>
  280. </td>
  281. </tr>
  282. EOF;
  283. $this->sTroubledElements .= <<<EOF
  284. <tr class="cont {$sElemCntStyle} troubled">
  285. <td>{$sCurElement}</td>
  286. <td class="span">
  287. <span class="unwritable">{$sPerm} {$sResultPerm}</span>
  288. </td>
  289. <td class="span">
  290. <span class="desired">{$sAwaitedPerm}</span>
  291. </td>
  292. </tr>
  293. EOF;
  294. }
  295. $i++;
  296. }
  297. return $sElements;
  298. }
  299. function performInstalCheck() { //check requirements
  300. $aErrors = array();
  301. $aErrors[] = (ini_get('register_globals') == 0) ? '' : '<font color="red">register_globals is On (warning, you should have this param in Off state, or your site will unsafe)</font>';
  302. $aErrors[] = (ini_get('safe_mode') == 0) ? '' : '<font color="red">safe_mode is On, disable it</font>';
  303. //$aErrors[] = (ini_get('allow_url_fopen') == 0) ? 'Off (warning, better keep this parameter in On to able register Dolphin' : '';
  304. $aErrors[] = (((int)phpversion()) < 4) ? '<font color="red">PHP version too old, update server please</font>' : '';
  305. $aErrors[] = (! extension_loaded( 'mbstring')) ? '<font color="red">mbstring extension not installed. <b>Warning!</b> Dolphin cannot work without <b>mbstring</b> extension.</font>' : '';
  306. if (version_compare(phpversion(), "5.2", ">") == 1) {
  307. $aErrors[] = (ini_get('allow_url_include') == 0) ? '' : '<font color="red">allow_url_include is On (warning, you should have this param in Off state, or your site will unsafe)</font>';
  308. };
  309. $aErrors = array_diff($aErrors, array('')); //delete empty
  310. if (count($aErrors)) {
  311. $sErrors = implode(" <br /> ", $aErrors);
  312. echo <<<EOF
  313. {$sErrors} <br />
  314. Please go to the <br />
  315. <a href="http://www.boonex.com/trac/dolphin/wiki/GenDolTShooter">Dolphin Troubleshooter</a> <br />
  316. and solve the problem.
  317. EOF;
  318. exit;
  319. }
  320. }
  321. function GenCacheEnginesTable() {
  322. $sRet = '<table width="100%" cellspacing="1" cellpadding="0" class="install_table">';
  323. $sRet .= '
  324. <tr class="head troubled">
  325. <td></td>
  326. <td class="center_aligned">' . _t('_sys_adm_installed') . '</td>
  327. <td class="center_aligned">' . _t('_sys_adm_available') . '</td>
  328. </tr>';
  329. $aEngines = array ('File', 'EAccelerator', 'Memcache', 'APC', 'XCache');
  330. foreach ($aEngines as $sEngine) {
  331. $oCacheObject = @bx_instance ('BxDolCache' . $sEngine);
  332. $sRet .= '
  333. <tr class="head troubled">
  334. <td class="left_aligned">' . $sEngine . '</td>
  335. <td class="center_aligned">' . (@$oCacheObject->isInstalled() ? '<font color="green">' . _t('_Yes') . '</font>' : '<font color="red">' . _t('_No') . '</font>') . '</td>
  336. <td class="center_aligned">' . (@$oCacheObject->isAvailable() ? '<font color="green">' . _t('_Yes') . '</font>' : '<font color="red">' . _t('_No') . '</font>') . '</td>
  337. </tr>';
  338. }
  339. $sRet .= '</table>';
  340. return $sRet;
  341. }
  342. function GenTabbedPage() {
  343. $sTitleC = _t('_adm_admtools_title');
  344. $sAuditC = _t('_adm_admtools_Audit');
  345. $sPermissionsC = _t('_adm_admtools_Permissions');
  346. $sCacheEnginesC = _t('_adm_admtools_cache_engines');
  347. $sAuditTab = $this->GenAuditPage();
  348. $sPermissionsTab = $this->GenPermTable();
  349. $sCacheEnginesTab = $this->GenCacheEnginesTable();
  350. $sBoxContent = <<<EOF
  351. <script type="text/javascript">
  352. <!--
  353. function switchAdmPage(iPageID) {
  354. //make all tabs - inactive
  355. //mace selected tab - active
  356. //hide all pages
  357. //show selected page
  358. $(".dbTopMenu").children().removeClass().toggleClass("notActive");
  359. $("#main_menu" + iPageID).removeClass().toggleClass("active");
  360. $("#adm_pages").children().removeClass().toggleClass("hidden");
  361. $("#adm_pages #page" + iPageID).removeClass().toggleClass("visible");
  362. return false;
  363. }
  364. -->
  365. </script>
  366. <div class="boxContent" id="adm_pages">
  367. <div id="page0" class="visible">{$sAuditTab}</div>
  368. <div id="page1" class="visible">{$sPermissionsTab}</div>
  369. <div id="page3" class="hidden">
  370. <iframe frameborder="0" width="100%" height="800" scrolling="auto" src="host_tools.php?get_phpinfo=true"></iframe>
  371. </div>
  372. <div id="page4" class="hidden">{$sCacheEnginesTab}</div>
  373. </div>
  374. EOF;
  375. $sActions = <<<EOF
  376. <div class="dbTopMenu">
  377. <div class="active" id="main_menu0"><span><a href="#" class="top_members_menu" onclick="switchAdmPage(0); return false;">{$sAuditC}</a></span></div>
  378. <div class="notActive" id="main_menu3"><span><a href="#" class="top_members_menu" onclick="switchAdmPage(3); return false;">phpinfo</a></span></div>
  379. <div class="notActive" id="main_menu4"><span><a href="#" class="top_members_menu" onclick="switchAdmPage(4); return false;">{$sCacheEnginesC}</a></span></div>
  380. </div>
  381. EOF;
  382. $sWrappedBox = $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $sBoxContent));
  383. return DesignBoxContent($sTitleC, $sWrappedBox, 1, $sActions);
  384. }
  385. //************
  386. function isFolderReadWrite($filename) {
  387. clearstatcache();
  388. $aPathInfo = pathinfo(__FILE__);
  389. $filename = $aPathInfo['dirname'] . '/../../' . $filename;
  390. return (@file_exists($filename . '/.') && is_readable( $filename ) && is_writable( $filename ) ) ? true : false;
  391. }
  392. function isFileReadWrite($filename) {
  393. clearstatcache();
  394. $aPathInfo = pathinfo(__FILE__);
  395. $filename = $aPathInfo['dirname'] . '/../../' . $filename;
  396. return (is_file($filename) && is_readable( $filename ) && is_writable( $filename ) ) ? true : false;
  397. }
  398. function isFileExecutable($filename) {
  399. clearstatcache();
  400. $aPathInfo = pathinfo(__FILE__);
  401. $filename = $aPathInfo['dirname'] . '/../../' . $filename;
  402. return (is_file($filename) && is_executable( $filename ) ) ? true : false;
  403. }
  404. //************
  405. function isAllowUrlInclude() {
  406. if (version_compare(phpversion(), "5.2", ">") == 1) {
  407. $sAllowUrlInclude = ini_get('allow_url_include');
  408. return !($sAllowUrlInclude == 0);
  409. };
  410. return false;
  411. }
  412. function GenAuditPage() {
  413. $sDolphinPath = BX_DIRECTORY_PATH_ROOT;
  414. $sEmailToCkeckMailSending = getParam('site_email');
  415. $sLatestDolphinVer = file_get_contents("http://rss.boonex.com/");
  416. if (preg_match ('#<dolphin>([\.0-9]+)</dolphin>#', $sLatestDolphinVer, $m))
  417. $sLatestDolphinVer = $m[1];
  418. else
  419. $sLatestDolphinVer = 'undefined';
  420. $sMinPhpVer = '5.2.0';
  421. $sMinMysqlVer = '4.1.2';
  422. $a = unserialize(file_get_contents("http://www.php.net/releases/index.php?serialize=1"));
  423. $sLatestPhpVersion = $a[5]['version'];
  424. $sLatestPhp52Version = '5.2.17';
  425. $aPhpSettings = array (
  426. 'allow_url_fopen' => array('op' => '=', 'val' => true, 'type' => 'bool'),
  427. 'allow_url_include' => array('op' => '=', 'val' => false, 'type' => 'bool'),
  428. 'magic_quotes_gpc' => array('op' => '=', 'val' => false, 'type' => 'bool', 'warn' => 1),
  429. 'memory_limit' => array('op' => '>=', 'val' => 128*1024*1024, 'type' => 'bytes', 'unlimited' => -1),
  430. 'post_max_size' => array('op' => '>=', 'val' => 50*1024*1024, 'type' => 'bytes', 'warn' => 1),
  431. 'upload_max_filesize' => array('op' => '>=', 'val' => 50*1024*1024, 'type' => 'bytes', 'warn' => 1),
  432. 'register_globals' => array('op' => '=', 'val' => false, 'type' => 'bool'),
  433. 'safe_mode' => array('op' => '=', 'val' => false, 'type' => 'bool'),
  434. 'short_open_tag' => array('op' => '=', 'val' => true, 'type' => 'bool'),
  435. 'disable_functions' => array('op' => '=', 'val' => ''),
  436. 'php module: curl' => array('op' => 'module', 'val' => 'curl'),
  437. 'php module: gd' => array('op' => 'module', 'val' => 'gd'),
  438. 'php module: mbstring' => array('op' => 'module', 'val' => 'mbstring'),
  439. 'php module: openssl' => array('op' => 'module', 'val' => 'openssl', 'warn' => 1),
  440. 'php module: ftp' => array('op' => 'module', 'val' => 'ftp', 'warn' => 1),
  441. );
  442. $aMysqlSettings = array (
  443. 'key_buffer_size' => array('op' => '>=', 'val' => 128*1024, 'type' => 'bytes'),
  444. 'query_cache_limit' => array('op' => '>=', 'val' => 1000000),
  445. 'query_cache_size' => array('op' => '>=', 'val' => 16*1024*1024, 'type' => 'bytes'),
  446. 'query_cache_type' => array('op' => 'strcasecmp', 'val' => 'on'),
  447. 'max_heap_table_size' => array('op' => '>=', 'val' => 16*1024*1024, 'type' => 'bytes'),
  448. 'tmp_table_size' => array('op' => '>=', 'val' => 16*1024*1024, 'type' => 'bytes'),
  449. 'thread_cache_size ' => array('op' => '>', 'val' => 0),
  450. );
  451. $aRequiredApacheModules = array (
  452. 'rewrite_module' => 'mod_rewrite',
  453. );
  454. $aDolphinOptimizationSettings = array (
  455. 'DB cache' => array('enabled' => 'sys_db_cache_enable', 'cache_engine' => 'sys_db_cache_engine', 'check_accel' => true),
  456. 'Page blocks cache' => array('enabled' => 'sys_pb_cache_enable', 'cache_engine' => 'sys_pb_cache_engine', 'check_accel' => true),
  457. 'Member menu cache' => array('enabled' => 'always_on', 'cache_engine' => 'sys_mm_cache_engine', 'check_accel' => true),
  458. 'Templates Cache' => array('enabled' => 'sys_template_cache_enable', 'cache_engine' => 'sys_template_cache_engine', 'check_accel' => true),
  459. 'CSS files cache' => array('enabled' => 'sys_template_cache_css_enable', 'cache_engine' => '', 'check_accel' => false),
  460. 'JS files cache' => array('enabled' => 'sys_template_cache_js_enable', 'cache_engine' => '', 'check_accel' => false),
  461. 'Compression for CSS/JS cache' => array('enabled' => 'sys_template_cache_compress_enable', 'cache_engine' => '', 'check_accel' => false),
  462. );
  463. ob_start();
  464. ?>
  465. <style>
  466. .ok {
  467. color:green;
  468. }
  469. .fail {
  470. color:red;
  471. }
  472. .warn {
  473. color:orange;
  474. }
  475. .undef {
  476. color:gray;
  477. }
  478. .code {
  479. border:1px solid #090;
  480. color:#090;
  481. padding:10px;
  482. margin:10px;
  483. width:550px;
  484. overflow:scroll;
  485. }
  486. </style>
  487. <h2>Software requirements</h2>
  488. <ul>
  489. <li><b>PHP</b>:
  490. <?php
  491. $sPhpVer = PHP_VERSION;
  492. echo $sPhpVer . ' - ';
  493. if (version_compare($sPhpVer, $sMinPhpVer, '<'))
  494. echo '<b class="fail">FAIL</b> (your version is incompatible with Dolphin, must be at least ' . $sMinPhpVer . ')';
  495. elseif (version_compare($sPhpVer, '5.3.0', '>=') && version_compare($sPhpVer, '6.0.0', '<') && !version_compare($sPhpVer, $sLatestPhpVersion, '>='))
  496. echo '<b class="warn">WARNING</b> (your PHP version is outdated, upgrade to the latest ' . $sLatestPhpVersion . ' maybe required)';
  497. elseif (version_compare($sPhpVer, '5.2.0', '>=') && version_compare($sPhpVer, '5.3.0', '<') && !version_compare($sPhpVer, $sLatestPhp52Version, '>='))
  498. echo '<b class="warn">WARNING</b> (your PHP version is outdated, upgrade to the latest ' . $sLatestPhp52Version . ' maybe required)';
  499. else
  500. echo '<b class="ok">OK</b>';
  501. ?>
  502. <ul>
  503. <?php
  504. foreach ($aPhpSettings as $sName => $r) {
  505. $a = $this->checkPhpSetting($sName, $r);
  506. echo "<li>$sName = " . $this->format_output($a['real_val'], $r) ." - ";
  507. if ($a['res'])
  508. echo '<b class="ok">OK</b>';
  509. elseif ($r['warn'])
  510. echo "<b class='warn'>WARNING</b> (should be {$r['op']} " . $this->format_output($r['val'], $r) . ")";
  511. else
  512. echo "<b class='fail'>FAIL</b> (must be {$r['op']} " . $this->format_output($r['val'], $r) . ")";
  513. echo "</li>\n";
  514. }
  515. ?>
  516. </ul>
  517. </li>
  518. <li><b>MySQL</b>:
  519. <?php
  520. $sMysqlVer = mysql_get_server_info($GLOBALS['bx_db_link']);
  521. echo $sMysqlVer . ' - ';
  522. if (preg_match ('/^(\d+)\.(\d+)\.(\d+)/', $sMysqlVer, $m)) {
  523. $sMysqlVer = "{$m[1]}.{$m[2]}.{$m[3]}";
  524. if (version_compare($sMysqlVer, $sMinMysqlVer, '<'))
  525. echo '<b class="fail">FAIL</b> (your version is incompatible with Dolphin, must be at least ' . $sMinMysqlVer . ')';
  526. else
  527. echo '<b class="ok">OK</b>';
  528. } else {
  529. echo '<b class="undef">UNDEFINED</b>';
  530. }
  531. ?>
  532. </li>
  533. <li><b>Web-server</b>:
  534. <?php
  535. echo $_SERVER['SERVER_SOFTWARE'];
  536. ?>
  537. <ul>
  538. <?php
  539. foreach ($aRequiredApacheModules as $sName => $sNameCompiledName)
  540. echo '<li>' . $sName . ' - ' . $this->checkApacheModule($sName, $sNameCompiledName) . '</li>';
  541. ?>
  542. </ul>
  543. </li>
  544. <li><b>OS</b>:
  545. <?php
  546. echo php_uname();
  547. ?>
  548. </li>
  549. </ul>
  550. <h2>Hardware requirements</h2>
  551. <p>
  552. Hardware requirements can not be determined automatically - <a href="#manual_audit">manual server audit</a> may be reqired.
  553. </p>
  554. <h2>Site setup</h2>
  555. <ul>
  556. <li>
  557. <b>Dolphin version</b> =
  558. <?php
  559. $sDolphinVer = BX_DOL_VERSION . '.' . BX_DOL_BUILD;
  560. echo $sDolphinVer . ' - ';
  561. if (!version_compare($sDolphinVer, $sLatestDolphinVer, '>='))
  562. echo '<b class="warn">WARNING</b> (your Dolphin version is outdated please upgrade to the latest ' . $sLatestDolphinVer . ' version)';
  563. else
  564. echo '<b class="ok">OK</b>';
  565. ?>
  566. </li>
  567. <li>
  568. <b>files and folders permissions</b>
  569. <br />
  570. Please <a href="javascript:void(0);" onclick="switchAdmPage(1);">click here</a> to find out if dolphin permissions are correct.
  571. </li>
  572. <li>
  573. <b>ffmpeg</b>
  574. <pre class="code"><?php echo `{$sDolphinPath}flash/modules/global/app/ffmpeg.exe 2>&1`;?></pre>
  575. if you don't know if output is correct then <a href="#manual_audit">manual server audit</a> may be reqired.
  576. </li>
  577. <li>
  578. <script language="javascript">
  579. function bx_sys_adm_audit_test_email() {
  580. $('#bx-sys-adm-audit-test-email').html('Sending...');
  581. $.post('<?php echo BX_DOL_URL_STUDIO; ?>host_tools.php?action=audit_send_test_email', function(data) {
  582. $('#bx-sys-adm-audit-test-email').html(data);
  583. });
  584. }
  585. </script>
  586. <b>mail sending - </b>
  587. <span id="bx-sys-adm-audit-test-email"><a href="javascript:void(0);" onclick="bx_sys_adm_audit_test_email()">click here</a> to send test email to <?php echo $sEmailToCkeckMailSending; ?></span>
  588. </li>
  589. <li>
  590. <b>cronjobs</b>
  591. <pre class="code"><?php echo `crontab -l 2>&1`;?></pre>
  592. if you are unsure if output is correct then <a href="#manual_audit">manual server audit</a> may be reqired.
  593. </li>
  594. <li>
  595. <b>media server</b>
  596. <br />
  597. Please follow <a href="<?php echo BX_DOL_URL_STUDIO; ?>flash.php">this link</a> to check media server settings. Also you can try video chat - if video chat is working then most probably that flash media server is working correctly, however it doesn't guarantee that all other flash media server application will work.
  598. </li>
  599. <li>
  600. <b>forums</b>
  601. <br />
  602. Please follow <a href="<?php echo BX_DOL_URL_ROOT; ?>forum/">this link</a> to check if forum is functioning properly. If it is working but '[L[' signs are displayed everywhere, then you need to <a href="<?php echo BX_DOL_URL_ROOT; ?>forum/?action=goto&manage_forum=1">compile language file</a> (you maybe be need to compile language file separately for every language and template you have).
  603. </li>
  604. </ul>
  605. <h2>Site optimization</h2>
  606. <ul>
  607. <li><b>PHP</b>:
  608. <ul>
  609. <li><b>php accelerator</b> =
  610. <?php
  611. $sAccel = $this->getPhpAccelerator();
  612. if (!$sAccel)
  613. echo 'NO - <b class="warn">WARNING</b> (Dolphin can be much faster if you install some php accelator))';
  614. else
  615. echo $sAccel . ' - <b class="ok">OK</b>';
  616. ?>
  617. </li>
  618. <li><b>php setup</b> =
  619. <?php
  620. $sSapi = php_sapi_name();
  621. echo $sSapi . ' - ';
  622. if (0 == strncasecmp('cgi', $sSapi, 3))
  623. echo '<b class="warn">WARNING</b> (your PHP setup maybe very inefficient, <a href="?action=phpinfo">please check it for sure</a> and try to switch to mod_php, apache dso module or FastCGI)';
  624. else
  625. echo '<b class="ok">OK</b>';
  626. ?>
  627. </li>
  628. </ul>
  629. </li>
  630. <li><b>MySQL</b>:
  631. <ul>
  632. <?php
  633. foreach ($aMysqlSettings as $sName => $r) {
  634. $a = $this->checkMysqlSetting($sName, $r, $l);
  635. echo "<li><b>$sName</b> = " . $this->format_output($a['real_val'], $r) ." - " . ($a['res'] ? '<b class="ok">OK</b>' : "<b class='fail'>FAIL</b> (must be {$r['op']} " . $this->format_output($r['val'], $r) . ")") . "</li>\n";
  636. }
  637. ?>
  638. </ul>
  639. </li>
  640. <li><b>Web-server</b>:
  641. <ul>
  642. <li>
  643. <b>User-side caching for static conten</b> =
  644. <a href="<?php echo $this->getUrlForGooglePageSpeed('LeverageBrowserCaching'); ?>">click here to check it in Google Page Speed</a>
  645. <br />
  646. If it is not enabled then please consider implement this optimization, since it improve perceived site speed and save the bandwidth, refer to <a target="_blank" href="http://www.boonex.com/trac/dolphin/wiki/HostingServerSetupRecommendations#Usersidecachingforstaticcontent">this tutorial</a> on how to do this.
  647. <br />
  648. <?php
  649. $sName = 'expires_module';
  650. echo 'To apply this optimization you need to have <b>' . $sName . '</b> Apache module - ' . $this->checkApacheModule($sName);
  651. ?>
  652. </li>
  653. <li>
  654. <b>Server-side content compression</b> = can be checked <a href="#manual_audit">manually</a> or in "Page Speed" tool build-in into browser.
  655. <br />
  656. If it is not enabled then please consider implement this optimization, since it improve perceived site speed and save the bandwidth, refer to <a href="http://www.boonex.com/trac/dolphin/wiki/HostingServerSetupRecommendations#Serversidecontentcompression">this tutorial</a> on how to do this.
  657. </textarea>
  658. <br />
  659. <?php
  660. $sName = 'deflate_module';
  661. echo 'To apply this optimization you need to have <b>' . $sName . '</b> Apache module - ' . $this->checkApacheModule($sName);
  662. ?>
  663. </li>
  664. </ul>
  665. </li>
  666. <li><b>Dolphin</b>:
  667. <ul>
  668. <?php
  669. foreach ($aDolphinOptimizationSettings as $sName => $a) {
  670. echo "<li><b>$sName</b> = ";
  671. echo ('always_on' == $a['enabled'] || getParam($a['enabled'])) ? 'On' : 'Off';
  672. if ($a['cache_engine'])
  673. echo " (" . getParam($a['cache_engine']) . ' based cache engine)';
  674. echo ' - ';
  675. if ('always_on' != $a['enabled'] && !getParam($a['enabled']))
  676. echo '<b class="fail">FAIL</b> (please enable this cache in Dolphin Admin Panel -> Settings -> Advanced Settings)';
  677. elseif ($a['check_accel'] && !$this->getPhpAccelerator() && 'File' == getParam($a['cache_engine']))
  678. echo '<b class="warn">WARNING</b> (installing php accelerator will speed-up file cache)';
  679. else
  680. echo '<b class="ok">OK</b>';
  681. echo "</li>\n";
  682. }
  683. ?>
  684. </ul>
  685. </li>
  686. </ul>
  687. <a name="manual_audit"></a>
  688. <h2>Manual Server Audit</h2>
  689. <p>
  690. Some things can not be determined automatically, manual server audit is required to check it. If you don't know how to do it by yourself you can submit <a target="_blank" href="http://www.boonex.com/help/tickets">BoonEx Server Audit Request</a>. Also if you are owner of <a target="_blank" href="http://www.boonex.com/enterprise">Enterprise package</a> - you have 1 free Server Audit Request.
  691. </p>
  692. <?php
  693. return ob_get_clean();
  694. }
  695. function checkPhpSetting($sName, $a) {
  696. $mixedVal = ini_get($sName);
  697. $mixedVal = $this->format_input ($mixedVal, $a);
  698. switch ($a['op']) {
  699. case 'module':
  700. $bResult = extension_loaded($a['val']);
  701. $mixedVal = $bResult ? $a['val'] : '';
  702. break;
  703. case '>':
  704. $bResult = (isset($a['unlimited']) && $mixedVal == $a['unlimited']) ? true : ($mixedVal > $a['val']);
  705. break;
  706. case '>=':
  707. $bResult = (isset($a['unlimited']) && $mixedVal == $a['unlimited']) ? true :($mixedVal >= $a['val']);
  708. break;
  709. case '=':
  710. default:
  711. $bResult = ($mixedVal == $a['val']);
  712. }
  713. return array ('res' => $bResult, 'real_val' => $mixedVal);
  714. }
  715. function checkMysqlSetting($sName, $a, $l) {
  716. $mixedVal = $this->mysqlGetOption($sName, $l);
  717. $mixedVal = $this->format_input ($mixedVal, $a);
  718. switch ($a['op']) {
  719. case '>':
  720. $bResult = ($mixedVal > $a['val']);
  721. break;
  722. case '>=':
  723. $bResult = ($mixedVal >= $a['val']);
  724. break;
  725. case 'strcasecmp':
  726. $bResult = 0 == strcasecmp($mixedVal, $a['val']);
  727. break;
  728. case '=':
  729. default:
  730. $bResult = ($mixedVal == $a['val']);
  731. }
  732. return array ('res' => $bResult, 'real_val' => $mixedVal);
  733. }
  734. function format_output ($mixedVal, $a) {
  735. switch ($a['type']) {
  736. case 'bool':
  737. return $mixedVal ? 'On' : 'Off';
  738. default:
  739. return $mixedVal;
  740. }
  741. }
  742. function format_input ($mixedVal, $a) {
  743. switch ($a['type']) {
  744. case 'bytes':
  745. return $this->format_bytes ($mixedVal);
  746. default:
  747. return $mixedVal;
  748. }
  749. }
  750. function format_bytes($val) {
  751. return return_bytes($val);
  752. }
  753. function checkApacheModule ($sModule, $sNameCompiledName = '') {
  754. $a = array (
  755. 'deflate_module' => 'mod_deflate',
  756. 'expires_module' => 'mod_expires',
  757. );
  758. if (!$sNameCompiledName && isset($a[$sModule]))
  759. $sNameCompiledName = $a[$sModule];
  760. if (function_exists('apache_get_modules')) {
  761. $aModules = apache_get_modules();
  762. $ret = in_array($sNameCompiledName, $aModules);
  763. } else {
  764. $sApachectlPath = trim(`which apachectl`);
  765. if (!$sApachectlPath)
  766. $sApachectlPath = trim(`which apache2ctl`);
  767. if (!$sApachectlPath)
  768. $sApachectlPath = trim(`which /usr/local/apache/bin/apachectl`);
  769. if (!$sApachectlPath)
  770. $sApachectlPath = trim(`which /usr/local/apache/bin/apache2ctl`);
  771. if (!$sApachectlPath)
  772. return '<b class="undef">UNDEFINED</b> (try to check manually: apachectl -M 2>&1 | grep ' . $sModule . ')';
  773. $ret = (boolean)`$sApachectlPath -M 2>&1 | grep $sModule`;
  774. if (!$ret)
  775. $ret = (boolean)`$sApachectlPath -l 2>&1 | grep $sNameCompiledName`;
  776. }
  777. return $ret ? '<b class="ok">OK</b>' : '<b class="fail">FAIL</b> (You will need to install ' . $sModule . ' for Apache)';
  778. }
  779. function getPhpAccelerator () {
  780. $aAccelerators = array (
  781. 'eAccelerator' => array('op' => 'module', 'val' => 'eaccelerator'),
  782. 'APC' => array('op' => 'module', 'val' => 'apc'),
  783. 'XCache' => array('op' => 'module', 'val' => 'xcache'),
  784. );
  785. foreach ($aAccelerators as $sName => $r) {
  786. $a = $this->checkPhpSetting($sName, $r);
  787. if ($a['res'])
  788. return $sName;
  789. }
  790. return false;
  791. }
  792. function mysqlGetOption ($s, $l) {
  793. return db_value("SELECT @@{$s}", $l);
  794. }
  795. function getUrlForGooglePageSpeed ($sRule) {
  796. $sUrl = urlencode(BX_DOL_URL_ROOT);
  797. return 'http://pagespeed.googlelabs.com/#url=' . $sUrl . '&mobile=false&rule=' . $sRule;
  798. }
  799. function sendTestEmail () {
  800. $sEmailToCkeckMailSending = getParam('site_email');
  801. $mixedRet = sendMail($sEmailToCkeckMailSending, 'Audit Test Email', 'Sample text for testing<br /><u><b>Sample text for testing</b></u>', '', array(), BX_EMAIL_SYSTEM);
  802. if (!$mixedRet)
  803. return '<b class="fail">FAIL</b> (mail send failed)';
  804. else
  805. return 'test mail was send, please check ' . $sEmailToCkeckMailSending . ' mailbox';
  806. }
  807. }
  808. /** @} */