what i have done on my site www.shadowdark.net is made one template with $variables in it for colors that are set by the header include - so each user has the same template, but different colors, but each journal is posted in the 'journal' category (and the community category also has set colors, as does the main site category)

https://cutephp.com/forum/index.php?showtopic=3733

sort by hack has been created, search the forums
it doesnt incorperate the average rating or referrals
but it does incorperate views and comments (search forums HINT: hacks section)

flexer didnt say you couldnt do it

if you do it and make a mysql version im sure lots of people here would like ya
as per the previous names of the cute news branched (aj-fork and p-fork) you might consider naming it sql-fork or something

i dont know sql AT ALL, but im going to consider writing some form of a better functions.php to work nicer when writing files and such

Name: Filter by Author
Author: NyNe
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Adds a variable you can use with your CN include code where you can choose from which user post most be shown.
This doesn't work well when used with pagination. A more advanced way can be found in the next post.
Instructions:
open shows.inc.php

find:

if($category and $requested_cats[$news_arr[6]] != TRUE){ continue; }

add above:

if (isset($show_user) && !stristr("|".$news_arr[1]."|", "|".$show_user."|")) { continue; }

in your include add $show_user = "username";
or if you'd like to make it changable by the user $show_user = $_GET['show_user']; then in the url set ?show_user=username

Name: No News Message
Author: NyNe
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: When there are no news articles ( or just no within a category ) a message is shown.
Instructions:
open ./inc/shows.inc.php
find:

$used_archives[$archive] = TRUE;


add above:

if ($output == "") { echo "Nothing To Display"; }

simple and easy

all it will do is display some text when the category is empty or when there are no posts to be displayed

Name: Sort By most Commented and/or most Viewed.
Author: NyNe
Updated by: FUNimations
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Instructions:
Start with installing the Sort By Hack
As these hacks need the sort by hack. https://cutephp.com/forum/style_emoticons/default/wink.gif

find:

}else{ $count_all = count($all_news); }


If you want to sort by most commented news.
add below:

// Top Comments
$comm_count = file($comm_file);
for ($a = 0; $a < sizeof($all_news); $a++) {
    $news_arr = explode("|", $all_news[$a]);
    foreach ($comm_count as $null => $comm_line)
    {
        if (stristr($comm_line, $news_arr[0]))
        {
            $comm_split = explode("|>|", $comm_line);
            $comm_arr = explode("||", $comm_split[1]);
            $com_number = count($comm_arr);
            $news_c[$a] = $com_number-1;
        }
    }
    if( $news_arr[count($news_arr)-1] == "\n" ) unset($news_arr[count($news_arr)-1]);
    $news_arr[count($news_arr)] = $news_c[$a];
    $all_news[$a] = implode( "|", $news_arr);
}
// Top Comments

For the top views sort hack:
Install the following hack Page View Counter
Put the following under the same place as if you where to install the Top Comments, or put it under the top comments hack.

// Top Views
$cn_do = "get";
include_once($cutepath."/counter.php");
for ($a = 0; $a < sizeof($all_news); $a++)
{
    $news_arr = explode("|", $all_news[$a]);
    if( $news_arr[count($news_arr)-1] == "\n" ) unset($news_arr[count($news_arr)-1]);
    if( isset($counter[$news_arr[0]]) )
        $news_arr[count($news_arr)] = implode( "|", $counter[$news_arr[0]]);
    else
        $news_arr[count($news_arr)] = "||||";
    $all_news[$a] = implode( "|", $news_arr);
}
// Top Views


to use thess hacks:
include show_news.php as if you were including headlines
you might want to make a new template that displays {comments-num} that looks just like the headlines template (create a template based on headlines and add {comments-num} to it somewhere)
remember to set $number = "X"; to determine the top X posts that will be shown, and $sortad="d"; to sort in decending order (largest first)
<!--coloro:blue--><span style="color:blue"><!--/coloro-->this part is a bit tricky, because it could be different for everyone[/color]
$sortby is also a parameter you can use now to determine how you must sort.

<? $static=true; $number="5"; $sortby="Y"; $sortad="d"; $template="topcomments"; include("cutenews/show_news.php"); ?>


In this example we used "Y", though this is supposed to be a number. Now if you look back at the sort By hack you see that every number will sort by a different field.

0 = date
1 = sort by author
...
6 = sort by category

6 being the last slot. Though CN add's a 7th empty slot in as well. These hack will add slots. So the first slot on which you can sort will be number 8. If you have the "top comments" hack installed this 8th slot will order by most commented.
The most viewed hack add's 2 slots. view counter & unique views counter.
These would be slot 8 &  9 if you don't have top comments hack. If you do, these slots will move 1 up.
Other hacks that save data in news.txt will have influece on the slots. So note that the slots may move depending on the kind of data saved in news.txt and the order that new data is saved.

Name: User display system
Author: NyNe
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: makes a list of your registered users to show on your site.
you can now choose the order to display the fields
you also now set which fields to hide from within the file rather than in the include
you now also can set the date format in the file
Instructions:
show_users.php > create in cutenews directory

<?PHP
// Order Start
//    put them in whatever order you want
//    u = usernames
//    n = nicknames
//    r = registration dates
//    a = avatar links
//    p = post counts
//    l = access levels
//    e = emails
// NOTE: these must ALL be set, even if you want them hidden, hide them below
$display1 = "u";
$display2 = "n";
$display3 = "r";
$display4 = "a";
$display5 = "p";
$display6 = "l";
$display7 = "e";
// Order End

// Hiding Start
//    add the letters from above to hide them
// ex: $user_flags = "np"; hides nickname and posts
$user_flags = "";
// Hiding End

// Date Format Start
//    this is the format to display when users joined
//    if you dont know what it is look for the date function on php.net
//    or just leave it alone...
$date_format = "F, d Y @ H:i a";
// Date Format End

// DO NOT EDIT BELOW
error_reporting (E_ALL ^ E_NOTICE);

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

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

$user_query = cute_query_string($QUERY_STRING, array( "sortus","sortad"));

if(isset($bgcolor) && $bgcolor != ""){ $bg = "bgcolor=\"$bgcolor\""; }
  if(!stristr($user_flags, "u")) { $u = "<td $bg> [u]Username[/u]"; }
  if(!stristr($user_flags, "n")) { $n = "<td $bg> [u]Nickname[/u]"; }
  if(!stristr($user_flags, "r")) { $r = "<td $bg> [u]Registration Date[/u]"; }
  if(!stristr($user_flags, "a")) { $a = "<td $bg> [u]Avatar[/u]"; }
  if(!stristr($user_flags, "p")) { $p = "<td $bg> [u]Posts[/u]"; }
  if(!stristr($user_flags, "l")) { $l = "<td $bg> [u]Access Level[/u]"; }
  if(!stristr($user_flags, "e")) { $e = "<td $bg> [u]EMail[/u]"; }

echo "<table border=0 cellspacing=0 cellpadding=0 ><tr>";
  echo $$display1.$$display2.$$display3.$$display4.$$display5.$$display6.$$display7;
echo "</tr>";

$all_users = file("$cutepath/data/users.db.php");
// Sort users v1.0 - Start addblock
if (!isset($sortus)) { $sortus="0"; } if (!isset($sortad)) { $sortad="a"; }
if (isset($sortus)) {
if (!function_exists('sortcmp')) {
 function sortcmp($a, $b) {
  global $all_users, $sortus;

  $users_a = explode('|', $all_users[$a]);
  $users_b = explode('|', $all_users[$b]);

  return strnatcasecmp($users_a[$sortus], $users_b[$sortus]);
 }
}
uksort($all_users, 'sortcmp');
if ($sortad=="d") { $all_users = array_reverse($all_users); }
Unset($sortus);
}
// Sort users v1.0 - End addblock
    $i = 1;
    foreach($all_users as $user_line)
    {
        $i++; $bg = "";
        if($i%2 == 0 && isset($bgcolor) && $bgcolor != ""){ $bg = "bgcolor=\"$bgcolor\""; }
        if(!eregi("<\?",$user_line)){
        $user_arr = explode("|", $user_line);

        if(isset($user_arr[9]) and $user_arr[9] != ''){ $last_login = date('r',$user_arr[9]); }
        else{ $last_login = 'never'; }

        if($user_arr[7]=="0"){$user_email = "[url=ailto:$user_arr[5]>[send mail]</a>]        else{$user_email = "[hidden]";}
        if($user_arr[8]!=""){$user_av = "<a href=$user_arr[8]>[click][/url]";}
        else{$user_av = "[none]";}

        $user_joined = date($date_format,$user_arr[0]);

        switch($user_arr[1]){
        case 1: $user_level = "administrator"; break;
        case 2: $user_level = "editor"; break;
        case 3: $user_level = "journalist"; break;
        case 4: $user_level = "commenter"; break;
        case 5: $user_level = "banned"; break;
        }
  if(!stristr($user_flags, "u")) { $u = "<td> $user_arr[2]"; }
  if(!stristr($user_flags, "n")) { $n = "<td> $user_arr[4]"; }
  if(!stristr($user_flags, "r")) { $r = "<td> $user_joined"; }
  if(!stristr($user_flags, "a")) { $a = "<td> $user_av"; }
  if(!stristr($user_flags, "p")) { $p = "<td> $user_arr[6]"; }
  if(!stristr($user_flags, "l")) { $l = "<td> $user_level"; }
  if(!stristr($user_flags, "e")) { $e = "<td> $user_email"; }
echo "<tr $bg title='$user_arr[2]'s last login was on: $last_login'>";
    echo $$display1.$$display2.$$display3.$$display4.$$display5.$$display6.$$display7;
echo "</tr>";
  }
    }
echo "</tr></table><form method=post action=\"$PHP_SELF?$user_query\" ><select name=sortus >";
    if(!stristr($user_flags, "u")) { echo"<option value=2 "; if($_POST['sortus']=="2"){echo "selected";} echo " >Username</option>"; }
    if(!stristr($user_flags, "n")) { echo"<option value=4 "; if($_POST['sortus']=="4"){echo "selected";} echo " >Nickname</option>"; }
    if(!stristr($user_flags, "r")) { echo"<option value=0 "; if($_POST['sortus']=="0"){echo "selected";} echo " >Registration Date</option>"; }
    if(!stristr($user_flags, "p")) { echo"<option value=6 "; if($_POST['sortus']=="6"){echo "selected";} echo " >Posts</option>"; }
    if(!stristr($user_flags, "l")) { echo"<option value=1 "; if($_POST['sortus']=="1"){echo "selected";} echo " >Access Level</option>"; }
echo "</select>
<select name=sortad >
<option value=d "; if($_POST['sortad']=="d"){echo "selected";} echo " >Descending Order</option>
<option value=a "; if($_POST['sortad']=="a"){echo "selected";} echo " >Ascending Order</option>
</select>
<input type=submit value=Sort >
</form>";
?>

just include the file in whatever page you want

to set an alternating row background color use $bgcolor="#COLOR"; when including the file

ex:

<? $bgcolor="#f7f7f7"; include("cutenews/show_users.php"); ?>


this makes the alternating bgcolor #f7f7f7

33

(0 replies, posted in Hacks & Tricks / FAQ)

*UPDATE*
now requires the following two (2) hacks:


fixed a misunderstanding in the mail path shizzle (delete any folders you created because of this hack in the past)
admin email now set in the config
cute mail function now used
make random password function now used (from functions instead of independantly)
shortened code in general - just made it quicker (hooray for milliseconds!)
updated email vs username checking to work better (CASE INSENSITIVE)


<?PHP
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 lostpass.php - Build 002 - DO NOT EDIT
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
error_reporting (E_ALL ^E_NOTICE);
require_once("./inc/functions.inc.php");
require_once("./data/config.php");
require_once("./skins/${config_skin}.skin.php");
//$PHP_SELF = "";

if($action == "dosend")
{
    if($user == "" or $email == ""){ msg("error", "Error !!!", "All fields are required"); }
    $found = FALSE;
    $all_users = file("./data/users.db.php");
    foreach($all_users as $user_line){
        $user_arr = explode("|", $user_line);
        if(stristr("|".$user_arr[2]."|", "|".$user."|") && stristr("|".$user_arr[5]."|", "|".$email."|")){ $found = TRUE; break;}
    }
    if(!$found){ msg("error", "Error !!!", "The username/email you enter did not match in our users database"); }
    else{

        $new_pass = makeRandomPassword();
     $new_db = fopen("./data/users.db.php", "w");
     foreach($all_users as $all_users_line){
         $all_users_arr = explode("|", $all_users_line);
         if($user != $all_users_arr[2]){
          fwrite($new_db,"$all_users_line");
         }else{
          fwrite($new_db,"$all_users_arr[0]|$all_users_arr[1]|$all_users_arr[2]|".md5($new_pass)."|$all_users_arr[4]|$all_users_arr[5]|$all_users_arr[6]|$all_users_arr[7]|||\n");
         }
     }
     fclose($new_db);

        cute_mail("$email", "Your New Password", "Hello $user,\n Your new password for the ".$_SERVER['SERVER_NAME']." news system is $new_pass, please change this password after you login.");

        msg("info", "Password Sent", "The new password for [b]$user[/b] was sent to [b]$email[/b]");
    }
}
// ********************************************************************************
// LP Main Page
// ********************************************************************************
else{

    echoheader("user","Lost Password");

    echo"<form method=post action=\"$PHP_SELF\"><table border=0 cellpading=0 cellspacing=0 width=\"654\" height=\"59\" >
    <td width=\"18\" height=\"11\">
    <td width=\"71\" height=\"11\" align=\"left\">

    Username<td width=\"203\" height=\"11\" align=\"left\">
        <input type=text name=user seize=20>
    <td width=\"350\" height=\"26\" align=\"left\" rowspan=\"2\" valign=\"middle\">
        If the username and email match in our users database,
 the new password will be automatically mailed to you.
        <tr>
        <td width=\"18\" valign=\"top\" height=\"15\">
          <td width=\"71\" height=\"15\" align=\"left\">
          Email
          <td width=\"203\" height=\"15\" align=\"left\">

        <input type=text name=email size=\"20\">

        </tr>
        <tr>
          <td width=\"18\" valign=\"top\" height=\"15\">
          <td width=\"628\" height=\"15\" align=\"left\" colspan=\"3\">
           

        </tr>
        <tr>
          <td width=\"18\" valign=\"top\" height=\"15\">
          <td         width=\"628\" height=\"15\" align=\"left\" colspan=\"3\">
          <input type=submit value=\"Send me the password\">
        </tr>
        <input type=hidden name=action value=dosend>
        <input type=hidden name=mod value=lostpass>
        <tr>
        <td width=\"18\" height=\"27\">
        <td width=\"632\" height=\"27\" colspan=\"3\">
        </tr></table></form>";

    echofooter();
}

?>


as with the original just place in the cute news directory and link to it

difference between this mod and the original:
this one has better random password generation, better mail delivery, and better email vs username checking

well i dont use the integration script so you'll have to figure it out yourself sometime though this script and the disable comments script in the hacks section *should* both work even with that hack

Title: Article Within Multiple Categories
Author: NyNe
Cutenews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: there are 4 user levels, this hack makes a 5th called 'banned'.
So if you are sick of flames, set it so only registered users can post, get the register.php (and i recomend lostpass.php) and then install this hack so you can set users to banned
The banned status prevents users from logging into the news system, so they can not change their profile information, which is useful with the souped up register.php which has an option to only allow one username per e-mail address
*UPDATE* forces banned users to logout after the login sequence (it didnt let them login before but this is just added security)
Instructions:
open functions.inc.php
find:

(strtolower($member_db[2]) == strtolower($username) && $member_db[3] == $md5_password)


replace with:

(strtolower($member_db[2]) == strtolower($username) && $member_db[3] == $md5_password && $member_db[1] != "5")

open editusers.mdu
find:

   <option value=4>4 (commenter)</option>
    <option selected value=3>3 (journalist)</option>
   <option value=2>2 (editor)</option>
   <option value=1>1 (administrator)</option>


add above:

    <option value=5>5 (banned)</option>


find:

   <tr>
   <td valign="top"> Administrator : have full access and privilegies

     Editor : can add news and edit others posts

     Journalist : can only add and edit own news

     Commenter : only post comments</td>
   </tr>


replace with:

   <tr>
   <td valign="top"> Administrator : have full access and privilegies

     Editor : can add news and edit others posts

     Journalist : can only add and edit own news

     Commenter : only post comments

     Banned : can not do anything</td>
  </tr>


find:

case 4: $user_level = "commenter"; break;


add under:

case 5: $user_level = "banned"; break;


find:

case "4": $level = "commenter"; break;


add under:

case "5": $level = "banned"; break;


find:

if($user_arr[1] == 4){echo" <option value=4 selected>4 (commenter)</option>";}   else {echo" <option value=4>4 (commenter)</option>";}


add above:

if($user_arr[1] == 5){echo" <option value=5 selected>5 (banned)</option>";}   else {echo" <option value=5>5 (banned)</option>";}

open shows.inc.php
find:

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 != "")


add under:

if ($user_arr[1] == "5") {
echo"<div style=\"text-align: center;\">This name is banned from commenting.</div>";
       $CN_HALT = TRUE;
     break 2;
} else {


find:

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


add above:

}

open main.mdu
find:

if($member_db[1] == 4 and $action == "dologin"){ header("Location: $config_http_script_dir/index.php?mod=options&action=personal"); exit; }


add under:

if($member_db[1] == 5 and $action == "dologin"){ header("Location: $config_http_script_dir/index.php?action=logout"); exit; }

Name: Date header for archives
Author: NyNe
CuteNews Compatibility: 1.3.6 - no incompatibility reported yet
Description: look #1

2004
----
jan
feb
...

2003
----
jan
feb
...


Requirements:
this hack requires the auto archive hack (CN 1.4.0 and up has this option built in) AND the date header hack
Discussion Topic: archives by month
Instructions:

open show_archives.php

find:

                    echo"[url=]".date("d M Y",$first_timestamp) ." - ". date("d M Y",$last_timestamp).", ([b]$count[/b])[/url]
";


replace with:

// Archive Date Header
if ($show_ah == true) {
$config_dateheaderformat = "Y";
if ($dateheader != date($config_dateheaderformat, $news_lines[0])) {
    $dateheader = date($config_dateheaderformat, $news_lines[0]);
if (!isset($template) || $template == "") { include ("$cutepath/data/Default_dh.tpl"); }
else { include ("$cutepath/data/".$template."_dh.tpl"); }
$template_active = str_replace("{dateheader}",$dateheader, $template_active);
echo $template_active;
if (!isset($template) || $template == "") { include ("$cutepath/data/Default.tpl"); }
else { include ("$cutepath/data/".$template.".tpl"); }
}}
// Archive Date Header
if (date("F",$first_timestamp) == date("F",$last_timestamp)) { $show_timestamp = date("F",$first_timestamp); } else { $show_timestamp = date("F",$first_timestamp)." - ".date("F",$last_timestamp); }
                 echo"[url=]$show_timestamp, ([b]$count[/b])[/url]
";

*NOTE* you must include $show_ah=TRUE; in your archive include code for this to work properly

look #2

jan 2004
feb 2004
...
jan 2003
feb2003
...

open show_archives.php

find:

.date("d M Y",$first_timestamp) ." - ". date("d M Y",$last_timestamp).


replace with:

.date("F Y",$last_timestamp).

both of the above date formats use "F" which will display the full month name, if you'd like the abreviated month name change F to M
both of the above examples have the post count for the archive in them, if you'd like to remove them find and remove

, ([b]$count[/b])

credit to dateheader hack (LOL i hope someone notices this)

37

(0 replies, posted in Hacks & Tricks / FAQ)

Name: sort users
Author: NyNe
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Sort your users by username instead of by registration date.
Instructions:
open editusers.mdu

find:

    <tr>
    <td width=130 bgcolor="#F7F6F4">
     [u]Username[/u]
    <td width=197 bgcolor="#F7F6F4">
    [u]registration date[/u]
    <td width=2 bgcolor="#F7F6F4">
     
    <td width=83 bgcolor="#F7F6F4">
    [u]written news[/u]
    <td width=132 bgcolor="#F7F6F4">
    [u]Access Level[/u]
    <td width=93 bgcolor="#F7F6F4">
    [u]action[/u]
    </tr>';

    $all_users = file("./data/users.db.php");


replace with:

// Sort users v1.0 - Start addblock
    <tr>
    <td width=120 bgcolor="#F7F6F4">
     [u]Username[/u] [[url=https://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=2&sortad=a]A[/url]][[url=https://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=2&sortad=d]D[/url]]
    <td width=220 bgcolor="#F7F6F4">
    [u]registration date[/u] [[url=https://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=0&sortad=a]A[/url]][[url=https://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=0&sortad=d]D[/url]]
    <td width=2 bgcolor="#F7F6F4">
     
    <td width=90 bgcolor="#F7F6F4">
    [u]posts[/u] [[url=https://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=6&sortad=a]A[/url]][[url=https://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=6&sortad=d]D[/url]]
    <td width=132 bgcolor="#F7F6F4">
    [u]Access Level[/u] [[url=https://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=1&sortad=a]A[/url]][[url=https://cutephp.com/forum/index.php?mod=editusers&action=list&sortus=1&sortad=d]D[/url]]
    <td width=93 bgcolor="#F7F6F4">
    [u]action[/u]
    </tr>';

    $all_users = file("./data/users.db.php");
if (isset($sortus)) {
if (!function_exists('sortcmp')) {
 function sortcmp($a, $b) {
  global $all_users, $sortus;

  $users_a = explode('|', $all_users[$a]);
  $users_b = explode('|', $all_users[$b]);

  return strnatcasecmp($users_a[$sortus], $users_b[$sortus]);
 }
}
uksort($all_users, 'sortcmp');
if ($sortad=="d") { $all_users = array_reverse($all_users); }
Unset($sortus);
}
// Sort users v1.0 - End addblock

credit to the sort news hack (this code was pretty much ripped and made from it)

i have noticed when posting my post cound didnt go up - so... I FIXED IT!
*NOTE* the code below is found ONLY after applying the ADMIN APPROVE HACK
apply the hack first then apply this modification

[edit: The original hack is to be found here: http://willyps.com/willyps/files/cutenews/...prove_0.9.3.zip ]

in addnews.mdu find:

    if ($member_db[1] == 1)
    {
        // Save The News Article In Active_News_File

        $all_db = file("./data/news.txt");

        foreach($all_db as $news_line)
        {

            $news_arr = explode("|", $news_line);

            if($news_arr[0] == $added_time){ $added_time++; }

        }

        $news_file = fopen("./data/news.txt", "w");

        fwrite($news_file, "$added_time|$member_db[2]|$title|$short_story|$full_story|$manual_avatar|$category||\n");

        foreach ($all_db as $line){ fwrite($news_file, "$line");}

        fclose($news_file);


        // Add Blank Comment In The Active_Comments_File

        $old_com_db = file("./data/comments.txt");

        $new_com_db = fopen("./data/comments.txt", "w");

        fwrite($new_com_db, "$added_time|>|\n");

        foreach ($old_com_db as $line){ fwrite($new_com_db, "$line");}

        fclose($new_com_db);



        msg("info","News added", "The news item was successfully added.");
    }

    else
    {
        // Save The News Article In Approve_DB

        $approve_db = file("./data/approve.db.php");

        foreach($approve_db as $news_line)
        {

            $news_arr = explode("|", $news_line);

            if($news_arr[0] == $added_time){ $added_time++; }

        }

        $approve_file = fopen("./data/approve.db.php", "w");

        fwrite($approve_file, "$added_time|$member_db[2]|$title|$short_story|$full_story|$manual_avatar|$category||\n");

        foreach ($approve_db as $line){ fwrite($approve_file, "$line");}

        fclose($approve_file);


        msg("info","News added", "The news item was successfully added and waiting for approval.");
    }

    // Incrase By 1 The Number of Written News for Current User

    $old_user_db = file("./data/users.db.php");

    $new_user_db = fopen("./data/users.db.php", w);

    foreach($old_user_db as $old_user_db_line){

        $old_user_db_arr = explode("|", $old_user_db_line);

        if($username!=$old_user_db_arr[2]){

            fwrite($new_user_db,"$old_user_db_line");

        }

        else {

            $countplus = $old_user_db_arr[6]+1;

            fwrite($new_user_db,"$old_user_db_arr[0]|$old_user_db_arr[1]|$old_user_db_arr[2]|$old_user_db_arr[3]|$old_user_db_arr[4]|$old_user_db_arr[5]|$countplus|$old_user_db_arr[7]|$old_user_db_arr[8]||\n");

        }

    }

    fclose($new_user_db);


replace with:

    if ($member_db[1] == 1)
    {
        // Save The News Article In Active_News_File

        $all_db = file("./data/news.txt");

        foreach($all_db as $news_line)
        {

            $news_arr = explode("|", $news_line);

            if($news_arr[0] == $added_time){ $added_time++; }

        }

$news_file = fopen("./data/news.txt", "w");
fwrite($news_file, "$added_time|$member_db[2]|$title|$short_story|$full_story|$manual_avatar|$category|$disable_comments||\n");
foreach ($all_db as $line){ fwrite($news_file, "$line");}
fclose($news_file);


        // Add Blank Comment In The Active_Comments_File

        $old_com_db = file("./data/comments.txt");

        $new_com_db = fopen("./data/comments.txt", "w");

        fwrite($new_com_db, "$added_time|>|\n");

        foreach ($old_com_db as $line){ fwrite($new_com_db, "$line");}

        fclose($new_com_db);

    // Incrase By 1 The Number of Written News for Current User

    $old_user_db = file("./data/users.db.php");

    $new_user_db = fopen("./data/users.db.php", w);

    foreach($old_user_db as $old_user_db_line){

        $old_user_db_arr = explode("|", $old_user_db_line);

        if($member_db[2]!=$old_user_db_arr[2]){

            fwrite($new_user_db,"$old_user_db_line");

        }

        else {

            $countplus = $old_user_db_arr[6]+1;

            fwrite($new_user_db,"$old_user_db_arr[0]|$old_user_db_arr[1]|$old_user_db_arr[2]|$old_user_db_arr[3]|$old_user_db_arr[4]|$old_user_db_arr[5]|$countplus|$old_user_db_arr[7]|$old_user_db_arr[8]||\n");

        }

    }

    fclose($new_user_db);

        msg("info","News added", "The news item was successfully added.");
    }

    else
    {
        // Save The News Article In Approve_DB

        $approve_db = file("./data/approve.db.php");

        foreach($approve_db as $news_line)
        {

            $news_arr = explode("|", $news_line);

            if($news_arr[0] == $added_time){ $added_time++; }

        }

        $approve_file = fopen("./data/approve.db.php", "w");

        fwrite($approve_file, "$added_time|$member_db[2]|$title|$short_story|$full_story|$manual_avatar|$category||\n");

        foreach ($approve_db as $line){ fwrite($approve_file, "$line");}

        fclose($approve_file);

    // Incrase By 1 The Number of Written News for Current User

    $old_user_db = file("./data/users.db.php");

    $new_user_db = fopen("./data/users.db.php", w);

    foreach($old_user_db as $old_user_db_line){

        $old_user_db_arr = explode("|", $old_user_db_line);

        if($member_db[2]!=$old_user_db_arr[2]){

            fwrite($new_user_db,"$old_user_db_line");

        }

        else {

            $countplus = $old_user_db_arr[6]+1;

            fwrite($new_user_db,"$old_user_db_arr[0]|$old_user_db_arr[1]|$old_user_db_arr[2]|$old_user_db_arr[3]|$old_user_db_arr[4]|$old_user_db_arr[5]|$countplus|$old_user_db_arr[7]|$old_user_db_arr[8]||\n");

        }

    }

    fclose($new_user_db);

        msg("info","News added", "The news item was successfully added and waiting for approval.");
    }

the reason it didnt work right before is the stupid mod didnt tell it to update the post count when it doesnt need to be approved - i havent tested approving news to see if it messes up the count or not but i dont think it will - if it does let me know

Name: search within categories
Author: NyNe
CuteNews Compatibility: 1.3.6 - 1.4.1 (incompatibility in higher versions due to multiple categories)
Description: adds an option in the advanced search where you can select a single category
Instructions:
open search.php

find TWICE:

"user",


add after BOTH:

 "category",

find:

// Show Search Form


add above:

// 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];
}

find:

  <tr>
    <td width="100%" align="right">Author <input type=text value="$user" name=user size="24">
  </tr>


add below:

<!-- search cats -->
HTML;
    if(count($cat_lines) > 0){
  echo"<tr>
  <td width=\"100%\" align=\"right\">
  Category 
  <select name=category>\n
  <option value=\"\" selected>- All -</option>\n";
        foreach($cat_lines as $single_line){
        $cat_arr = explode("|", $single_line);
        if (strlen($cat_arr[1]) > 17) { $cat_arr['disp'] = substr($cat_arr[1], 0, 17 - 3) . '...'; }
          else { $cat_arr['disp'] = $cat_arr[1]; }
              echo"<option value=\"$cat_arr[0]\">$cat_arr[disp]</option>\n";
    }
     echo"</select></tr>";
    }
echo <<<HTML
<!-- search cats -->

find:

$found  = 0;


add below:

$fcat   = FALSE;

find:

if($story and (@preg_match("/$story/i", "$news_db_arr[4]") or @preg_match("/$story/i", "$news_db_arr[3]"))){ $fstory = TRUE;}


add below:

if($category == $news_db_arr[6]){ $fcat = TRUE;}

find:

if($user  and $fuser) { $fuser  = TRUE; }elseif(!$user) { $fuser  = TRUE; }else{ $fuser  = FALSE; }


add below:

if($category  and $fcat) { $fcat  = TRUE; }elseif(!$category) { $fcat  = TRUE; }else{ $fcat  = FALSE; }

find:

$fdate and $ftitle and $fuser and $fstory


add after:

 and $fcat

find:

                                   if($local_id == $news_id){
////////// Showing Result

                    echo"
[b][url=]$item_arr[2][/url][/b] (". date("d F, Y", $item_arr[0]) .")";

////////// End Showing Result
                }


replace with:

// search cats
if($category == $item_arr[6] || $fcat == TRUE || !isset($category)){
    if($local_id == $news_id){ echo"
[b][url=]$item_arr[2][/url][/b] (". date("d F, Y", $item_arr[0]) .")"; }
}
// show cats

Name:  Characters left in comments form
Author: NyNe
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Under system configurations you can limit the length of the comments. With this hack you can let users know how many characters they have left.
*UPDATE, YET AGAIN*
the javascript now alerts the user that they had input too much and their text has been shortened
the script no longer displays negetive numbers (because it shortened the length anyways)
Instructions:

Add the following javascript to all pages that have a CN include and are supposed to show a comments form.
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><script type="text/javascript">
var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0) {
theform.value=theform.value.substring(0,maxlength)
alert('Your message has been shortened because you entered too much!')
lengthleft=0
}
placeholderobj.innerHTML=lengthleft
}
}


function displaylimit(theform,thelimit){
var limit_text='<span id="'+theform.toString()+'">'+thelimit+'</span> characters remaining'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true);
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true);
}
}
</script>
</div>

in shows.inc.php find:

$template_form = str_replace("{config_http_script_dir}", "$config_http_script_dir", $template_form);


add below:

$template_form = str_replace("{config_comment_max_long}", "$config_comment_max_long", $template_form);

find in your add comment template:

<textarea cols="40" rows="6" name="comments" tabindex="3"></textarea>


add after:

<script>displaylimit('document.comment.comments',{config_comment_max_long})</script>


you can edit the comment length under System Configuration

Name: Sort News By (show_news.php)
Author: Flexer & NyNe
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: If you want to sort you news by a specific field like by author, title, ....
Instructions:

this hack will allow you to sort ascending and descending
Add this between

}else{ $count_all = count($all_news); }

and

$i = 0;

of ./inc/shows.inc.php:

// Sort News v1.1 - Start addblock
// To specify sorting, put the following in your include code:
// $sortby = X;
// Where X is a number from 0-6, which mean the following:
// 0 = sort by time
// 1 = sort by author
// 2 = sort by title
// 3 = sort by short story
// 4 = sort by long story
// 5 = sort by avatar
// 6 = sort by category
//
// To specify ascending/descending, put the following in your include code:
// $sortad = X;
// Where X is either "a" or "d"
//
// The lines below will automatically sort your news if news if the sort variables are unset
if (!isset($sortby)) { $sortby="0"; } if (!isset($sortad)) { $sortad="a"; }

// DO NOT EDIT BELOW
if (isset($sortby)) {
$every_news = $all_news;
if (!function_exists('sortcmp')) {
function sortcmp($a, $b) {
global $every_news, $sortby;

$news_a = explode('|', $every_news[$a]);
$news_b = explode('|', $every_news[$b]);

return strnatcasecmp($news_a[$sortby], $news_b[$sortby]);
}
}
uksort($all_news, 'sortcmp');
if ($sortad=="d") { $all_news = array_reverse($all_news); }
unset($sortby, $sortad);
}
// Sort News v1.1 - End addblock


use the following parameters with your CN include news
$sortad, $sortby as explained in the code.

*UPDATE*
choose to generate passwords and send them in emails to users or ask them for passwords

requires the following two (2) hacks:

<?PHP
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 register.php - Build 004a - Configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

// With what level to be registered member.
//  4 = Commenter
//  3 = Journalist
//  2 = Editor
//  1 = Administrator
$register_level = "4";

// Allow multiple users to use same Email Address?
//  yes
//  no
$email_multiple = "no";

// Send password in an email (if no the script will ask for password)
//  yes
//  no
$email_password = "yes";

// Send an email to the admin when a new user signs up?
//  yes
//  no
$email_admin = "no";

// Username Filter
//  These characters will not be allowed in usernames or passwords
$filter = array(" ", "<", ">", "\n", "\r", "|", "'", "\"");

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 END - END - END - END - END -- Do Not Edit Below
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
if ($register_level=="4") $level_mail="Commenter";
if ($register_level=="3") $level_mail="Journalist";
if ($register_level=="2") $level_mail="Editor";
if ($register_level=="1") $level_mail="Administrator";
error_reporting (E_ALL ^E_NOTICE);
require_once("./inc/functions.inc.php");
require_once("./data/config.php");
require_once("./skins/${config_skin}.skin.php");

if($action != "doregister"){
echoheader("user", "$level_mail Registration");

if ($email_password == "no") {
$prompt_password = <<<HTML
    <tr>
      <td width=80>Password: </td>
      <td><input tabindex=3 type=text name=regpassword  style="width:134" size="20"></td>
    </tr>
    <tr>
      <td width=80>Confirm Password: </td>
      <td><input tabindex=4 type=text name=confpassword  style="width:134" size="20"></td>
    </tr>
HTML;
} else { $prompt_password = ""; }

echo<<<HTML
   <table leftmargin=0 marginheight=0 marginwidth=0 topmargin=0 border=0 height=100% cellspacing=0>
    <form  name=login action="$PHP_SELF" method=post>
    <tr>
      <td width=80>
Username: </td>
      <td>
<input tabindex=1 type=text name=regusername  style="width:134" size="20"></td>
    </tr>
    $prompt_password
    <tr>
      <td width=80>Email: </td>
      <td><input tabindex=3 type=text name=regemail  style="width:134" size="20"></td>
    </tr>
    <tr>
      <td width=80>Confirm Email: </td>
      <td><input tabindex=4 type=text name=confemail  style="width:134" size="20"></td>
    </tr>
    <tr>
      <td width=80>Hide Email: </td>
      <td><input type=checkbox name=reghide></td>
    </tr>
     <tr>
      <td></td>
      <td ><input accesskey="s" type=submit style="background-color: #F3F3F3;" value='Register'></td>
     </tr>
    <input type=hidden name=action value=doregister>
    </form>
   </table>
HTML;

echofooter();
}else{
if($email_password == "yes"){ $regpassword = makeRandomPassword(); $confpassword = $regpassword; }
if(!$regusername){ msg("error","Error !!!", "Username can not be blank"); }
if(!$regpassword || !$confpassword || $regpassword != $confpassword)  { msg("error","Error !!!", "Password can not be blank, both fields must match"); }
if(!$regemail || !$confemail || $regemail != $confemail)  { msg("error","Error !!!", "Email can not be blank, both fields must match"); }
if(!preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $regemail)){ msg("error","Error !!!", "Invalid Email."); }
for ($f = 0; $f <= sizeof($filter); $f++) { if (stristr($regusername, $filter[$f])) { msg("error","Error !!!", "Invalid Username."); } }
for ($f = 0; $f <= sizeof($filter); $f++) { if (stristr($regpassword, $filter[$f])) { msg("error","Error !!!", "Invalid Password."); } }

$add_time = time()+($config_date_adjust*60);
if ($reghide=="on") { $hidemail="1"; } else { $hidemail="0"; }

$all_users = file("./data/users.db.php");
foreach($all_users as $null => $user_line) {
    $user_arr = explode("|", $user_line);
    if(stristr("|".$user_arr[2]."|", "|".$regusername."|")){ msg("error", "Error", "This username is already taken"); }
    if($email_multiple=="no" && stristr("|".$user_arr[5]."|", "|".$regemail."|")){ msg("error", "Error", "This email address is registered to another user!"); }
}

$users_file = fopen("./data/users.db.php", "a");
fwrite($users_file, "$add_time|$register_level|$regusername|".md5($regpassword)."||$regemail|0|$hidemail||||||\n");
fclose($users_file);

if ($email_password == "yes"){ cute_mail($regemail, "Registration at $SERVER_NAME", "$regusername, you have registered successfully. \n ---------- \n Your User Level is: $level_mail \n Your Password is: $regpassword \n You can change this once you login. \n ---------- \n You can login here: $config_http_script_dir/ \n Thank You for Registering!"); }
if ($email_admin == "yes") { cute_mail($config_mail_admin_address, "New User: $regusername", "$regusername has registered on your CuteNews system. \n The address used to register was: $regemail \n To delete this user go to the following address: $config_http_script_dir/index.php?mod=editusers&action=dodeleteuser&id=$add_time"); }

if (!isset($config_mail_admin_address) || $config_mail_admin_address == "") { $problem_contact = "our staff"; }
else { $problem_contact = "[url=]".$email_admin_address."[/url]"; }
if ($email_password == "yes"){ msg("user", "$level_mail Added", "You have successfully registered as [b]\"$regusername\"[/b].
Your password has been emailed to [b]\"$regemail\"[/b].
If this information is wrong or you do not recieve your password please contact $problem_contact."); }
else { msg("user", "$level_mail Added", "You have successfully registered as [b]\"$regusername\"[/b].
Your password is [b]\"$regpassword\"[/b].
Your email address is [b]\"$regemail\"[/b].
If this information is wrong please contact $problem_contact."); }
}
?>

credits:
vallgard/VienoZ: send e-mail to successfully registered users
chonz0: confirm password (used to make confirm e-mail)

changes i made:
confirm e-mail instead of confirm password (password isnt asked for anymore)
password is randomly generated, and e-mailed to the user as a way of confirmation (enable/disable this option at top)
usernames can not match existing usernames ( CASE INSENSITIVE )
e-mail address can only be used by one user (enable/disable this option at top)
send mail to admin when user registers (enable/disable this option at top)

if anyone has any other suggestions let me know :-)

mods who see this, please do not delete it
i just need a way to upload the php file so that people can download it
so i am attatching it to this post (i cant edit the attatchment on the post in the hacks section - if someone could make it so i can they can delete this post)

if you dont know what the files below are, go check the hacks section for the post with this name

Name: Date Header
Author: StealthEye
Updated by: Nyne & Jetski
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Show news by date
Look 1

2004
----
jan
feb
...

2003
----
jan
feb
...


Discussion Topic:
Instructions:
for each template you want to have date headers make *TEMP_NAME*_dh
ex: Default_dh, Headlines_dh, extra_dh (the _dh must always be lowercase)
inside these templates you should use {dateheader} to display the date header text
example

<?php
$template_active='<p>{dateheader}</p>
<hr>';
?>

feel free to change the html inside the ' '
(you can format the php method for outputting it in the code below if needed)

Open up inc/shows.inc.php.
find:

                echo $output;
                $showed++;

add above:

// Date Header
if ($show_dh == true) {
$config_dateheaderformat = "l, F jS Y";
if ($dateheader != date($config_dateheaderformat, $news_arr[0])) {
    $dateheader = date($config_dateheaderformat, $news_arr[0]);
if (!isset($template) || $template == "") { include ("$cutepath/data/Default_dh.tpl"); }
else { include ("$cutepath/data/".$template."_dh.tpl"); }
$template_active = str_replace("{dateheader}",$dateheader, $template_active);
echo $template_active;
if (!isset($template) || $template == "") { include ("$cutepath/data/Default.tpl"); }
else { include ("$cutepath/data/".$template.".tpl"); }
}}
// Date Header

*DO THIS ONLY IF YOU WANT THE DATE HEADER TO SHOW ON FULL NEWS PAGES*
find:

                        echo $output;
        }
        }
        if(!$found){
            echo("<div style=\"text-align: center;\">Can not find an article with id: <strong>". @(int) htmlspecialchars($id)."</strong></div>");
                $CN_HALT = TRUE;
                break 1;
    }
}

add above:

// Date Header
if ($show_dh == true) {
$config_dateheaderformat = "l, F jS Y";
if ($dateheader != date($config_dateheaderformat, $news_arr[0])) {
    $dateheader = date($config_dateheaderformat, $news_arr[0]);
if (!isset($template) || $template == "") { include ("$cutepath/data/Default_dh.tpl"); }
else { include ("$cutepath/data/".$template."_dh.tpl"); }
$template_active = str_replace("{dateheader}",$dateheader, $template_active);
echo $template_active;
if (!isset($template) || $template == "") { include ("$cutepath/data/Default.tpl"); }
else { include ("$cutepath/data/".$template.".tpl"); }
}}
// Date Header

in show_news.php find

unset($static, $template, $requested_cats, $category, $catid, $cat,$reverse, $in_use, $archives_arr, $number, $no_prev, $no_next, $i, $showed, $prev, $used_archives);

add inside that code just before

 ,$show_dh

before

);

with your CN include code also put

$show_dh=TRUE;

to activate date headers for that specific Cn include

bump

build 105 released
(fixed all issues with comments, try deleting your fusion posts from the news.txt then re running the script)

*106 released to fix 105*

donno what that is, but sure, make a new post for it so ppl know what to look for

yeah i know im just lazy, i havent fucked with comments in cute yet, so i havent decided to convert them, plus i dont think people need them yet

eh, well i dont plan on making a converter for that then, if fusion news comes out and its that much better people will switch and wont need converters to cute - but for now cute is the better option so a converter is nice to have

no problem, just let me know if it causes any trouble or there's anything missing

future versions might include comment converters

bump

build 102 released

Posts found: 26 to 50 of 52

Pages Previous 1 2 3 Next

CutePHP Forums → Posts by NyNe



The pun_antispam official extension is installed. Copyright © 2003–2009 PunBB.