Topic: [HACK] Ensure Comm_File Validity
Name: Ensure Comm_File Validity
Author: NyNe
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description:
CuteNews did not added your comment because there is some problem with the comments database.
This will run through your news.txt and collect news IDs, and match them to IDs in comments.txt, if there is an ID in comments.txt thats not in news.txt it will remove the line - if there is a missing ID in comments.txt it will create a comment line so that new comments can be added.
this is very useful for those of you (like me) who have tampered with your news.txt or comments.txt and need it fixed
Instructions:
Step 1:
If your entire comments.txt is empty, make a seperate file (name it anything you want, as long as you can find it afterwards) with the .php extension naturally, wich you'll locate inside the CuteNews Root directory.
Inside put this code<?php echo "Done"; $news_file = "data/news.txt"; $comm_file = "data/comments.txt"; //CODE FROM STEP 3 HERE// ?>
In the case of a completly empty comments.txt this is usually due to too many spam comments. So get some spam protection.
Ofcourse, having alot of news without having ever archived can cause this as well.
When you're done making this file. Go to it 1 time with your browser. The page WILL only show the word "Done".
Running this file a second time migth corrupt your comments.txt again.Step 2:
If it's just 1 article that randomly has this problem
open ./inc/shows.inc.php
find://################################################################################ #################################### if($allow_comments){
add above:
the code from step 3Step 3:
// Ensure $comm_file is valid - Start AddBlock // build news $news_db = file("$news_file"); foreach($news_db as $null => $news_db_line){ $item_arr = explode("|", $news_db_line); $news_item[$item_arr[0]]['n'] = true; $news_item[$item_arr[0]]['nv'] = $item_arr[0]."|>|"; } // build comments $comm_db = file("$comm_file"); foreach($comm_db as $null => $comm_db_line){ $item_arr = explode("|", $comm_db_line); $news_item[$item_arr[0]]['c'] = true; $news_item[$item_arr[0]]['cv'] = str_replace("\n", "", $comm_db_line); } // run validation rsort($news_item); reset($news_item); $fp = fopen($comm_file, "wb"); foreach($news_item as $null => $comm_item){ if ($comm_item['n'] == true) { if ($comm_item['c'] == true) { $news_comm = $comm_item['cv']."\n"; } else { $news_comm = $comm_item['nv']."\n"; } fwrite($fp, $news_comm); } } fclose($fp); // Ensure $comm_file is valid - End AddBlock