Using a CMS with an external database - php

I am looking at building an external site with a CMS, probably Drupal or ExpressionEngine. The problem is that our company already has a membership database that is designed to work with our existing enterprise software, currently the membership database consists of over 400k rows.
Migrating data from the database manually is not an option as modifications and new data must be accessible in real-time. Because the design of the external database will differ from the CMS's own I have decided the best way forward is to use two databases and force the CMS to use the external to read user information (cannot write to) and a local for everything else the CMS needs to do (read + write).
Is this feasible with these Drupal or ExpressionEngine? Ideally I need to be able to use hooks as I do not wan't to modify core CMS files. Sifting through the docs I am not able to find what I would hook into for ether CMS.
(Note: I know it is possible, but I want to know if it's feasible).
Finally if there is a better way of handling this situation please also chime in. Perhaps there is something at the database level to reference a column in an external database?
I'm clutching at straws someone can point me in the right direction I'm sure.
Edit: Moodle has this functionality built in. Moodle is not suitable to my needs but perhaps their documentation will help you understand my issue better: Moodle - External database authentication

If the data is to remain in an external database, then you probably want to look at creating a web service like an API that allows your external site to access the data. Queries to an external database or notoriously slow.

I'm not a Drupal (D)/ExpressionEnginge (EE) Expert.
For TYPO3 (which I know in depth) (and also for D & EE, I think) you can write your own extension which fetches the user data from your membership database and stores them in the local frontend or backend user table for temp. authentication.
We have build such a thing for a big financial institution even with single sign on and setting the corresponding rights depending on the remote groups.
There are plenty of TYPO3 extensions which can be used as an example.
The other possibility is to avoid again the real time feature and use a synchronization script on database level with checks the membership tables with the D or EE user table in e.g. 5min rhythm.
There is also the option to use a LDAP authentication.
If databases are all MySql then you can create a view which points to the remote membership table you only need to implement the correct columns.
It is always a bad idea to modify the core. ;-)

There's an EE extension for working with external data in MySQL: http://devot-ee.com/add-ons/external-entries . I don't know what db you'll need to access or if this might be made to work with it, though.

In ExpressionEngine there are six tables that contain Member and Member Group data (EE's lingo for users/user groups).
exp_members
exp_member_groups
exp_member_bulletin_board
exp_member_data
exp_member_fields
exp_member_homepage
In all likelihood you'd need to sync your user database with exp_members and exp_member_groups at a regular interval to make this happen. Trying to have EE connect to the external DB will likely get you in trouble fast.
If you are simply wanting access to your external database, you can write plugins that connect behind the scenes and make your data available inside your templates.
I worked a a Rails app once that pushed the Rails users to become EE members and shared sessions between them so users could view both systems and stay logged in.

Related

Enhancing Performance of Change History Logs in CRM App

I’m a completely new developer so forgive me for asking something weird but any help would be appreciated.
I’ve been assigned a feature enhancement task for an application.
The application is a CRM type application built using Core PHP / Phalcon Framework... the DB is on MySQL... it's a fully running application and needs some enhancements to existing features.
The CRM has a list of Contacts. Any user of the CRM who updates the profile of a contact, the system writes the change to it log.
There is a button called “History” when the user clicks on it, it shows the list of all changes that have been made to that particular contact… along with a couple of other information - like a revision history.
The changes are maintained and displayed from a few different tables in the DB.
The system is currently showing the changes but in plain text format.
Now the main requirement is to enhance this feature and make it look like a Facebook Timeline and also make sure that the page load times are much faster and retrieving the history of changes does not take a lot of time and does not affect performance of the CRM.
What should one do in such cases? What are the different ways to render information from different tables without affecting the performance.

Website Replication using PHP

I would like to know the concept of website replication where when a user sign up a subdomain is created and the user can create his website online. Just the way it is being done in www.empowerkit.com
Lots of ways to structure multi-tenant SaaS.
There is the single site, single database database approach:
Basically you have the website binding listen to * on a dedicated IP Address.
DNS Bind *.yourdomain.com to ip address
Have your signup function create a customer database record containing the subdomain.
Have routing code that can determine what the customer id is for a specific request on a subdomain, then use row-level filtering in your data repository to only return data for that specific customer id.
You could also have your code create a whole separate website on the filesystem, and add the appropriate virtualhosts entries for the new site.
Pros: Less database overheads from multiple database instances, easy to backup and restore (single database)
Cons: Bit more working getting the data access, harder to shard
Then there is single-site, multi-database:
Same as above, but the subdomain maps to a specific customer database.
Pros: Easier to shard, Customer database better segregated
Cons: High memory overhead, requires lots of database instances, hard to backup
Finally, multi-site multi-database
You create separate physical sites and add the appropriate virtualhost records for your clients during signup, as well as creating a separate database for that client
Pros: Simple application code, easy to scale, better user segregation, easier to customize "per user" if required.
Cons: Complex "signup code", requires lots of resources, requires your application to have write access to important configuration files, wastes lots of disk space.
It depends on how your application works and what per user customization you offer.
Well, for the subdomain part you could:
Use a database and .htaccess to redirect
Use your control panel API (like DirectAdmin API)
The user can create his website with a WYSIWYG (What You See Is What You Get) editor (as CMS) and save all the content in a SQL database which you can retrieve later on to display the page.
I don't think there's a simple answer to what you are asking. Most effective solutions actually have the concept of dealing with the sub domain built into the product.
It all depends on the environment you are going to deploy in and what runs your site.
Many CMSes can deal with serving different content for the subdomain by nature.

How to capture session information from PHP in ASP?

I'm working in a website that is going to work like a landing point, providing a specialized service for many other websites. Users log-in to different sites and those sites have links to my website.
Now, I want to create my website using asp .net, and also I want to be able to use SSO (Single Sign-On) so the users doesn't have to authenticate again when they land on my site.
The problem is that most of the websites that are going to use the services of my site are in php, when users login on these sites, all the authentication process is handled and also a lot of data is fetched into the Session variable; what I want to do is to be able to capture all the data in the session variable coming from the php page, in my asp site.
I don't know if this is possible, maybe this can be done in another way
So far, the only thing I've been able to do in the asp is, ask for a parameter in the url and using that parameter query the database to get all the data that was already in the session in php.
So if any of you know a way to do this.
Thanks
My company does this extensively. Our app passes information from our software to other systems such as CRM's, appointment schedulers, data aggregators, etc. In cases where systems are radically different and access is not explicitly given, the best solution we've found is to use cURL and negotiate a data interchange via API. Setups with people of varying technical abilities can be challenging (we've actually provided code for several systems we wanted to communicate with) but in the end it's efficient and secure.
Unlike many UI guys, I'm a fan of OpenID for single login. However, that doesn't pass all the data you likely want to interchange between the sites.
You could either use a database as a session store point accessible by all pages. this makes it pretty easy to access session data by either php or asp.
I think this would be the mos performant way.
If you don'T want to give the other php sites any access to your databases you also could create a special page not for vewing in asp and tell the php sites to drop the session contents via curl there and in that sie then save the session stuff in your database.
It's not clear from your question whether you are hosting both ASP and PHP websites on one server or if your ASP site will be used with other third-party sites.
If you run and manage the ASP and PHP sites on one machine, then storing session information in the database will be the way to go and isn't too difficult. You'll need to make sure that the session data you store in the database can be read by both PHP and ASP--I'd pick something simple like JSON. A url parameter would be a bad way to get at this data, as it makes user information available to anyone who could guess a user id.
It's not so simple, however, if you want to provide SSO capabilities with third party sites. In this case, you'll have to implement an authentication API that the third party sites can call to log their user into your site when they initially authenticate the user on their own.

PHP e-commerce site talking to internal database for stock / ordering?

I'm working on an e-commerce site (either bespoke with PHP, or using Drupal/Ubercart), and I'd like to investigate the site interacting with an internal (filemaker) database we use to manage stock and orders. Currently we manually transfer orders from the web site to our own database, and the site does not check or record changes in stock.
My plan to allow the 2 to interact is as follows:
Make the internal database available externaly on a machine with a fixed IP
Allow external access from the site only
Connect to the internal database using ODBC (or similar)
Use simple queries to check stock / record stock changes / record order details
Am I missing something here as this sounds quite straight forward?
Is there another solution I should be taking a look at?
Thanks in advance for any help or comments.
Your plan sounds completely straightforward. You might want to consider making sure that end-users can never take an immediate action that updates the backend. Backend stuff should only be modified when a backend user takes an action, i.e. approves of an order. I'm not sure how your preferred e-commerce solutions work, though.

Login Integration in PHP

In my host, I currently have installed 2 wordpress applications, 1 phpBB forum and one MediaWiki.
Is there a way to merge the login so that all applications share the same credentials?
For instance, I want to register only in my phpBB and then I want to access all other applications with the given username and password.
Even if you don't know a unified way, what other login integration do you know of? Pros and cons of each?
when you integrate the system. Just remember 2 things:
Login to system
Check username/password with both systems.
Change of Password
Update the password on both systems.
I don't know how to share the session cookies, but you can easily share the same login.
i.e. People will need to log separately into both sites, but will be able to use the same username and password.
In the mediawiki file "LocalSettings.PHP", you can tell it to use a different (wordpress) database for authentication:
e.g.
require_once('includes/AuthPlugin.php');
require_once('extensions/AuthPress.php');
$wgAuth = new AuthPress();
$wgAuth->setAuthPressTablePrefix('evo_');
# Only include the following if you aren't using the same db as MediaWiki
$wgAuth->setAuthPressDBServer ('localhost');
$wgAuth->setAuthPressDBName('yourWordPressDB');
$wgAuth->setAuthPressUser('mySQL user for same');
$wgAuth->setAuthPressPassword('The password');
See http://bbpress.org/forums/topic/mediawiki-bbpress-and-wordpress-integration
One option is OpenID, which you can integrate into phpBB, WordPress, and MediaWiki.
A second option is to set up an LDAP server, which you can also integrate into phpBB, WordPress, and MediaWiki.
If the sites are all on the same root domain, a third option is to modify the registration, login, and logout code so that these actions are replicated on every site at the same time. This gets messy, but it may be the easiest short-term solution if you're in a hurry. Once you track down the account code in each site, it's just a matter of copying and pasting and changing a few cookie parameters.
If you're integrating a bunch of different apps, and you really just want a bridge, I've had good success with the bridge from Single-Signon.com. You can see there supported apps here:
http://www.single-signon.com/en/applications.html
I've also used a MediaWiki extension for phpBB integration:
http://www.mediawiki.org/wiki/Extension:PHPBB/Users_Integration
I once did a phpBB/MediaWiki login integration from the phpBB end.
Check it out.
Having tried to do this some years ago I remember it not being very easy.
The way I did it was to create totally new table to user/pass and then replace these columns in the respective software with foreign keys to your new table - this required a lot of custom tweaking of core files in each application - mainly making sure all SQL requests to this data have the extra join needed for your new table. If I find the time I will maybe try and provide a step by step of the changes needed.
There are some pretty big drawbacks to this approach though. The main one being from now on your gonna have to hand update any patches
If you have no content or users yet look at http://bbpress.org/documentation/integration-with-wordpress/ which will make things a lot simpler for you.
I can't quite remember but I believe that I big problem I had was that MediaWiki requires usernames formatted a certain that conflicted with phpBB.
Of course, a totally different approach would be to mod each piece of software to use OpenID _ I believe plugins/extensions are readily available for all the applications you mentioned.
I personally think that integration login systems is one of, if not the, hardest job when utilizing multiple prebuilt applications. As a fan of reuse and modularity, I find this disappointing. If anyone knows of any easy ways to handle this problem between random app X and random app Y, I would love to know.
You can write a custom login hook for mediaWiki. I've done it for LibraryThing so that login credentials from our main site are carried over to our mediaWiki installation. The authentication hook extends mediaWiki's AuthPlugin.
There are several small issues:
mediaWiki usernames must start with initial caps (so if you allow case sensitive user names it could be a problem if two users have colliding wiki names)
underscores in usernames are converted to spaces in mediaWiki
But if you can deal with those then it is certainly possible to use your own user/password data with mediaWiki.
Advantages:
The user doesn't have to login to each area separately. Once they login to the main site they are logged into the wiki also.
You know that usernames are the same across the systems and can leverage that in links, etc.

Categories