Jump to content

My final question about integration


Kian

Recommended Posts

I make it very simple

 

My WHMCS is installed on xxxxxxx.tld

My website is installed on yyyyyyy.tld

 

They are on 2 different servers. I want to integrate content from WHMCS such as knowledgebase, announcements on yyyyyyy.tld. Possible solutions:

 

a) php include(). Not possible because you can't include scripts from xxxxxxx.tld to yyyyyyy.tld.

b) iframe. Don't want because it sucks for web browsers.

c) ajax iframe (s2s). Tryed tens of time but it's a mess because of relative paths.

d) create my own sql + scripts to skip WHMCS. No omg! Hard work, long to do, totally unsupported and tricky for WHMCS updates.

 

After so many tryes i relized that i can't do this with the above a,b,c,d. The easyiest way i found is uploading in my website all files of WHMCS reqired to show announcements and knowledgebase. Example:

 

templates/default/knowledgebase.tpl

templates/default/announcements.tpl

includes/smarty/[ALL]

includes/dbfunctions.php

includes/functions.php

configuration.php ($db_host with IP address and not localhost)

dbconnect.php

knowledgebase.php

announcements.php

 

Can someone of WHMCS Staff tell me what files are required? Or al least can you provide us a script that allow us to inlcude WHMCS pages on external website? It's true that WHMCS is fully customizable but not all users use WHMCS on mywebsite.com/clientarea or clientarea.mywebsite.com. There is also a group of users that use WHMCS on a separate hosting for security reasons or because they have more that one e-commerce website. It's sad that we have nothing that let us integrate easily WHMCS.

 

Note: when i say that i want to integrate announcements on my website i'm not talking of "Last 5 announcements" module or similar scripts. I don't want to redirect users on WHMCS when they read announcements or knowledgebase. I want to view this content in my website.

Link to comment
Share on other sites

Update

 

Well i tryed for about 2 hours... i tryed uploading almost the entire WHMCS directory. Blank page. At this point i wonder if someone from the Staff can PLEASE share the sql queryes and a base script to get announcements and knowledgebase (articles and categories) directly from database.

 

In documentation we have a basic and very simple "Last 5 news" php + tpl. Why can't we have the same for announcements and knowledgebase?

 

It's 2 years that i'm WHMCS customers and amost every month i face this problem of integration >.< never succeded in fixing it... i'm boring :(

Link to comment
Share on other sites

Use curl and regex :

 

myserver.tld/test.php

<?php
$target_url = 'http://demo.whmcs.com/knowledgebase.php';
$this_page = 'test.php';

$tail = ( !empty( $_SERVER['QUERY_STRING'] ) ? '?'.$_SERVER['QUERY_STRING'] : '' );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url.$tail  );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
// cats
$output = preg_replace( '~^.+?(<h2>categories</h2>.+?</table>).+?$~is', '$1', $output );
// articles
$output = preg_replace( '~^.+?(<h2>articles</h2>.+?)<br /><p align="center">.+?$~is', '$1', $output );
// article
$output = preg_replace( '~^.+?(<h2>.+?)<br /><p align="center">.+?$~is', '$1', $output );
echo preg_replace( '~knowledgebase\.php~i', $this_page, $output );
?>

 

Note : You'll also need to handle $_POST if you want to enable voting and stuff

 

¥

Link to comment
Share on other sites

Very helpful, thank you

 

I never used curl before. I don't understand a single line of this code :P Anyway i can understand the first part

$target_url = 'http://mywhmcs.com/knowledgebase.php';
$this_page = 'knowledgebase.php';

How can i halde it dinamically? I mean now it's like a simple "print" page. All links contained in the page are mywhmcs.com/knowledgebase/id/title. I can replace mywhmcs.com with mywebsite.com but pages does not exist in mywebsite.com... so how can i change dinamically the $target_url?

Link to comment
Share on other sites

The reason why it looks like a print is because it just pulls out the body of the page as I was under the impression that you wanted to embed it on your site, could you possibly give me a real link for yyyy.tld so I can see what you mean by the urls point to xxxx.tld?

 

For clean urls you *should* (untested) just be able to add this snippet to your htaccess on the site that you're displaying the articles on : (yyyyy.tld)

 

# Knowledgebase
RewriteRule ^knowledgebase/([0-9]+)/[a-z0-9_-]+\.html$ ./knowledgebase.php?action=displayarticle&id=$1 [L,NC]
RewriteRule ^knowledgebase/([0-9]+)/([^/]*)$ ./knowledgebase.php?action=displaycat&catid=$1 [L,NC]
RewriteRule ^knowledgebase$ ./knowledgebase.php [L,NC]

 

¥

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated