/** Luo HTML kysymykselle
 * @param $title string
 * @param $tags array
 * @param $question_id integer
 * @param $user_id integer
 * @param $username string
 * @param $was_sent_at_time string
 * @param $describtion string
 */
function create_question($title, $tags, $question_id, $user_id, $username, $was_sent_at_time, $describtion)
{
    // TODO include("validate_url_parameters.php");
    create_question_count_box($question_id);
    create_title($title, $question_id);
    create_tags($tags);
    create_user_info_box_question($user_id, $username, $was_sent_at_time, $describtion);
    echo "</div>";
}
Ejemplo n.º 2
0
global $LSP_URL;
function apply_settings($password, $password2, $realname)
{
    global $LSP_URL;
    if ($password != $password2) {
        display_error('Password mismatch');
        return false;
    } else {
        change_user(SESSION(), $realname, $password);
        display_success('Account settings have been updated', array('<a href="">User Settings</a>', 'Success'), $LSP_URL . "?account=settings");
        return true;
    }
}
if (POST('settings') != "apply" || !apply_settings(POST('password'), POST('password2'), POST('realname'))) {
    echo '<div class="col-md-9">';
    create_title('<a href="">User Settings</a>');
    $form = new form("{$LSP_URL}?account=settings", 'User Settings', 'fa-gear');
    ?>
	<div class="form-group">
	<label for="username" class="text-muted">User Name:</label>
	<input type="text" name="username" class="form-control" value="<?php 
    echo SESSION();
    ?>
" disabled="disabled" />
	<p class="help-block">User name cannot be changed</p>
	</div>
	<div class="form-group">
	<label for="realname">Full Name:</label>
	<input type="text" name="realname" class="form-control" value="<?php 
    echo get_user_realname(SESSION());
    ?>
Ejemplo n.º 3
0
$request_uri = substr($request_uri, 1, -1);
$request_file = determine_request_file($request_uri);
if (!file_exists($request_file)) {
    header('HTTP/1.1 404 Not Found');
    include '404.php';
    die;
}
$fcontents = file($request_file);
$page_header = trim(@$fcontents[0]);
$fcontents = join('', $fcontents);
if (@$_GET['view'] == 'text') {
    header('Content-type: text/plain');
    echo $fcontents;
} else {
    $breadcrumbs = create_breadcrumbs($request_uri, $page_header);
    $title = create_title($breadcrumbs, $page_header);
    render(array('title' => $title, 'content' => Markdown($fcontents), 'breadcrumbs' => $breadcrumbs, 'links' => array('view_source' => "{$_SERVER['REQUEST_URI']}?view=text")));
}
######################################################
function determine_request_file($uri)
{
    return "doc/{$uri}.text";
}
function render($__vars)
{
    extract($__vars);
    require 'inc/template.php';
}
function create_breadcrumbs($request_uri, $title)
{
    $breadcrumbs = array();
Ejemplo n.º 4
0
                $file_size = $_FILES["filename"]["size"];
            } else {
                $file_size = POST('fsize');
            }
            $no_copyright = POST('nocopyright');
            if (POST('ok') == 'OK') {
                if (POST_EMPTY('nocopyright')) {
                    display_error("Copyrighted content is forbidden", array('<a href="">Add File</a>', 'Error'), $LSP_URL . '?content=add');
                    return;
                }
                $file_extension = parse_extension($file_path);
                $categories = get_categories_for_ext($file_extension);
                if ($categories != false) {
                    if (isset($_FILES["filename"]["tmp_name"])) {
                        echo '<div class="col-md-9">';
                        create_title(array('<a href="">Add File</a>', $file_path));
                        $tmp_path = $_FILES["filename"]["tmp_name"];
                        $tmp_ext = trim(pathinfo($tmp_path, PATHINFO_EXTENSION));
                        $tmp_name_only = pathinfo($tmp_path, PATHINFO_FILENAME) . ($tmp_ext == "" ? '' : '.' . $tmp_ext);
                        move_uploaded_file($tmp_path, $TMP_DIR . $tmp_name_only);
                        //echo "<code>moving $tmp_path to $TMP_DIR$tmp_name_only</code>";
                        ?>
					<?php 
                        $form = new form($LSP_URL . '?content=add', 'File Details', 'fa-upload');
                        ?>
					<div class="form-group">
					<label for="category">Category</label>
					<select name="category" class="form-control"><?php 
                        echo $categories;
                        ?>
</select>
Ejemplo n.º 5
0
function display_message($message, $severity = 'danger', $title = 'Error', $title_array = null, $redirect = null, $counter = 5)
{
    switch ($severity) {
        case 'info':
            $icon = 'fa-info-circle';
            break;
        case 'success':
            $icon = 'fa-check-circle';
            break;
        case 'warning':
            // move down
        // move down
        default:
            $icon = 'fa-exclamation-circle';
    }
    $icon = '<span class="fa ' . $icon . '"></span>&nbsp;';
    echo '<div class="col-md-9">';
    create_title(isset($title_array) ? $title_array : $title);
    echo '<div data-redirect="' . (isset($redirect) ? htmlentities($redirect) : '') . '" ' . 'class="alert alert-' . $severity . ' text-center"><strong>' . $icon . ($title == '' ? '' : "{$title}:") . '</strong> ' . $message . '</div>';
    if (isset($redirect)) {
        echo '<p class="text-center">You will automatically be redirected in <strong>' . '<span class="redirect-counter">' . $counter . '</span> seconds</strong></p>';
    }
    echo '</div>';
}
Ejemplo n.º 6
0
function show_file($file_id, $user, $success = null)
{
    global $LSP_URL, $DATA_DIR;
    $dbh =& get_db();
    $stmt = $dbh->prepare('SELECT licenses.name AS license, size, realname, filename, users.login, ' . 'categories.name AS category, subcategories.name AS subcategory,' . 'insert_date, update_date, description, downloads, files.id FROM files ' . 'INNER JOIN categories ON categories.id=files.category ' . 'INNER JOIN subcategories ON subcategories.id=files.subcategory ' . 'INNER JOIN users ON users.id=files.user_id ' . 'INNER JOIN licenses ON licenses.id=files.license_id ' . 'WHERE files.id=:file_id');
    $stmt->bindParam(':file_id', $file_id);
    $found = false;
    if ($stmt->execute()) {
        while ($object = $stmt->fetch(PDO::FETCH_ASSOC)) {
            $title = array($object['category'], $object['subcategory'], get_file_url($file_id));
            if ($success == null) {
                echo '<div class="col-md-9">';
                create_title($title);
            } else {
                if ($success === true) {
                    display_success("Updated successfully", $title);
                    echo '<div class="col-md-9">';
                } else {
                    if ($success === false) {
                        display_error("Update failed.", $title);
                        echo '<div class="col-md-9">';
                    } else {
                        display_success("{$success}", $title);
                    }
                }
            }
            echo '<table class="table table-striped">';
            show_basic_file_info($object, false);
            // Bump the download button under details block
            $url = htmlentities('download_file.php?file=' . $object['id'] . '&name=' . $object['filename']);
            echo '<tr><td><strong>Name:</strong>&nbsp;' . $object['filename'];
            if (is_image($url)) {
                echo '<br><br><a href="' . $url . '"><img class="thumbnail" src="' . scale_image($DATA_DIR . $file_id, 300, parse_extension($url)) . '" alt=""></a>';
            }
            echo '</td><td class="lsp-file-info">';
            echo '<a href="' . $url . '" id="downloadbtn" class="lsp-dl-btn btn btn-primary">';
            echo '<span class="fa fa-download lsp-download"></span>&nbsp;Download</a>';
            echo '</td></tr>';
            echo '<tr><td colspan="2"><div class="well"><strong>Description:</strong><p>';
            echo $object['description'] != '' ? parse_links(newline_to_br($object['description'], true)) : 'No description available.';
            echo '</p></div></td></tr>';
            echo '<tr><td colspan="2">';
            echo '<nav id="lspnav" class="navbar navbar-default"><ul class="nav navbar-nav">';
            $can_edit = $object['login'] == $user || is_admin(get_user_id($user));
            $can_rate = !SESSION_EMPTY();
            $rate_self = $object['login'] == $user;
            global $LSP_URL;
            create_toolbar_item('Comment', "{$LSP_URL}?comment=add&file={$file_id}", 'fa-comment', $can_rate);
            create_toolbar_item('Edit', "{$LSP_URL}?content=update&file={$file_id}", 'fa-pencil', $can_edit);
            create_toolbar_item('Delete', "{$LSP_URL}?content=delete&file={$file_id}", 'fa-trash', $can_edit);
            $star_url = $LSP_URL . '?' . file_show_query_string() . '&rate=';
            create_toolbar_item(get_stars($file_id, $star_url, $rate_self ? false : $can_rate), '', null, $can_rate, $rate_self);
            echo '</ul></nav>';
            echo '<strong>Comments:</strong>';
            echo '</td></tr>';
            get_comments($file_id);
            echo '</table></div>';
            $found = true;
            break;
        }
    }
    if (!$found) {
        display_error('Invalid file: "' . sanitize($file_id) . '"');
    }
    $stmt = null;
    $dbh = null;
}
Ejemplo n.º 7
0
<?php

require_once 'utils.php';
require_once 'dbo.php';
require_once 'xhtml.php';
global $LSP_URL;
if (get_user_id(SESSION()) == get_object_by_id("files", GET('file'), 'user_id') || is_admin(get_user_id(SESSION()))) {
    if (!POST('updateok', false)) {
        $file_name = get_file_name(GET('file'));
        $file_extension = parse_extension($file_name);
        $categories = get_categories_for_ext($file_extension, get_file_category(GET('file')) . ' - ' . get_file_subcategory(GET('file')));
        echo '<div class="col-md-9">';
        create_title(array('Edit', get_file_url()));
        $form = new form($LSP_URL . '?content=update&file=' . GET('file'), $title = 'Edit File', 'fa-pencil');
        ?>
		<div class="form-group">
			<label for="category">Category</label>
			<select name="category" class="form-control">
			<?php 
        echo $categories;
        ?>
	
			</select>
		</div>
		<div class="form-group">
			<label for="license">License</label>
			<select name="license" class="form-control">
			<?php 
        echo get_licenses(get_license_name(get_file_license(GET('file'))));
        ?>
			</select>