Jump to content


Alternating Rows


17 replies to this topic

#1 iPsyko

    Young Padawan

  • Members
  • Pip
  • 53 posts

Posted 02 July 2006 - 03:58 PM

Anyone know how to do alternating rows without mysql?

thanks a ton

#2 DanWilliamson

    P2L Jedi

  • Members
  • PipPipPip
  • 650 posts

Posted 02 July 2006 - 04:21 PM

Not too good on this but and index search gives me the idea that mySQL would be your best bet on this although I don't really use to much PHP/MySQL only when needed.

http://www.pixel2life.com/tutorials/All/Al...ernating%20Rows

#3 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 02 July 2006 - 04:50 PM

hi there,

This is simple, I wrote a tutorial for it with mySQL here.

http://www.pixel2lif...showtopic=21893

However, if you dont wan sql simply take out the queries, so you have this.

 <?php

// Change the colours!
define("Bg1", "#FFF");
define("Bg2", "#EEE");

$x = 0;
for ($i = 1; $i <= 10; $i++) 
{
					 
	$x = ($x > 1 ? '0' : $x );
	$loopedBG = ($x > 0 ? Bg1 : Bg2 );		
					 
	echo '<div style="background-color: '. $loopedBG; .'">Text!</div>';  
	$x++;		   
}
?>

Same code, but the while loop is changed to a for.

Anything you dont understand is explained it my tutorial :)

Edited by .Matt, 02 July 2006 - 04:52 PM.


#4 iPsyko

    Young Padawan

  • Members
  • Pip
  • 53 posts

Posted 02 July 2006 - 04:51 PM

yea, i know. but i'm running cutenews.

unfortunately cutenews isnt mysql.

#5 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 02 July 2006 - 04:54 PM

The code above is not designed for sql. You can use that for anything.

You will just need to find where cutenews displays the news articles or whatever you are alternating, and replace some code.

#6 DanWilliamson

    P2L Jedi

  • Members
  • PipPipPip
  • 650 posts

Posted 02 July 2006 - 04:55 PM

View PostiPsyko, on Jul 2 2006, 10:51 PM, said:

yea, i know. but i'm running cutenews.

unfortunately cutenews isnt mysql.

Sorry to be off-topic but I suggest you don't use Cutenews as it's been proven to be easily exploitable.

#7 iPsyko

    Young Padawan

  • Members
  • Pip
  • 53 posts

Posted 02 July 2006 - 04:56 PM

really?

what should i use?

#8 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 02 July 2006 - 05:00 PM

haha, lol. I give up perswading people off cutenews.

Its flatfile, of course its exploitable :)

The best idea is to look upsome of the news posting tutorials on the site, and use them.

Otherwise, snews is becoming quite popular recently.

http://www.solucija.com/home/snews/

There is a flatfile and mysql version.

#9 iPsyko

    Young Padawan

  • Members
  • Pip
  • 53 posts

Posted 02 July 2006 - 05:24 PM

hey, i'm trying your code.

It gives me this error. http://fusionds.net/...Testing%20News/

here's my code.

<?php

// Change the colours!
define("Bg1", "#FFF");
define("Bg2", "#EEE");

$x = 0;
for ($i = 1; $i <= 10; $i++)
{
					
	$x = ($x > 1 ? '0' : $x );
	$loopedBG = ($x > 0 ? Bg1 : Bg2 );		
					
	echo '<div style="background-color: '. $loopedBG; .'"><?PHP
$number=10;
$static="true";
$PHP_SELF = 'index.php'; 
$template="Headlines";
include("/home/fusionds/public_html/downloads/news/Testing News/news/show_news.php");
?></div>';  
	$x++;		  
}
?>


#10 DanWilliamson

    P2L Jedi

  • Members
  • PipPipPip
  • 650 posts

Posted 02 July 2006 - 05:28 PM

Whats line 59 as that is only 23 lines..?

#11 iPsyko

    Young Padawan

  • Members
  • Pip
  • 53 posts

Posted 02 July 2006 - 05:30 PM

	echo '<div style="background-color: '. $loopedBG; .'"><?PHP
\\

this is 59. i dunno what the prob is.

#12 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 02 July 2006 - 05:38 PM

Ok.....i wont bother to correct that code as you are implementing it wrongly. (into the wrong file).

Can you please post the contents of show_news.php please :)

I will add it and you can see :D

Oh and also, the code you have added to my code, you should use on its own where you want to display the news.

Edited by .Matt, 02 July 2006 - 05:38 PM.


#13 iPsyko

    Young Padawan

  • Members
  • Pip
  • 53 posts

Posted 02 July 2006 - 05:43 PM

thanks here it is:

<?PHP

error_reporting (E_ALL ^ E_NOTICE);

$cutepath =  __FILE__;
$cutepath = preg_replace( "'\\\show_news\.php'", "", $cutepath);
$cutepath = preg_replace( "'/show_news\.php'", "", $cutepath);

require_once("$cutepath/inc/functions.inc.php");
require_once("$cutepath/data/config.php");

// If we are showing RSS, include some need variables.
if($template == 'rss'){
   include("$cutepath/data/rss_config.php");
}

//----------------------------------
// Check if we are included by PATH
//----------------------------------
if($HTTP_SERVER_VARS["HTTP_ACCEPT"] or $HTTP_SERVER_VARS["HTTP_ACCEPT_CHARSET"] or $HTTP_SERVER_VARS["HTTP_ACCEPT_ENCODING"] or $HTTP_SERVER_VARS["HTTP_CONNECTION"]){ /* do nothing */ }
elseif(eregi("show_news.php", $PHP_SELF)){
die("<h4>CuteNews has detected that you are including show_news.php using the URL to this file.<br>
This is incorrect and you must include it using the PATH to show_news.php</h4><br>Example:<br>
this is <font color=red>WRONG</font> :&nbsp;&nbsp; &lt;?PHP include(\"http://yoursite.com/cutenews/show_news.php\"); ?&gt;<br>
this is <font color=green>CORRECT</font>:&nbsp;&nbsp; &lt;?PHP include(\"cutenews/show_news.php\"); ?&gt;<br>
<br><BR>// <font size=2>if you think this message shouldn't be shown, open show_news.php and delete it from there</font>");
}
//----------------------------------
// End of the check
//----------------------------------

if(!isset($subaction) or $subaction == ""){ $subaction = $POST["subaction"]; }

if(!isset($template) or $template == "" or strtolower($template) == "default"){ require_once("$cutepath/data/Default.tpl"); }
else{
		if(file_exists("$cutepath/data/${template}.tpl")){ require("$cutepath/data/${template}.tpl"); }
	else{ die("Error!<br>the template <b>".htmlspecialchars($template)."</b> does not exists, note that templates are case sensetive and you must write the name exactly as it is"); }
}

// Prepare requested categories
if(eregi("[a-z]", $category)){
		die("<b>Error</b>!<br>CuteNews has detected that you use \$category = \"".htmlspecialchars($category)."\"; but you can call the categories only with their <b>ID</b> numbers and not with names<br>
	example:<br><blockquote>&lt;?PHP<br>\$category = \"1\";<br>include(\"path/to/show_news.php\");<br>?&gt;</blockquote>");
}
$category = preg_replace("/ /", "", $category);
$tmp_cats_arr = explode(",", $category);
foreach($tmp_cats_arr as $key=>$value){
	if($value != ""){ $requested_cats[$value] = TRUE; }
}

if($archive == ""){
		$news_file = "$cutepath/data/news.txt";
		$comm_file = "$cutepath/data/comments.txt";
}else{
		$news_file = "$cutepath/data/archives/$archive.news.arch";
		$comm_file = "$cutepath/data/archives/$archive.comments.arch";
}

$allow_add_comment						= FALSE;
$allow_full_story						= FALSE;
$allow_active_news						 = FALSE;
$allow_comments						 = FALSE;



//<<<------------ Detarime what user want to do
if( $CN_HALT != TRUE and $static != TRUE and ($subaction == "showcomments" or $subaction == "showfull" or $subaction == "addcomment") and ((!isset($category) or $category == "") or ($requested_cats[$ucat] == TRUE )  ) ){
	if($subaction == "addcomment"){  $allow_add_comment		= TRUE; $allow_comments = TRUE; }
	if($subaction == "showcomments"){ $allow_comments = TRUE; }
	if(($subaction == "showcomments" or $allow_comments == TRUE) and $config_show_full_with_comments == "yes"){$allow_full_story = TRUE; }
	if($subaction == "showfull") $allow_full_story = TRUE;
	if($subaction == "showfull" and $config_show_comments_with_full == "yes") $allow_comments = TRUE;

}
else{
	if($config_reverse_active == "yes"){ $reverse = TRUE; }
		$allow_active_news = TRUE;
}
//----------->>> Detarime what user want to do

require("$cutepath/inc/shows.inc.php");
	if($_GET['archive'] and $_GET['archive'] != ''){ $archive = $_GET['archive']; } // stupid fix ?
unset($static, $template, $requested_cats, $category, $catid, $cat,$reverse, $in_use, $archives_arr, $number, $no_prev, $no_next, $i, $showed, $prev, $used_archives);
?>


#14 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 02 July 2006 - 06:00 PM

Still using cutenews? :) lol

Well.....for starters....how crap is the cutenews source code??!?!??!one!!....

OK, there's nothing in that file that i can apply it to....the strange methods of cutenews...

Lets try: inc/shows.inc.php

#15 iPsyko

    Young Padawan

  • Members
  • Pip
  • 53 posts

Posted 02 July 2006 - 06:06 PM

[code] <?PHP


do{ // Used if we want to display some error to the user and halt the rest of the script

$user_query = cute_query_string($QUERY_STRING, array( "comm_start_from","start_from", "archive", "subaction", "id", "ucat"));
$user_post_query = cute_query_string($QUERY_STRING, array( "comm_start_from", "start_from", "archive", "subaction", "id", "ucat"), "post");
//################################################################################
####################################
// Define Categories
//################################################################################
####################################
$cat_lines = file("$cutepath/data/category.db.php");
foreach($cat_lines as $single_line){
$cat_arr = explode("|", $single_line);
$cat[$cat_arr[0]] = $cat_arr[1];
$cat_icon[$cat_arr[0]]=$cat_arr[2];
}



///////////////////////////////////////////////////////
// Function: Category ID to Name
// Description: convert to category name from ID
if ( !function_exists('catid2name') )
{

function catid2name($thecat){
global $cat;

if(strstr($thecat,',')){
$thecat_arr = explode(',',$thecat);
foreach($thecat_arr as $single_thecat){
if($thecat_not_first){ $thecat_str .= ', '. $cat[$single_thecat]; }
else{ $thecat_str .= $cat[$single_thecat]; }

$thecat_not_first = TRUE;
}

return $thecat_str;

}else{
return $cat[$thecat];
}

}

}

//################################################################################
####################################
// Define Users
//################################################################################
####################################
$all_users = file("$cutepath/data/users.db.php");
foreach($all_users as $user)
{
if(!eregi("<\?",$member_db_line)){
$user_arr = explode("|",$user);
if($user_arr[4] != "")
{
if($user_arr[7] != 1 and $user_arr[5] != ""){ $my_names[$user_arr[2]] = "<a href=\"mailto:$user_arr[5]\">$user_arr[4]</a>"; }
else{ $my_names[$user_arr[2]] = "$user_arr[4]"; }
$name_to_nick[$user_arr[2]] = $user_arr[4];
}
else
{
if($user_arr[7] != 1 and $user_arr[5] != ""){ $my_names[$user_arr[2]] = "<a href=\"mailto:$user_arr[5]\">$user_arr[2]</a>"; }
else{ $my_names[$user_arr[2]] = "$user_arr[2]"; }
$name_to_nick[$user_arr[2]] = $user_arr[2];
}

if($user_arr[7] != 1){ $my_mails[$user_arr[2]] = $user_arr[5]; }
else{ $my_mails[$user_arr[2]] = ""; }
$my_passwords[$user_arr[2]] = $user_arr[3];
$my_users[] = $user_arr[2];
}
}
//################################################################################
####################################
// Activate Postponed Articles
//################################################################################
####################################


ResynchronizePostponed();

//################################################################################
####################################
// Auto-Archive Function
//################################################################################
####################################

if($config_auto_archive == "yes"){
ResynchronizeAutoArchive();
}

//################################################################################
####################################
// Add Comment
//################################################################################
####################################
if($allow_add_comment){

$name = trim($name);
$mail = trim($mail);
$id = (int) $id; // Yes it's stupid how I didn't thought about this :/

//----------------------------------
// Check the lenght of comment, include name + mail
//----------------------------------

if( strlen($name) > 50 ){
echo"<div style=\"text-align: center;\">Your name is too long!</div>";
$CN_HALT = TRUE;
break 1;
}
if( strlen($mail) > 50){
echo"<div style=\"text-align: center;\">Your e-mail is too long!</div>";
$CN_HALT = TRUE;
break 1;
}
if( strlen($comments) > $config_comment_max_long and $config_comment_max_long != "" and $config_comment_max_long != "0"){
echo"<div style=\"text-align: center;\">Your comment is too long!</div>";
$CN_HALT = TRUE;
break 1;
}

//----------------------------------
// Get the IP
//----------------------------------
$foundip = TRUE;
if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");
else {$ip = "not detected"; $foundip = FALSE;}

if( !$foundip or !preg_match("/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", "$ip") ){ $ip = "not detected"; $foundip = FALSE;} //ensure that what we have is a real IP
//----------------------------------
// Flood Protection
//----------------------------------
if($config_flood_time != 0 and $config_flood_time != "" ){
if(flooder($ip, $id) == TRUE ){
echo("<div style=\"text-align: center;\">Flood protection activated !!!<br />you have to wait $config_flood_time seconds after your last comment before posting again at this article.</div>");
$CN_HALT = TRUE;
break 1;
}
}

//----------------------------------
// Check if IP is blocked
//----------------------------------
$blockip = FALSE;
$old_ips = file("$cutepath/data/ipban.db.php");
$new_ips = fopen("$cutepath/data/ipban.db.php", "w");
@flock ($new_ips,2);
foreach($old_ips as $old_ip_line){
$ip_arr = explode("|", $old_ip_line);

//implemented wildcard match
$ip_check_matches = 0;
$db_ip_split = explode(".", $ip_arr[0]);
$this_ip_split = explode(".", $ip);

for($i_i=0;$i_i<4;$i_i++){
// echo"IF $this_ip_split[$i_i] == $db_ip_split[$i_i] or $db_ip_split[$i_i] == '*'<br>";
if ($this_ip_split[$i_i] == $db_ip_split[$i_i] or $db_ip_split[$i_i] == '*') {
$ip_check_matches += 1;
}

}

if ($ip_check_matches == 4) {
$countblocks = $ip_arr[1] = $ip_arr[1] + 1;
fwrite($new_ips, "$ip_arr[0]|$countblocks||\n"); $blockip = TRUE;
} else {
fwrite($new_ips, $old_ip_line);
}

}
@flock ($new_ips,3);
fclose($new_ips);
if($blockip){
echo("<div style=\"text-align: center;\">Sorry but you have been blocked from posting comments</div>");
$CN_HALT = TRUE;
break 1;
}

//----------------------------------
// Check if the name is protected
//----------------------------------
$is_member = FALSE;
foreach($all_users as $member_db_line)
{
if(!eregi("<\?",$member_db_line) and $member_db_line != ""){
$user_arr = explode("|",$member_db_line);

//if the name is protected
if((strtolower($user_arr[2]) == strtolower($name) or strtolower($user_arr[4]) == strtolower($name)) and ($user_arr[3] != $CNpass and $user_arr[3] != md5($password)) and $name != "")
{
//$comments = replace_comment("add", $comments); //commented because will mess up the <br />
$comments = preg_replace(array("'\"'", "'\''", "''"), array("&quot;", "'", ""), $comments);
$name = replace_comment("add", preg_replace("/\n/", "",$name));
$mail = replace_comment("add", preg_replace("/\n/", "",$mail));


echo"<div style=\"text-align: center;\">This name is owned by a registered user and you must enter password to use it<br />
<form name=passwordForm id=passwordForm method=\"post\" action=\"\">
Password: <input type=\"password\" name=\"password\" />
<input type=\"hidden\" name=\"name\" value=\"$name\" />
<input type=\"hidden\" name=\"comments\" value=\"$comments\" />
<input type=\"hidden\" name=\"mail\" value=\"$mail\" />
<input type=\"hidden\" name=\"ip\" value=\"$ip\" />
<input type=\"hidden\" name=\"subaction\" value=\"addcomment\" />
<input type=\"hidden\" name=\"show\" value=\"$show\" />
<input type=\"hidden\" name=\"ucat\" value=\"$ucat\" />
$user_post_query
<input type=\"submit\" /> \n <br>
<input type=\"checkbox\" name=\"CNrememberPass\" value=1 /> Remember password in cookie (md5 format)
</form>
</div>";
$CN_HALT = TRUE;
break 2;

}

if(strtolower($user_arr[2]) == strtolower($name)) $is_member = TRUE;

//----------------------------------
// Member wants to save his pass in cookie ?
//----------------------------------
if($CNrememberPass == 1){
if(file_exists("$cutepath/remember.js")){
echo"<script type=\"text/javascript\" src=\"$config_http_script_dir/remember.js\"></script>";
echo"<script>CNRememberPass('".md5($password)."')</script>";
}
}

}
}

//----------------------------------
// Check if only members can comment
//----------------------------------
if($config_only_registered_comment == "yes" and !$is_member){
echo"<div style=\"text-align: center;\">Sorry but only registered users can post comments, and '".htmlspecialchars($name)."' is not recognized as valid member.</div>";
$CN_HALT = TRUE;
break 1;
}

//----------------------------------
// Wrap the long words
//----------------------------------
if($config_auto_wrap > 1){
$comments_arr = explode("\n", $comments);
foreach($comments_arr as $line){
$wraped_comm .= ereg_replace("([^ \/\/]{".$config_auto_wrap."})","\\1\n", $line) ."\n";
}
if(strlen($name) > $config_auto_wrap){ $name = substr($name, 0, $config_auto_wrap)." ..."; }
$comments = $wraped_comm;
}



//----------------------------------
// Do some validation check 4 name, mail..
//----------------------------------
$comments = replace_comment("add", $comments);
$name = replace_comment("add", preg_replace("/\n/", "",$name));
$mail = replace_comment("add", preg_replace("/\n/", "",$mail));

if($name == " " or $name == ""){
echo("<div style=\"text-align: center;\">You must enter name.<br /><a href=\"java script:history.go(-1)\">go back</a></div>");
$CN_HALT = TRUE;
break 1;
}
if($mail == " " or $mail == ""){ $mail = "none"; }
else{ $ok = FALSE;
if(preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $mail)) $ok = TRUE;
elseif($config_allow_url_instead_mail == "yes" and preg_match("/((http(s?):\/\/)|(www\.))([\w\.]+)([\/\w+\.-?]+)/", $mail)) $ok = TRUE;
elseif($config_allow_url_instead_mail != "yes"){
echo("<div style=\"text-align: center;\">This is not a valid e-mail<br /><a href=\"java script:history.go(-1)\">go back</a></div>");
$CN_HALT = TRUE;
break 1;
}
else{
echo("<div style=\"text-align: center;\">This is not a valid e-mail or site URL<br /><a href=\"java script:history.go(-1)\">go back</a></div>");
$CN_HALT = TRUE;
break 1;
}
}

if($comments == ""){
echo("<div style=\"text-align: center;\">Sorry but the comment can not be blank<br /><a href=\"java script:history.go(-1)\">go back</a></div>");
$CN_HALT = TRUE;
break 1;
}

$time = time()+($config_date_adjust*60);

//----------------------------------
// Add The Comment ... Go Go GO!
//----------------------------------

$old_comments = file("$comm_file");
$new_comments = fopen("$comm_file", "w");
@flock ($new_comments,2);
$found = FALSE;
foreach($old_comments as $old_comments_line)
{
$old_comments_arr = explode("|>|", $old_comments_line);
if($old_comments_arr[0] == $id)
{
$old_comments_arr[1] = trim($old_comments_arr[1]);
fwrite($new_comments, "$old_comments_arr[0]|>|$old_comments_arr[1]$time|$name|$mail|$ip|$comments||\n");
$found = TRUE;
}else{
fwrite($new_comments, $old_comments_line);
//if we do not have the news ID in the comments.txt we are not doing anything (see comment below) (must make sure the news ID is valid)
}
}
if(!$found){
/* // do not add comment if News ID is not found \\ fwrite($new_comments, "$id|>|$time|$name|$mail|$ip|$comments||\n");*/

echo("<div style=\"text-align: center;\">CuteNews did not added your comment because there is some problem with the comments database.<br /><a href=\"java script:history.go(-1)\">go back</a></div>");
$CN_HALT = TRUE;
break 1;
}
@flock ($new_comments,3);
fclose($new_comments);

//----------------------------------
// Sign this comment in the Flood Protection
//----------------------------------
if($config_flood_time != "0" and $config_flood_time != "" ){

$flood_file = fopen("$cutepath/data/flood.db.php", "a");
@flock ($flood_file,2);
fwrite($flood_file, time()."|$ip|$id|\n");
@flock ($flood_file,3);
fclose($flood_file);
}
//----------------------------------
// Notify for New Comment ?
//----------------------------------

if($config_notify_comment == "yes" and $config_notify_status == "active"){
send_mail("$config_notify_email", "CuteNews - New Comment Added", "New Comment was added by $name:\n--------------------------$comments");
}

echo "<script type=\"text/javascript\">window.location=\"$PHP_SELF?subaction=showfull&id=$id&ucat=$ucat&archive=$archive&start_from=$start_from&$user_query\";</script>";
}
//################################################################################
####################################
// Show Full Story
//################################################################################
####################################
if($allow_full_story){

if(!file_exists($news_file)){ die("Error!<br>news file does not exists!"); }
$all_active_news = file("$news_file");

foreach($all_active_news as $active_news)
{
$news_arr = explode("|", $active_news);
if($news_arr[0] == $id and (!$catid or $catid == $news_arr[6]))
{
$found = TRUE;
if($news_arr[4] == "" and (!eregi("\{short-story\}", $template_full)) ){ $news_arr[4] = $news_arr[3]; }

if($my_names[$news_arr[1]]){ $my_author = $my_names[$news_arr[1]]; }
else{ $my_author = $news_arr[1]; }

$output = str_replace("{title}", $news_arr[2], $template_full);
$output = str_replace("{date}", date($config_timestamp_active, $news_arr[0]), $output);
$output = str_replace("{author}", $my_author, $output);
$output = str_replace("{short-story}", $news_arr[3], $output);
$output = str_replace("{full-story}", $news_arr[4], $output);
if($news_arr[5] != ""){$output = str_replace("{avatar}", "<img alt=\"\" src=\"$news_arr[5]\" style=\"border: none;\" />", $output); }
else{ $output = str_replace("{avatar}", "", $output); }
$output = str_replace("{avatar-url}", "$news_arr[5]", $output);
$output = str_replace("{comments-num}", countComments($news_arr[0], $archive), $output);
$output = str_replace("{category}", catid2name($news_arr[6]), $output);
$output = str_replace("{category-id}", $news_arr[6], $output);
if($cat_icon[$news_arr[6]] != ""){ $output = str_replace("{category-icon}", "<img style=\"border: none;\" alt=\"".$cat[$news_arr[6]]." icon\" src=\"".$cat_icon[$news_arr[6]]."\" />", $output); }
else{ $output = str_replace("{category-icon}", "", $output); }

if($config_comments_popup == "yes"){
$output = str_replace("[com-link]","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showcomments&amp;template=$template&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]', '_News', '$config_comments_popup_string');return false;\">", $output);
}else{
$output = str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">", $output);
}
$output = str_replace("[/com-link]","</a>", $output);
$output = str_replace("{author-name}", $name_to_nick[$news_arr[1]], $output);

if($my_mails[$news_arr[1]] != ""){
$output = str_replace("[mail]","<a href=\"mailto:".$my_mails[$news_arr[1]]."\">", $output);
$output = str_replace("[/mail]","</a>", $output);
}else{
$output = str_replace("[mail]","", $output);
$output = str_replace("[/mail]","", $output);
}
$output = str_replace("{news-id}", $news_arr[0], $output);
$output = str_replace("{archive-id}", $archive, $output);
$output = str_replace("{php-self}", $PHP_SELF, $output);
$output = str_replace("{cute-http-path}", $config_http_script_dir, $output);


$output = replace_news("show", $output);

echo $output;
}
}
if(!$found){

//
// Article ID was not found, if we have not specified an archive -> try to find the article in some archive.
//

// Auto-Find ID In archives
//----------------------------------------------------------------------

if(!$archive or $archive == ''){
//get all archives. (if any) and fit our lost id in the most propper archive.
$lost_id = $id;
$all_archives = FALSE;
$hope_archive = FALSE;

if(!$handle = opendir("$cutepath/data/archives")){ echo("<!-- Can not open directory $cutepath/data/archives --> "); }
while (false !== ($file = readdir($handle)))
{
if($file != "." and $file != ".." and !is_dir("./data/archives/$file") and eregi("news.arch", $file))
{
$file_arr = explode(".", $file);
$all_archives[] = $file_arr[0];
}
}
closedir($handle);


if($all_archives){
sort($all_archives);
if(isset($all_archives[1])){
foreach($all_archives as $this_archive){
if($this_archive > $lost_id){ $hope_archive = $this_archive; break;}
}
}else{
if($all_archives[0] > $lost_id){ $hope_archive = $all_archives[0]; break;}
}
}
}

if($hope_archive){
echo"
<center>You are now being redirected to the article in our archives<br>if the redirection fails, please <a href=\"$PHP_SELF?start_from=$start_from&ucat=$ucat&subaction=$subaction&id=$id&archive=$hope_archive&$user_query\">click here</a></center>
<script LANGUAGE=\"JavaScript\">
<!-- Lets hope the archive id is correct.
window.location=\"$PHP_SELF?start_from=$start_from&ucat=$ucat&subaction=$subaction&id=$id&archive=$hope_archive&$user_query\";
// -->
</script>";
}else{
echo("<div style=\"text-align: center;\">Can not find an article with id: <strong>". @(int) htmlspecialchars($id)."</strong></div>");
}


$CN_HALT = TRUE;
break 1;
}
}
//################################################################################
####################################
// Show Comments
//################################################################################
####################################
if($allow_comments){


$comm_per_page = $config_comments_per_page;

$total_comments = 0;
$showed_comments = 0;
$comment_number = 0;
$showed = 0;
$all_comments = file("$comm_file");

foreach($all_comments as $comment_line)
{
$comment_line = trim($comment_line);
$comment_line_arr = explode("|>|", $comment_line);
if($id == $comment_line_arr[0])
{
$individual_comments = explode("||", $comment_line_arr[1]);

$total_comments = @count($individual_comments) - 1;

//show the page with our new comment, if we just added one
/* causes some problems, will be updated !!!
if($allow_add_comment and true){
$comm_start_from = $total_comments-1;
if($config_reverse_comments == "yes"){
$comm_start_from = 0;
}
}
*/

$iteration = 0;
if($config_reverse_comments == "yes"){$iteration = count($individual_comments)+1; $individual_comments = array_reverse($individual_comments); }

foreach($individual_comments as $comment)
{
if($config_reverse_comments == "yes") { $iteration --; }
else{ $iteration ++; }


$comment_arr = explode("|", $comment);
if($comment_arr[0] != "")
{

if(isset($comm_start_from) and $comm_start_from != ""){
if($comment_number < $comm_start_from){ $comment_number++; continue; }
elseif($showed_comments == $comm_per_page){ break; }
}

$comment_number ++;
$comment_arr[4] = stripslashes(rtrim($comment_arr[4]));

if($comment_arr[2] != "none"){
if( preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $comment_arr[2])){ $url_target = "";$mail_or_url = "mailto:"; }
else{
$url_target = "target=\"_blank\"";
$mail_or_url = "";
if(substr($comment_arr[2],0,3) == "www"){ $mail_or_url = "http://"; }
}

$output = str_replace("{author}", "<a $url_target href=\"$mail_or_url".stripslashes($comment_arr[2])."\">".stripslashes($comment_arr[1])."</a>", $template_comment);
}
else{ $output = str_replace("{author}", $comment_arr[1], $template_comment); }

$comment_arr[4] = preg_replace("/\b((http(s?):\/\/)|(www\.))([\w\.]+)([&-~\%\/\w+\.-?]+)\b/i", "<a href=\"http$3://$4$5$6\" target=\"_blank\">$2$4$5$6</a>", $comment_arr[4]);
 

#16 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 02 July 2006 - 06:18 PM

edit: ok, 2 things, your code got cut off because the message if too big to posted on a ipb board, so i edited it a bit and posted back but i cant repost it. (i dont think it would have worked anyway as the only bit posted is the code for viewing full news stories.)

I'm gonna go to bed now, its 12.15am lol, actually feeling pretty ill.

Sorry i cant help, if someone else could take over tonight it would be great :)

Edited by .Matt, 02 July 2006 - 06:23 PM.


#17 iPsyko

    Young Padawan

  • Members
  • Pip
  • 53 posts

Posted 02 July 2006 - 06:21 PM

bah! of course theres an error.

http://fusionds.net/...Testing%20News/

thanks alot for your help man.

Edited by iPsyko, 02 July 2006 - 06:23 PM.


#18 iPsyko

    Young Padawan

  • Members
  • Pip
  • 53 posts

Posted 05 July 2006 - 09:58 AM

It's still not working. unfortunatly.

can anyone help?

thanks





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users