Guest User

CPP Installation 2.3.2-RELEASE-p1

a guest
Feb 9th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.17 KB | None | 0 0
  1. <?php
  2.  
  3. require("guiconfig.inc");
  4. require("functions.inc");
  5.  
  6. $cpp_dir = "/usr/local/www/packages/cpp";
  7.  
  8. $file_list = array("vouchers_cpp.php","users_cpp.php","settings_cpp.php","index_cpp.php","include_cpp.inc","fpdf.php","escpos.php","helvetica.php","helveticab.php","helveticabi.php","helveticai.php","pdf.png","escpos.png","config.xml","cpp_priv.inc");
  9.  
  10. $menu_link_before = '$services_menu[] = array(gettext("Captive Portal"), "/services_captiveportal.php");';
  11. $menu_link_cpp = '$services_menu[] = array(gettext("Captive Portal Plus"), "/packages/cpp/index_cpp.php");';
  12.  
  13.  
  14.  
  15. if ($_POST['upload']) {
  16.     conf_mount_rw();
  17.     if (!file_exists($cpp_dir)) {
  18.         if (@mkdir("/usr/local/www/packages", 0755) OR file_exists("/usr/local/www/packages")) {
  19.             if (!@mkdir("/usr/local/www/packages/cpp", 0755))
  20.                 $input_errors[] = gettext("Cannot create folder ".$cpp_dir);
  21.         }
  22.         else
  23.             $input_errors[] = gettext("Cannot create folder ".$cpp_dir);
  24.     }
  25.     for ($i = 0; $i < count($_FILES['files']['name']); $i++) {
  26.    
  27.         if ($_FILES['files']['tmp_name'][$i] != ""){
  28.             if (in_array($_FILES['files']['name'][$i], $file_list)) {
  29.                 if ($_FILES['files']['name'][$i] == "cpp_priv.inc")
  30.                     $new = "/etc/inc/priv/".$_FILES['files']['name'][$i];
  31.                 else
  32.                     $new = $cpp_dir."/".$_FILES['files']['name'][$i];
  33.                
  34.                 if(!@move_uploaded_file($_FILES['files']['tmp_name'][$i], $new))
  35.                     $input_errors[] = gettext("Cannot upload file to ".$new);
  36.             }
  37.         }
  38.         else
  39.             $input_errors[] = gettext("Please selecet a file on your computer.");
  40.     }
  41.     conf_mount_ro();
  42. }
  43.  
  44. if ($_POST['menu_link']) {
  45.     conf_mount_rw();
  46.     if ($file_fbegin = @file("/usr/local/www/head.inc")) {
  47.         foreach ($file_fbegin as $line) {
  48.             if (strpos($line, $menu_link_cpp) !== false) {
  49.                 $menu_link_cpp_line = true;
  50.                 break;
  51.             }
  52.         }
  53.         if (!isset($menu_link_cpp_line)) {
  54.             $i = 0;
  55.             foreach ($file_fbegin as $line) {
  56.                 if (strpos($line, $menu_link_before) !== false) {
  57.                     $menu_link_before_line = $i;
  58.                     break;
  59.                 }
  60.                 $i++;
  61.             }
  62.             if (isset($menu_link_before_line)) {
  63.                 array_splice($file_fbegin, $menu_link_before_line+1, 0, $menu_link_cpp."\n");
  64.                 $file_fbegin_string = implode("", $file_fbegin);
  65.                 if (@file_put_contents("/usr/local/www/head.inc", $file_fbegin_string))
  66.                     $menu_link_created = true;
  67.                 else
  68.                     $errormsg = gettext("Cannot write the menu code line. Please insert the menu link manually.");
  69.             }
  70.             else
  71.                 $errormsg = gettext("Cannot find the correct line in head.inc. Please insert the menu link manually.");
  72.         }
  73.         else
  74.             $errormsg = gettext("Menu link already exists.");
  75.     }
  76.     else
  77.         $errormsg = gettext("Cannot read the head.inc file.");
  78.  
  79.     conf_mount_ro();
  80. }
  81.  
  82.  
  83. $pgtitle = array(gettext("Captive Portal Plus Installation"));
  84. $g['help_base_url'] = "http://cpp-help.tassilo.net/#";
  85.  
  86. include("head.inc");
  87. ?>
  88.  
  89. <body link="#000000" vlink="#000000" alink="#000000" onload="show_fields(); <?= $jsevents["body"]["onload"] ?>">
  90. <?php include("fbegin.inc"); ?>
  91. <?php
  92.     if ($input_errors)
  93.         print_input_errors($input_errors);
  94.     if ($savemsg OR $errormsg)
  95.         print_info_box($savemsg.$errormsg);
  96. ?>
  97.  
  98. <p>Required files: (<span style="color: red;">RED</span> = not found, <span style="color: green;">GREEN</span> = found)</p>
  99. <?php
  100. foreach ($file_list as $file) {
  101.     if ($file == "cpp_priv.inc") $dir = "/etc/inc/priv";
  102.     else $dir = $cpp_dir;
  103.     if (file_exists($dir."/".$file)) $color = "green";
  104.     else $color = "red";
  105. ?>
  106. <span style="color: <?=$color;?>;"><?=$dir."/".$file;?></span><br />
  107. <?
  108. }
  109. ?>
  110.  
  111. <h3>1. Upload all files from the downloaded .zip file.</h3>
  112. <p>(You can upload multiple files.)</p>
  113. <form action="" method="post" enctype="multipart/form-data">
  114.     <input type="file" name="files[]" multiple="multiple">
  115.     <input type="submit" name="upload" value="Upload">
  116. </form>
  117. <h3>2. Generate the menu link.</h3>
  118. <form action="" method="post" enctype="multipart/form-data">
  119.     <input type="submit" name="menu_link" value="Generate">
  120.     <?php if ($menu_link_created): ?>
  121.     &nbsp;<span style="color: green;">Generated!</span>
  122.     <? endif; ?>
  123. </form>
  124. <h3>3. Install done. :-)</h3>
  125. <p>Klick on the CP+ menu link to delete the installation file.</p>
  126.  
  127. <?php include("fend.inc");?>
  128. </body>
  129. </html>
Advertisement
Add Comment
Please, Sign In to add comment