1 barkingstars Jan 27, 2005 23:29
3 agoss Feb 01, 2005 06:42
powerspike wrote:
// SUPER DUPER HORRIBLE CLUDGE !
$DB->query( "INSERT INTO evo_blogs VALUES ('', '$login', '$login', '', '', '', 'en-AU', 'index.php', '', NULL, '$login', '', '', 0, 0, 0, 0, 1, 0, 'custom',
This portion of the code is incomplete and is causing an error. It need to be something more along these lines.
$DB->query( "INSERT INTO evo_blogs VALUES ('', '$login', '$login', '', '', '', 'en-EU', 'index.php', '', NULL, '$login', '', '', 0, 0, 0, 0, 1, 0, 'custom', 0, 1, 1, 4, '')");
That leads me to the next two error messages.
Warning: Missing argument 1 for last_insert_id() in /home/rcmadmin/public_html/blog/b2evocore/_class_db.php on line 200
Fatal error: Call to undefined function: mysql_last_insert_id() in /home/rcmadmin/public_html/blog/b2evocore/_class_db.php on line 202
Can someone provide a little help with these errors.
Thanks,
Andy
4 powerspike Feb 01, 2005 11:49
whoop my very big bad mistake there - i done all the code, and put it intot he files, and forgot to update the notepad file i was working on - i have updated the code in the code snippets above directly from the files in my install =)
so sorry for that once again.
(both code snippets where updated for reference that anyone that tryed to use them)
5 agoss Feb 01, 2005 21:17
First, I just want to thank you for your work. This was exactly what I was looking for and now I feel comfortable enough with the change that I don't have to fear an upgrade. This is because trying to resolve the problems on my own really taught me a lot about the inner workings of the software even if on a small scale.
After I posted I did a little research a found that the function you originally referenced didn't exist.
So, I came up with a different solution and I am hoping you can review the slight changed I made and see if there are any obvious problems with the way I did thinkgs.
First, I restored my original _class.php file.
Second, I changed the following line in the register.php supplied code to:
$new_blog_id = $DB->query( "select last_insert_id() from evo_blogs");
Finally, I changed the following line from using blanks to NULLs since that was in the table and for some reason it acted as thought the catagories didn't exist until I made the change.
$category_query = "insert into evo_categories VALUES(NULL,NULL,'General','$new_blog_id',NULL,NULL,NULL)";
$DB->query( $category_query );
Of course it took me until 1:30 am and a complete reinstall of the software to finally getting it working properly but atleast I can say I learned something along the way.
Thanks again for the code.
Andy
6 bellator_aries Feb 08, 2005 00:10
OK, I installed the hack exactly like I was supposed to but don't see that it made a difference. I was lead to understand that the users would be able to automatically create their own blog upon registration, but I tested that several times and this is not the case.
Am I missing something or did I just misunderstand the purpose of the hack?
7 powerspike Feb 08, 2005 02:59
Ok, what the hack does (the one i posted) Created a blog with the same name as the user (username), gives them access to control that blog, and automaticly creates a catagory called general. so once they have signed up, they can make a post straight away in there own blog.
8 agoss Feb 08, 2005 04:17
What did it do? Provide a little more detail what exactly did or din't work and many we can help figure out what isn't working right.
Mine is working just fine. I have had atleast six people automatically register themselves.
Login to admin and check to see if the users you registered appeared.
Check to see if there are blog created. if so, are they associated with the correct user?
Check to see if there is a general category for each blog.
If you register and one of these three things didn't happen then the problem could lie in that section of the code.
Here is the code as it appears in my register.php file.
// SUPER DUPER HORRIBLE CLUDGE !
$loginid = $DB->get_var( "SELECT ID FROM evo_users WHERE user_login='$login'" );
# Create New Blog for user - we can safely insert new data without an id because the id field is auto increase.
$DB->query( "INSERT INTO evo_blogs VALUES ('', '$login', '$login', '', '', '', 'en-EU', 'index.php', '', NULL, '$login', '', '', 0, 0, 0, 0, 1, 0, 'custom', 0, 1, 1, 4, '')");
#This gets the ID of the new blog, hopefully :P
$new_blog_id = $DB->query( "select last_insert_id() from evo_blogs");
# Create New Blog Permissions for user
$new_query = "INSERT INTO evo_blogusers VALUES ($new_blog_id,$loginid, 1, 'published,deprecated,protected,private,draft', 1, 1, 1, 1)";
$DB->query( $new_query );
# Create A Generic Category so that the users don't have to work it out !
$category_query = "insert into evo_categories VALUES(NULL,NULL,'General','$new_blog_id',NULL,NULL,NULL)";
$DB->query( $category_query );
// END SUPER DUPER HORRIBLE CLUDGE !
9 bellator_aries Feb 08, 2005 20:10
Ok, here's what's happening now - when I inserted the original code that barkingstars provided, nothing changed. However, when I switched that code for the one AGoss provided, it does create a new blog for every person that registers, matching their username.
The problem is, when you hit "register", it says that "User registration is not allowed at this time" - however the user does get registered. Why is that? I checked the settings, and I made sure to allow users to register themselves, and that still appears. And once they're registered, and can access their own blog, how do they begin blogging? The options don't seem to be there, it seems that they're only allowed to post in one blog - and it's not their own.
10 powerspike Feb 08, 2005 23:38
ok, what version are you using ?
the i posted was for 0.9.0.11 - if your using a different version, there may be differences in the table stuctor, BTW i fixed the code i posted (there was a typo in the ones i posted at first - stupid copy and paste!)
ok, if you open up htsrv/register.php
and add in the line at the top after the <?
error_reporting(E_ALL);
it should pop up ALL errors that are gernerated when running the script - that should be able to help us help you alot easier.
at worse, if you still can't get it working, and your using 9.0.11,just pm me with your email and i'll send you a COPY of the 2 files that i am using on my LIVE site.
11 bellator_aries Feb 09, 2005 21:15
Aaah I see that it's version 0.9.0.10 - what would be the difference in the script in this case?
12 djones Feb 10, 2005 20:56
Is it possible to have all this happen automatically when an Administrator sets up a new user manually through the admin panel?
David
13 powerspike Feb 10, 2005 22:29
djones wrote:
Is it possible to have all this happen automatically when an Administrator sets up a new user manually through the admin panel?
David
I'm quite sure it is - but if your setting up a user manualy, it's only going to take a couple of extra seconds to manualy add a new blog and catagory as well ? and you'll be able to custom name / custamoize the blog a little as well ?
bellator Aries wrote:
Aaah I see that it's version 0.9.0.10 - what would be the difference in the script in this case?
Afraid i can't answer that one, obviously there is either a different in the tables that are having data added to them (either an extra field, or one missing), or the coding is different. i would be assuming the first choice there.
i don't have a copy of 0.9.0.10 (and honestly don't feel like setting up up either :P quite sure you can understand) so can't check.
14 edb Feb 10, 2005 22:38
The differences from ...10 to ...11 were in the code. Small diffs to clean up this and that, but enough that hacks for the current release sometimes don't go backwards. You should upgrade.
15 djones Feb 11, 2005 00:02
I'm quite sure it is - but if your setting up a user manualy, it's only going to take a couple of extra seconds to manualy add a new blog and catagory as well ? and you'll be able to custom name / custamoize the blog a little as well ?
It is, I agree, but I'm setting this up for a school and would like some staff to be able to setup blogs for children very quickly with the minimum of clicks etc.
I've only just started to experiment with b2evo so I'm unsure at the moment where everything fits together plus my php skills are not far above noobee level ;-)
Thanks, David
16 powerspike Feb 11, 2005 02:26
well if your getting the teachers themselfs to do it, maybe just get them to do all the accounts by hiting the register link ?
17 djones Feb 11, 2005 09:19
But wouldn't this also allow children to still register themselves?
18 powerspike Feb 12, 2005 11:43
well how about this as a quick solution.
in the register screen, add in a "add user password" field
ie <input type="password" name="teacherpassword">
and at the top of /htsrv/register.php - add in a little section, that checks the password, and if isn't right, just redirects them back to the register page
ie
right at the top after the <?
if($_POST['teacherpassword'] != "supersecretpasswordthatyouwontguess")
{
header("Location: http://" . $_SERVER['server_name'] . "/htsrv/register.php");
die();
}
(you should be able just to dump that straight in excuse formatting :P)
that way - the teachers can still add all the blogs themselfs, and the students wouldn't be able to at all :P
very quick and simple :P
and fits the purpose ?
19 djones Feb 12, 2005 14:49
Superb and as you say...very simple! This certainly fits the bill.
However, it doesn't seem to be working. I've added the code to 'register.php' and altered the '_reg_form.php' file (I'm assuming that is correct) to include the new form field. When I click register using an incorrect password it still goes through ok.
Can you help shed any light on this?
Thank you, David
20 powerspike Feb 13, 2005 01:43
if($_POST['teacherpassword'] != "supersecretpasswordthatyouwontguess" && $_POST['action'] == "register")
{
header("Location: http://" . $_SERVER['SERVER_NAME'] . "/htsrv/register.php");
die();
}
try that :P
tested and works :P
and it doesn't put you into a continious redirection loop either :P
(in my defence the code a couple of posts above was typed out off the top of my head without testing :P)
21 djones Feb 13, 2005 02:19
Cracking! That doesn't now allow users to register, however, when you click register with an incorrect password, I get a page cannot be found.
I have tried various alterations but to no avail?! Am I being really thick or am I just not learning fast enough :lol:
Thank you for your efforts so far!
22 djones Feb 13, 2005 02:27
Never mind!
I needed to put in...
if($_POST['teacherpassword'] != "password" && $_POST['action'] == "register")
{
header("Location: http://" . $_SERVER['SERVER_NAME'] . "/blogs/htsrv/register.php");
die();
}
...the complete (subdirectory) path of the b2evolution installation folder!
Sorry and thank you again for your efforts!
23 powerspike Feb 13, 2005 06:48
arrrrr yes yes :P
different install location would of caused that for sure - i have b2 sitting on my base url (hence the page not found for you =))
good to hear !
hope it works out well djones =)
24 jc May 29, 2005 10:08
:roll:
when the users had just created his own blog he doesn't recieve the mail confirmation, i do recieve it ( the adminitrator)
what can i do ?
thank you
(Edit : fixed typo's in code - should be fine now)
barkingstars little hack basicly almost done what i had wanted, have added somethings to it
What this does IS
1) Creates A _NEW_ Blog
2) Adds in Permissions for the New Blog for the new User (so they can access it :P)
3) Adds in a default generic category so that they can post straight away if they like.
ok just a couple of notes
*if YOUR install has a table prefix other then evo_ you'll need to change the evo_ part of the "insert into evo_XXX" query lines.
* it'll add a blog for EVERY user that signs up.
* done on version 0.9.0.11
could be a hell of alot prettier, but it's only a 5 min hack :P
Open UP htsrv/register.php
find
Add in right after
Next,Open UP _class_db.php
find (aprox row 203)
ADD Before
[/b]