示例#1
0
文件: common.php 项目: ezeql/fups
function output_update_html($token, $status, $done, $cancelled, $failed, $err, $errs, $errs_admin = false, $ajax = false)
{
    global $fups_url_cancel, $fups_url_notify_email_address, $fups_url_run;
    if ($err) {
        ?>
			<div class="fups_error"><?php 
        echo format_html($err);
        ?>
</div>
<?php 
        return;
    }
    ?>
			<h3>Status</h3>

			<div id="fups_div_status">
<?php 
    echo htmlspecialchars($status);
    ?>
			</div>

<?php 
    if ($done) {
        $output_info = json_decode(file_get_contents(make_output_info_filename($token)), true);
        if ($output_info == null) {
            ?>
			<p>We are sorry, but an unexpected error occurred. The scraping process completed, and the output was created, however we were unable to decode the list of output files. Please feel free to <a href="<?php 
            echo FUPS_CONTACT_URL;
            ?>
">contact me</a> for help with accessing your output files, quoting token "<?php 
            echo $token;
            ?>
".</p>
<?php 
        } else {
            ?>
			<p>Success! Your posts were retrieved and the output is ready. The following output files are available:</p>

			<table style="border-collapse: collapse;">
				<tr><th style="border: 1px solid black;">Description</th><th style="border: 1px solid black;">View/download file (opens in a new window)</th><th style="border: 1px solid black;">File size</th></tr>
<?php 
            foreach ($output_info as $opv) {
                ?>
				<tr><td style="border: 1px solid black;"><?php 
                echo $opv['description'];
                ?>
</td><td style="border: 1px solid black;"><a target="_blank" href="<?php 
                echo $opv['url'];
                ?>
">View/download file</a></td><td style="border: 1px solid black;"><?php 
                echo number_format($opv['size']) . ' bytes';
                ?>
</td></tr>
<?php 
            }
            ?>
			</table>

			<p>If you're wondering what to do next, here are some possible steps:</p>
			<ol>
				<li>Click on the "View/download file" link beside the HTML file which is sorted according to your preference. This will open up a new window/tab for that file. Switch to this window/tab if necessary, and then save the page, e.g. in Firefox click the "File" menu option and under that click "Save Page As". Select the directory/folder and filename you wish to save this output as (remember this location for the next step).</li>
				<li>Start up a word processor such as LibreOffice/OpenOffice or Microsoft Word. Open up in that word processor the HTML file that you saved in the previous step, e.g. click the "File" menu option and under that click "Open", then select the file you saved in the previous step. You are now free to edit the file as you like. You can now (if you so desire) save the file in a friendlier format than HTML, a format such as your editor's default format, e.g. in LibreOffice, click the "File" menu option and then click "Save As" or "Export", and choose the format you desire.</li>
			</ol>
<?php 
            show_delete($token, true);
        }
    } else {
        if ($cancelled) {
            ?>
			<p>Cancelled by your request.</p>
<?php 
            show_delete($token, false);
        } else {
            if ($failed) {
                ?>
			<p>The script appears to have exited due to an error; the error message is shown below. I have been notified of this error by email; if you would like me to get back to you if/when I have fixed the error, then please enter your email address into the following box and press the button to notify me of it.</p>

			<div>
				<form method="post" action="<?php 
                echo $fups_url_notify_email_address;
                ?>
">
					<input type="hidden" name="token" value="<?php 
                echo $token;
                ?>
" />
					<label for="email_address.id">Your contact email address:</label><br />
					<input type="text" name="email_address" id="email_address.id" /><br />
					<label for="message.id">Any message you'd like to include (leaving this blank is fine):</label><br />
					<textarea rows="5" cols="80" name="message" id="message.id"></textarea><br />
					<input type="submit" value="Notify the FUPS maintainer" />
				</form>
			</div>

			<p>Alternatively, feel free to retry or to <a href="<?php 
                echo FUPS_CONTACT_URL;
                ?>
">contact me</a> manually about this error, quoting your run token of "<?php 
                echo $token;
                ?>
".</p>

<?php 
                show_delete($token, false);
            } else {
                $same_status = isset($_GET['last_status']) && $status == $_GET['last_status'];
                ?>
			<p>
				<a href="<?php 
                echo $fups_url_run . '?token=' . $token . ($same_status ? '&amp;last_status=' . htmlspecialchars(urlencode($status)) : '') . ($ajax ? '&amp;ajax=yes' : '');
                ?>
"><?php 
                echo $ajax ? 'Refresh page' : 'Check progress';
                ?>
</a><?php 
                if ($ajax) {
                    echo ' (it should not be necessary to click this link unless something goes wrong)';
                }
                ?>
.
<?php 
                if ($same_status) {
                    ?>
				(It appears that progress has halted unexpectedly - the current status is the same as the previous status. It is likely that an error has caused the process to exit before finishing. We are sorry about this failure. In case you want to be sure that progress has indeed halted, you are welcome to click the preceding link, but otherwise, this page will no longer automatically refresh.)

<?php 
                    show_delete($token, false);
                } else {
                    ?>
				<?php 
                    echo !$ajax ? 'Your browser should automatically refresh this page every ' . FUPS_META_REDIRECT_DELAY . ' seconds or so to update progress, but if you don\'t want to wait, you\'re welcome to click the link. ' : '';
                    ?>
If you have changed your mind about wanting to run this script through to the end, <strong>please</strong> click this <a href="<?php 
                    echo $fups_url_cancel;
                    ?>
?token=<?php 
                    echo $token . ($ajax ? '&amp;ajax=yes' : '');
                    ?>
">cancel</a> link rather than just closing this page - clicking the cancel link will free up the resources (in particular a background process) associated with your task.
<?php 
                }
                ?>
			</p>
<?php 
            }
        }
    }
    $paren_msg_will_be_emailed = '(Unless a mailing error occurs, these will be emailed to me as-is if/when FUPS finishes running, with your token, "' . htmlspecialchars($token) . '", included in the email\'s subject)';
    $paren_msg_emailed = '(Unless a mailing error occurred, these have been emailed to me as-is, with your token, "' . htmlspecialchars($token) . '", included in the email\'s subject)';
    if ($errs) {
        ?>

			<h3>Errors</h3>

			<p><?php 
        echo $done || $failed ? $paren_msg_emailed : $paren_msg_will_be_emailed;
        ?>
</p>

<?php 
        $len = strlen($errs);
        if ($len > FUPS_MAX_ERROR_FILE_EMAIL_LENGTH) {
            $errs = substr($errs, 0, FUPS_MAX_ERROR_FILE_EMAIL_LENGTH);
            $trunc_msg = '[Truncated from ' . number_format($len) . ' bytes to ' . number_format(FUPS_MAX_ERROR_FILE_EMAIL_LENGTH) . ' bytes]';
            ?>
				<p><?php 
            echo $trunc_msg;
            ?>
</p>
<?php 
        }
        ?>

			<div class="fups_error">
<?php 
        echo format_html($errs);
        ?>
			</div>
<?php 
        if ($errs_admin && ($done || $failed)) {
            // The toggle_ext_errs() Javascript function below is defined in run.php
            ?>

			<p><a href="javascript:toggle_ext_errs();">Show/hide extended error messages</a> <?php 
            echo $paren_msg_emailed;
            ?>
</p>

			<div id="id_ext_err" style="display: none;">

				<h3>Extended error messages</h3>
<?php 
            $len = strlen($errs_admin);
            if ($len > FUPS_MAX_ADMIN_FILE_EMAIL_LENGTH) {
                $errs_admin = substr($errs_admin, 0, FUPS_MAX_ADMIN_FILE_EMAIL_LENGTH);
                $trunc_msg = '[Truncated from ' . number_format($len) . ' bytes to ' . number_format(FUPS_MAX_ADMIN_FILE_EMAIL_LENGTH) . ' bytes]';
                ?>
				<p><?php 
                echo $trunc_msg;
                ?>
</p>
<?php 
            }
            ?>
				<div class="fups_error"><?php 
            echo format_html($errs_admin);
            ?>
</div>
			</div>
<?php 
        }
    }
    // Early return possible
}
示例#2
0
						<?php 
    if (isset($_GET['form'])) {
        if ($_GET['form'] == "home" || $_GET['form'] == "") {
            show_home();
        } else {
            if ($_GET['form'] == "show_passcode") {
                show_passcode();
            } else {
                if ($_GET['form'] == "show_passw") {
                    show_passw();
                } else {
                    if ($_GET['form'] == "show_username") {
                        show_username();
                    } else {
                        if ($_GET['form'] == "show_delete") {
                            show_delete();
                        }
                    }
                }
            }
        }
    } else {
        show_home();
    }
    if (isset($_POST['deletepassword'])) {
        //Delete the account and all its data
        $con = mysqli_connect("localhost", "root", "PASS", "secure_login");
        if (mysqli_connect_errno()) {
            die('Could not connect: ' . mysqli_connect_error());
        }
        $result = mysqli_query($con, "SELECT * FROM members WHERE email='" . strtolower($_SESSION['email']) . "'");