PageRenderTime 28ms CodeModel.GetById 5ms RepoModel.GetById 0ms app.codeStats 1ms

/freichat/installation/info.php

https://bitbucket.org/itoxable/chiron-gaming
PHP | 224 lines | 151 code | 66 blank | 7 comment | 33 complexity | aec72c2682b830d72e7cccfb6947299d MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
  1. <?php
  2. session_start();
  3. /* Make me secure */
  4. if (!isset($_SESSION['FREIX']) || $_SESSION['FREIX'] != 'authenticated') {
  5. header("Location:index.php");
  6. exit;
  7. }
  8. /* Now i am secure */
  9. function is__writable($path) {
  10. //will work in despite of Windows ACLs bug
  11. //NOTE: use a trailing slash for folders!!!
  12. //see http://bugs.php.net/bug.php?id=27609
  13. //see http://bugs.php.net/bug.php?id=30931
  14. if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
  15. return is__writable($path.uniqid(mt_rand()).'.tmp');
  16. else if (is_dir($path))
  17. return is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
  18. // check tmp file for read/write capabilities
  19. $rm = file_exists($path);
  20. $f = @fopen($path, 'a');
  21. if ($f===false)
  22. return false;
  23. fclose($f);
  24. if (!$rm)
  25. unlink($path);
  26. return true;
  27. }
  28. class Info {
  29. public function __construct() {
  30. if (isset($_POST['cms']) == true) {
  31. if($_POST['cms'] == "CBE" && $_POST['CBE_ver'] == '2') {
  32. $_SESSION['cms'] = 'CBE_2';
  33. }else{
  34. $_SESSION['cms'] = $_POST['cms'];
  35. }
  36. }
  37. }
  38. public function set_file() {
  39. $redir = false;
  40. if(is_file('integ/'.$_SESSION['cms'].'.php')){
  41. $cname=$_SESSION['cms'];
  42. require 'integ/'.$_SESSION['cms'].'.php';
  43. $cls=new $cname();
  44. $redir=$cls->redir;
  45. $set_file=$cls->set_file;
  46. }
  47. else{
  48. $_SESSION['error']='Invalid Integration Driver Selected';
  49. header("Location: error.php");
  50. exit(0);
  51. }
  52. $this->set_path($set_file);
  53. if ($redir == true) {
  54. header('Location: params.php');
  55. exit(0);
  56. }
  57. return $set_file;
  58. }
  59. public function set_path($set_file) {
  60. if (isset($_POST['paths']) == true) {
  61. $_SESSION['config_path'] = $_POST['paths'];
  62. $_SESSION['config_path'] = str_replace('\\', '/', $_SESSION['config_path']);
  63. $_SESSION['cms_path'] = str_replace($set_file, "", $_SESSION['config_path']);
  64. } else {
  65. $ROOT_path = str_replace('\\', '/', dirname(__FILE__));
  66. $_SESSION['cms_path'] = str_replace("freichat/installation", "", $ROOT_path);
  67. $_SESSION['config_path'] = str_replace("freichat/installation", "", $ROOT_path) . $set_file;
  68. }
  69. }
  70. public function get_flags() {
  71. $flags = Array();
  72. $flags['flag'] = true;
  73. $flags['color1'] = $flags['color0']=$flags['color3']=$flags['color4'] = $flags['color5'] = "green";
  74. $flags['text1'] = $flags["text0"] = $flags["text3"]= $flags["text4"]= $flags['text5'] = "is writable";
  75. if (!is_writable("../hardcode.php")) {
  76. $flags['flag'] = false;
  77. $flags['color1'] = "red";
  78. $flags['text1'] = "is not writable(Please change file permissions to 0777)";
  79. }
  80. if (!is_writable("../cache/perm/request.001")) {
  81. $flags['flag'] = false;
  82. $flags['color3'] = "red";
  83. $flags['text3'] = "is not writable(Please change file permissions to 0777)";
  84. }
  85. if(!is__writable('../client/plugins/upload/upload')){
  86. $flags['flag'] = false;
  87. $flags['color5'] = "red";
  88. $flags['text5'] = "is not writable(Please change file permissions to 0777)";
  89. }
  90. if (!is__writable("../cache/temp/")) {
  91. $flags['flag'] = false;
  92. $flags['color4'] = "red";
  93. $flags['text4'] = "is not writable(change folder permissions to 0777)";
  94. }
  95. if (isset($_SESSION['config_path']) == true) {
  96. if (is_readable($_SESSION['config_path'])) {
  97. $flags['color2'] = "green";
  98. $flags['text2'] = "is readable";
  99. } else {
  100. $flags['flag'] = false;
  101. $flags['color2'] = "red";
  102. $flags['text2'] = "is not readable";
  103. }
  104. }
  105. return $flags;
  106. }
  107. }
  108. $info = new Info();
  109. $set_file = $info->set_file();
  110. $flags=$info->get_flags();
  111. require 'header.php';
  112. ?>
  113. <div style="text-align: center">
  114. <br/> <span style="font-family: 'Sonsie One', cursive;font-size: 18pt;text-align: center"><b>
  115. <?php
  116. if ($flags['flag'] == false) {
  117. echo "Please Correct the following";
  118. }
  119. else{
  120. echo "Everything Seems Alright!";
  121. }
  122. ?>
  123. </b></span><br/><br/><br/>
  124. freichat/hardcode.php <font color='<?php echo $flags['color1']; ?>'><?php echo $flags['text1']; ?> </font><br/>
  125. freichat/cache/perm/request.001 <font color='<?php echo $flags['color3']; ?>'><?php echo $flags['text3']; ?> </font><br/>
  126. freichat/cache/temp <font color='<?php echo $flags['color4']; ?>'><?php echo $flags['text4']; ?> </font><br/>
  127. <p><?php echo $set_file; ?> <font color=<?php echo $flags['color2']; ?>><?php echo $flags['text2']; ?></font><br/>
  128. freichat/client/plugins/upload/upload <font color='<?php echo $flags['color5']; ?>'><?php echo $flags['text5']; ?> </font><br/>
  129. <?php
  130. if ($flags['flag'] == false) {
  131. echo " <br/>
  132. <br/>
  133. <br/><form name='path' action='info.php' id='sameform' method='POST'>
  134. <span style=\"font-family: 'Sonsie One', cursive;font-size: 18pt;text-align: center\">is the path to your <font color=green>$set_file</font> file correct?</span><br/>
  135. <br/><input style=\"font-family: 'Exo', sans-serif;font-weight:600 ;font-style:italic;font-size:16px;width:500px;\" name='paths' type='text' value= ".$_SESSION['config_path']." /><br/><br/>";
  136. echo '<br/><a href="JavaScript:void(0)" class="refreshbutton" onclick="modify()">Refresh</a>';
  137. }
  138. echo "</form>
  139. <form name='cms' id='nextform' action='params.php' method='POST'>
  140. <br/>
  141. ";
  142. if ($flags['flag'] == true) {
  143. echo '<br/><br/><a href="JavaScript:void(0)" class="nextbutton" onclick="proceed()">Proceed</a>';
  144. }
  145. echo " </form>";
  146. ?>
  147. </div>
  148. <script type="text/javascript">
  149. function proceed(){
  150. $('#nextform').submit();
  151. }
  152. function modify(){
  153. $('#sameform').submit();
  154. }
  155. </script>
  156. <?php
  157. require 'footer.php';
  158. ?>