İçeriğe geç
ShiftDelete.Net
Haber ara/ SDN'ye SorGiriş
Haber Akışı SDNTV İnceleme Forum Yapay Zeka Akıllı Telefon Elektrikli Otomobil Oyun ShiftDelete.Net Global Teknoloji Haberleri Mobil Otomobil Donanım Savunma Bilim Sosyal Medya İnternet Giyilebilir Teknoloji Rehber Ürünler Son dakika Yazarlar
  1. Ana sayfa
  2. Topluluk
  3. Programlama
  4. SDN Programlama Kafe
SDN Programlama Kafe

Pagination

light10015.08.201115 cevap2.665 görüntüleme
2011'den beri23 mesaj
#1
Merhaba arkadaslar ben sayfama hazir bir newsscript ekledim sonrada paginationnun sytleni degistirdim .cssyle ama simdi bir problemim var sayfa sayisinin sadece 7 tane gözükmesini istiyorum yani <1234567>
ama bende 3 tane gözüküyor aslinda ilkbasdada 3 tane gözükmüyordu 16 ya kadar devam ediyordu <123456789101213141516> sonra ben newsscriptin ayarlarina gidib Haber Sayfalandirma yerine gidib {pages} {newpages} le degistirdim cünkü üste degistirirsem sadece 3 sayfa göstercegi yaziyordu bunu yaptikdan sonra 7 tane gözükmesi icin newsscriptin dosyasina gidib fuctions.phpyi acip ordada function commentspagintation bölümüne gittim orda
if($type == "newpages"){
        $d = 1;
        $newpages = '';
        $maxtoshow = 3;
maxtoshowu 7yle degistirdim simdi websitemde 7 sayfa görünüyor ama diger sayfaya gitdigimde mesela 2 sayfaya gitdigimde paginationun styleyi bozuluyor class="n13_pages_active">2 yaziyor sadece 2 yazcagina

functions.php
function newspagintation($type){
    global $amountofpages, $linkprefix, $page;
    if($type == "currentpage"){
        $currentpage = $page;
        return $currentpage;
    }
    if($type == "previouspage"){
        if($page <= 1){
            $previouspage = 1;
        }else{
            $previouspage = ($page - 1);
        }

        return $previouspage;
    }
    if($type == "nextpage"){
        $nextpage = ($page + 1);
        if($nextpage >= $amountofpages){
            $nextpage = $amountofpages;
        }else{

        }
        return $nextpage;
    }
    if($type == "pages"){
        $pages = '';
        $d = 1;
        while($d <= $amountofpages){
            if($amountofpages == 1){
            }else{
                if($d == $page){
                    $pages .= "<span class=\"n13_pages_active\">$d</span> ";
                }else{
                    if(FRIENDLY){
                        $pages .= sprintf("<a class=\"n13_pages_nonactive\" href=\"%s%s-%s-%s\">%s</a> ", PREFIX, '0', $d, NEWSSUFFIX, $d);
                    }else{
                        $pages .= sprintf("<a class=\"n13_pages_nonactive\" href=\"?%spage=%s\">%s</a> ", $linkprefix, $d, $d);
                    }
                }
            }
            $d++;
        }
        return $pages;
    }
    if($type == "newpages"){
        $d = 1;
        $newpages = '';
        $maxtoshow = 7;
        if($amountofpages <= $maxtoshow){
            while($d <= $amountofpages){
                if($amountofpages !== 1){
                    if($d == $page){
                        $newpages .= "<span class=\"n13_pages_active\">$d</span> ";
                    }else{
                        if(FRIENDLY){
                            $newpages .= sprintf("<a class=\"n13_pages_nonactive\" href=\"%s0-%s-%s\">%s</a> ", PREFIX, $d, NEWSSUFFIX, $d);
                        }else{
                            $newpages .= "<a class=\"n13_pages_nonactive\" href=\"?$linkprefix" . "page=$d\">$d</a> ";
                        }
                    }
                }
                $d++;
            }
        }else{
            if($page <= 1){
                $r = 1;
                while($r <= $maxtoshow){
                    if($r == $page){
                        $newpages .= "<span class=\"n13_pages_active\">$r</span> ";
                    }else{
                        if(FRIENDLY){
                            $newpages .= sprintf("<a class=\"n13_pages_nonactive\" href=\"%s0-1-%s\">%s</a> ", PREFIX, NEWSSUFFIX, $r);
                        }else{
                            $newpages .= sprintf("<a class=\"n13_pages_nonactive\" href=\"?%spage=%s\">%s</a> ", $linkprefix, $r, $r);
                        }
                    }
                $r++;
                }
            }elseif($page >= $amountofpages){
                $r = $page - $maxtoshow;
                while($r <= $amountofpages){
                    if($r == $page){
                        $newpages .= sprintf("<span class=\"n13_pages_active\">%s</span> ", $r);
                    }else{
                        if(FRIENDLY){
                            $newpages .= sprintf("<a class=\"n13_pages_nonactive\" href=\"%s0-%s-%s\">%s</a> ", PREFIX, $r, NEWSSUFFIX, $r);
                        }else{
                            $newpages .= sprintf("<a class=\"n13_pages_nonactive\" href=\"?%spage=%s\">%s</a> ", $linkprefix, $r, $r);
                        }
                    }
                $r++;
                }
            }else{
                $d = $page - 1;
                $r = 1;
                while($r <= $maxtoshow){
                    if($d == $page){
                        $newpages .= "class=\"n13_pages_active\">$d</span> ";
                    }else{
                        if(FRIENDLY){
                            $newpages .= sprintf("<a class=\"n13_pages_nonactive\" href=\"%s0-%s-%s\">%s</a> ", PREFIX, $d, NEWSSUFFIX, $d);
                        }else{
                            $newpages .= sprintf("<a class=\"n13_pages_nonactive\" href=\"?%spage=%s\">%s</a> ", $linkprefix, $d, $d);
                        }
                    }
                    $d++;
                    $r++;
                }
            }
        }
        return $newpages;
    }

    if($type == "firstpage"){
        # [firstpage] & [/firstpage]
        if($amountofpages == 1 || $page == 1){
            $firstpagelink = "";
        }else{
            if(FRIENDLY){
                $firstpagelink = sprintf("<a class=\"n13_pages_firstpage\" href=\"%s0-1-%s\"> ", PREFIX, NEWSSUFFIX);
            }else{
                $firstpagelink = sprintf("<a class=\"n13_pages_firstpage\" href=\"?%spage=1\"> ", $linkprefix);
            }
        }
        return $firstpagelink;
    }

    if($type == "prevlink"){
        # [prev-link] & [/prev-link]
        if($amountofpages == 1 || $page == 1){
            $plink = "";
        }else{
            $g = $page - 1;
            if(FRIENDLY){
                $plink = sprintf("<a class=\"n13_pages_prevlink\" href=\"%s0-%s-%s\"> ", PREFIX, $g, NEWSSUFFIX);
            }else{
                $plink = sprintf("<a class=\"n13_pages_prevlink\" href=\"?%spage=%s\"> ", $linkprefix, $g);
            }

        }
        return $plink;
    }

    if($type == "lastpage"){
        # [lastpage] & [/lastpage]
        if($amountofpages == $page || $amountofpages == 0){
            $lastpagelink = "";
        }else{
            $g = $page + 1;
            if(FRIENDLY){
                $lastpagelink = sprintf("<a class=\"n13_pages_lastpage\" href=\"%s0-%s-%s\">", PREFIX, $amountofpages, NEWSSUFFIX);
            }else{
                $lastpagelink = sprintf("<a class=\"n13_pages_lastpage\" href=\"?%spage=%s\">", $linkprefix, $amountofpages);
            }
        }
        return $lastpagelink;
    }

    if($type == "nextlink"){
        # [next-link] & [/next-link]
        if($amountofpages == $page || $amountofpages == 0){
            $nlink = "";
        }else{
            $g = $page + 1;
            if(FRIENDLY){
                $nlink = sprintf("<a class=\"n13_pages_nextlink\" href=\"%s0-%s-%s\">", PREFIX, $g, NEWSSUFFIX);
            }else{
                $nlink = sprintf("<a class=\"n13_pages_nextlink\" href=\"?%spage=%s\">", $linkprefix, $g);
            }
        }
        return $nlink;
    }

}
function formatcommentspagintation(){
    global $cpagintation, $plink, $firstpagelink, $nlink, $lastpagelink, $pages, $newpages, $ccurrentpage, $cpreviouspage, $cnextpage, $cpid, $cfriendlytitle;
    if(!$plink){
        $cpagintation = preg_replace('#\[prev-link\](.*?)\[\/prev-link\]#se','', $cpagintation);
    }
    if(!$firstpagelink){
        $cpagintation = preg_replace('#\[firstpage\](.*?)\[\/firstpage\]#se','', $cpagintation);
    }
    if(!$lastpagelink){
        $cpagintation = preg_replace('#\[lastpage\](.*?)\[\/lastpage\]#se','', $cpagintation);
    }
    if(!$nlink){
        $cpagintation = preg_replace('#\[next-link\](.*?)\[\/next-link\]#se','', $cpagintation);
    }
    $cpagintation = str_replace("[prev-link]", $plink,$cpagintation);
    $cpagintation = str_replace("[firstpage]", $firstpagelink,$cpagintation);

    if($plink == ""){
        $cpagintation = str_replace("[/prev-link]", "",$cpagintation);
        $cpagintation = str_replace("[/firstpage]", "",$cpagintation);
    }else{
        $cpagintation = str_replace("[/prev-link]", "</a>",$cpagintation);
        $cpagintation = str_replace("[/firstpage]", "</a>",$cpagintation);
    }
    $cpagintation = str_replace("[next-link]", $nlink,$cpagintation);
    $cpagintation = str_replace("[lastpage]", $lastpagelink,$cpagintation);
    if($nlink == ""){
        $cpagintation = str_replace("[/next-link]", "",$cpagintation);
        $cpagintation = str_replace("[/lastpage]", "",$cpagintation);
    }else{
        $cpagintation = str_replace("[/next-link]", "</a>",$cpagintation);
        $cpagintation = str_replace("[/lastpage]", "</a>",$cpagintation);
    }
    $cpagintation = str_replace("{pages}", $pages,$cpagintation);
    $cpagintation = str_replace("{newpages}", $newpages,$cpagintation);

    $cpagintation = str_replace("{currentpage}", $ccurrentpage, $cpagintation);
    $cpagintation = str_replace("{previouspage}", $cpreviouspage, $cpagintation);
    $cpagintation = str_replace("{nextpage}", $cnextpage, $cpagintation);
    $cpagintation = str_replace("{pid}", ID, $cpagintation);
    $cpagintation = str_replace("{friendlytitle}", $cfriendlytitle, $cpagintation);
    return $cpagintation;
}
function formatnewspagintation(){
    global $npagintation, $pages,$newpages,$firstpagelink,$plink,$lastpagelink,$nlink, $currentpage, $nextpage, $previouspage;
    if(!$plink){
        $npagintation = preg_replace('#\[prev-link\](.*?)\[\/prev-link\]#se','', $npagintation);
    }
    if(!$firstpagelink){
        $npagintation = preg_replace('#\[firstpage\](.*?)\[\/firstpage\]#se','', $npagintation);
    }
    if(!$lastpagelink){
        $npagintation = preg_replace('#\[lastpage\](.*?)\[\/lastpage\]#se','', $npagintation);
    }
    if(!$nlink){
        $npagintation = preg_replace('#\[next-link\](.*?)\[\/next-link\]#se','', $npagintation);
    }

    $npagintation = str_replace("[prev-link]", $plink,$npagintation);
    $npagintation = str_replace("[firstpage]", $firstpagelink,$npagintation);

    if($plink == ""){
        $npagintation = str_replace("[/prev-link]", "",$npagintation);
        $npagintation = str_replace("[/firstpage]", "",$npagintation);
    }else{
        $npagintation = str_replace("[/prev-link]", "</a>",$npagintation);
        $npagintation = str_replace("[/firstpage]", "</a>",$npagintation);
    }
    $npagintation = str_replace("[next-link]", $nlink,$npagintation);
    $npagintation = str_replace("[lastpage]", $lastpagelink,$npagintation);
    if($nlink == ""){
        $npagintation = str_replace("[/next-link]", "",$npagintation);
        $npagintation = str_replace("[/lastpage]", "",$npagintation);
    }else{
        $npagintation = str_replace("[/next-link]", "</a>",$npagintation);
        $npagintation = str_replace("[/lastpage]", "</a>",$npagintation);
    }
    $npagintation = str_replace("{pages}", $pages,$npagintation);
    $npagintation = str_replace("{newpages}", $newpages,$npagintation);

    $npagintation = str_replace("{currentpage}", $currentpage, $npagintation);
    $npagintation = str_replace("{previouspage}", $previouspage, $npagintation);
    $npagintation = str_replace("{nextpage}", $nextpage, $npagintation);
    return $npagintation;
}
function strip_only($str, $tags, $stripContent = false) {
    $content = '';
    if(!is_array($tags)) {
        $tags = (strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags));
        if(end($tags) == '') array_pop($tags);
    }
    foreach($tags as $tag) {
        if ($stripContent)
            $content = '(.+</'.$tag.'[^>]*>|)';
        $str = preg_replace('#</?'.$tag.'[^>]*>'.$content.'#is', '', $str);
    }
    return $str;
}
function displayhtml($str){
    $str = str_replace("&","&amp;",$str);
    $str = str_replace("<","&lt;",$str);
    $str = str_replace(">","&gt;",$str);
    $str = str_replace("\"","&quot;",$str);
    return $str;
}
function addrating($parent, $value){
    ###update rating system
    if($value){
        $ip = $_SERVER['REMOTE_ADDR'];
        $alreadyrated = DataAccess::fetch("SELECT COUNT(uid) AS alreadyrated FROM " . NEWS_RATING . " WHERE ip = ? AND storyid = ?", $ip, $parent);
        $alreadyrated = $alreadyrated['0']['alreadyrated'];
        if($alreadyrated == (int)"1"){
            return "Already rated";
        }else{
            #make sure the user enters onl 1-5
            if($value == (int)"1" || $value == (int)"2" || $value == (int)"3" || $value == (int)"4" || $value == (int)"5"){
                #add rating
                DataAccess::put("INSERT INTO " . NEWS_RATING . " (vote,ip,storyid) VALUES (?, ?, ?)", $value, $ip, $parent);
                $average = DataAccess::fetch("SELECT avg(vote) AS average FROM " . NEWS_RATING . " WHERE storyid = ?", $parent);
                $average = $average['0']['average'];
                DataAccess::put("UPDATE " . NEWS_ARTICLES . " SET rating = ? WHERE id = ?", $average, $parent);
                return "Success";
            }else{
                #incase the user tries to post with a value other than 1-5
                #do nothing
                return false;
            }
        }
        #$ratingvalue = slash2($_POST['ratingvalue']);
        #echo $ratingvalue;
    }
}
function nothingtoseehere($str){
    //move along now
    return $str . base64_decode("PGRpdiBzdHlsZT0idGV4dC1hbGlnbjogY2VudGVyOyBmb250LWZhbWlseTogVmVyZGFuYTsgZm9udC1zaXplOiA4cHQiPlBvd2VyZWQgYnkgPGEgaHJlZj0iaHR0cDovL25ldHdvcmstMTMuY29tIj5OLTEzIE5ld3M8L2E+PC9kaXY+");
}
function dologout(){
    DataAccess::put("UPDATE " . NEWS_USERS . " SET cookie = ? , language = ? WHERE uid = ?", "", "", $_SESSION['uid']);
    setcookie('data', false);
    setcookie('name', false);
    setcookie('language', false);
    session_destroy();
    header ("Location: ?");
}
function setcookies($name,$uid,$language){
    $hash    = rand(0,9999999);
    $hash    = md5(SALT . $hash);
    if(!file_exists(ABSPATH . '/language/' . basename($_SESSION['language']) . '.php')){
        $language = 'English';
    }

    DataAccess::put("UPDATE " . NEWS_USERS . " SET cookie = ?, language = ? WHERE user = ?", $hash, $language, $name);
    setcookie("data", $hash, time()+60*60*24*90);
    setcookie("name", $name, time()+60*60*24*90);
    setcookie("language", $language, time()+60*60*24*90);
}

function checkcookie(){
    $_COOKIE['data']    = (empty($_COOKIE['data'])) ? '' : $_COOKIE['data'];

    $_COOKIE['name']    = (empty($_COOKIE['name'])) ? '' : $_COOKIE['name'];
    if($_COOKIE['data']){
        $data = $_COOKIE['data'];
        $user = $_COOKIE['name'];
        $cookie_exists = DataAccess::fetch("SELECT email, user, uid, language FROM " . NEWS_USERS . " WHERE user = ? AND cookie = ?", $user, $data);
        if(count($cookie_exists) > 0){
            $uid        = $cookie_exists['0']['uid'];
            $language    = $cookie_exists['0']['language'];
            $name        = $cookie_exists['0']['user'];
            $email        = $cookie_exists['0']['email'];
            $_SESSION['userlogged20']    = "true";
            $_SESSION['name']            = $name;
            $_SESSION['email']            = $email;
            $_SESSION['uid']            = $uid;
            $_SESSION['language']        = $language;
        }
    }
}


function uniqueid2(){
    $id = md5(uniqid(rand(), true));
    $id = md5($id);
    $id = substr($id,0,20);
    return $id;
}
function makefriendly($str){
    $str = str_replace("%20","-",$str);
    $str = preg_replace("/[^a-z\d]/i", "-", $str);
    $str = str_replace("--", "-", $str);
    $str = str_replace("--", "-", $str);
    $str = trim($str, "-");
    $str = $str . SUFFIX;
    return $str;
}
function ascii_encode($string) {
    $i = strlen($string);
    $s = 0;
    $encoded = '';
    while($s < $i){
    $encoded .= "&#" . ord(substr($string,$s)) . ";";
    $s++;
    }
    return $encoded;
}
function slash2($string) {
#    if(get_magic_quotes_gpc()) {
#        return $string;
#    }else{
#        return addslashes($string);
#    }
return $string;
}
function uniqueid(){
    $str = md5(uniqid(rand(), true));
    $str = substr($str,rand(0,16),16);
    return $str;
}
function bbcode($str,$usehtml,$style){
    global $image_clickable;
    $str = bb2html($str,$usehtml,$style);
    return $str;
}
function getsmilies(){
    $allsmilies = DataAccess::fetch("SELECT keycode,path FROM " . NEWS_SMILIES . " WHERE showhide = ? ORDER BY 0+ID", "1");
    $smilies = '';
    foreach($allsmilies AS $smiley){
        $smilies .= "<a href=\"javascript:insertsmiley('" . $smiley['keycode'] . "');\"><img border=\"0\" src=\"" . $smiley['path'] . "\" alt=\"" . $smiley['keycode'] . "\"></a>\n";
    }
    $jscript    = "\n<script type=\"text/javascript\">\n";
    $jscript    .= " //<![CDATA[\n";
    $jscript    .= " function insertsmiley(key){\n";
    $jscript    .= " document.commentsform.message.value=document.commentsform.message.value+' '+ key;\n";
    $jscript    .= " document.commentsform.message.focus();\n";
    $jscript    .= "}\n";
    $jscript    .= "//]]>";
    $jscript    .= "\n</script>\n";
    return $jscript . $smilies;
}

function allnews(){
    global $langmsg, $postids;
    $all = DataAccess::fetch("SELECT access, " . NEWS_USERS . ".uid, " . NEWS_ACCESS . ".accesslevel as accesslevel FROM " . NEWS_USERS . "
    LEFT JOIN " . NEWS_ACCESS . " ON " . NEWS_USERS . ".access = " . NEWS_ACCESS . ".uid
    WHERE user = ?", $_SESSION['name']);
    $all    = $all['0'];
    $access    = $all['accesslevel'];
    $id        = $all['uid'];
    if($_GET['archives'] == "true"){
        $showarchives = '1';
    }else{
        $showarchives = '0';
    }
    $_GET['filtercat'] = (empty($_GET['filtercat'])) ? '' : $_GET['filtercat'];
    if($access == "3"){
        if($_GET['filtercat']){
            $sql = "SELECT DISTINCT " . NEWS_ARTICLES . ".id FROM " . NEWS_ARTICLES . "
            LEFT JOIN " . NEWS_GROUPCATS . " ON " . NEWS_ARTICLES . ".id = " . NEWS_GROUPCATS . ".storyid
            WHERE archived = '$showarchives'";
            $sql .= " AND " . NEWS_GROUPCATS . ".type = 'news' AND " . NEWS_GROUPCATS . ".catid = ?";
            $allnews = DataAccess::fetch($sql, $_GET['filtercat']);
        }else{
            $sql = "SELECT DISTINCT " . NEWS_ARTICLES . ".id FROM " . NEWS_ARTICLES . "
            LEFT JOIN " . NEWS_GROUPCATS . " ON " . NEWS_ARTICLES . ".id = " . NEWS_GROUPCATS . ".storyid
            WHERE archived = '$showarchives'";
            $allnews = DataAccess::fetch($sql);
        }
    }elseif($access == 2){
        if($_GET['filtercat']){
            $sql = "SELECT DISTINCT " . NEWS_ARTICLES . ".id FROM " . NEWS_ARTICLES . "
            LEFT JOIN " . NEWS_USERS . " ON " . NEWS_ARTICLES . ".author = " . NEWS_USERS . ".uid
            LEFT JOIN " . NEWS_ACCESS . " ON " . NEWS_USERS . ".access = " . NEWS_ACCESS . ".uid
            LEFT JOIN " . NEWS_GROUPCATS . " ON " . NEWS_ARTICLES . ".id = " . NEWS_GROUPCATS . ".storyid
            WHERE (author = '$id' OR " . NEWS_ACCESS . ".accesslevel = '1') AND archived = '$showarchives'";
            $sql .= " AND " . NEWS_GROUPCATS . ".type = 'news' AND " . NEWS_GROUPCATS . ".catid = ?";
            $allnews = DataAccess::fetch($sql, $_GET['filtercat']);
        }else{
            $sql = "SELECT DISTINCT " . NEWS_ARTICLES . ".id FROM " . NEWS_ARTICLES . "
            LEFT JOIN " . NEWS_USERS . " ON " . NEWS_ARTICLES . ".author = " . NEWS_USERS . ".uid
            LEFT JOIN " . NEWS_ACCESS . " ON " . NEWS_USERS . ".access = " . NEWS_ACCESS . ".uid
            LEFT JOIN " . NEWS_GROUPCATS . " ON " . NEWS_ARTICLES . ".id = " . NEWS_GROUPCATS . ".storyid
            WHERE (author = '$id' OR " . NEWS_ACCESS . ".accesslevel = '1') AND archived = '$showarchives'";
            $allnews = DataAccess::fetch($sql);
        }
    }elseif($access == 1){
        if($_GET['filtercat']){
            $sql = "SELECT DISTINCT " . NEWS_ARTICLES . ".id FROM " . NEWS_ARTICLES . "
            LEFT JOIN " . NEWS_GROUPCATS . " ON " . NEWS_ARTICLES . ".id = " . NEWS_GROUPCATS . ".storyid
            WHERE author = '$id' AND archived = '$showarchives'";
            $sql .= " AND " . NEWS_GROUPCATS . ".type = 'news' AND " . NEWS_GROUPCATS . ".catid = ?";
            $allnews = DataAccess::fetch($sql, $_GET['filtercat']);
        }else{
            $sql = "SELECT DISTINCT " . NEWS_ARTICLES . ".id FROM " . NEWS_ARTICLES . "
            LEFT JOIN " . NEWS_GROUPCATS . " ON " . NEWS_ARTICLES . ".id = " . NEWS_GROUPCATS . ".storyid
            WHERE author = '$id' AND archived = '$showarchives'";
            $allnews = DataAccess::fetch($sql);
        }
    }

    $totalnews = count($allnews);
    $_SESSION['newsoptions'] = (empty($_SESSION['newsoptions'])) ? '' : $_SESSION['newsoptions'];
    if($_SESSION['newsoptions'] == true){
        $_POST['changeoptions'] = (empty($_POST['changeoptions'])) ? '' : $_POST['changeoptions'];
        if($_POST['changeoptions']){
            $_SESSION['amounttoshow']    = $_POST['newsoptions_amount'];
            $_SESSION['sortby']            = $_POST['newsoptions_sort'];
            $_SESSION['order']            = $_POST['newsoptions_order'];
            $_SESSION['newsoptions']    = true;
            $amounttoshow                = $_SESSION['amounttoshow'];
            $sortby                        = $_SESSION['sortby'];
            $order                        = $_SESSION['order'];
        }else{
            $amounttoshow    = $_SESSION['amounttoshow'];
            $sortby            = $_SESSION['sortby'];
            $order            = $_SESSION['order'];
            if(!$order){ $order = 'DESC'; }
        }
    }else{
        $_POST['changeoptions'] = (empty($_POST['changeoptions'])) ? '' : $_POST['changeoptions'];
        if($_POST['changeoptions']){
            $_SESSION['amounttoshow']    = $_POST['newsoptions_amount'];
            $_SESSION['sortby']            = $_POST['newsoptions_sort'];
            $_SESSION['order']            = $_POST['newsoptions_order'];
            $_SESSION['newsoptions']    = true;
            $amounttoshow                = $_SESSION['amounttoshow'];
            $sortby                        = $_SESSION['sortby'];
            $order                        = $_SESSION['order'];
        }else{
            $sortby                        = NEWS_ARTICLES . '.timestamp';
            $amounttoshow                = 15;
            $order                        = 'DESC';
            $_SESSION['order']            = $order;
            $_SESSION['newsoptions']    = true;
            $_SESSION['amounttoshow']    = $amounttoshow;
            $_SESSION['sortby']            = $sortby;
            $_SESSION['newsoptions']    = true;
        }
    }


    #$amounttoshow = 15;
    #$amounttoshow = $_POST['newsoptions_amount'];
    $_GET['page'] = (empty($_GET['page'])) ? '' : $_GET['page'];
    $page = $_GET['page'];
    $amountofpages = ceil($totalnews / $amounttoshow);
    if(!$page){
        $start = 0;
        $page = 1;
    }else{
        if(!is_numeric($page)){
            $page = 1;
        }
        if($page > $amountofpages){
            $start = 0;
            $page = 1;
        }else{
            $start = $page * $amounttoshow - $amounttoshow;
        }
    }

    if($access == "3"){
        $sql    = "SELECT DISTINCT title, story, shortstory, author, origauthor, ip, timestamp, allowcomments, short, approved, id, (SELECT COUNT(id) FROM " . NEWS_COMMENTS . " WHERE " . NEWS_COMMENTS . ".pid = " . NEWS_ARTICLES . ".id) AS numcomments,
                " . NEWS_ARTICLES . ".id AS postid, " . NEWS_ARTICLES . ".approved AS postapproved,
                (SELECT COUNT(uid) FROM " . NEWS_LINKEDFILES . " WHERE storyid = " . NEWS_ARTICLES . ".id) AS totalfiles,
                (SELECT " . NEWS_USERS . ".user FROM " . NEWS_USERS . " WHERE " . NEWS_USERS . ".uid = " . NEWS_ARTICLES . ".author) AS authorname,
                " . NEWS_USERS . ".user FROM " . NEWS_ARTICLES . "
                LEFT JOIN " . NEWS_USERS . " ON " . NEWS_ARTICLES . ".author = " . NEWS_USERS . ".uid
                LEFT JOIN " . NEWS_GROUPCATS . " ON " . NEWS_ARTICLES . ".id = " . NEWS_GROUPCATS . ".storyid
                WHERE archived = '$showarchives' ";
        if($_GET['filtercat']){
            $sql .= "AND " . NEWS_GROUPCATS . ".type = 'news' AND " . NEWS_GROUPCATS . ".catid = ?";
        }
        $sql .= " ORDER BY $sortby $order LIMIT $start, $amounttoshow";
    }elseif($access == "2"){
        $sql    = "SELECT DISTINCT title, story, shortstory, author, origauthor, ip, timestamp, allowcomments, short, approved, id, " . NEWS_ARTICLES . ".approved AS postapproved, (SELECT COUNT(id) FROM " . NEWS_COMMENTS . " WHERE " . NEWS_COMMENTS . ".pid = " . NEWS_ARTICLES . ".id) AS numcomments,
                " . NEWS_ARTICLES . ".id AS postid,
                (SELECT COUNT(uid) FROM " . NEWS_LINKEDFILES . " WHERE storyid = " . NEWS_ARTICLES . ".id) AS totalfiles,
                (SELECT " . NEWS_USERS . ".user FROM " . NEWS_USERS . " WHERE " . NEWS_USERS . ".uid = " . NEWS_ARTICLES . ".author) AS authorname,
                " . NEWS_USERS . ".user FROM " . NEWS_ARTICLES . "
                LEFT JOIN " . NEWS_USERS . " ON " . NEWS_ARTICLES . ".author = " . NEWS_USERS . ".uid
                LEFT JOIN " . NEWS_ACCESS . " on " . NEWS_USERS . ".access = " . NEWS_ACCESS . ".uid
                LEFT JOIN " . NEWS_GROUPCATS . " ON " . NEWS_ARTICLES . ".id = " . NEWS_GROUPCATS . ".storyid
                WHERE (author = '$id' OR " . NEWS_ACCESS . ".accesslevel = '1')
                AND archived = '$showarchives' ";
        if($_GET['filtercat']){
            $sql .= "AND " . NEWS_GROUPCATS . ".type = 'news' AND " . NEWS_GROUPCATS . ".catid = ?";
        }
        $sql .= " ORDER BY $sortby $order LIMIT $start, $amounttoshow";
    }elseif($access == "1"){
        $sql    = "SELECT DISTINCT title, story, shortstory, author, origauthor, ip, timestamp, allowcomments, short, approved, id, (SELECT COUNT(id) FROM " . NEWS_COMMENTS . " WHERE " . NEWS_COMMENTS . ".pid = " . NEWS_ARTICLES . ".id) AS numcomments,
                " . NEWS_ARTICLES . ".id AS postid, " . NEWS_ARTICLES . ".approved AS postapproved,
                (SELECT COUNT(uid) FROM " . NEWS_LINKEDFILES . " WHERE storyid = " . NEWS_ARTICLES . ".id) AS totalfiles,
                (SELECT " . NEWS_USERS . ".user FROM " . NEWS_USERS . " WHERE " . NEWS_USERS . ".uid = " . NEWS_ARTICLES . ".author) AS authorname,
                " . NEWS_USERS . ".user FROM " . NEWS_ARTICLES . "
                LEFT JOIN " . NEWS_USERS . " ON " . NEWS_ARTICLES . ".author = " . NEWS_USERS . ".uid
                LEFT JOIN " . NEWS_GROUPCATS . " ON " . NEWS_ARTICLES . ".id = " . NEWS_GROUPCATS . ".storyid
                WHERE author = '$id'
                AND archived = '$showarchives' ";
        if($_GET['filtercat']){
            $sql .= "AND " . NEWS_GROUPCATS . ".type = 'news' AND " . NEWS_GROUPCATS . ".catid = ?";
        }
        $sql .= " ORDER BY $sortby $order LIMIT $start, $amounttoshow";
    }
    $d = 1;
    $pages = '';
    while($d <= $amountofpages){
        if($amountofpages !== 1){
            if($d == $page){
                $pages .= "<span class=\"page2\">$d</span> ";
            }else{
                $pages .= "<a class=\"page1\" href=\"admin.php?action=editnews&filtercat=$_GET[filtercat]&archives=$_GET[archives]&page=$d\">$d</a> ";
            }
        }
        $d++;
    }
    if($amountofpages == 1 || $page == 1){
        $plink = "";
    }else{
        $g = $page - 1;
        $plink = "<a class=\"page1\" href=\"admin.php?action=editnews&filtercat=$_GET[filtercat]&archives=$_GET[archives]&page=$g\"><</a> ";
    }

    if($amountofpages == $page || $amountofpages == 0){
        $nlink = "";
    }else{
        $g = $page + 1;
        $nlink = "<a class=\"page1\" href=\"admin.php?action=editnews&filtercat=$_GET[filtercat]&archives=$_GET[archives]&page=$g\">></a>";
    }
    if($_GET['filtercat']){
        $allnews = DataAccess::fetch($sql, $_GET['filtercat']);
    }else{
        $allnews = DataAccess::fetch($sql);
    }
    $shownnews = count($allnews);
    $langmsg['editnews'][1] = $langmsg['editnews'][1] . " <b>$shownnews</b> " . $langmsg['editnews'][21] . " <b>$totalnews</b> " . $langmsg['editnews'][22];
    echo "<div onclick=\"toggle_section2('newsoptions')\" class=\"subheaders subheaders2 slink\" style=\"cursor: pointer\"><div style=\"float: right\">";

    echo "<span style=\"cursor: pointer; text-decoration: underline;\">".$langmsg['editnews'][2]."</span>&nbsp;</div>".$langmsg['editnews'][1]."</div><form style=\"margin: 0px\" method=\"POST\" name=\"editform\" id=\"editform\" action=\"?action=editnews&archives=" . $_GET['archives'] . "&filtercat=" . $_GET['filtercat'] . "\">\n";
    echo "<div class=\"subheaders_body displaytable\" style=\"";
    if($_POST['changeoptions']){
        echo "display: table";
    }else{
        echo "display: none;";
    }
    echo "text-align: left; margin-bottom: 18px; width: 691px\" id=\"section_newsoptions\">";
    if($_GET['archives']){ $archives = "true"; }else{ $archives = ''; }
    echo $langmsg['editnews'][25] . " <select onchange=\"editnews_filtercat('$archives');\" id=\"filter_cat\" style=\"margin-right: 6px; margin-top: -2px\" name=\"filter_cat\">";


    $allowedcats = DataAccess::fetch("SELECT " . NEWS_ACCESS . ".cats FROM " . NEWS_USERS . " LEFT JOIN " . NEWS_ACCESS . " ON " . NEWS_USERS . ".access = " . NEWS_ACCESS . ".uid WHERE " . NEWS_USERS . ".user = ?", $_SESSION['name']);
    $allowedcats = $allowedcats['0']['cats'];

    $d = '';
    if($allowedcats !== "all"){
        $a = explode(",",$allowedcats);
        foreach($a as $c){
            $d .= "id LIKE '$c' OR ";
        }
    $d = substr($d,0,(strlen($d) - 3));
    $d = "WHERE " . $d;
    }

    $sql = "SELECT * FROM " . NEWS_CATS . " $d ORDER BY name";

    $selcats = DataAccess::fetch($sql);
    echo "<option value=\"\"></option>";
    foreach($selcats AS $row){
        echo "<option value=\"$row[id]\"";
        if($_GET['filtercat'] == $row['id']){
            echo " selected=\"selected\"";
        }
        echo ">" . $row['name'] . "</option>";
    }

    echo "</select>";
    echo "<hr />";
    echo $langmsg['editnews'][3] . " <select name=\"newsoptions_amount\">";
    $amount = $_SESSION['amounttoshow'];
    for($i=1; $i<=50; $i++){
        echo "<option";
        if($amount == $i){
            echo " selected=\"selected\"";
        }
        echo " value=\"$i\">$i</option>";
    }
    $sort = $_SESSION['sortby'];
    echo "</select> ".$langmsg['editnews'][4]." <select name=\"newsoptions_sort\">";
    echo "<option value=\"" . NEWS_ARTICLES . ".timestamp\""; if($sort == NEWS_ARTICLES . ".timestamp"){ echo " selected=\"selected\""; } echo ">".$langmsg['selectfield'][11]."</option>";
    echo "<option value=\"" . NEWS_ARTICLES . ".title\""; if($sort == NEWS_ARTICLES . ".title"){ echo " selected=\"selected\""; } echo ">".$langmsg['selectfield'][12]."</option>";
    echo "<option value=\"" . NEWS_ARTICLES . ".author\""; if($sort == NEWS_ARTICLES . ".author"){ echo " selected=\"selected\""; } echo ">".$langmsg['selectfield'][13]."</option>";
    echo "<option value=\"numcomments\""; if($sort == "numcomments"){ echo " selected=\"selected\""; } echo ">".$langmsg['selectfield'][15]."</option>";
    echo "<option value=\"" . NEWS_ARTICLES . ".approved\""; if($sort == NEWS_ARTICLES . ".approved"){ echo " selected=\"selected\""; } echo ">Approval</option>";
    echo "</select>";
    echo " ".$langmsg['editnews'][5]." ";
    $order = $_SESSION['order'];
    echo "<select name=\"newsoptions_order\">";
    echo "<option value=\"ASC\""; if($order == "ASC"){ echo " selected=\"selected\""; } echo ">Ascending</option>";
    echo "<option value=\"DESC\""; if($order == "DESC"){ echo " selected=\"selected\""; } echo ">Descending</option>";
    echo "</select> <input type=\"submit\" name=\"changeoptions\" value=\"".$langmsg['submitfield'][0]."\" />";
    echo "<br><br></div>";


    $i = 0;
    $allcats = DataAccess::fetch("SELECT * FROM " . NEWS_CATS . "");
    $cats = array();
    foreach($allcats AS $row2){
        $cats[$i] = array("name" => $row2['name'], "id" => $row2['id']);
        $i++;
    }
    echo "<br />";
    echo "<table id=\"rows\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";
    echo "<tr><td class=\"tableshead tablerightborder\"></td><td class=\"tableshead tablerightborder\" width=\"25%\">".$langmsg['editnews'][7]."</td><td class=\"tableshead tablerightborder\" width=\"20%\">".$langmsg['editnews'][8]."</td><td class=\"tableshead tablerightborder\" width=\"15%\"><a href=\"javascript:void(0); showalleditnewscats()\">".$langmsg['editnews'][9]."</a></td><td class=\"tableshead tablerightborder\" width=\"11%\">".$langmsg['editnews'][10]."&nbsp;</td><td width=\"15%\" class=\"tableshead tablerightborder\" >".$langmsg['editnews'][11]."</td><td width=\"15%\" class=\"tableshead tablerightborder\">".$langmsg['editnews'][12]."</td><td class=\"tableshead tablerightborder\"><input name=\"allcheck\" id=\"allcheck\" onclick=\"selectall()\" type=\"checkbox\" /></td></tr>\n";

    $tmpcolor = "1";
    $d = 1;
    $postids = array();
    foreach($allnews AS $row){
        if($tmpcolor == 1){
            $class = "row1";
            $tmpcolor = 2;
        }elseif($tmpcolor = 2){
            $class = "row2";
            $tmpcolor = 1;
        }
        echo "  <tr onmouseover=\"markfield('$d')\" onmouseout=\"unmarkfield('$d')\" id=\"$d\" class=\"$class\">\n";
        $numcomments = $row['numcomments'];
        if($row['allowcomments'] == "0"){
            $numcomments = $langmsg['editnews'][20];
        }
        $title = $row['title'];
        $totalfiles = $row['totalfiles'];
        $title = "$title";
        if($row['totalfiles'] > 0){
            $hasfiles = "<img class=\"slink\" src=\"http://forum.shiftdelete.net/images/icons/page_white_office.png\" onclick=\"showhideeditnewsfiles('files_" . $d . "')\" style=\"\" />";
        }else{
            $hasfiles = '';
        }
        echo "    <td class=\"tablebody tablerightborder\"><a href=\"?action=editnews&id=$row[postid]\"><img src=\"http://forum.shiftdelete.net/images/icons/pencil.png\" alt=\"Edit\" Title=\"Edit\" /></a>$hasfiles</td><td class=\"tablebody tablerightborder\"><div style=\"height: 17px; width: 136px; overflow: hidden\">$title</div></td><td class=\"tablebody tablerightborder\">";
        unset($hasfiles);
        if(!$row['user']){
            echo $row['origauthor'];
        }else{
            echo $row['user'];
        }
        if($row['postapproved'] == "1"){
            $approved = "<span style=\"color: #00AA00\">" . $langmsg['editnews'][14] . "</span>";
        }else{
            $approved = "<span style=\"color: #AA0000\">" . $langmsg['editnews'][15] . "</span>";
        }
        $groupcats         = DataAccess::fetch("SELECT * FROM " . NEWS_GROUPCATS . " WHERE type = ? AND storyid = ?", "news", $row['postid']);
        $catsperstory    = count($groupcats);
        $dcats = '';
        foreach($groupcats AS $row2){
            $dcats .= ":".$row2['catid'].":";
        }
        if(count($cats) > 0){
            foreach($cats as $cat){
                $dcats = str_replace(":" . $cat['id'] . ":",$cat['name'] .", ",$dcats);
            }
        }
        $dcats = substr($dcats,0,strlen($dcats) - 2);
        if($catsperstory > 0){
            $g = "<a href=\"#\" id=\"showcatlink_$row[postid]\" onclick=\"this.style.display = 'none'; document.getElementById('showcats_$row[postid]').style.display = '';\">".$langmsg['editnews'][13]."</a>";
        }else{
            $g = "<a href=\"#\" id=\"showcatlink_$row[postid]\" onclick=\"this.style.display = 'none'; document.getElementById('showcats_$row[postid]').style.display = '';\"></a>";
        }
        echo "</td><td class=\"tablebody tablerightborder\">$g<span style=\"display: none\" id=\"showcats_$row[postid]\">$dcats</span>";
        echo "</td><td class=\"tablebody tablerightborder\">" . date("d-m-y" ,$row['timestamp']) . "</td><td class=\"tablebody tablerightborder\">$approved</td><td align=center class=\"tablebody tablerightborder\"><a href=\"?action=editcomments&pid=$row[postid]\">$numcomments</a></td><td class=\"tablebody\"><input type=\"checkbox\" onclick=\"if(document.getElementById('check_'+$d).checked == true){ markfield('$d'); }else{ unmarkfield('$d') }\" value=\"$row[postid]\" id=\"check_$d\" name=\"selectedposts[]\">";
        echo "</td></tr>\n";
        if($row['totalfiles'] > 0){
            echo "<tr style=\"display: none\" id=\"files_$d\"><td style=\"\" style=\"background-color: #FFFFFF\" colspan=\"8\">";
            echo "<table width=\"100%\" cellpadding=\"0\" style=\"background-color: #FFFFFF\" cellspacing=\"0\">";
            echo "<tr><td class=\"tableshead tablerightborder\" style=\"width: 136px;\">" . $langmsg['uploadedfiles'][23] . "</td><td class=\"tableshead tablerightborder\" >" . $langmsg['uploadedfiles'][12] . "</td><td class=\"tableshead tablerightborder\" >" . $langmsg['uploadedfiles'][33] . "</td><td class=\"tableshead tablerightborder\" >" . $langmsg['uploadedfiles'][24] . "</td><td class=\"tableshead tablerightborder\" >" . $langmsg['uploadedfiles'][34] . "</td><td class=\"tableshead\" >" . $langmsg['uploadedfiles'][25];
            $files = DataAccess::fetch("SELECT title, url, filesize, downloadcount, author, timestamp FROM " . NEWS_FILES . " WHERE uid IN (SELECT fileid FROM " . NEWS_LINKEDFILES . " WHERE storyid = ?)", $row['postid']);
            foreach($files AS $file){
                echo "<tr>";
                echo "<td class=\"tablebody tablerightborder\">";
                #echo "<img src=\"http://forum.shiftdelete.net/images/icons/page_white_office.png\" style=\"postition: absolute; float: left; margin-left: -20px;\" />";
                echo $file['title'] . "</td>";
                echo "<td class=\"tablebody tablerightborder\">" . basename($file['url']) . "</td>";
                echo "<td class=\"tablebody tablerightborder\">" . $file['downloadcount'] . "</td>";
                echo "<td class=\"tablebody tablerightborder\">" . round($file['filesize'],1) . " KB</td>";
                echo "<td class=\"tablebody tablerightborder\">" . date("j-m-y",$file['timestamp']) . "</td>";
                $uploader = DataAccess::fetch("SELECT user FROM " . NEWS_USERS . " WHERE uid = ?", $file['author']);
                $uploader = $uploader['0']['user'];
                echo "<td class=\"tablebody\">$uploader</td>";
                echo "</tr>";
            }
            echo "</table>";
        }
        $d++;
        $postids[] = $row['postid'];
    }


    echo "</table>\n";
    echo "<div align=\"right\" style=\"float: right\">";
    echo "<select name=\"action\" id=\"action\" onclick=\"editnewsaction();\">";
    echo "<option value=\"\">".$langmsg['selectfield'][0]."</option>";
    echo "<option value=\"addtoarchive\">Add to archive</option>";
    echo "<option value=\"removefromarchive\">Remove from archive</option>";
    echo "<option value=\"allowcomments\">".$langmsg['selectfield'][5]."</option>";
    $canapprove = DataAccess::fetch("SELECT " . NEWS_ACCESS . ".canapprove FROM " . NEWS_USERS . " LEFT JOIN " . NEWS_ACCESS . " ON " . NEWS_USERS . ".access = " . NEWS_ACCESS . ".uid WHERE " . NEWS_USERS . ".user = ?", $_SESSION['name']);
    $canapprove = $canapprove['0']['canapprove'];
    if($canapprove == "1"){
        echo "<option value=\"changeapproval\">".$langmsg['selectfield'][6]."</option>";
    }
    echo "<option value=\"resetview\">" . $langmsg['selectfield'][20] . "</option>";
    echo "<option value=\"resetratings\">" . $langmsg['selectfield'][21] . "</option>";
    echo "<option value=\"delete\">".$langmsg['selectfield'][3]."</option>";
    echo "</select>&nbsp;";
    echo "<select style=\"margin-right: 2px; display: none\" id=\"allowcomments\" name=\"allowcomments\"><option value=\"1\">".$langmsg['selectfield'][1]."</option><option value=\"0\">".$langmsg['selectfield'][2]."</option><option value=\"2\">".$langmsg['selectfield'][4]."</option></select>";
    echo "<select id=\"approveaction\" style=\"margin-right: 2px; display: none\" name=\"approveaction\">";
    echo "<option value=\"1\">".$langmsg['selectfield'][9]."</option>";
    echo "<option value=\"0\">".$langmsg['selectfield'][10]."</option>";
    echo "</select>";
    echo "<input type=\"button\" value=\"".$langmsg['submitfield'][0]."\" class=\"nostyle\" onclick=\"doeditaction();\" name=\"S1\" /></div>";
    if($amountofpages > 1){
        echo "<br />";
        echo "<br />";
        echo "<div style=\"float: right\">$plink $pages $nlink</div>";
    }
    $_SESSION['formauth'] = md5(HASH . time());
    echo "<input type=\"hidden\" name=\"formauth\" value=\"" . $_SESSION['formauth'] . "\" />";
    echo "</form>\n";
}
function selectimages(){
    global $langmsg, $imageuploaddir, $imageupload_thumbnails;
    echo "<div style=\"display: none\" id=\"whichbox\">x</div>";
    echo "<div style=\"position: absolute; width: 580px; left: 35%; display: none; z-index: 10001\" id=\"imagebox\">";
    echo "<div style=\"width:580px; height: 340px; background-color: #FFFFFF padding: 10px; border: 1px solid #AAAAAA position: absolute; left: -190px\">";
    echo "<a style=\"float: right; text-decoration: underline; cursor: pointer\" onclick=\"bbcode('image','story')\">[close]</a><span class=\"header\" style=\"padding-left: 0px; background-color: #FFFFFF\">" . $langmsg['newsform'][23] . "</span>";
    echo "<hr />";
    echo "<input id=\"imageurl\" type=\"text\" style=\"width: 300px\" value=\"http://\" /> <input type=\"button\" onclick=\"insertimage(document.getElementById('whichbox').innerHTML,''+ document.getElementById('imageurl').value + ''); bbcode('image','')\" value=\"" . $langmsg['newsform'][24] . "\" />";

    echo "<br />";
    echo "<br />";
    echo "<span style=\"float: right\">";
    echo "<select name=\"news_selectcat\" onchange=\"newschangecatgroup();\" id=\"news_selectcat\">";
    echo "<option value=\"1\"></option>";

    $allowedcats = DataAccess::fetch("SELECT " . NEWS_ACCESS . ".cats FROM " . NEWS_USERS . " LEFT JOIN " . NEWS_ACCESS . " ON " . NEWS_USERS . ".access = " . NEWS_ACCESS . ".uid WHERE " . NEWS_USERS . ".user = ?", $_SESSION['name']);
    if($allowedcats['0']['cats'] !== "all"){
        $e = $allowedcats['0']['cats'];
        if(!$e){ $e = ''; }else{ $e = "WHERE id IN ($e)"; }
        $allcats = DataAccess::fetch("SELECT name, id FROM " . NEWS_CATS . " $e ORDER BY name");
    }else{
        $allcats = DataAccess::fetch("SELECT name, id FROM " . NEWS_CATS . " ORDER BY name");
    }

    $g = 2;
    foreach($allcats AS $row){
        echo "<option value=\"$g\"";
        $_GET['catid'] = (empty($_GET['catid'])) ? '' : $_GET['catid'];
        if(in_array($_GET['catid'], $allcats)){
            echo " selected=\"selected\"";
        }
        echo ">" . $row['name'] . "</option>";
        $g++;
    }

    echo "</select>";
    echo "</span>";
    echo "<span class=\"header\" style=\"background-color: #FFFFFF padding-left: 0px\">" . $langmsg['newsform'][25] . "</span>";
    echo '<hr style="clear: both; background-color: #FFFFFF color: #FFFFFF border: 1px solid #FFFFFF" />
    <hr style="clear: both;" />';


    $b = 0;
    echo "<div style=\"height: 225px; width: 580px; overflow: auto\">";

    // container for loading thumbnails
    echo "<div id=\"thumbnails_container\">";

    #get all images not assigned to cats
    echo "<div id=\"imagecat_1\">";
    #echo $xsql;
    $noncatimages = DataAccess::fetch("SELECT file,filesize,uploader,height,width,uid FROM " . NEWS_IMAGES . " WHERE uid NOT IN (SELECT storyid FROM " . NEWS_GROUPCATS . " WHERE type = 'image') ORDER BY uid DESC");
    $totalfilesize = 0;
    foreach($noncatimages AS $row){
        $file = $row['file'];
        list($width, $height, $type, $attr) = getimagesize($imageuploaddir . $file);
        if($width > 80 || $height > 80){
            $new_width    = $width;
            $new_height    = $height;
            $percent = 0.9;
            while($new_width > 80|| $new_height > 80){
                $new_width    = $width * $percent;
                $new_height    = $height * $percent;
                $percent    = $percent - 0.01;
            }
        }else{
            $new_width    = $width;
            $new_height    = $height;
        }

        $filesize = round(filesize($imageuploaddir . $file) / 1024,0);
        $totalfilesize += $filesize;
        $filesize .= " KB";
        $x = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
        $x = str_replace(basename($_SERVER['REQUEST_URI']),SCRIPTPATH . 'uploads/' . $file,$x);

        echo '<div style="float: left; width: 112px; height: 130px"><div id="'.$b.'" class="thumbnail" style="cursor: pointer">';
        echo '<div style="text-align: left">';

        echo '</div>';
        if($imageupload_thumbnails == "1"){
            echo "<img onclick=\"insertimage(document.getElementById('whichbox').innerHTML,'";
            echo UPLOADPATH . $file;
            echo "'); bbcode('image','')\" width=\"$new_width\" height=\"$new_height\" style=\"background-color: #FFFFFF border: 1px solid #DDDDDD\" src=\"?action=options&mod=imageuploads&thumb=" . UPLOADPATH . $file . "&height=$new_height&width=$new_width\" />";
        }else{
            echo '<img onclick="insertimage(document.getElementById(\'whichbox\').innerHTML,\''.UPLOADPATH . $file.'\'); bbcode(\'image\',\'\')" width="'.$new_width.'" height="'.$new_height.'" style="background-color: #FFFFFF border: 1px solid #DDDDDD" src="'.$imageuploaddir.$file.'" />';
        }
        echo '</div></div>';
         $b++;
    }
    echo "</div>";



    echo "</div>";
    //




    echo '</div></div>';




    echo "</div>";
    echo "</div>";
    echo "</div>";

}
function newsform($type){
    global $imageuploaddir,$newsform_options, $langmsg, $imageupload_thumbnails;
    $_SESSION['formauth'] = md5(HASH . time());
    $uploaddir = $imageuploaddir;

    if(!$_POST['S1']){
        $allowcomments    = 1;
        $day            = date('d',time());
        $month            = date('F',time());
        $year            = date('Y',time());
        $hour            = date('H',time());
        $minute            = date('i',time());
        $second            = date('s',time());

        $archive_day        = date('d',time());
        $archive_month        = date('F',time());
        $archive_year        = date('Y',time());
        $archive_hour        = date('H',time());
        $archive_minute        = date('i',time());
        $archive_second        = date('s',time());
        $neverarchive        = $newsform_options['never_archive'];
        $togglesummary        = $newsform_options['toggle_summary'];
        $allowcomments        = $newsform_options['allow_comments'];
        $togglearchive        = $newsform_options['toggle_archive'];
        $toggledate            = $newsform_options['toggle_date'];

        $title                = $langmsg['news'][50];
        $story                = '';
        $shortstory            = '';

        $changecolor        = "onfocus=\"this.style.color='#000000'; if(this.value=='" . $langmsg['news'][50] . "'){ this.value=''; }\" style=\"width: 99%; color: #AAAAAA\" ";

        if($_GET['action'] == "editnews"){
             if(!$_POST['S1']){
                $id                    = $_GET['id'];
                $all                = DataAccess::fetch("SELECT old,title,story,shortstory,author,origauthor,ip,timestamp,allowcomments,short,approved,viewcount,rating,archivedate,neverarchive,archived,id FROM " . NEWS_ARTICLES . " WHERE id = ?", $id);
                $title                = displayhtml($all['0']['title']);
                if($all['0']['old'] == "1"){
                    $story            = bbcode(displayhtml($all['0']['story']), '1', '1');
                    $shortstory        = bbcode(displayhtml($all['0']['shortstory']), '1', '1');
                }else{
                    $story            = displayhtml($all['0']['story']);
                    $shortstory        = displayhtml($all['0']['shortstory']);
                }
                if($shortstory){
                    $togglesummary = '1';
                }else{
                    $togglesummary = '0';
                }
                $allowcomments        = htmlspecialchars($all['0']['allowcomments']);
                $day    = date('d',$all['0']['timestamp']);
                $month    = date('F',$all['0']['timestamp']);
                $year    = date('Y',$all['0']['timestamp']);
                $hour    = date('H',$all['0']['timestamp']);
                $minute    = date('i',$all['0']['timestamp']);
                $second    = date('s',$all['0']['timestamp']);

                $archive_day    = date('d',$all['0']['archivedate']);
                $archive_month    = date('F',$all['0']['archivedate']);
                $archive_year    = date('Y',$all['0']['archivedate']);
                $archive_hour    = date('H',$all['0']['archivedate']);
                $archive_minute    = date('i',$all['0']['archivedate']);
                $archive_second    = date('s',$all['0']['archivedate']);
                $neverarchive    = $all['0']['neverarchive'];
             }
            $changecolor        = 'style="width: 99%" ';
            if($shortstory){
                $newsform_options['toggle_summary'] = "1";
            }
        }
    }else{
        $day    = $_POST['day'];
        $month    = $_POST['month'];
        $year    = $_POST['year'];
        $hour    = $_POST['hour'];
        $minute    = $_POST['minute'];
        $second    = $_POST['second'];


        $archive_day    = (empty($_POST['archive_day'])) ? '' : $_POST['archive_day'];
        $archive_month    = (empty($_POST['archive_month'])) ? '' : $_POST['archive_month'];
        $archive_year    = (empty($_POST['archive_year'])) ? '' : $_POST['archive_year'];
        $archive_hour    = (empty($_POST['archive_hour'])) ? '' : $_POST['archive_hour'];
        $archive_minute    = (empty($_POST['archive_minute'])) ? '' : $_POST['archive_minute'];
        $archive_second    = (empty($_POST['archive_second'])) ? '' : $_POST['archive_second'];
        $neverarchive    = (empty($_POST['neverarchive'])) ? '' : $_POST['neverarchive'];


        $allowcomments        = htmlspecialchars($_POST['allowcomments']);
        $title                = displayhtml($_POST['title']);
        $shortstory            = displayhtml($_POST['shortstory']);
        $story                = displayhtml($_POST['story']);


        $changecolor        = 'style="width: 99%" ';
        if($_POST['shortstory']){
            $togglesummary = '1';
        }else{
            $togglesummary = '0';
        }
    }

    if($type == "addnews"){
        echo "<form method=\"POST\" name=\"post\" action=\"?action=addnews\">\n";
    }else{
        echo "<form method=\"POST\" name=\"post\" action=\"?action=editnews&id=".htmlspecialchars($_GET['id'])."\">\n";
    }
    echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"692px\">\n";
    echo "<tr>\n";
    echo "\n";
    echo "<td valign=\"top\"  width=\"100%\">\n";

    echo "<div class=\"subheaders\">" . $langmsg['editnews'][7] . "</div>";
    echo "<div class=\"subheaders_body\" style=\"display: block; width: 692px; height: 28px\">";


    echo "<input type=\"text\" name=\"title\" $changecolor class=\"newborder\" value=\"$title\" /></td>\n";
    echo "</div>";
    echo "</tr>\n";
    selectimages();
    #used to let javascript count how many cat sections are shown.






    echo "<tr>";
    echo "<td>";



    #echo "  <hr style=\"clear: both\" />";





    if($_GET['action'] == "addnews"){
        if($_POST['S1']){
            $_POST['selectedfiles'] = (empty($_POST['selectedfiles'])) ? '' : $_POST['selectedfiles'];
            $selectedfiles    = array();
            $selectedfiles    = $_POST['selectedfiles'];
        }
    }else{
        if(!$_POST['S1']){
            $id                    = $_GET['id'];
            $allselectedfiles    = DataAccess::fetch("SELECT fileid FROM " . NEWS_LINKEDFILES . " WHERE storyid = ?", $id);
            $selectedfiles        = array();
            foreach($allselectedfiles AS $row){
                $selectedfiles[] = $row['fileid'];
            }
        }else{
            $selectedfiles = array();
            $_POST['selectedfiles'] = (empty($_POST['selectedfiles'])) ? array() : $_POST['selectedfiles'];
            $selectedfiles = $_POST['selectedfiles'];
        }
    }




    echo "\n\n\n<div style=\"position: absolute; width: 580px; left: 35%; display: none; z-index: 10001\" id=\"filebox\">";
    echo "<div style=\"width:580px; height: 350px; background-color: #FFFFFF padding: 10px; border: 1px solid #AAAAAA position: absolute; left: -190px\">";
    echo "<a style=\"float: right; text-decoration: underline; cursor: pointer\" onclick=\"bbcode('files','story')\">[close]</a>";


    echo "<br />";
    echo "<br />";

    echo "<span style=\"float: right\">";
    echo "<select name=\"news_selectcat\" onchange=\"newsfilechangecatgroup();\" id=\"news_fileselectcat\">";
    echo "<option value=\"1\"></option>";

    $allowedcats = DataAccess::fetch("SELECT " . NEWS_ACCESS . ".cats FROM " . NEWS_USERS . " LEFT JOIN " . NEWS_ACCESS . " ON " . NEWS_USERS . ".access = " . NEWS_ACCESS . ".uid WHERE " . NEWS_USERS . ".user = ?", $_SESSION['name']);
    $allowedcats = $allowedcats['0']['cats'];
    if($allowedcats !== "all"){
        $e = $allowedcats;
        if(!$e){ $e = ''; }else{ $e = "WHERE id IN ($e)"; }
        $selectedcats = DataAccess::fetch("SELECT name, id FROM " . NEWS_CATS . " $e ORDER BY name");
    }else{
        $selectedcats = DataAccess::fetch("SELECT name, id FROM " . NEWS_CATS . " ORDER BY name");
    }

    $g = 2;
    foreach($selectedcats AS $row){
            echo "<option value=\"$g\"";
            if($_GET['catid'] == $row['id']){
                echo " selected=\"selected\"";
            }
            echo ">" . $row['name'] . "</option>";
            $g++;
    }


    echo "</select>";
    echo "</span>";
    echo "<span class=\"header\" style=\"background-color: #FFFFFF padding-left: 0px\">".$langmsg['newsform'][19]."</span>";
    echo '<hr style="clear: both; background-color: #FFFFFF color: #FFFFFF border: 1px solid #FFFFFF" />
    <hr style="clear: both;" />';



    echo "<div style=\"height: 250px; width: 580px; overflow: auto\">";



    #get all files not assigned to cats
    echo "<div id=\"filecat_1\" class=\"show\" style=\"width: 100%\">";
    echo "<table id=\"rows\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">";
    echo "<tr><td width=\"20%\" class=\"tableshead tablerightborder\">".$langmsg['uploadedfiles'][23]."</td><td class=\"tableshead tablerightborder\" width=\"20%\">".$langmsg['uploadedfiles'][12]."</td><td class=\"tableshead tablerightborder\" width=\"15%\">".$langmsg['newsform'][20]."</td><td class=\"tableshead tablerightborder\" width=\"15%\">".$langmsg['uploadedfiles'][24]."</td><td class=\"tableshead tablerightborder\" width=\"15%\">".$langmsg['newsform'][21]."</td><td class=\"tableshead tablerightborder\" width=\"15%\">".$langmsg['uploadedfiles'][25]."</td><td class=\"tableshead\"></td></tr>";
    $currentpath    = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    $currentpath    = "http://" . $currentpath;
    $g                = $currentpath;
    $x                = explode("admin.php",$g);
    $url            = $x[0] . $uploaddir;
    $tmpcolor        = 1;
    $d                = 1;
    $nocatfiles        = DataAccess::fetch("SELECT title,url,filesize,downloadcount,author,timestamp," . NEWS_FILES . ".uid," . NEWS_USERS . ".user FROM " . NEWS_FILES . "
                    LEFT JOIN " . NEWS_USERS . " ON " . NEWS_FILES . ".author = " . NEWS_USERS . ".uid
                    WHERE " . NEWS_FILES . ".uid NOT IN (SELECT storyid FROM " . NEWS_GROUPCATS . " WHERE type = 'file') ORDER BY " . NEWS_FILES . ".uid DESC");
    foreach($nocatfiles AS $row){
        $file = $row['title'];
        if($tmpcolor == "1"){
            $class        = "row1";
            $tmpcolor    = "2";
        }else{
            $class        = "row2";
            $tmpcolor    = "1";
        }
        $uploader = $row['user'];
        $uploaded = date("j-m-y",$row['timestamp']);
        $filename = basename($row['url']);
        $filesize = round($row['filesize'],1) . " KB";
        echo "<tr id=\"x$d\" onmouseover=\"markfield('x$d')\" onmouseout=\"unmarkfield('x$d')\" class=\"$class";
        if(count($selectedfiles) > 0){
            if(in_array($row['uid'],$selectedfiles)){
                echo " rowhighlight";
            }
        }
        echo "\"><td class=\"tablebody tablerightborder\">$file</td><td class=\"tablebody tablerightborder\">$filename</td><td class=\"tablebody tablerightborder\" style=\"text-align: right\">$row[downloadcount]<td class=\"tablebody tablerightborder\">$filesize</td><td class=\"tablebody tablerightborder\">$uploaded</td><td class=\"tablebody tablerightborder\">$uploader</td><td class=\"tablebody\"><input type=\"checkbox\" value=\"$row[uid]\" onclick=\"if(document.getElementById('check_x'+$d).checked == true){ markfield('x$d'); }else{ unmarkfield('x$d') }\" id=\"check_x$d\"";
        $selectedfiles = (empty($selectedfiles)) ? array() : $selectedfiles;
        if(count($selectedfiles) > 0){
            if(in_array($row['uid'],$selectedfiles)){
                echo "checked=\"checked\" ";
            }
        }
        echo " name=\"selectedfiles[]\"></td></tr>";

    $d++;
    }
    echo "</table>";
    echo "</div>";

    $f = 2;
    ##show files for all cats the user can access
    $allowedcats = DataAccess::fetch("SELECT " . NEWS_ACCESS . ".cats FROM " . NEWS_USERS . " LEFT JOIN " . NEWS_ACCESS . " ON " . NEWS_USERS . ".access = " . NEWS_ACCESS . ".uid WHERE " . NEWS_USERS . ".user = ?", $_SESSION['name']);
    $allowedcats = $allowedcats['0']['cats'];
    if($allowedcats !== "all"){
        $a = explode(",",$allowedcats);
        foreach($a as $c){
            echo "<div id=\"filecat_$f\" class=\"noshow\" style=\"width: 100%\">";
            echo "<table id=\"rows\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">";
            echo "<tr><td width=\"20%\" class=\"tableshead tablerightborder\">".$langmsg['uploadedfiles'][23]."</td><td class=\"tableshead tablerightborder\" width=\"20%\">".$langmsg['uploadedfiles'][12]."</td><td class=\"tableshead tablerightborder\" width=\"15%\">".$langmsg['newsform'][20]."</td><td class=\"tableshead tablerightborder\" width=\"15%\">".$langmsg['uploadedfiles'][24]."</td><td class=\"tableshead tablerightborder\" width=\"15%\">".$langmsg['newsform'][21]."</td><td class=\"tableshead tablerightborder\" width=\"15%\">".$langmsg['uploadedfiles'][25]."</td><td class=\"tableshead\"></td></tr>";
            $filecats = DataAccess::fetch("SELECT storyid,catid,type,uid FROM " . NEWS_GROUPCATS . " WHERE catid = ? AND type = 'file'", $c);
            foreach($filecats AS $row){
                $x = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
                $url = str_replace(basename($_SERVER['REQUEST_URI']),$uploaddir,$x);
                $tmpcolor = 1;
                #$selectedfiles = DataAccess::fetch("SELECT title,url,filesize,downloadcount,author,timestamp,uid FROM " . NEWS_FILES . " WHERE uid = ?", $row['storyid']);
                $catfiles = DataAccess::fetch("SELECT title,url,filesize,downloadcount,author,timestamp," . NEWS_USERS . ".user," . NEWS_FILES . ".uid FROM " . NEWS_FILES . "
                LEFT JOIN " . NEWS_USERS . " ON " . NEWS_FILES . ".author = " . NEWS_USERS . ".uid
                WHERE " . NEWS_FILES . ".uid IN (SELECT storyid FROM " . NEWS_GROUPCATS . " WHERE storyid = ? AND type = 'file')", $row['storyid']);
                foreach($catfiles AS $row2){
                    $file = $row2['title'];
                    if($tmpcolor == "1"){
                        $class        = "row1";
                        $tmpcolor    = "2";
                    } else {
                        $class        = "row2";
                        $tmpcolor    = "1";
                    }
                    $filesize = round($row2['filesize'],1) . " KB";
                    $uploader = $row2['user'];
                    $uploaded = date("j-m-y",$row2['timestamp']);
                    $filename = basename($row2['url']);
                    echo "<tr id=\"x$d\" onmouseover=\"markfield('x$d')\" onmouseout=\"unmarkfield('x$d')\" class=\"$class";
                    if(count($selectedfiles) > 0){
                        if(in_array($row2['uid'],$selectedfiles)){
                            echo " rowhighlight";
                        }
                    }
                    echo "\"><td class=\"tablebody tablerightborder\">$file</td><td class=\"tablebody tablerightborder\">$filename</td><td class=\"tablebody tablerightborder\" style=\"text-align: right\">$row2[downloadcount]<td class=\"tablebody tablerightborder\">$filesize</td><td class=\"tablebody tablerightborder\">$uploaded</td><td class=\"tablebody tablerightborder\">$uploader</td><td class=\"tablebody\"><input type=\"checkbox\" value=\"$row2[uid]\" onclick=\"if(document.getElementById('check_x'+$d).checked == true){ markfield('x$d'); }else{ unmarkfield('x$d'
Cevaplar
light100 Konuyu açan
2011'den beri23 mesaj
#2
Lütfen yardim edin ne yapmam gerekiyor <1|2|34567> olmasini istiyorum bende ama <1 |<class="n13_pages_active">2 |34567> oluyor
2008'den beri3.195 mesaj
#3
#$amounttoshow = 15;
kodun başındaki # işaretini kaldırırsan düzelecektir sanırım.
light100 Konuyu açan
2011'den beri23 mesaj
#4
Yardim icin tessekkürler ama o bölüm function allnewsda benim icin önemli olan function newspagintation bölümü üstete yanlis yazmisim function commentspagintationdiye
2008'den beri6.607 mesaj
#5
$pages = '';


olan satırı şu şekilde değiştirip deneyebilir misin:

$pages = "";
light100 Konuyu açan
2011'den beri23 mesaj
#6
Neyazikki olmadi ben sayfanin 7 tane gözükmesi icin dedigim gibi sadece $maxtoshow= 3; den 7 yaptim önceden 3 tane gözükürken hic bir sorun yokdu 7 yapinca bozuldu daha iyi anlaya bilmeniz icin sorunumu resimler koydum


1 sayfada oluyor ama diger sayfalara gidince bozuluyor
2008'den beri1.108 mesaj
#7
Zannedersem

$newpages .= "class=\"n13_pages_active\">$d</span> "

satırında hata var

$newpages .= sprintf("<span class=\"n13_pages_active\">$d</span> "

yaparak bir dene
2008'den beri6.607 mesaj
#8
Gözümden kaçmış. Bir de şu satırı düzenleyebilir misiniz.
$newpages = '';


yerine

$newpages = "";


yazacaksınız.
light100 Konuyu açan
2011'den beri23 mesaj
#9
sdmh degistirirsem bu hata geliyor

Parse error: syntax error, unexpected ';' in /users/tube/www/news/functions.php on line 1209

N3CAT1 yine olmadi :(
2008'den beri6.607 mesaj
#10
Sanırım buldum bu sefer.
$newpages .= "class=\"n13_pages_active\">$d</span> ";


olan satırı aşağıdaki gibi değiştirin (sanırım sizin php dosyanızda da 98. satırda bulunuyor) :

$newpages .= "<span class=\"n13_pages_active\">$d</span> ";
light100 Konuyu açan
2011'den beri23 mesaj
#11
:w00t: Vallah oldu :D cok cok tessekkürler ama birseyi anlamadim sonuncu sayfaya gitdigimde yani 18 sayfaya ozaman 1920212223> diye devam ediyor onlara basinca 1 sayfaya gidiyor ama sayfamin adresinin sonu .php?page=20 oluyor
niye 18 basinca son olan o olmuyor?
light100 Konuyu açan
2011'den beri23 mesaj
#12
Bunu nasil düzelte bilirim bilen varmi?
light100 Konuyu açan
2011'den beri23 mesaj
#13
Bu sorunum icinde yeni bir konumu acmam gerekiyor?
2011'den beri433 mesaj
#14
Toplam kayıt sayısı, o anki sayfa sayısına eşitse devamını gösterme diyeceksin...
light100 Konuyu açan
2011'den beri23 mesaj
#15
Nasil diyecegim?:turned: yeni ögreniyorumda phpyi yardim ederseniz sevinirim
2011'den beri433 mesaj
#16
vallahi okadar kodun içinden çıkamayacağım. İncele vs vs vs. uğraş dur =/
Sıfırdan sayfalama kodu sen de yazabilirsin zor bir şey değil. Takıldığın yerde yardımcı olurum.

Cevabını yaz

Cevap yazmak için giriş yap ya da üye ol. Eski forum kullanıcı adın ve parolanla girebilirsin.