Page 2 of 2

PostPosted: Wed Feb 04, 2004 6:40 am
by bozoka45
Ok, I'll look at it and see what I can fudge out, I dont know Perl but I should be able to get it.


PostPosted: Mon Feb 23, 2004 1:25 am
by faithless
plushpuffin wrote:

Here's a shell of what you need. I've left the guts to you, because my server was bugging out on me. Dunno why.

I think what you need to do is call modifynews_toprow hook, and then call modifysave_3 hook. This will simulate editing and saving a news item, hopefully it will be compatible with all other addons. Who knows...

Made some bug fixes as well as complete your "shell"

Code: Select all
$Subs{'AnneRiceUpdate'} = << 'END_SUB';
sub AnneRiceUpdate {
   my $addon = shift;

   $addon->pageHeader('Anne Rice Running...', 1);
   print qq~Starting Anne Rice MegaRun!<br>\n\n\n~;

   my ($fh, $fh2) = EditNewsdat_Start();

   my $stoppermnow = 0;
   ARNDLOOP: while (<$fh>) {
      $stoppermnow = 0;
      chomp $_;

      if ($up <= 1 && $User ne $CurrentUser) {
         # User doesn't have permission for this item
         next ARNDLOOP;
      # Addons: please only hook in here if you're restricting access to items based
      # on permissions. If you're filtering/searching, your hook is later.
      # HOOK: ModifyNews_Permissions
      # if($Addons{'ModifyNews_Permissions'}){my $w;foreach $w (@{$Addons{'ModifyNews_Permissions'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};}

      # BUG FIX: NDLOOP label not accessible from outside
      if ($stoppermnow == 1){
         next ARNDLOOP;

      # let's make all other addons think that we're in modify news
      # first we edit, then we save. taa-daa!
      # note: I have no freaking clue what effect this will have on
      # any other addons that might hook into Edit_TopRow or EditSave_3
      # I hope it doesn't do anything super bad! ;)

      print qq~Running Anne Rice on # $FileCount, $Subject / $newsid<br>\n~;

      # HOOK: ModifyNews_Edit_TopRow
      # if($Addons{'ModifyNews_Edit_TopRow'}){my $w;foreach $w (@{$Addons{'ModifyNews_Edit_TopRow'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};}
      eval $ModifyNews_Edit_TopRow;

      # HOOK: ModifyNews_EditSave_3
      # if($Addons{'ModifyNews_EditSave_3'}){my $w;foreach $w (@{$Addons{'ModifyNews_EditSave_3'}}){my $addon=$w->[2];eval ${$w->[0]};AErr($addon,$@)if $@;};}
      eval $AnneRice_SaveNews;

      my $newsline = JoinDataFile();
      print $fh2 $newsline, "\n";
      $CConfig{'LastBuildOverride'} = ($newstime - 1) if ($newstime - 1) < $CConfig{'LastBuildOverride'};


   if ($CConfig{'AutoBuild_Modify'}) {
   print qq~\n\n\n<br>DONE.<br>\n~;

I don't think addons need to run for this search and replace option.
So I just added an eval statement to run the search and save routines.

Also, I believe the $fh and $fh2 was not closed properly, thus causing some news items to be truncated on my test site. it is now closed properly with close($fh); and close($fh2);

PostPosted: Mon Feb 23, 2004 3:15 am
by plushpuffin
Ah, ok. Good job, faithless. Sorry about the closing of the filehandles, I never actually tested it.

PostPosted: Mon Feb 23, 2004 2:51 pm
by faithless
That screwed up my 2 sites badly before I found out bout the unclosed file handles. thankfully I had some backups on hand. (I can't believe I forgot to backup before trying)

some news were lost, but later swiftly restored.

PostPosted: Tue Feb 24, 2004 5:29 pm
by plushpuffin
:) sorry for the trouble, but as I said, it was just a skeleton, and I didn't actually test it.

PostPosted: Wed Feb 25, 2004 1:39 am
by faithless
plushpuffin wrote::) sorry for the trouble, but as I said, it was just a skeleton, and I didn't actually test it.

It's ok. I don't blame you. :lol:

PostPosted: Tue Dec 21, 2004 3:08 pm
by bozoka45
Dont know why I never noticed this before, but now I'm trying to get this addon up and running 100%.

Have you gotten it working, faithless? It seems as though I can never get the "eval" function to run. I'm suspecting that while the addon is "working" its not going through the regexp part, which is called through eval.

Anyone have any ideas as to why eval wouldn't work?

PostPosted: Tue Dec 21, 2004 3:33 pm
by faithless
No idea. The above still works for me.

PostPosted: Tue Dec 21, 2004 3:42 pm
by bozoka45
Its weird cause I tried using eval in my FakeSQL addon and it didn't work there either. :confused:

Time to do a little googling. Maybe my eval is broken.

PostPosted: Tue Dec 21, 2004 4:17 pm
by bozoka45
Tried using this code in the same directory as Coranto and it worked fine:

Code: Select all

print "Content-type: text/html\n\n";

my $eval = << 'END_CODE';
   print "Hello!";

eval $eval;


PostPosted: Wed Dec 22, 2004 5:34 am
by faithless
Check to see if you removed all the extra spaces after the lines that phpBB inserts in all pasted code, and also, check that you didn't have any line breaks where they arn't supposed to be.

PostPosted: Wed Dec 22, 2004 5:58 am
by bozoka45
Doesn't look like there are any linebreaks and I trimmed all the lines.