1 combatwombat Mar 13, 2009 09:52
3 yabba Mar 13, 2009 14:02
By the looks of things :
Starter.php should be in function SkinTag().
Forex.php should be split into a separate class file and then the code at the end should be in function htsrv_your_cool_name(). Don't forget that you need to let the core know that your plugin has a htsrv method.
function GetHtsrvMethods()
{
return array('your_cool_name');
}
function htsrv_your_cool_name( $params )
{
Note : ajax will fail if the htsrv (sub)domain is different to the pages (sub)domain. It's easy enough to work around with a smidge of imagination ;)
Note 2 :
Your readme wrote:
Requirements
============
PHP5, modern standards-compliant web browser with javascript enabled. Web host supporting PHP5, eg Apache2.Installation
============
Extract the files of the archive "forex_1.0.zip" to a folder in your webserver. eg /forex. Then use your web browser to go to http://webservername/forex/starter.phpChangelog
=========1.0 Initial release. March 2009.
TODO
====
* Turn it into a plugin for B2Evolution blogging engine.
b2evo currently supports PHP4.x so ideally your plugin would as well.
Finally, forget writing an xml file, you'll end up with a shedload of "this doesn't work even though my folder is 777", just use the database and save yourself a world of pain ;)
¥
4 afwas Mar 13, 2009 15:42
5 combatwombat Mar 13, 2009 21:13
Thanks for the prompt reply guys. I will have a go at mashing it together over the weekend as chores allow ;)
@Yabba: those pointers are really useful, thanks
6 combatwombat Mar 22, 2009 03:06
Ok, only just getting back to it now. The issues I am having are...
my PHP script cannot load the XML from out of domain, nor pick up the XML file locally when functioning inside B2evo. Is there some sort of extra security to stop this happening? Methinks Yabba mentioned something about this. But without getting the XML feed I am not able to punch it into a DB. Foreign exchange feeds obviously need to change daily.
Error:
fopen(./currencyFeed.xml) [function.fopen]: failed to open stream: Permission denied in /var/www/b2evolution/blogs/plugins/forex_plugin/forex.php on line 96
And yes, the ownership of the files is www-data, and is set with identical perms to that of the forex project on the same server.
Because it cannot load the XML data, none of the code to build the form works (it requires the feed).
Some images are loading, others not. Specifically I use a graphic progress bar:
<img src="<?php echo $this->get_plugin_url(); ?>preprocess.gif" id="progimg" width="140" height="4" alt="progress indicator" />
Which doesn't show. But
<img src="<?php echo $this->get_plugin_url(); ?>close.png" alt="X" />
, a graphic close button does. Huh? is this a GIF issue? I use GIF because of animation required.
Also I would like to add onload javascript to the body tag when the skin loads, but I cannot find a method that does this.
Please let me know if you require the totality of the code so far, and I will zip it up for ya.
TIA
CW :-/
7 yabba Mar 22, 2009 11:23
It'd probably be a lot easier with a zip.
You really don't need the xml file, store your initial data in the database and then update it when you call whatever feed you call ;)
¥
8 combatwombat Mar 22, 2009 11:33
Thanks Yabba!
9 yabba Mar 22, 2009 11:46
forex.js :
// initiate the asynchronous HTTP request - AJAX ( not cleaning liquid)
xmlHttp.open("GET", forexUrl + params, true);
forex_plugin.php
function SkinBeginHtmlHead( )
{
?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->get_plugin_url(); ?>forex.css" />
<script type="text/javascript" src="<?php echo $this->get_plugin_url(); ?>forex.js"></script>
<script type="text/javascript">
function showhelp(id){
vis=document.getElementById(id).style.visibility;
if (vis=="visible"){
vis="hidden";
} else {
vis="visible";
}
document.getElementById(id).style.visibility= vis;
}
var forexUrl = "<?php echo $this->get_plugin_url(); ?>forex.php?";
¥
10 combatwombat Mar 22, 2009 21:58
Ok... does this work for your install Yabba? Not here. How can I debug this witihn B2?
Javascript alerts aren't firing out of forex.js.
I added:
alert ("URL:"+forexUrl+params);
at line 77 of forex.js, and nothing.
I would really like to understand what b2 does to lock it out.
11 yabba Mar 23, 2009 10:26
I needed to make the above changes before it would work on my install. I run suPHP though so I wasn't expecting any permissions errors.
I still advise that you kill the xml file though. In your SkinTag function, call the remote xml file ( if cache expired ), pull out the values and slap them in a plugin table.
Then change your ajax to call a htsrv method, so you can access the database, and strut your stuff.
That way you won't have any permissions errors and your plugin won't require 0777 on non-suphp servers, which is always a good thing ;)
¥
12 yabba Mar 23, 2009 13:33
See if this helps ( [url=http://innervisions.org.uk/forex.zip]forex.zip[/url] )
¥
13 combatwombat Mar 24, 2009 03:08
Still no go for me. No calculating or AJAX or anything. But no error messages either. Thanks anyhow, I see what you were saying regarding dragging the data into the DB first then using it. Will see if I can mash that idea into the code.
Cheers
CW
RenderItemAsHTML is probably not needed for this because it seems like a trinket you would put in a sidebar - not something that would be put in a post that needs to be converted. The way:) gets converted to :) is what I mean.
The Ajaxyness of it is not important ... except for you're expecting javascript to be available and allowed by visitors. Which is unrelated to how to make it a plugin eh?
This sounds like the easiest plugin in the world to make. Well, maybe not the easiest but certainly quite easy. Actually it's not easy. I must be crazy. Or coffee-free this early. But it's not hard! If you make no progress at it I'll give it a go and PM you something over the weekend, but first I really gotta put the icing on the cake that will be known as "killer bees" and maybe fly.
I wish I could think of a really simple widget making plugin to take a look at...
Oh and I dunno squat about creating a file in it's own directory. Oh wait yes I do. visiglyphs creates hundreds of files - in a folder inside itself. So I guess if there are security concerns it'd be stuff like "is the file storing passwords" and whatnot. But I dunno.