Recent Topics

1 Dec 19, 2005 19:57    

Hiya, I'm writing a plugin that allows auto blog generation and sub domains for version 1.6, can you please add the following... there may be more to come but i think that is it for now. The plugin will be finished tomorrow.


htsrv/register.php
105						$UserCache->add( $new_User );
106+
107+					$Plugins->trigger_event( 'Registration', array('user_data_obj' => $new_User ) );

evocore/_plugins.class.php

220		$filename = $this->plugins_path.'_'.str_replace( '_plugin', '.plugin', $plugin_name ).'.php';
221		require_once $filename;
222+
223+		$new_plugin_ref = new $plugin_name;
224+		if($new_plugin_ref->requires_install) $installed_ok = $new_plugin_ref->Install();
225+		if(!$installed_ok)
226+		{
227+			return false;
228+		}

evocore/_plugins.class.php

273			if( $Plugin->ID == $plugin_ID )
274			{ 
277+			// if plugin requires a uninstall function call set the pluing var requires_uninstall to true and make sure function Uninstall exists.
278+			if($Plugin->requires_uninstall) $Plugin->Uninstall();


admin/_header.php

242			'tools' => array(
243				'text'=>T_('Tools'),
244				'href'=>'tools.php'
245			),
246		)
247	);
248+	
249+	$Plugins->trigger_event( 'AddToAdminMenu' );

2 Dec 19, 2005 20:24

What does your plugin actually do?
auto blog generation sorta means nothing to me...

3 Dec 19, 2005 20:27

Basically it seems to be the holy grail of b2evo,

when a user registers it will send them a confirmation email. when the confirmation link is clicked it will autosetup a blog for them. It will also create a subdomain stub file and htaccess reference based on raptors htaccess...

there will be other stuff also.

it is to be called AUROR btw

4 Dec 19, 2005 20:36

oh so something like msn spaces....
I register an account on mysite.com
accept the confirm confirm

then i get my own blog at mysite.com/myusername

I never thought of using b2evo like that good work, as long as you haven't given them permission to upload files, then it should be good.
As soon as you give them permission to upload a file or to allow javascript or object tags the security will die.

5 Dec 19, 2005 22:34

the initial user levels and group will still be based on the standard settings, it;s just an extra

6 Dec 19, 2005 22:35

what whould be wrong about allowing file uploads? especially if you limited it to images?

7 Dec 19, 2005 22:37

ok if its only images, thats fine as long as they can't change mime types.

Main threats would be htm, html, asp, aspx, php etc anything that displays html code.
.js, .script anything that displays scripts
.swf - kinda bad but not really

Just as long as they can't upload anything that can contain scripts, or change mime types

8 Dec 19, 2005 22:39

indeed, but the best way to protect against that is to have a php file that opens the image and outputs it but setting the content/type to jpeg, that way it is always given as a jpg if i am not mistaken, same with all other files

9 Dec 19, 2005 22:41

Good point ;) never thought of that.
Again javascript/scripts is a big problem and if you have that covered then it should be fine.

10 Dec 19, 2005 22:46

Oh and for your install/uninstall code shouldnt u use:

if( @function_exists($Plugin->Install) )
$Plugin->Install();


if( @function_exists($Plugin->Uninstall) )
$Plugin->Uninstall();

11 Dec 19, 2005 22:50

No i've tried that, because in the uninstall main b2e uninstall function references a dynamically created class it just won;t see that the function is there, but it does see vars..

I'm sure this has something to do with the '&' sybmol usage in php but i;ve never fully understood that.

12 Dec 19, 2005 22:56

You should'nt ever need to use '&', so if i did:


$var = 'cool';
$var2 = &$var;
$var2 = 'polony';
echo $var.$var2;
//Outputs: polonypolony


$var2 is a reference to $var, (i use the word reference but some people use the word pointer coz their old ;))
so when $var2 is changed it changes $var.

If you meant the '@' symbol, that just says we don't care about errors so don't display them. (for only the line of code that it shows)

For the function exists are you sure that u used the same syntax as i posted?
Seems strange to me that it won't work....

13 Dec 19, 2005 23:01

yeah i know the @, thanks for explaining the & i understand now. but yeah the thing still doesn;t work. i puzzled about it for about 15mins. annoying to do it this way.

you see in the install function, once the reference is stored in the db, it calls another function which in turn creates the reference. see below

		// Register the plugin:
		$Plugin = & $this->register( $plugin_name, 0 );	// ID will be set a few lines below

calls this function

	function & register( $classname, $ID = 0, $priority = -1 )
	{
		global $Debuglog;

		if( !class_exists( $classname ) )
		{ // the given class does not exist
			$Debuglog->add( 'ERROR: Plugin class for ['.$classname.'] not defined - must match the filename.', 'plugins' );
			return false;
		}
		$Plugin = new $classname;	// COPY !

		// Tell him his ID :)
		$Plugin->ID = $ID;
		// Tell him his name :)
		$Plugin->classname = $classname;
		// Tell him his priority:
		if( $priority > -1 ) { $Plugin->priority = $priority; }

		// Memorizes Plugin in sequential array:
		$this->Plugins[] = & $Plugin;
		// Memorizes Plugin in code hash array:
		$this->index_Plugins[ $Plugin->code ] = & $Plugin;
		$this->index_name_Plugins[ $Plugin->classname ] = & $Plugin;

		// Request event callback registrations:
		// events = $Plugin->RegisterEvents();

		return $Plugin;
	}

which in turn return the plugin reference, so yes it is still wierd, maybe it;s just my version of php though (4.3.11)

14 Dec 19, 2005 23:06

hmmmm what wierd code......
lets wait for blueyed to tell us why it doesnt work aye ;)

15 Dec 19, 2005 23:08

aye... indeed. btw for someone who's actually a bot you seem to be programmed very well... ;)

16 Dec 19, 2005 23:46

buggedcom, great to see someone working on plugins.

Don't go into detail on the Phoenix-alpha Plugins class though, as I've just gotten the OK from François to merge an improved implementation into HEAD for the beta.

The Plugins class has a list of known events and parses the php source file of the plugin on installing it.

Therefor, I'll add your requests as events and your plugin just has to have those methods.

I'll add the "Registration", "Install" and "Uninstall" events.

I think, the plugins Uninstall() method should also get checked for it's return value and the plugin not uninstalled from b2evo if it fails. Not?

As for "AddToAdminMenu" this is already implemented (in post-phoenix yet only) and is called "AdminInitMenu".

There are helper methods to easily register a tab in the tools menu.

And, you can begin to smile, you are able to easily provide and use Settings that are editable in the "Settings / Plugins" tab.

Just take the [url=http://cvs.sourceforge.net/viewcvs.py/evocms/b2evolution/blogs/plugins/_test.plugin.php?rev=1.11.2.5&only_with_tag=post-phoenix&view=markup]Test plugin[/url] as an example. The detailed docu it with the [url=http://cvs.sourceforge.net/viewcvs.py/evocms/b2evolution/blogs/evocore/_plugin.class.php?rev=1.10.2.5&only_with_tag=post-phoenix&view=markup]base Plugin class[/url].

You can also see it in action on the demo site for the post-phoenix branch of course.

17 Dec 19, 2005 23:59

Hi blueyed,

Yeah the only things i was adding to the plugin class were the event handlers and the return causes, so that's no problem as long as they are implemented in a similar way.

Yes indeedy, it is easy to smile when plugins are this easy to create.

Erm am i being dumb, how do i get access to the demo, i went to the opensource demo link created an account, logged in and still can;t get access to it. Do you know whats up?

19 Dec 20, 2005 00:39

I like what i see alot. i see a lot of improvement going on. question though regarding the init menu event, using that is it only possible to add the new tabs to the tools or can i still add them wherever? do you have a prefered format for it?

I'm going to be adding a lot of plugins over the next couple of months mainly due to the work that i will be using it for, it is going to be a large multi user multi blog site and i will make sure a donation is made at the end.

Another question i do have is have you any plans for adding ajax to b2evo? I've done a lot of work with http://script.aculo.us/ and am planning on intergrating it with my setup. I can try to create an ajax template system after the main project is done looseley based on the project (obviously can;t use the actuall same template cos the client wouldn;t be too happy about that)

also with regards to the "New post in blog:" menu bar when there are lots of users blogs in there? I had plans to alter it using scriptaclous's live search functionality as there will hopefully be a stupendous amount of blogs in the clients site.

another thing i will be implmenting is an advanced mms upload plugin, I haven;t actually tried your version because i don;t actually have mms functionality on my poor old phone but i read somewhere in the forums there was a few things wrong with it? is this so? i don;t really want to re write anything, because duplicating something is just plain stupid, however i do want to be able to strip out image attachments and audio / video from the mms so does your version do that and add the files to the filemanager?

20 Dec 20, 2005 06:33

So what about skinners is there anything new to us in 1.7CVS?

EDIT:
About Ajax, i'm using it in my skin.
I found problems, usually speed problems, with using ajax.
As most of the time u need the b2evocore loaded to make your thing work.
So then that will give speed problems....
I eventually threw in the towel saying meh its good enough ill keep it as it is without using ajax for the things that these problems occur in.

But i'm pretty sure that i will have another go at it later on.

PS
Oh an buggedcom you saying my mates are programmed badly ;)

21 Dec 20, 2005 11:37

balupton wrote:

As most of the time u need the b2evocore loaded to make your thing work.
So then that will give speed problems....
I eventually threw in the towel saying meh its good enough ill keep it as it is without using ajax for the things that these problems occur in.

but sureley even if you do have to load the core every request it's still going to be quicker that loading the whole page again because you can strip out much stuff like header links, javscripot links, menu calls, etc etc? It would require pretty much a partial rewrite of the engine, but i'm willing to do that.

I was just wondering if anybody had a preffered ajax system, php, javascript and ajax or just pure ajax and javascript? Dojo does look pretty good, however scriptaculous is the only one i have managed to find that is pretty much cross browser compatible?

balupton wrote:

PS
Oh an buggedcom you saying my mates are programmed badly ;)

eh i don;t follow? you mean the bot stuff?

22 Dec 20, 2005 11:40

you know what whould also be good, a read writeable plugin dir in the admin section by default so the admin pages could be moved from the plugin folder to the admin directory on install...

23 Dec 20, 2005 12:09

Yer i did mean bot stuff.

Back to the ajax stuff i would have to disagree that it would be faster.
Instead of one load of the evocore you have it loading multiple times, slowing it down there.
And the loads for each ajax item would take some time, as well.

So ultimely you have more times the evocore is loaded, more pages being loaded, more javascript and activex controls being loaded.

I just can't see where ajax would be usefull in the back office...
Plus the backoffice is already good, y change it?

24 Dec 20, 2005 12:20

you are right when you say instead of on load of the evocore you would get multiple, but that is onlt when the application starts up. when the first page has loaded, all you will be loading is little sections. after all the sections have loaded the all you are doing is loading smaller sub sections of content.

admittedly you are reloading the evocore, however you wouldn;t be loading the entire page again just the small subsection. If you were going to reload the whole page again you would agian be loading the evo core anyway so your argument for that is kinda moot.


standard loading
- initial load
   - no intital load
- per page load
   - load evocore in php
   - load all html templates for that page
   - load all javascript and stylesheet references in the html

ajax loading
- initial load
   - load evocore in php
   - load all html templates for that page
   - load all javascript and stylesheet references in the html
- per page load
   - load evocore in php
   - load single template file (possibly multiple depending on the page request)

you can see whilst you do have an inital load in ajax, the per page loading is ALOT smaller than standard. and whilst you are correct it would load the evo core each time so does the standard. The advantage over the ajax is that you would be loading smaller templates.

i'm not entirely sure about "more pages being loaded, more javascript and activex controls being loaded". i don;t thing this would be the case. but i could of course be wrong. in apps i;ve used and created i've experience no slowdown and generally the pages are served faster due to the lack of page refreshing.

Also i wasn;t really talking about making backoffice completely ajax, just adding touches here and there. I meant adding a complete ajax skin to the front end blog.

[/list]

25 Dec 20, 2005 12:26

it would also be good to be able to prevent multiple installs if required.

26 Dec 20, 2005 12:29

Ok i was thinking you were gonna try and make everything ajax.
Have you already started or is it 'what if?' still?

Because you should probz hold it off until 1.6 has reached final, or do some serious discussions with the core developers.

But back to the loading issues, the only real stuff that woudlnt be getting re-loaded would be the menus?
And if thats true, then thats only a tiny amount of load.

I just think what you are trying to do is too much work for little gain.

it would also be good to be able to prevent multiple installs if required.

What thing are you referring to with multiple installs?[/code]

27 Dec 20, 2005 12:32

yes i do agree with you about the menus issue, it would be a tiny amount of gain for a fair amount of work, still i thin k in the long wrong it should be done.

as for the multiple installs. i should of explained better. In the plugins page you can install each plugin more than once, i don;t really understand why you would want to. With my plugin i want to be able to only allow the install once, because other wise it will feck things up.

28 Dec 20, 2005 12:36

The way i think the plugin page should be run is:

[Plugin Name] [Description] [Priority???] [Apply???] [Use]

So all the plugins are installed, but can only be used if the use checkbox is checked.

29 Dec 20, 2005 12:38

Yes that does sound good, but that's pertty much what it does at the moment, just witha dif interface isn;t it? I would also like to see a plugin user-level, so the plugin is only available for certain levels of user...

30 Dec 20, 2005 12:53

That's a good point - userlevels.

About my recomendation:
Yer just the install is dif, and the interface is better :P

Oh and also a good think i rekon would be if the plugin is called, then it shouldnt need to be installed.
So like for skins that depend on plugins for sidebaritems the plugin that gets called should be successfully called even if it isnt installed.

31 Dec 20, 2005 12:55

hmm, not sure about the no install thing. If admins don;t wont a certain plugin installed i don;t think it should be auto included... potential security risks there me thinks

32 Dec 20, 2005 12:58

well it's getting called by the skin, and it would be just as bad as downloading a skin, i could delete the whole persons blog in my skin at a certain time if i wanted.

So i think the risk is just as bad as anything else.

33 Dec 20, 2005 15:39

blueyed... would it be possible to change the plugin unistall function to


	/**
	 * Uninstall a plugin
	 *
	 * Removes it from the database
	 *
	 * {@internal Plugins::uninstall(-)}}
	 *
	 * @return boolean success
	 */
	function uninstall( $plugin_ID )
	{
		global $DB, $Debuglog;

		$this->init();  // Init if not done yet.

		// for( $i = 0; $i < count( $this->Plugins ); $i++ )
		$move_by = 0;
		$items = count($this->Plugins);
		foreach( $this->Plugins as $key => $Plugin )
		{ // Go through plugins:
			if( $Plugin->ID == $plugin_ID )
			{ 
				if($Plugin->requires_uninstall) $Plugin->Uninstall();
			// This one must be unregistered...
				unset( $this->index_Plugins[ $Plugin->code ] );
				unset( $this->index_name_Plugins[ $Plugin->classname ] );
				$move_by--;
			}
			elseif($move_by)
			{ // This is a normal one but must be moved up
				$this->Plugins[$key+$move_by] = & $this->Plugins[$key];
			}

			if( $key >= $items+$move_by )
			{ // We are reaching the end of the array, we should unset
				unset($this->Plugins[$key]);
			}
		}
		// Delete from DB
		if( ! $DB->query( "DELETE FROM T_plugins
		                    WHERE plug_ID = $plugin_ID" ) )
		{ // Nothing removed!?
			return false;
		}

		// unset( $this->Plugins[ $key ] );
		return true;
	}

34 Dec 20, 2005 22:20

buggedcom wrote:

blueyed... would it be possible to change the plugin unistall function to [snip]

What do you mean? And remember that it already looks different in post-phoenix/beta.

35 Dec 20, 2005 22:25

He would like this to be added:

if($Plugin->requires_uninstall) $Plugin->Uninstall();

So if a plugin gets uninstalled it can perform additional operations unique to that plugin.

36 Dec 20, 2005 22:26

close but not quite balupton, I checked and the function is the same in the 1.7 beta. basically i want to move the query that deletes the plugin reference to after the plugin uninstall function call so the plugin uninstall function can prompt the user for input from a javascript confirm box and possibly cancel the uninstall.

37 Dec 22, 2005 00:46

buggedcom, your code snippet from above is not from post-phoenix and yes, for the beta the Uninstall event will be called before the plugin gets un-installed.

However, you won't be able to have a JS alert there.. you could just return false and add a message, where you could ask for confirmation and query a GET/POST param then in your Uninstall() event.

38 Dec 22, 2005 02:31

I am interested in following the development of this plugin. I was about to embark on this journey myself, given that b2evo is quite a well-written piece of software.

Is this plugin going to be shared or private, and when do you expect to finish it?

39 Dec 22, 2005 11:37

Sorry, blueyed i must of checked the wrong version. but yeah i can get it to issue js confims just by exiting the script in the uninstall function, then using document.location.href to redirect the page...

Crimson, yes it will be shared on open and i should get it finished b4 friday.

41 Jan 02, 2006 10:24

ah yes sorry been away for all of christmas... i haven;t finished it yet. i was planning to work over christmas but then couldn;t actually be bothered. I'll start again on the 4th.

42 Jan 16, 2006 23:23

Maybe I'll have to code this plugin myself, then. :( I really want to get my site online.

-Christine

43 Feb 05, 2006 17:25

Hello all,

This Plugin is awailable for publc ?

Thanx

Aferkiw.

Crimson wrote:

Maybe I'll have to code this plugin myself, then. :( I really want to get my site online.

-Christine

44 Feb 06, 2006 10:24

yeah i'll post what i have now. I am actually creatin g a bespoke registration system now, but the basics of this plugin is working. It is in no way finished though.

anybody interested in taking over the plugin or to see where i am up to know, send me an email and i will send you the zip

45 Feb 15, 2006 22:39

I'd be interested in working with what you have. My email is crimson -at- n00bstories dot com.


Form is loading...