コード例 #1
0
ファイル: wallpaper.lib.php プロジェクト: KuBe-zz/hamsterpaj
function wallpapers_action_preview($arg)
{
    $out = '';
    $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
    $wallpapers = wallpapers_fetch(array('id' => $id, 'limit' => 1));
    $cat = $wallpapers[0]['cid'];
    $query = 'SELECT a.title, a.extension
	FROM ' . WALLPAPERS_TABLE . ' AS a 
	LEFT JOIN ' . WALLPAPERS_CATS . ' AS d ON a.cid = d.id
	WHERE a.id = "' . $id . '" 
	AND a.is_removed = 0 
	AND d.is_removed = 0
	AND a.is_verified = 1
	LIMIT 1';
    $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
    if (mysql_num_rows($result) > 0) {
        $data = mysql_fetch_assoc($result);
        //next wallpaper
        $query = 'SELECT id FROM `' . WALLPAPERS_TABLE . '` WHERE id > "' . $id . '" AND cid = "' . $cat . '" AND is_removed = 0 AND is_verified = 1 LIMIT 1';
        $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
        $next = mysql_num_rows($result) > 0 ? mysql_fetch_assoc($result) : false;
        $next = $next['id'];
        //previous wallpaper
        $query = 'SELECT id FROM `' . WALLPAPERS_TABLE . '` WHERE id < "' . $id . '" AND cid = "' . $cat . '" AND is_removed = 0 AND is_verified = 1 ORDER BY id DESC LIMIT 1';
        $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
        $previous = mysql_num_rows($result) > 0 ? mysql_fetch_assoc($result) : false;
        $previous = $previous['id'];
        echo '<br />' . "\n";
        //for the admins later on
        $imagetitle = $data['title'];
        $out .= '<h1 id="wallpaper_header">' . $data['title'] . '</h1>' . "\n";
        $out .= '<img src="' . WALLPAPER_URL . $id . '_preview.' . $data['extension'] . '" id="wallpaper_preview" />' . "\n";
        $out .= '<div>' . "\n";
        if ($previous) {
            $out .= '<input type="button" value="&laquo; Föregående" class="button" id="wallpaper_prev" onclick="document.location.href = \'?action=preview&id=' . $previous . '\';" />' . "\n";
        }
        if ($next) {
            $out .= '<input type="button" value="Nästa &raquo;" class="button" onclick="document.location.href = \'?action=preview&id=' . $next . '\';" style="float:right;" />' . "\n";
        }
        $out .= '<br style="clear:both;" />' . "\n";
        $out .= '<br />' . "\n";
        $out .= '</div>' . "\n";
        $out .= '<div id="wallpaper_resolutions">' . "\n";
        $out .= rounded_corners_top(array('color' => 'orange'));
        $out .= '<h2>Ladda hem bakgrundsbilden</h2>' . "\n";
        $out .= '<ul>' . "\n";
        $query = 'SELECT a.id, a.resolution_w AS width, a.resolution_h AS height 
	FROM ' . WALLPAPERS_RES . ' AS a 
	LEFT JOIN ' . WALLPAPERS_RES_RELATION . ' AS b ON b.resolution_pid = a.id 
	LEFT JOIN ' . WALLPAPERS_TABLE . ' AS c ON c.id = b.pid 
	LEFT JOIN ' . WALLPAPERS_CATS . ' AS d ON c.cid = d.id
	WHERE c.id = "' . $id . '" 
	AND a.is_removed = 0
	AND b.is_removed = 0
	AND c.is_removed = 0
	AND d.is_removed = 0
	AND c.is_verified = 1
	ORDER BY resolution_w, resolution_h ASC
	';
        $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
        $num_res = mysql_num_rows($result);
        if ($num_res > 0) {
            while ($data = mysql_fetch_assoc($result)) {
                if ($data['width'] == $arg['resolution']['w'] && $data['height'] == $arg['resolution']['h']) {
                    $same_res = true;
                } else {
                    $same_res = false;
                }
                $out .= '<li><a href="download_wallpaper.php?action=download&w=' . $data['width'] . '&h=' . $data['height'] . '&id=' . $id . '" title="Ladda ner bilden med upplösningen ' . $data['width'] . ' x ' . $data['height'] . '">' . ($same_res ? '<strong>' : '') . $data['width'] . ' x ' . $data['height'] . ($same_res ? '</strong>' : '') . '</a>';
                if (login_checklogin() && $_SESSION['login']['userlevel'] >= 5) {
                    $out .= ' [<a href="/site_admin/wallpapers_admin.php?action=wallpapers&sub_action=delete_res&id=' . $id . '&w=' . $data['width'] . '&h=' . $data['height'] . '" onclick="return confirm(\'Sure?' . ($num_res == 1 ? '\\n\\n***** OBS! LÄS DETTA *****\\n\\nEftersom den här upplösningen är den sista kommer även bilden tas bort.\\n\\nStill sure?' : '') . '\')" title="Radera upplösningen">X</a>]';
                }
                $out .= '</li>' . "\n";
            }
        } else {
            $out .= 'Inga upplösningar tillgängliga';
        }
        $out .= '</ul>' . "\n";
        $out .= rounded_corners_bottom();
        $out .= wallpapers_instructions();
        $out .= '</div>
<div class="wallpaper_formalia">

	</div>' . "\n";
        $is_image = true;
        $tags = implode(',', $tags);
    } else {
        $out .= '<h1>Bilden hittades inte</h1>';
        $tags = '';
        $imagetitle = '';
        $is_image = false;
    }
    return array('out' => $out, 'tags' => $tags, 'imagetitle' => $imagetitle, 'is_image' => $is_image);
}
コード例 #2
0
    	}
    */
}
if (is_privilegied('backgrounds_admin')) {
    switch (isset($_GET['action']) ? $_GET['action'] : 'home') {
        case 'preview':
            if (isset($_POST['title'], $_POST['tags'], $_GET['id'])) {
                $cat = wallpapers_fetch(array('id' => intval($_GET['id']), 'limit' => 1));
                $cat = $cat[0]['cid'];
                //title
                $query = 'UPDATE ' . WALLPAPERS_TABLE . ' SET title = "' . $_POST['title'] . '", cid = ' . intval($_POST['cat']) . ' WHERE id = ' . intval($_GET['id']);
                mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
                jscript_go_back();
            } else {
                if ($is_image) {
                    $cat = wallpapers_fetch(array('id' => intval($_GET['id']), 'limit' => 1));
                    $cat = $cat[0]['cid'];
                    echo rounded_corners_top();
                    echo '<h2>Admin</h2>' . "\n";
                    echo '<form action="' . $_SERVER['PHP_SELF'] . '?action=preview&id=' . intval($_GET['id']) . '" method="post">' . "\n";
                    echo '<h5>Titel</h5>
						<input type="text" name="title" value="' . $imagetitle . '" />' . "\n";
                    echo '<br />' . "\n";
                    echo '<h5>Kategori</h5>' . "\n";
                    echo '<select name="cat">' . "\n";
                    echo get_cats(0, 0, $cat);
                    echo '</select>' . "\n";
                    echo '<br />' . "\n";
                    echo '<input type="button" onclick="confirm(\'Sure?\') ? document.location.href=\'?action=delete&id=' . intval($_GET['id']) . '\' : false;" value="Radera" class="button" />' . "\n";
                    echo '<input type="submit" value="Spara" />';
                    echo rounded_corners_bottom();