Basic PHP Site with billing profiles

Started by tmlander, February 17, 2012, 09:50:37 AM

Previous topic - Next topic

tmlander

Hello out there!!

Been looking around for a little bit but not quite sure where to turn for some advice...

I have a site I am working on that is a subscription style site....

Basically I need a means to manage users and a billing profile and I am wondering how to take my next step....

I bought a basic user management script but then I realized I would like a forum on this site and I could probably manage users that way instead anyway....

Basically I am thinking that I could use SMF to manage users with some tweeks and then I could set up a different table to handle billing profiles....

I read some and realized there was some talk about in SMF.... out of SMF... using integration hooks.... etc.... so I think I could handle login logout with SMF anywhere on my site... but not sure where I should set up other data... Should I set it up on the same database as SMF... will it matter...?

Any advice would be appreciated....

Thanks...

spottedhog

OK, this is just my personal preference here.  Let SMF provide the members table, the membergroups table, and the subscription table.  If you do this, you will not need to mess with any integration hooks. 

The basic idea is to include the SMF file called SSI.php in whichever php files you are using.  SSI.php brings in EVERYTHING from SMF so can code your PHP files accordingly.  Permissions and member info is contained in the $context variable.

Of course there are more details, but that is it in a nutshell.

tmlander

Thanks for the info....

Of course, it will be more than just a paragraph of work but it give me an idea of what is possible and I appreciate that...

I will have to do some more reading to get a better idea....

Basically I would use my own header, footer, etc. and then drop the forum into the body...

I am hoping that is easily accomplished...

Thanks for your help

Kindred

Actually, no... Doing that is not actually all that simple.

Linking to another system canbe a bother, hut is fairly straight forward... Getting the forum wrapped in another system is  less so.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

vbgamer45

Example page and browser used?

I see some pages have an extra topic title in the center area on topic display.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

spottedhog

#5
tmlander, it is very easy to use the SMF theme/graphical look for your code.  Does SMF have a theme exactly like you want?  Well, with the low selection and variety of SMF 2.0 themes, maybe not, but it is not that hard to create something using your own graphics.  For me, I look for a layout I like then make changes where needed.  The end result is that your code and the forum code will display the same graphical look.

Side note:  wish someone with time on their hands convert most of the SMF 1.1.x themes to 2.0...  (I know, major task)

OH tmlander, you can use any theme version 2.0 RC3 or higher.  (another wishful thought here... allow a theme search that would include all themes 2.0 RC3 or higher to be shown on the Theme page here.  It is a pain in the butt to go through every page of every category.)

Not sure how important or critical this is for you, but in using the $context variable you can dynamically display meta page title and meta keywords.  :-) Actually you can use SMF's $context to make it work better for outside code than it works for the forum code.

spottedhog

#6
The Basics:

-Include SSI.php into a file that you include in nearly all your other files.  For example, maybe you have a file that creates the database connection.  Include the SSI.php file on the first line.

OK, soapbox mini rant...  There have been times in the past where it was recommended that one "include" SSI.php on every outside code line.  In my feeble mind this leads to possible errors.  I like to "include" something just once somewhere and then forget about it.  Just my humble opinion.

-Create a function or file that includes this line to display the SMF header -->  template_header();

-Create a function or file that includes these lines to display the SMF footer  -->  themefooter();   ssi_shutdown();

Now your regular page PHP/html can be put between your new header and footer.

Next, for each page and/or function, you can use the $context variable.  Of course for functions you will need to "global" it.


Here are the key $context variables I use:

if ($context['user']['is_guest'])  ---> checks if visitor is guest
if ($context['user']['is_logged')  ---> checks if visitor is logged in
if ($context['user']['is_admin'])  ---> checks if visitor is an admin


if (in_array(9, $user_info['groups'])) ---> checks if user is in Group 9 (or whatever membergroup # you use)  (global $user_info)  You would use this for your Subscriptions.
if (in_array(9, $user_info['groups']) || $context['user']['is_admin']) ---> checks for Group 9 and also allows the Admin access


You can do a check for multiple groups but you would need to use array_intersect instead of in_array.  For example:

$mygroups = array(10, 13, 15);
if (array_intersect($mygroups, $user_info['groups']) || $context['user']['is_admin'])


Other $context Variables:

$context['user']['id']  (great for pulling in the id_member table field to be stored in your code tables)
$context['user']['name']  (used to display the logged in visitor's name)


Meta Tags:

$context['page_title_html_safe'] = 'page title here';
$context['meta_description'] = 'meta tag description';
$context['meta_keywords'] = 'meta keywords here';


You can also pull in avatars, IP addresses, gender, custom profile fields, and many more variables.  I just listed the ones you will use probably 95% of the time.

Here is a function I created that pulls in all the possible Member data:

function memberinfo ($id_member) {
global $memberContext;
loadMemberData($id_member);
loadMemberContext($id_member);  // found in file:  forum/Sources/Load.php around line: 1080
return $memberContext[$id_member];
unset($memberContext);

// Partial list of available memberinfo --- called like this:
// ---replace "$id_member"  with the Member's id_member number  OR use this:  $id_member = X;  // where:  X = member's id #
// Example of usage:
// global $memberContext;
// $id_member = 1;
// memberinfo($id_member);
// echo $memberContext[$id_member]['gender']['image'];
// ---the above will display the Admin's (whose ID# = 1) gender image---

//               Info List
// $memberContext[$id_member]['name']
// $memberContext[$id_member]['buddies']
// $memberContext[$id_member]['title']
// $memberContext[$id_member]['link']
// $memberContext[$id_member]['email']
// $memberContext[$id_member]['registered']
// $memberContext[$id_member]['blurb']
// $memberContext[$id_member]['gender']['name']
// $memberContext[$id_member]['gender']['image']
// $memberContext[$id_member]['website']['title']
// $memberContext[$id_member]['website']['url']
// $memberContext[$id_member]['birthday']
// $memberContext[$id_member]['signature']
// $memberContext[$id_member]['location']
// $memberContext[$id_member]['real_posts']
// $memberContext[$id_member]['posts']
// $memberContext[$id_member]['avatar']['name']
// $memberContext[$id_member]['avatar']['image']
// $memberContext[$id_member]['avatar']['href']
// $memberContext[$id_member]['avatar']['url']
// $memberContext[$id_member]['last_login']
// $memberContext[$id_member]['last_login_timestamp']
// $memberContext[$id_member]['karma']['good']
// $memberContext[$id_member]['karma']['bad']
// $memberContext[$id_member]['ip']
// $memberContext[$id_member]['ip2']
// $memberContext[$id_member]['online']['text']
// $memberContext[$id_member]['online']['link']
// $memberContext[$id_member]['langauge']
// $memberContext[$id_member]['options']['custom_field_name']   // replace "custom_field_name" with the true Custom Field Name
// $memberContext[$id_member]['group']
// $memberContext[$id_member]['group_id']
// $memberContext[$id_member]['post_group']
// $memberContext[$id_member]['warning']
// $memberContext[$id_member]['local_time']
}  // end function memberinfo


This is the tip of the SMF iceberg, but there is maybe enough code to do what you were originally asking.

tmlander

Wow... thanks for everybody's suggestions... I will have to sift through them and see what works and applies to me at this point.... I was able to dive into integration with my custom php site and have it working...

The biggest reason I posted here with this issue is that I found the integration manual that is posted online to be out of date.  After some disagreeable altercations with the <a href="http://wiki.simplemachines.org/smf/Integrate_SMF">online manual for integration of SMF found here</a> I dove in solo... It really wasn't that hard but being new to php as well made it a little more trying...

Below is the first step in the manual which actually helped me....

Quoteyou'll want to make a copy of the default theme.  To do this, go into your administration center, and select "Theme and Layout Settings".  From there, under "Install a New Theme", type a name for your theme next to "Create a copy of Default named" and click Install!  You will be prompted to click OK - please do so.

Now you have a copy of the default theme.  If you want to customize the images for your theme, go to the theme's settings and change the URL from default/images to "yourname"/images, and use an FTP client to copy the files from default into your theme.

After I had a copy of the default theme... I went ahead and began editing the theme's index.template.php file.... This should be located in the Themes folder... So
Your-install-root-directory/Themes/Your-Copied-Default-Theme-Folder/index.template.php

So far so good... then I tried to do what the manual linked above said... which was create two seperate files for the header and footer but I kept getting errors... finally I said screw it and simply edited the index.template.php file itself....

basically just edit the functions:
function template_html_above() - HEADER
function template_html_below() - FOOTER

This is how I did it but I am sure there are other ways... I am using version 2.0.2 of the forum... I have also used this
< a href="http://wiki.simplemachines.org/smf/How_to_use_the_SMF_user_system_outside_of_SMF">Here</a>
which showed me how to use SSI and get the login/logout functionality working...

Pretty slick system thus far... Hope my comments and those above helps anyone trying to integrate this great software to their existing php site...

Advertisement: