';
echofooter();
}elseif($action == "doreplace"){
if( !isset($snr_search_in_news) and !isset($snr_search_in_comments) ){ msg("error", "Error !!!", "You must select an option to search in the news or in comments, or both"); }
elseif( !isset($snr_sources) ){ msg("error", "Error !!!", "You must select where to search"); }
elseif( !isset($snr_search_text) or $snr_search_text == ''){ msg("error", "Error !!!", "You must specify a text to search for."); }
$snr_sources[] = 'fake';
foreach($snr_sources as $source){
if($source == 'fake') continue;
if($source == "active"){ $news_file = "./data/news.txt"; $comm_file = "./data/comments.txt"; }
else{ $news_file = "./data/archives/${source}.news.arch"; $comm_file = "./data/archives/${source}.comments.arch"; }
//----------------------------------
// Search in the News
//----------------------------------
if( isset($snr_search_in_news) ){
$all_news_arr = file("$news_file");
$new_db = fopen("$news_file", w);
foreach($all_news_arr as $news_line){
$news_arr = explode("|", $news_line);
if( isset($snr_include_title) ){
$news_arr[2] = preg_replace("'$snr_search_text'", "$snr_replace_text", $news_arr[2]);
}
if( isset($snr_include_short) ){
$news_arr[3] = preg_replace("'$snr_search_text'", "$snr_replace_text", $news_arr[3]);
}
if( isset($snr_include_full) ){
$news_arr[4] = preg_replace("'$snr_search_text'", "$snr_replace_text", $news_arr[4]);
}
if( isset($snr_include_avatar) ){
$news_arr[5] = preg_replace("'$snr_search_text'", "$snr_replace_text", $news_arr[5]);
}
if( isset($snr_include_music) ){
$news_arr[7] = preg_replace("'$snr_search_text'", "$snr_replace_text", $news_arr[7]);
}
$new_news_line = "$news_arr[0]|$news_arr[1]|$news_arr[2]|$news_arr[3]|$news_arr[4]|$news_arr[5]|$news_arr[6]|$news_arr[7]|\n";
fwrite($new_db, $new_news_line);
}
fclose($new_db);
}
//----------------------------------
// Search in the Comments
//----------------------------------
if( isset($snr_search_in_comments) ){
$old_com = file("$comm_file");
$new_com = fopen("$comm_file","w");
foreach($old_com as $line)
{
$line_arr = explode("|>|",$line);
fwrite($new_com,"$line_arr[0]|>|");
$comments = explode("||", $line_arr[1]);
foreach($comments as $single_comment)
{
$single_comment = trim($single_comment);
$comment_arr = explode("|", $single_comment);
if(isset($comment_arr[0]) and $comment_arr[0] != ''){
if( isset($snr_include_name) ){
$comment_arr[1] = preg_replace("'$snr_search_text'", "$snr_replace_text", $comment_arr[1]);
}
if( isset($snr_include_comment) ){
$comment_arr[4] = preg_replace("'$snr_search_text'", "$snr_replace_text", $comment_arr[4]);
}
fwrite($new_com, "$comment_arr[0]|$comment_arr[1]|$comment_arr[2]|$comment_arr[3]|$comment_arr[4]||");
}
}
fwrite($new_com,"\n");
}
}
}
msg("info", "SnR Complete", "Successfully replaced \"$snr_search_text\" with \"$snr_replace_text\"");
}
?>
Historical archive. This is a preserved copy of 36 Degrees Design (2005–2008), the early web-design weblog of Stuart Frisby. It is maintained independently as a piece of web history and is not operated by, affiliated with, or endorsed by Stuart Frisby. If you are the original owner and would like this domain returned, get in touch — it’s yours, no fuss.