Need help! I use a news script, but the sorting pages (pagination) is not very nice! Hope someone can help me out to get a better way to sort the pages.
Here's the site: CearáBowl
Now, would like to add a bbcode area on text box:
Hope someone can help me out! I've tried many times to make the changes, but no luck so far!
Here's the site: CearáBowl
Code:
[FONT=Arial][SIZE=2]//HEAD
echo '<p align="center"><strong><img src="imagens/icons/16x16/football3.png" width="16" height="16" align="absmiddle" > CENTRAL DE NOTÍCIAS <img src="imagens/icons/16x16/football3.png" width="16" height="16" align="absmiddle" ></strong> </p> ';
if(USER_ADD_NEWS == TRUE) {
echo '<small> - <a href="?do=6">Adicionar Notí</a><br /></small>';
}[/SIZE][/FONT]
[FONT=Arial][SIZE=2] //CAT
$sqlc1 = "SELECT COUNT(*) FROM mns_cat";
$qc1 = mysql_query($sqlc1);
$rc1 = mysql_fetch_array($qc1);[/SIZE][/FONT]
[FONT=Arial][SIZE=2] if(@$_GET["cid"]) {
$cid = trim($_GET["cid"]);
$cid = intval($cid);
if($cid < 0) { exit('-1'); }
}[/SIZE][/FONT]
[FONT=Arial][SIZE=2] if($rc1[0] != 0) {
echo '<div class="text"><img src="imagens/icons/mini-category.png" width="12" height="12"><small><strong> Categorias:</strong> <br /></small>';
$sql = "SELECT * FROM mns_cat ORDER BY cat_id ASC LIMIT 10";
$query = mysql_query($sql) or die(mysql_error());
while($res = mysql_fetch_array($query)) {
$sqlc = "SELECT COUNT(*) FROM mns_news WHERE news_cat = {$res["cat_id"]}";
$qc = mysql_query($sqlc);
$rc = mysql_fetch_array($qc);
if($res["cat_id"] == $cid) {
echo '<small>>></small>';
$categ_n = $res["cat_name"];
$qqq = 1;
}
if(empty($res["cat_about"])) {
$br = '';
} else $br = '<br />';
echo '<small>- <a href="?cid='.$res["cat_id"].'">'.stripslashes($res["cat_name"]).'</a> ['.$rc[0].'] </i> </small> '.$br;
$br = '';
}
$sql2 = "SELECT COUNT(*) FROM mns_news";
$q = mysql_query($sql2);
$r = mysql_fetch_array($q);
echo '<br /><small><a href="?all">Todas as Notícias</a> ['.$r[0].']</small></div>';
}
if(@!$cid) {
echo '<br /><img src="imagens/icons/newspaper.png" width="12" height="12"><small><strong> Últimas Notícias:</strong></small>';
} else {
echo '<br /><img src="imagens/icons/mini-category.png" width="12" height="12"> <small><strong>Categoria: '.stripslashes($categ_n).'</strong></small>';
if(@!$qqq) exit('error');
}
//<<
//<<
if(@!$cid) {
$sql = "SELECT * FROM mns_news ORDER BY news_date $sort1 LIMIT 10";
} else {
$sql = "SELECT * FROM mns_news WHERE news_cat='".mysql_escape_string($cid)."' ORDER BY news_date $sort1 LIMIT 10";
}
$query = mysql_query($sql) or die(mysql_error());
while($res = mysql_fetch_array($query)) {
$sqlr = "SELECT * FROM mns_cat WHERE cat_id='{$res["news_cat"]}'";
$queryr = mysql_query($sqlr) or die(mysql_error());
$resr = mysql_fetch_array($queryr);
if($c == 1) $c = $c+1; else $c = $c - 1;
$texte = new bbcode(stripslashes($res["news_text"]));
$texte -> mnemonics = $smiles;
$texte = $texte -> get_html();
if(strlen($texte) > $main_ch) {
$full = ' <a href="?do=1&id='.$res["news_id"].'&sort='.$sort.'">...</a>';
} else $full = '';
$texte = substr($texte, 0, $main_ch);
$sql2 = "SELECT COUNT(*) FROM mns_comm WHERE news_id='{$res['news_id']}'";
$q = mysql_query($sql2);
$count = mysql_fetch_array($q);
if(empty($resr["cat_name"])) {
$resr["cat_name"] = 'Uncategorized';
}
echo $b[$c].'<br /><div class="n"> <small><strong> <a href="?do=1&id='.$res["news_id"].'&sort='.$sort.'">'.stripslashes($res["news_theme"]).'</a> </strong> ['.date("d/m/y - H:i", $res["news_date"]).'] </small> </div> <small>
'.$texte.' '.$full.' <br />
<a href="?do=1&id='.$res["news_id"].'&sort='.$sort.'">Ler Mais</a>|<a href="?do=2&id='.$res["news_id"].'">Comentários</a> ['.$count[0].'] <img src="imagens/icons/mini-comment.png" width="12" height="12"><hr />
</small> </div>';
}
$sql2 = "SELECT COUNT(*) FROM mns_news";
$q = mysql_query($sql2);
$r = mysql_fetch_array($q);
if($st > $r[0]) {
exit('>');
}
echo '<div class="beg2">
<small>';
for($i=0;$i<=($r[0]/$fu);$i++) {
if($st == ($i*$fu)) {
echo '['.($i+1).'';
} else {
echo '[<a href="?st='.($i*$fu).'&sort='.$sort.'&cid='.$cid.'">'.($i+1).'</a>';
}
if($i<($r[0]/$fu)) echo ']';
}
echo '</small></div>';[/SIZE][/FONT]
Code:
[FONT=Arial][SIZE=2]//1st value
case 1: { //Add news
if(@$_POST["add"]) {[/SIZE][/FONT]
[FONT=Arial][SIZE=2] $theme = trim($_POST["theme"]);
if(empty($theme)) {
exit('THEME ERROR');
}
$theme = strip_tags($theme);
$theme = mysql_escape_string($theme);[/SIZE][/FONT]
[FONT=Arial][SIZE=2] $text = trim($_POST["text"]);
if(empty($text)) {
exit('TEXT ERROR');
}
$text = strip_tags($text);
$text = mysql_escape_string($text);[/SIZE][/FONT]
[FONT=Arial][SIZE=2] if(@$_POST["comm"]) {
$comm = trim($_POST["comm"]);
$comm = strip_tags($comm);
$comm = mysql_escape_string($comm);
}[/SIZE][/FONT]
[FONT=Arial][SIZE=2] if(@$_POST["img"]) {
$img = trim($_POST["img"]);
$img = strip_tags($img);
$img = mysql_escape_string($img);
}[/SIZE][/FONT]
[FONT=Arial][SIZE=2] if(@$_POST["links"]) {
$links = trim($_POST["links"]);
$links = strip_tags($links);
$links = mysql_escape_string($links);
}[/SIZE][/FONT]
[FONT=Arial][SIZE=2] if(@$_POST["cop"]) {
$cop = trim($_POST["cop"]);
$cop = strip_tags($cop);
$cop = mysql_escape_string($cop);
}[/SIZE][/FONT]
[FONT=Arial][SIZE=2] if($_POST["n_cat"]) {
$n_cat = trim($_POST["n_cat"]);
if(!is_numeric($n_cat)) $n_cat = 0;
} else $n_cat = 0;
#########
#########
#########
for($i=1;$i<=$cfd;$i++) {[/SIZE][/FONT]
[FONT=Arial][SIZE=2]if($_FILES["file$i"]["size"]) {
if($_FILES["file$i"]["size"] > 1024*$mbf*1024) {
echo ("files size exceeded $mbf MB!. files not loaded!");[/SIZE][/FONT]
[FONT=Arial][SIZE=2] $ftg = FALSE;
} else {
$ftg == TRUE;[/SIZE][/FONT]
[FONT=Arial][SIZE=2] }
if($ftg !== FALSE) {[/SIZE][/FONT]
[FONT=Arial][SIZE=2] $ext = strrchr($_FILES["file$i"]["name"], '.');
if(!stristr($fext, $ext)) {[/SIZE][/FONT]
[FONT=Arial][SIZE=2] exit('invalid extensions.');
}
$end = $end.$ext;
if(is_file($dir_f.$_FILES["file$i"]["name"].$end)) {
$end = $end.mt_rand(1111,9999).'_'.$ext;[/SIZE][/FONT]
[FONT=Arial][SIZE=2] }
@chmod($dir_f, 0777);
if(move_uploaded_file($_FILES["file$i"]["tmp_name"], $dir_f.$_FILES["file$i"]["name"].$end)) {
@chmod($dir_f.$_FILES["file$i"]["name"].$end, 0777);
@$links = $links.mysql_escape_string(' #FILE#'.$_FILES["file$i"]["name"].$end);
} else echo 'File not loaded. error!';
}
}
}[/SIZE][/FONT]
[FONT=Arial][SIZE=2]
########
########
########
$date = mysql_escape_string(time());
@$sql_add = "INSERT INTO mns_news VALUES (
'', '$theme', '$text', '$date', '$img' , '$links', '$cop', '$n_cat'
)";
mysql_query($sql_add) or die(mysql_error());
$news_id = mysql_insert_id();
if($comm) {
$sql_c_comm = "INSERT INTO mns_comm VALUES (
'', '$login', '$comm', '$date', '$news_id'
)";
mysql_query($sql_c_comm) or die(mysql_error());
}
if($_POST["mail"]) { // (Email Module)
$headers = "From: ".MAIL_FROM."\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
$headers .= "Content-Type: text/plain; charset=\"utf-8\"\r\n";
$headers .= "X-Mailer: PHP v.".phpversion();
$sql = "SELECT * FROM mns_mail";
$q = mysql_query($sql);
$mes1 = str_replace('{[THEME]}', $_POST["theme"], $newMAIL);
$mes2 = str_replace('{[NEW]}', $_POST["text"], $mes1);
$mes3 = str_replace('{[DATE]}', date("d/m/y - H:i",$date), $mes2);
while($res = mysql_fetch_array($q)) {
@mail($res["user_mail"], MAIL_THEME, $mes3, $headers);
}
}
echo '<br /><div class="text">INFO: Notícia Adicionada!</div>';
} else {
$sql2 = "SELECT COUNT(*) FROM mns_cat";
$q = mysql_query($sql2);
$r = mysql_fetch_array($q);
if($r[0] == 0) {
echo '<small>Warning You have not created any categories of news! You can add news without categories. To create a category, go <a href="?do=8">here</a>.</small>';
}
echo '<strong><small>» Adicionar Notícia</small></strong> <br /><br /><form action="'.$_SERVER["PHP_SELF"].'?do=1" method="POST" enctype="multipart/form-data">
<div class="text">
<strong><small>Título: </small></strong> <br />
<input type="text" name="theme" class="q"> <br />
<strong><small>Descrição:</small></strong> <br />
<textarea name="text" class="q" cols="26" rows="9"></textarea> <br />
<small> BBCODE ativo para notícias e comentários </small>
<br />
<strong><small>Categoria:</small></strong> <br />
<select size="1" name="n_cat" class="q">
<option selected>ESCOLHER CATEGORIA</option>';
$sq = mysql_query("SELECT * FROM mns_cat");
while($sql_r = mysql_fetch_array($sq)) {
echo '<option value="'.$sql_r["cat_id"].'">'.htmlspecialchars(stripslashes($sql_r["cat_name"])).'</option>';
}
echo '</select>
<br />
<strong><small>Imagem</strong> <br /> endereço completo (com http://)</small> <br />
<input type="text" name="img" class="q">
<br />
<strong><small>Link da Notícia</strong> <br /> (com http://)</small> <br />
<input type="text" name="links" class="q">
<br />
<strong><small>Copyright</strong> </small> <br />
© <input type="text" name="cop" class="q">
<br />
<strong><small>Arquivos para Download</strong> [maximo '.$mbf.' MB] <br /> ('.$fext.')</small> <br />
<div class="f">';
for($i=1;$i<=$cfd;$i++) {
echo '<br /> <input type="file" name="file'.$i.'" class="q">';
}
echo '</div>
<strong><small>Adicionar comentário:</small></strong> <br />
<textarea name="comm" class="q" cols="26" rows="3"></textarea> <br />
<strong><small>Enviar notícia para os cadastrados?</small></strong> <input type="checkbox" name="mail" value="1" class="q"> <br />
<small>Obs: Se tiver muitos cadastrados, esta operação pode vir a demorar.</small> <br />
<input type="submit" name="add" value="add" class="q"> <small> <a href="./smileys.php">smiley</a> </small>
</div>
</form>';
}
} break;
[/SIZE][/FONT]