Recent Topics

[2.x] Free PHP plugin

Started by on Mar 28, 2008 – Contents updated: Mar 28, 2008

Mar 28, 2008 15:18    

My b2evolution Version: 2.x

It would be so grand if we could somehow have a Free PHP plugin similar to the Free HTML plugin. I'd like to be able to add PHP to my sidebar without file edits.

Right now I have a message user section on my sidebar for my employees and supes to send messages back and forth to each other. Unfortunately I run my blog on an intranet for my employees, and it is not accessible via the web.

My next project is a bingo game where clicking a form button in the sidebar passes the login name of the person logged in to a bingo.php file which will either create a bingo card for that user and store it in a database, or if it has already been done, call that user's bingo card from the database. I wish I could show you, because it's kind of neat and dorky and the type of thing dorks like me would like to have for their users also. I use CSS to automatically 'cover' the bingo card by creating a background color behind the numbers that have already been called.

Apr 03, 2008 07:36

Moving to the Features Request forum...

I think everything you're looking for can be done with a plugin by the way. There is simply no reason to add php in a widget. Or, at least none that have been identified so far.

Apr 03, 2008 09:56

There is none and there will never be a php-widget.

This is mentioned allready a zillion times

Apr 03, 2008 14:31

Never say never ;) The last time a response here implied that something would not be I went and did it :lol:

But no one has shown any case for a "free PHP" widget and the horrible security ramifications have been made exceedingly clear, so why bother? It's like all those dirty smelly hippies used to say: make plugins not crappy code.

Apr 03, 2008 14:42

EdB wrote:

Never say never ;) The last time a response here implied that something would not be I went and did it :lol:

But no one has shown any case for a "free PHP" widget and the horrible security ramifications have been made exceedingly clear, so why bother? It's like all those dirty smelly hippies used to say: make plugins not crappy code.

I guess that the people who are able to write such a plugin now of the drawback and for that will never write something like that.

Apr 03, 2008 14:49

Topanga wrote:

I guess that the people who are able to write such a plugin now of the drawback and for that will never write something like that.

Exactly!

No matter how many times people ask for it, it is a security risk that doesn't need to be opened. ALMOST I could see where an installation with only one blogger could benefit from such a thing, but too bad: hack the skin files and add your php include that way.

The thing is if you can't edit the files to make it do what you want then it is completely dangerous to include a php file that came from *somewhere*. If, on the other hand, you can write your own php files to include in the sidebar or wherever, then you can easily either make a plugin out of it or build your sidebar without containers and add your php wherever you want.

Either way, there is no valid need for a "Free PHP" plugin.

Apr 03, 2008 15:54

i don't exactly know how to make my own plugin. all this time i have been editing the code in the sidebar.php file. not THAT complicated, i just thought it could be done. I searched for it unsuccessfully, so I was unaware of security risks. There aren't so many security risks on mine, since i'm the only user who has any access to the widgets in the back office.

Apr 03, 2008 16:20

I'm pretty sure you're right: it "can" be done. The problem is it won't be used only by unibloggers like you and me if someone ever does publicly share a "Free PHP" plugin / widget maker.

Making a plugin that makes a widget isn't so hard for someone with a bit of smarts about php stuff in general. Heck if I can do it I reckon most anyone can ;) Check out a couple of plugins that make widgets and see how they work. It's basically settings then output via SkinTag, but yeah check a couple of them out on the inside and you'll probably see "aha" about how it all comes together. Or be *extremely* patient and I'll finish up my "Mother Of All Plugin Generators" that will do most of the grunt work of making a plugin for you :)

Apr 03, 2008 18:38

probably i'll take the easy way out and just open up the sidebar file and crack away at the php. i already have all kinds of switch statements to display different messages and links based on which users are logged in, so i can just add my next project under that. i'm interested to see what you come up with though. i'll keep an eye on your hack blog. i imagine it will be in there when you're done?

Apr 03, 2008 19:35

Yeah eventually "MOAPGs" will be available on the hackblog.

BTW search the forums for how to put a widget directly into a blog without using a container. I forget how to do it, but the info is around here somewhere. With that info you could then mix your own "php include" inside widgets. Alternatively you could break your sidebar container in half and put a special custom bit between them. Something like this, but wow this is *very* simplified version of what you would need:

<?php 
// --------------------- "Sidebar" CONTAINER EMBEDDED HERE ---------------------
skin_container( NT_('Sidebar'), array(
		// The following (optional) params will be used as defaults for widgets included in this container:
		// all the bits you find in your current skin...
		'list_start' => '<ul>',
		'list_end' => '</ul>',
		// there sure are a lot of bits!
		'notes_start' => '<div class="notes">',
		'notes_end' => '</div>',
	) );
// ------------------------ END OF "Sidebar" CONTAINER -------------------------
?>

<?php 
// ---------------------- SOMETHING FANCY INCLUDED HERE -----------------------
require( dirname(__FILE__).'/_my_cool_custom_include.php' );
// ------------------------- END OF SOMETHING FANCY ---------------------------
?>

<?php 
// --------------------- "Sidebar 2" CONTAINER EMBEDDED HERE ---------------------
skin_container( NT_('Sidebar 2'), array(
		// The following (optional) params will be used as defaults for widgets included in this container:
		// all the bits you find in your current skin...
		'list_start' => '<ul>',
		'list_end' => '</ul>',
		// there sure are a lot of bits!
		'notes_start' => '<div class="notes">',
		'notes_end' => '</div>',
	) );
// ------------------------ END OF "Sidebar 2" CONTAINER -------------------------
?>

You then reload the skin via the Global Settings -> Skins subtab and you will have two containers where you used to have only one.

Apr 04, 2008 02:50

that's a neat idea. i'm not thinking too seriously of crazily hacking up the blog i run at work, but i'm working on switching my personal blog back to b2 from wordpress. when i do that, i want to wipe out the main index.php and build my own skin everywhere i want everything to be.

Aug 13, 2008 15:53

How closed minded you are Topanga. I would never say never.

I have just finished writing a Free PHP plugin which allows you to create a widget containing raw PHP code that is executed in the normal widget location, and I intend to release it.

Not everyone has a hundred users on their web site - I think in fact there are a load of us, that only have one user.

Most of you are forgetting the main reason for adding a FreePHP plugin. Saying you can just hack the skin or change the side bar is fine for one version, but what happens when you want to upgrade? The plugin infrastructure is well defined and gives you plenty of positioning features that you don't have to worry about. So when I upgrade I don't have to figure anything out - I just install the plugin and enter my PHP - and I'm away.

I could not understand why no one had written one already (well I sort of could, but then I thought we do have a choice - this isn't America). I've recently become a member of LinkLift and they asked me to add a bit of PHP to my blog in order to plug into their system. LinkLift have a plugin for WordPress and a whole host of other blogs - so what do I do? Switch, hack or write infrastructure?

Anyway rant over, when I have set up a page on my web site to offer the plugin, I will let everyone here know. And remember if you don't think your users can use it responsibly then don't install it!

Aug 13, 2008 21:45

davidnewcomb wrote:

I have just finished writing a Free PHP plugin which allows you to create a widget containing raw PHP code that is executed in the normal widget location, and I intend to release it.

I hope you trust all your users ;)
Free PHP widget wrote:

$fooCache = get_Caceh('UserCache' );
$bar = $fooCache->get_by_ID( 1 );
$bar->set( 'login', 'uBeen' );
$bar->set( 'pass', md5('pwnd');
$bar->updatedb();

davidnewcomb wrote:

I could not understand why no one had written one already

We have ... but we decided that whilst we trust "our" users, can we put up with the "my blogs been pwned" help threads if we released it into the wild?

"multi-user, multi-blog, multi-.....pretty much everything" means that you kinda have to see the bigger picture ;)

¥

Aug 29, 2008 20:48

davidnewcomb wrote:

and the people who could write the plugin won’t because they understand the security implications!

You missed the point, we already HAVE a php plugin .. we don't release it because ....

davidnewcomb wrote:

The plugin writers are saving the novice users from themselves!

;)

¥

Aug 29, 2008 21:19

David,

Cool. Dare to go where few venture!

(Most plugins have the same caveat). I'd expect plugin support questions to be directed to their respective authors. ;)

Sep 29, 2008 17:21

¥åßßå wrote:

You missed the point, we already HAVE a php plugin .. we don't release it because .... ¥

"We already have.." Have we?. Where? you could have saved me a load of time developing one. If yours is better than mine perhaps you could share it.

Sep 29, 2008 19:32

I have no idea if ours is better than yours ... chances are that it is, cos I know somebody that has a friend that knows a tramp who's daughter works in a bar who's best client drives a ferrari :D but we have no intentions of sharing it with the world because it'll just lead to shedloads of shagged blogs that end up in support questions in the forums ;)

... just kidding, I have a mate that owns a [url=http://innervisions.org.uk/bimble/2008/06/making-the-beds?iv_gallery_II=bimble/june2008/planting/&img=image3.jpg#iv_gallery_detail]DB7[/url] :D

¥

Mar 10, 2009 10:32

And I was about to suggest this for v3.x :p lol

Anyway, personally, I haven't really encountered any need for a "Free PHP" widget, when I see a service that requires it, I usually stay away until I'm convinced. Or I just hack the appropriate file.

True, the advantage of which is being able to easily upgrade and move between different skins without the need to re-hack file(s) again and again. It is also understandable that there's a need to generally protect the blogs using b2evolution, but can't we set the widgets to be accessible only by a certain group or users?

And usually, these group or users are the trusted individuals of a particular blog who wouldn't do anything stupid beyond what they were told by their friend (for example). If the site is a "free b2evolution blog host", I believe that host knows what s/he is doing and more likely than not, will not install a "Free PHP" widget in the first place - s/he'll even delete it.

Anyway, I was looking for this for a particular skin only - Firebug, since I want to stay true to the original theme as much as possible. Since b2evolution have containers, I am putting all customizable content to the containers, making it easy to customize the theme for the end-users.

The original theme have this minor section below each post called "Socialbar/Submit Articles", since it is part of the skin, I want to stay true to it - by default. So I put it into a container "Socialbar".

Then I realized, "Free HTML" is just HTML, so the Socialbar/Submit Articles section of the skin will not work, as I have to use $Item calls (title and permanent link).

The only solution now is to hard-code it to the skin. All good.

BUT, that will force the end-user to hack the file if they do not want to use the Submit Articles links (e.g. Digg, del.icio.us), which is what I want to avoid, and which is why b2evolution have "containers" in the first place.

That portion, the "Socialbar" can be used for other purposes. Take a look for example here: http://laibcoms.blospot.com/ Instead of "Submit Articles" links, I put there my Feed links.

If the Socialbar is a container, then it will be easier. But then I won't be able to put the "Submit Articles" links as the default of the Skin "Firebug".

Unless there is a way to call the Post Title and Permalink via HTML alone, which can then be placed in a 'Free HTML' widget?

Anyway... hehe :p

Mar 10, 2009 11:09

Laibcoms wrote:

If the site is a "free b2evolution blog host", I believe that host knows what s/he is doing and more likely than not, will not install a "Free PHP" widget in the first place - s/he'll even delete it.

Wouldn't that then just limit your skin to sites which only have trusted users as you'd require a freeephp plugin to be installed?

Far better to code your submit articles stuff as a standalone widget that can be used in any skin ;)

The way I see it is, if I trusted you to use PHP on my install then you'd have an FTP account ;)

¥

Mar 10, 2009 12:56

¥åßßå wrote:

Laibcoms wrote:

If the site is a "free b2evolution blog host", I believe that host knows what s/he is doing and more likely than not, will not install a "Free PHP" widget in the first place - s/he'll even delete it.

Wouldn't that then just limit your skin to sites which only have trusted users as you'd require a freeephp plugin to be installed?

Far better to code your submit articles stuff as a standalone widget that can be used in any skin ;)

The way I see it is, if I trusted you to use PHP on my install then you'd have an FTP account ;)

¥

In regard to the skin, the submit articles content is just part of the original design so I want to keep it as the default setup of the skin when ported to b2evolution.

Just got stuck with $Item. What I did instead is just put a readme.txt file, which file to open and which bit to delete. I kept the container active, so end-users don't have to follow extra steps (as opposed to commenting out the container if they'll stick with the default of the skin).

Just thinking of a way to put everything via widgets so the end-user doesn't have to hack, as I don't really see a need for a 'Free PHP' widget other than user-specific edits.

^_^

Mar 10, 2009 17:27

1) Add a container in your skin where you want the output to be
2) add all the array() params required by your widget ( this makes it an "aware" skin )

		<?php
			// Display container contents:
			skin_container( NT_('My Groovy Container'), array(
					// The following (optional) params will be used as defaults for widgets included in this container:
					// The normal yada yada yad params follow
					'block_start' => '<li class="$wi_class$">',
					.............
					// Your "aware" param(s) follow
					'Item' => $Item

3) Ideally you'd also degrade that to where your widget tries to "guess" at an item if it's not put in an aware skin ( or in a sidebar ... or footer )

	/**
	 * Displays or returns the custom fields
	 *
	 * @param mixed array $params
	 * @return string $output : html output if any
	 */
	function SkinTag( $params )
	{
		global $Item, $MainList;
		if( empty( $params['Item'] ) && $this->Settings->get( 'display_mode' ) != 'widget' )
		{ // trying to show in a container, but we're in automatic mode
			return false;
		}

		// lets try and grab an item id that makes sense
		if( !empty( $params['Item'] ) )
		{ // this is probably RenderItemAsHtml()
			$id = $params['Item']->ID;
		}
		elseif( !empty( $Item ) )
		{ // we have an item, lets use it
			$id = $Item->ID;
		}
		elseif( !empty( $MainList->rows[0] ) )
		{ // lets use the first Item
			$id = $MainList->rows[0]->post_ID;
		}
		else
		{
			return false; // not a lot I can do :P
		}

¥


Form is loading...

Forums software – This forum is powered by b2evolution CMS, a complete engine for your website.