Topic: [HACK] Article Within Multiple Categories
Title: Article Within Multiple Categories
Author: FI-DD
Cutenews Compatibility: 1.3.6 - 1.4.1 (higher versions have such an option built in)
Description: Post 1 article in more then 1 category
Demo: See FI-DD's homepage (in his signature)
username: demo
password: demo
Instructions: All lines refer to the unchanged cutenews 1.3.6. version of each file.
Part 1: addnews.mdu
1. Find (line 41):
if(count($cat_lines) > 0){
echo"<tr>
<td width=\"75\">
Category
<td width=\"575\" colspan=\"2\">
<select name=category tabindex=3>\n
<option value=\"\"> </option>\n";
foreach($cat_lines as $single_line){
$cat_arr = explode("|", $single_line);
$if_is_selected = "";
if($category == $cat_arr[0]){ $if_is_selected = " selected "; }
echo"<option $if_is_selected value=\"$cat_arr[0]\">$cat_arr[1]</option>\n";
}
echo"</select></tr>";
Replace with:
$fp = file($cutepath.'/data/category.db.php');
if(count($fp) > 0){
$i = 0;
foreach($fp as $fo){
$cat_arr = explode('|', $fo);
$lex_arr = explode(',', $item_db[6]);
foreach($lex_arr as $cat_num => $cat_echo){
if ($lex_arr[$cat_num] == $cat_arr[0]){$lex_arr[$cat_arr[0]] = $cat_arr[1];}
}
$echo_cat .= '
<td style="font-size: 10px;">
<label for="cat'.$cat_arr[0].'">
<input type="checkbox"'.($cat_arr[1] == $lex_arr[$cat_arr[0]] ? ' checked' : '').' name="setcat['.$cat_arr[0].']"
id="cat'.$cat_arr[0].'" class="panel" style="border: solid none #ccc;vertical-align: middle;background: transparent;">'.$cat_arr[1].'</label>';
$i++;
if ($i%4 == 0){$echo_cat .= '<tr>';}
}
echo '
<tr>
<td valign="top">Category:</td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="panel">'.$echo_cat.'</table>';
2. Find (line 138):
// Save The News Article In Active_News_File
$all_db = file("./data/news.txt");
Add above:
if (is_array($setcat))
foreach($setcat as $cat => $set){$category .= $cat.',';}
$category = preg_replace('{([,]+)$}', '', $category);
Part 2: editnews.mdu
1. Find (line 28):
// choose only needed news items
if ($category != "" or $author != "" or $member_db[1] == 3){
foreach($all_db as $raw_line){
$raw_arr = explode("|", $raw_line);
if (($category == "" or $raw_arr[6] == $category) and ($author == "" or $raw_arr[1] == $author) and( $member_db[1] != 3 or $raw_arr[1]
== $member_db[2] )){
$all_db_tmp[] = $raw_line;
Replace with:
// choose only needed news items
if ($category != "" or $author != "" or $member_db[1] == 3){
foreach($all_db as $raw_line){
$raw_arr = explode("|", $raw_line);
$cat_arr = explode(',', $raw_arr[6]);
if (($category == "" or ($cat_arr[0] == $category or $cat_arr[1] == $category or $cat_arr[2] == $category or $cat_arr[3] == $category or $cat_arr[4] == $category or $cat_arr[5] == $category or $cat_arr[6] == $category or $cat_arr[7] == $category or $cat_arr[8] == $category or $cat_arr[9] == $category or $cat_arr[10] == $category or $cat_arr[11] == $category or $cat_arr[12] == $category or $cat_arr[13] == $category or $cat_arr[14] == $category or $cat_arr[15] == $category or $cat_arr[16] == $category or $cat_arr[17] == $category or $cat_arr[18] == $category or $cat_arr[19])) and ($author == "" or $raw_arr[1] == $author) and( $member_db[1] != 3 or $raw_arr[1] == $member_db[2] )){
$all_db_tmp[] = $raw_line;
2. Find (line 69):
if($item_db[6] == ""){ $my_cat = "<font color=gray>---</font>"; }
elseif($cat[$item_db[6]] == ""){ $my_cat = "<font color=red>ID [b]$item_db[6][/b]</font>"; }
else{ $my_cat = $cat[$item_db[6]]; }
Replace with:
$cat_arr = explode(',', $item_db[6]);
if (!$cat_arr[0] and !$cat_arr[1] and !$cat_arr[2] and !$cat_arr[3] and !$cat_arr[4] and !$cat_arr[5] and !$cat_arr[6] and !$cat_arr[7] and !$cat_arr[8] and !$cat_arr[9] and !$cat_arr[10] and !$cat_arr[11] and !$cat_arr[12] and !$cat_arr[13] and !$cat_arr[14] and !$cat_arr[15] and !$cat_arr[16] and !$cat_arr[17] and !$cat_arr[18] and !$cat_arr[19]){$my_cat = '[color=#gray]---[/color]';}
elseif (!$cat[$cat_arr[0]]){$my_cat = '[color=#red]ID [b] [/b][/color]'; }
else {
$my_cat = $cat[$cat_arr[0]].', '.$cat[$cat_arr[1]].', '.$cat[$cat_arr[2]].', '.$cat[$cat_arr[3]].', '.$cat[$cat_arr[4]].', '.$cat[$cat_arr[5]].', '.$cat[$cat_arr[6]].', '.$cat[$cat_arr[7]].', '.$cat[$cat_arr[8]].', '.$cat[$cat_arr[9]].', '.$cat[$cat_arr[10]].', '.$cat[$cat_arr[11]].', '.$cat[$cat_arr[12]].', '.$cat[$cat_arr[13]].', '.$cat[$cat_arr[14]].', '.$cat[$cat_arr[15]].', '.$cat[$cat_arr[16]].', '.$cat[$cat_arr[17]].', '.$cat[$cat_arr[18]].', '.$cat[$cat_arr[19]].', ';
$my_cat = preg_replace('[([, ]+)$]', '', $my_cat);
}
3. Find (line 427):
echo"
<tr>
<td valign=middle width=\"75\" valign=\"top\">
Category
<td width=\"464\" colspan=\"3\">
<select name=\"category\" >";
$cat_lines = file("./data/category.db.php");
foreach($cat_lines as $single_line){
$cat_arr = explode("|", $single_line);
if($item_db[6] == $cat_arr[0]){
echo"<option selected=\"selected\" value=\"$cat_arr[0]\">$cat_arr[1]</option>\n";
$selected = TRUE;
}else{ echo"<option value=\"$cat_arr[0]\">$cat_arr[1]</option>\n"; }
}
if(!$selected){ echo"<option selected value=\"\"> </option>"; }
else{ echo"<option value=\"\"> </option>"; }
echo"</select>
<td width=\"103\" valign=\"top\">
</tr>
Replace with:
$fp = file($cutepath.'/data/category.db.php');
if(count($fp) > 0){
$i = 0;
foreach($fp as $fo){
$cat_arr = explode('|', $fo);
$lex_arr = explode(',', $item_db[6]);
foreach($lex_arr as $cat_num => $cat_echo){
if ($lex_arr[$cat_num] == $cat_arr[0]){$lex_arr[$cat_arr[0]] = $cat_arr[1];}
}
$echo_cat .= '
<td style="font-size: 10px;">
<label for="cat'.$cat_arr[0].'">
<input type="checkbox"'.($cat_arr[1] == $lex_arr[$cat_arr[0]] ? ' checked' : '').' name="setcat['.$cat_arr[0].']"
id="cat'.$cat_arr[0].'" class="panel" style="border: solid none #ccc;vertical-align: middle;background: transparent;">'.$cat_arr[1].'</label>';
$i++;
if ($i%4 == 0){$echo_cat .= '<tr>';}
}
echo '
<tr>
<td valign="top">Category:</td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="panel">'.$echo_cat.'</table>';
}
echo "</td></tr>
4. Find (line 653):
$okchanges = TRUE;
Add below:
if (is_array($setcat))
foreach($setcat as $cat => $set){$category .= $cat.',';}
$category = preg_replace('{([,]+)$}', '', $category);
Part 3: shows.inc.php
1. Find (line 281):
$output = str_replace("{title}", $news_arr[2], $template_full);
Add below:
if ($news_arr[6]){
$cat_arr = explode(',', $news_arr[6]);
foreach($cat_arr as $cats){
$news_arr[6] = $cat_arr[0];
$cat_all .= '[url=]'.$cat[$cats].'[/url], ';
}
$cat_all = preg_replace('{, $}', '', $cat_all);
}
$output = str_replace('{category}', $cat_all, $output);
2. Find (line 298):
$output = str_replace("[com-link]","[url=]$news_arr[6]&$user_query\">", $output);
Replace with:
$output = str_replace("[com-link]","<a
href=\"$PHP_SELF?subaction=showcomments&id=$news_arr[0]&archive=$archive&start_from=$my_start_from&ucat=
$news_arr[6]\">", $output);
3. Find (line 483):
if($requested_cats and $requested_cats[$news_arr[6]] == TRUE){ $count_all ++; }
Replace with:
$cat_arr = explode(",", $news_arr[6]);
if($requested_cats and ($requested_cats[$cat_arr[0]] or $requested_cats[$cat_arr[1]] or $requested_cats[$cat_arr[2]] or $requested_cats[$cat_arr[3]] or $requested_cats[$cat_arr[4]] or $requested_cats[$cat_arr[5]] or $requested_cats[$cat_arr[6]] or $requested_cats[$cat_arr[7]] or $requested_cats[$cat_arr[8]] or $requested_cats[$cat_arr[9]] or $requested_cats[$cat_arr[10]] or $requested_cats[$cat_arr[11]] or $requested_cats[$cat_arr[12]] or $requested_cats[$cat_arr[13]] or $requested_cats[$cat_arr[14]] or $requested_cats[$cat_arr[15]] or $requested_cats[$cat_arr[16]] or $requested_cats[$cat_arr[17]] or $requested_cats[$cat_arr[18]] or $requested_cats[$cat_arr[19]]) == TRUE){ $count_all ++; }
4. Find (line 497):
if($category and $requested_cats[$news_arr[6]] != TRUE){ continue; }
Replace with:
$cat_arr = explode(",", $news_arr[6]);
if ($category and ($requested_cats[$cat_arr[0]] or $requested_cats[$cat_arr[1]] or $requested_cats[$cat_arr[2]] or $requested_cats[$cat_arr[3]] or $requested_cats[$cat_arr[4]] or $requested_cats[$cat_arr[5]] or $requested_cats[$cat_arr[6]] or $requested_cats[$cat_arr[7]] or $requested_cats[$cat_arr[8]] or $requested_cats[$cat_arr[9]] or $requested_cats[$cat_arr[10]] or
$requested_cats[$cat_arr[11]] or $requested_cats[$cat_arr[12]] or $requested_cats[$cat_arr[13]] or $requested_cats[$cat_arr[14]] or
$requested_cats[$cat_arr[15]] or $requested_cats[$cat_arr[16]] or $requested_cats[$cat_arr[17]] or $requested_cats[$cat_arr[18]] or $requested_cats[$cat_arr[19]]) != TRUE){continue;}
5. Find (line 507):
$output = $template_active;
Add below:
if ($news_arr[6]){
$cat_arr = explode(',', $news_arr[6]);
foreach($cat_arr as $cats){
$news_arr[6] = $cat_arr[0];
$cat_all .= '<a href="'.$config_http_home_url.'?category='.$cats.'">'.$cat[$cats].'[/url], ';
}
$cat_all = preg_replace('{, $}', '', $cat_all);
}
$output = str_replace('{category}', $cat_all, $output);
unset($cat_all);
6. Find (line 514):
$output = str_replace("[link]","<a href=\"$PHP_SELF?subaction=showfull&id=$news_arr[0]&archive=$archive&start_from=$my_start_from&ucat=$news_arr[6]&$user_query\">", $output);
Replace with:
$output = str_replace("[link]","<a href=\"$PHP_SELF?subaction=showfull&id=$news_arr[0]&archive=$archive&start_from=$my_start_from&ucat=$news_arr[6]\">", $output);
7. Find (line 547):
$output = str_replace("[full-link]","<a href=\"$PHP_SELF?subaction=showfull&id=$news_arr[0]&archive=$archive&start_from=$my_start_from&ucat=$news_arr[6]&$user_query\">", $output);
Replace with:
$output = str_replace("[full-link]","<a href=\"$PHP_SELF?subaction=showfull&id=$news_arr[0]&archive=$archive&start_from=$my_start_from&ucat=$news_arr[6]\">", $output);
8. Find (line 557):
$output = str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&id=$news_arr[0]&archive=$archive&start_from=$my_start_from&ucat=$news_arr[6]&$user_query\">", $output);
Replace with:
$output = str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&id=$news_arr[0]&archive=$archive&start_from=$my_start_from&ucat=$news_arr[6]\">", $output);
That's it!