Last active
December 11, 2015 10:08
-
-
Save anvyst/4584705 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Custom API function to extract all products configoptions from tblproducts */ | |
if( preg_match('/^\d+$/', $_POST['pid']) ) { | |
$resource_id = mysql_query("SELECT * FROM tblproducts WHERE id='{$_POST['pid']}'"); | |
$rows = mysql_num_rows($resource_id); | |
$xml = array(); | |
$xml[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; | |
$xml[] = "<whmcsapi version=\"5.1.3\">\n"; | |
$xml[] = "<action>getproductconfigurations</action>\n"; | |
if( $rows !== 0) { | |
$xml[] = "<result>success</result>\n"; | |
$xml[] = "<totalresults>".$amount."</totalresults>\n"; | |
$xml[] = "<products>"; | |
while( $row = mysql_fetch_assoc($resource_id) ) { | |
$xml[] = "<id>{$row['id']}</id>"; | |
$xml[] = "<configoption1>{$row['configoption1']}</configoption1>"; | |
//and all the stuff you want to get from tblproducts records | |
} | |
$xml[] = "</products>"; | |
} else { | |
$xml[] = "<result>error</result>"; | |
$xml[] = "<message>Couldn't find product by {$_POST['pid']}</message>"; | |
} | |
$xml[] = "</whmcsapi>"; | |
echo join("\n", $xml); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment