1 (edited by 2004-12-21 15:21:58)

Topic: Admin Approve Hack Fix

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