PageRenderTime 30ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/4.6/installation/common.php

http://miacms.googlecode.com/
PHP | 93 lines | 64 code | 8 blank | 21 comment | 22 complexity | ab639f35e10f0c9fc864c295c014cb07 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, LGPL-2.0
  1. <?php
  2. /**
  3. * Install instructions
  4. * @package MiaCMS
  5. * @author MiaCMS see README.php
  6. * @copyright see README.php
  7. * See COPYRIGHT.php for copyright notices and details.
  8. * @license GNU/GPL Version 2, see LICENSE.php
  9. * MiaCMS is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; version 2 of the License.
  12. */
  13. error_reporting( E_ALL );
  14. header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  15. header ("Pragma: no-cache"); // HTTP/1.0
  16. require_once('../includes/phpgettext/phpgettext.class.php');
  17. /**
  18. * Utility function to return a value from a named array or a specified default
  19. */
  20. define( "_MOS_NOTRIM", 0x0001 );
  21. define( "_MOS_ALLOWHTML", 0x0002 );
  22. function mosGetParam( &$arr, $name, $def=null, $mask=0 ) {
  23. $return = null;
  24. if (isset( $arr[$name] )) {
  25. if (is_string( $arr[$name] )) {
  26. if (!($mask&_MOS_NOTRIM)) {
  27. $arr[$name] = trim( $arr[$name] );
  28. }
  29. if (!($mask&_MOS_ALLOWHTML)) {
  30. $arr[$name] = strip_tags( $arr[$name] );
  31. }
  32. if (!get_magic_quotes_gpc()) {
  33. $arr[$name] = addslashes( $arr[$name] );
  34. }
  35. }
  36. return $arr[$name];
  37. } else {
  38. return $def;
  39. }
  40. }
  41. function mosMakePassword($length) {
  42. $salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  43. $len = strlen($salt);
  44. $makepass="";
  45. mt_srand(10000000*(double)microtime());
  46. for ($i = 0; $i < $length; $i++)
  47. $makepass .= $salt[mt_rand(0,$len - 1)];
  48. return $makepass;
  49. }
  50. /**
  51. * Chmods files and directories recursivel to given permissions
  52. * @param path The starting file or directory (no trailing slash)
  53. * @param filemode Integer value to chmod files. NULL = dont chmod files.
  54. * @param dirmode Integer value to chmod directories. NULL = dont chmod directories.
  55. * @return TRUE=all succeeded FALSE=one or more chmods failed
  56. */
  57. function mosChmodRecursive($path, $filemode=NULL, $dirmode=NULL)
  58. {
  59. $ret = TRUE;
  60. if (is_dir($path)) {
  61. $dh = opendir($path);
  62. while ($file = readdir($dh)) {
  63. if ($file != '.' && $file != '..') {
  64. $fullpath = $path.'/'.$file;
  65. if (is_dir($fullpath)) {
  66. if (!mosChmodRecursive($fullpath, $filemode, $dirmode))
  67. $ret = FALSE;
  68. } else {
  69. if (isset($filemode))
  70. if (!@chmod($fullpath, $filemode))
  71. $ret = FALSE;
  72. } // if
  73. } // if
  74. } // while
  75. closedir($dh);
  76. if (isset($dirmode))
  77. if (!@chmod($path, $dirmode))
  78. $ret = FALSE;
  79. } else {
  80. if (isset($filemode))
  81. $ret = @chmod($path, $filemode);
  82. } // if
  83. return $ret;
  84. } // mosChmodRecursive
  85. ?>