Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require("guiconfig.inc");
- require("functions.inc");
- $cpp_dir = "/usr/local/www/packages/cpp";
- $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");
- $menu_link_before = '$services_menu[] = array(gettext("Captive Portal"), "/services_captiveportal.php");';
- $menu_link_cpp = '$services_menu[] = array(gettext("Captive Portal Plus"), "/packages/cpp/index_cpp.php");';
- if ($_POST['upload']) {
- conf_mount_rw();
- if (!file_exists($cpp_dir)) {
- if (@mkdir("/usr/local/www/packages", 0755) OR file_exists("/usr/local/www/packages")) {
- if (!@mkdir("/usr/local/www/packages/cpp", 0755))
- $input_errors[] = gettext("Cannot create folder ".$cpp_dir);
- }
- else
- $input_errors[] = gettext("Cannot create folder ".$cpp_dir);
- }
- for ($i = 0; $i < count($_FILES['files']['name']); $i++) {
- if ($_FILES['files']['tmp_name'][$i] != ""){
- if (in_array($_FILES['files']['name'][$i], $file_list)) {
- if ($_FILES['files']['name'][$i] == "cpp_priv.inc")
- $new = "/etc/inc/priv/".$_FILES['files']['name'][$i];
- else
- $new = $cpp_dir."/".$_FILES['files']['name'][$i];
- if(!@move_uploaded_file($_FILES['files']['tmp_name'][$i], $new))
- $input_errors[] = gettext("Cannot upload file to ".$new);
- }
- }
- else
- $input_errors[] = gettext("Please selecet a file on your computer.");
- }
- conf_mount_ro();
- }
- if ($_POST['menu_link']) {
- conf_mount_rw();
- if ($file_fbegin = @file("/usr/local/www/head.inc")) {
- foreach ($file_fbegin as $line) {
- if (strpos($line, $menu_link_cpp) !== false) {
- $menu_link_cpp_line = true;
- break;
- }
- }
- if (!isset($menu_link_cpp_line)) {
- $i = 0;
- foreach ($file_fbegin as $line) {
- if (strpos($line, $menu_link_before) !== false) {
- $menu_link_before_line = $i;
- break;
- }
- $i++;
- }
- if (isset($menu_link_before_line)) {
- array_splice($file_fbegin, $menu_link_before_line+1, 0, $menu_link_cpp."\n");
- $file_fbegin_string = implode("", $file_fbegin);
- if (@file_put_contents("/usr/local/www/head.inc", $file_fbegin_string))
- $menu_link_created = true;
- else
- $errormsg = gettext("Cannot write the menu code line. Please insert the menu link manually.");
- }
- else
- $errormsg = gettext("Cannot find the correct line in head.inc. Please insert the menu link manually.");
- }
- else
- $errormsg = gettext("Menu link already exists.");
- }
- else
- $errormsg = gettext("Cannot read the head.inc file.");
- conf_mount_ro();
- }
- $pgtitle = array(gettext("Captive Portal Plus Installation"));
- $g['help_base_url'] = "http://cpp-help.tassilo.net/#";
- include("head.inc");
- ?>
- <body link="#000000" vlink="#000000" alink="#000000" onload="show_fields(); <?= $jsevents["body"]["onload"] ?>">
- <?php include("fbegin.inc"); ?>
- <?php
- if ($input_errors)
- print_input_errors($input_errors);
- if ($savemsg OR $errormsg)
- print_info_box($savemsg.$errormsg);
- ?>
- <p>Required files: (<span style="color: red;">RED</span> = not found, <span style="color: green;">GREEN</span> = found)</p>
- <?php
- foreach ($file_list as $file) {
- if ($file == "cpp_priv.inc") $dir = "/etc/inc/priv";
- else $dir = $cpp_dir;
- if (file_exists($dir."/".$file)) $color = "green";
- else $color = "red";
- ?>
- <span style="color: <?=$color;?>;"><?=$dir."/".$file;?></span><br />
- <?
- }
- ?>
- <h3>1. Upload all files from the downloaded .zip file.</h3>
- <p>(You can upload multiple files.)</p>
- <form action="" method="post" enctype="multipart/form-data">
- <input type="file" name="files[]" multiple="multiple">
- <input type="submit" name="upload" value="Upload">
- </form>
- <h3>2. Generate the menu link.</h3>
- <form action="" method="post" enctype="multipart/form-data">
- <input type="submit" name="menu_link" value="Generate">
- <?php if ($menu_link_created): ?>
- <span style="color: green;">Generated!</span>
- <? endif; ?>
- </form>
- <h3>3. Install done. :-)</h3>
- <p>Klick on the CP+ menu link to delete the installation file.</p>
- <?php include("fend.inc");?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment