61
Tobias
Re: Akismet implementation for Xoops
  • 2007/2/25 16:06

  • Tobias

  • Not too shy to talk

  • Posts: 172

  • Since: 2005/9/13


Well, I guess I revived the thread myself, by posting that I had a little solution.

The problem is that it's just a hack which has to be implemented on a module by module basis. There is also a difference whether you use PHP 4 or PHP 5, so you'll have to experiment a little on your own. It also seems you are interested in implementing it on the system-wide comment function. I don't know where the comment function writes the comment to the database, or where otherwise to catch a comment and test it against Akismet in the most efficient way. I think one could dig a little and find a good spot to apply the hack. But there're more qualified people here to help out with that bit of information. It must also depend on the XOOPS version you're using. The question to be asked being: Where can I catch the system as it is writing a comment to the database in XOOPS version XY?

Now, if you want to use it on some individual module where your users can submit something, You also will have to find the correct spot in the php code where the submission is written to the database. I think you have a fair chance of finding it if you look for the words "INSERT INTO" in files called "post.php" or "sumbit.php" inside the module folder.

Once you found a good place for your operation and are ready to go, you, of course, need the Akismet class for the PHP version your server is running. In my last post is a link to a page which links to the two in question, for PHP4 and PHP5. You also need the Akismet API key. But it looks like you have one already.

You drop that Akismet class (a php file) somewhere handy in your file structure. Let's assume into the "class" folder, because it sounds like a good place for it

Then the operation:

1. You call the class from the place you have identified as a good one to perform the check, again I assume it's immediately before a line which instructs the database server to write the comment to the database. (I think that's a good place, because that's where you have performed all your local checks, and the variables are all set up).

2. You identify the relevant variables which you pass on to the Akismet class. At least, you need to know what variable the body of the submission comes wrapped into. In the code below, you replace the variables you would have to replace "$submission_author" and "$submission_body" with the relevant variables from the module you're hacking.

2. You perform the check

3. If spam check returns positive, you abort the dtabase writing process and return something, perhaps send yourself an email if you don't have a problem with shifting to spamming from your blog to your email account.

4. If spam check returns negative, you just let the script do whatever it wanted to do anyway.

Both Akismet classes (for PHP4 and 5) come with instructions and a ready made code snippet which you slightly adapt, and then can use to call the relevant function. For me, WF-Links and PHP5, this code used to call the class/function looks something like this (red needs attention):
// start Akismet hack
include_once [color=CC0000]XOOPS_ROOT_PATH '/class/Akismet.class.php'[/color];
$WordPressAPIKey =  '[color=CC0000]yourAkismetkey[/color]';
$MyBlogURL '[color=CC0000]http://www.yoursite.tld/modules/whatevermodule[/color]';
$name = [color=CC0000]$submission_author[/color];
$comment = [color=CC0000]$submission_body[/color];

$akismet = new Akismet($MyBlogURL ,$WordPressAPIKey);
$akismet->setCommentAuthor($name);
$akismet->setCommentAuthorEmail($email);
akismet->setCommentAuthorURL($url);
$akismet->setCommentContent($comment);
$akismet->setPermalink('[color=CC0000]http://www.yoursite.tld/modules/linkToAnActualPageWhereUsersCanSubmitSomething[/color]');
if(
$akismet->isCommentSpam()){
// Here, the routine you want to perform when spam is caught
redirect_header'index.php'2, [color=CC0000]'Your submission looks like spam to us'[/color]);
exit();
}
// end Akismet, store the submission normally


From there, again, you hand it back to the original script which should go on with something like a line containing "INSERT INTO" and which stores the submission in the database.

This will just stop everything identified by Akismet as spam and never tell you about it. If you care about a notification, you can send yourself an email, or you can also create a database table to which to write your spam. But that's a more complex operation.

If you only want to check if user hasn't logged in or is anonymous, you have to wrap the entire thing into the corresponding test.

Hope that helps a little. Sorry I cannot be more precise, but it depends on a whole lot of things. Perhaps you can do something with it.
www.affvu.org



62
Tobias
Re: Akismet implementation for Xoops
  • 2007/2/23 22:23

  • Tobias

  • Not too shy to talk

  • Posts: 172

  • Since: 2005/9/13


I actually figured out a way to use Akismet for my wf-links, and I certainly don't think it requires a rocket scientist to modify other modules in a similar way. My way is quick and dirty, would of course be better to have a full implementation, but that would imply fooling around with the database. Certainly not worth it for the amount of traffic in my links section, and XOOPS wide, I think it's not that easy.

I basically just use the Akismet class you can find by following the respective link on the following page, depending on whether you're on PHP4 or 5:http://akismet.com/development/ I call this class immediately before the module would otherwise write a new submission to the database, and if the submission does not pass the Akismet test, writing to database is aborted and I send myself an email or whatever, so I can see I've successfully blocked some spam and have a little party.

For this to work, you need to get for yourself an Akismet API key athttp://akismet.com/personal/

I can give a little more detail if that is wished.
www.affvu.org



63
Tobias
Re: Dutch month format
  • 2007/2/2 20:38

  • Tobias

  • Not too shy to talk

  • Posts: 172

  • Since: 2005/9/13


My workaround is still working fine for me. I've had to adapt the respective strings in some more modules which use the function, but so far, that's been easy to handle.
www.affvu.org



64
Tobias
Re: check database Problem
  • 2006/11/27 0:17

  • Tobias

  • Not too shy to talk

  • Posts: 172

  • Since: 2005/9/13


That means that XOOPS cannot connect to the database server. Nothing to do with whether your database exists or not.

So, make sure you specify the database server (or host) correctly when prompted, also a user and a password which work. The address of the database server you have to get from your webhosting company. It's the same to which phpMyAdmin connects if you're using that. You might find the address of your database server on the first page of phpMyAdmin if you can connect. The user and password are also the same with which you connect to the database through phpMyAdmin.

If you're trying out on a local install, with Xampp or any of those as server, "localhost" normally does as the database server. You could try with "root" as user and an empty password.
www.affvu.org



65
Tobias
Re: New? (hacked...) Wireframe for XOOPs in process
  • 2006/11/23 22:57

  • Tobias

  • Not too shy to talk

  • Posts: 172

  • Since: 2005/9/13


Quote:
<span></span> doesn't validate either

Depends on what you have inside. <span> cannot enclose block level elements, like <div> or <p> or <table> or <form>. <span></span> is for inline markup and really at the lowest (or innermost) structural level.

If you append the attribute display:inline; to the div or p in question, it should not want to clear whatever comes before, if that is the problem. Even with display set to "block," you should also normally be able to force them into the same line (float:left; and float:right; if you want to have more than two elements in one line, then you'd of course have to nest them so that always a pair of two is floated against each other).

If it's about preventing line breaks inside whatever the element, use &nbsp; instead of a space.
www.affvu.org



66
Tobias
Re: Possible to change homepage?
  • 2006/11/22 22:06

  • Tobias

  • Not too shy to talk

  • Posts: 172

  • Since: 2005/9/13


Well, don't quite know how my post solved the problem, but I'm glad you got it back to life.

If you're sure YOU didn't change the file extension of index.html, then you might nevertheless want to contact your webhost's support on that. Should not normally happen.
www.affvu.org



67
Tobias
Re: Possible to change homepage?
  • 2006/11/22 21:14

  • Tobias

  • Not too shy to talk

  • Posts: 172

  • Since: 2005/9/13


In your case, it's probably a good idea to install XOOPS to a subfolder. The webserver might get confused what to serve, index.html or index.php. That's something that has to be configured on the server, or with htaccess. In any case, under normal circumstances, you should get either your old homepage, or the XOOPS frontpage.

Now, what's strange is that redirection to some placeholder from what seems to be your webhost if you try to hit directly on the index.php. If your XOOPS were installed correctly, you should be able to access it at yourdomain/index.php. Also, index.html or index.htm are not present or accessible it seems.

There may be an issue with file permissions set on the server. If, for instance, you've played around with permissions for the webroot folder and made it non-executable and/or non-readable for the world, then that might explain something. You could try to undo all the changes in permissions you've made if you remember them. 755 is a good choice for the webroot, assuming that your site is hosted on a Linux/Unix box. That would be read/write/execute access for the server, and read/execute for everyone else.

Also try removing or renaming all .htaccess files that might apply to your webroot. Those would be those that are at your root level and at /htdocs or /public_html. You should, of course, back them up and go through them to see what are the settings you would want to restore afterwards.

Finally, if the thing worked at some point but stopped without you doing anything, you should get in touch with support at your webhost. There may have been some hack attack, or they've just screwed something up big time.

In any case: If you install XOOPS over a working site (something with index.html) and install it correctly, then the two things shouldn't interfere I believe. Only that the webserver would make a choice what to serve up. Your static index.html, or Xoops's index.php.
www.affvu.org



68
Tobias
Re: style="clear: both; & FireFox problems
  • 2006/11/22 18:11

  • Tobias

  • Not too shy to talk

  • Posts: 172

  • Since: 2005/9/13


Quote:
Another great tool for Firefox is the web developer toolbar.


Agreed. I love it! Particularly what's in the "Outline" and "Information" menus.

Another great extension is IE Tab. Kiss good bye to one of those gzillion browser windows typically populating the screen when one is trying to design something, and use the IE rendering engine from inside a Firefox tab:

https://addons.mozilla.org/firefox/1419/

Then, of course, you want to save the time to run from computer to computer only to see how things look in the several versions of IE. Now possible, thanks to Multiple IE:

http://tredosoft.com/Multiple_IE
www.affvu.org



69
Tobias
Re: style="clear: both; & FireFox problems
  • 2006/11/22 7:21

  • Tobias

  • Not too shy to talk

  • Posts: 172

  • Since: 2005/9/13


Looks very good. Seems to be more than 100% wide, though. It produces a horizontal scrollbar at the bottom. More importantly: It throws tons of warnings (errors, for validation purposes) when checked for tidiness, some of them related to <div>s not closed properly or in a wrong order. That's very likely to break your layout at some point. You may want to get the HTML Validator extension for Firefox fromhttps://addons.mozilla.org/firefox/249/. It's extremely helpful for sifting through malformed html code. Also, once you're done, to enjoy the fact that yours is clean and so much out there terribly dirty.

Btw.: Since you're obviously caring about standards compliance and "separation of structure and presentation," if it displays "correctly" in IE6 and not in Firefox, then that's most probably because it does NOT display correctly (i.e., how the standards demand it should display) in IE6. IE7 has come a long way toward compliance, meaning it displays many things more like Firefox than like IE6. But I guess that, to reach the full range of browsers, including Opera, Safari and the Linux browsers, it's a better idea to make it work with the Fox, and then see how to fix it in IE6.

Monty has already pointed to positioniseverything.net. That's really an indispensable resource for all clearing and floating purposes. They have a really nifty pagemaker there which produces a series of layouts--fixed width, fluid, n number of columns, headers, footers, etc.--according to your specs, and with a variety of browser specific hacks already in it. It's athttp://www.positioniseverything.net/articles/pie-maker/pagemaker_form.php. Might be interesting for you to have an eye into that, even though yours seems to be mostly working now, the problems with the divs not withstanding. I think I've seen something similar somewhere else but don't remember where.

Nothing against JMorris's solution, but while you're at it, you may consider swapping the main column with the left column, so the content comes before the navigation. Good for small devices and search engine optimization.
www.affvu.org



70
Tobias
Re: Akismet implementation for Xoops
  • 2006/11/1 18:12

  • Tobias

  • Not too shy to talk

  • Posts: 172

  • Since: 2005/9/13


Would be great to have it in forums and comments, but with all the work phppp is doing for all of us, I don't feel like asking him for another feature.

I seem to have effectively blocked myself from posting anonymously to my Akismet protected Coppermine gallery by just sending two or three spam samples through the system, for testing purposes. I guess I should change my IP.
www.affvu.org




TopTop
« 1 ... 4 5 6 (7) 8 9 10 ... 14 »



Login

Who's Online

305 user(s) are online (195 user(s) are browsing Support Forums)


Members: 0


Guests: 305


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits