Jamesking56 Posted September 5, 2010 Share Posted September 5, 2010 Hey! I'm trying to use the licensing addon in WHMCS for my product but i'm having some trouble. How do I parse the addons from the product? I have the check code working and it shows their name etc. Here is what it shows when printing the array: Array ( [status] => Active [registeredname] => James King [email] => james@jamesking56.co.uk [productid] => 6 [productname] => MyShout Free License [regdate] => 2010-09-04 [nextduedate] => 0000-00-00 [billingcycle] => Free Account [validdomain] => jamesking56.zapto.org,www.jamesking56.zapto.org [validip] => 192.168.1.68 [validdirectory] => F:\xampp\htdocs\MyShout\TEST [addons] => name=Test License Addon;nextduedate=2010-10-05;status=Active|name=Test License Addon 2;nextduedate=2010-10-06;status=Pending [checkdate] => 20100905 [localkey] => 9tjI1ATOwATMwIjI6gjOztjIlRXYkt2Ylh2YioTO6M3OicmbpRmblBVPzVHdhR3c7YDMtATMtATMwITP lRXYkVWdkRHel52OyAibvRGZBBSZz5WZjlGTgQ3clRVPl1WYuxXZ2lGdjFUPzVHdhR3c7UDMtATMtATM wITPlRXYkVWdkRHel52Ou9GZkFEIlNnblNWaMBCdzVGV9UWbh5mI6QjMxozc7Iycu9GZkFmI6YjOztjI UNVRUxFd19GaTlXTcN3YvRGdoxFcw1WY4xlOGJiO4IjOztjI5J3b0NWZylGZklGbhZnI6QTM6M3OigjN uEjL4YTMuITOxIiOyEjOztjIwlGZpxWY2JiO3ozc7IyZy9mLvRHchpnL2UzZul2azVWbhpmL3d3dscmc v5yb0BXY65iN1cmbpt2cl1WYqJiO3QjOztjIulWYt9GZklGbhZnI6ETM6M3OiQnb192YjFEIlVmcGJiO yEjOztjIlx2Y5N2ZulGbslmYiojMxozc7ICMw0CMw0CMwADMioDMxozc7ISZ0FGZlVHZ0hXZuJiOxEjO ztjI0ATL5ATLwEDMyIiOwEjOztjIlRXYkdWZyJiO3ozc7ISZz5WZjlGTgUWZyZEI0V3boNVeNJiOwIjO ztjIl1WYuR3Y1R2byBnI6ETM6M3OiYjI6EjOztjIklGdjVHZvJHcioTO6M3OisWdu82YuYTNn5WarNXZ tFmaANXZtFmaiozMyozc7ICbpFWblJiO1ozc7IyZul2SgMXZtFmSioDMxozc7ISZtFmbkVmclR3cpdWZ yJiO0EjOztjIlZXa0NWQiojN6M3OiMXd0FGdzJiO2ozc7pzMxoTYae9524b945f9c4eaef2e0e892291 3e019b28298da0bd1347f20a2c48a0f2eb84 [remotecheck] => 1 ) How do I parse the [addons] => part? its just a long string with ; and |.... Whats the best way to parse it and remove the name= etc. 0 Quote Link to comment Share on other sites More sharing options...
kongolo Posted August 17, 2011 Share Posted August 17, 2011 I suppose you want to do this in PHP, if so looks like you need to explode the string first on "|", this will give you the different addons, then on ";", this will give you the parameter sets for each addon and finally each parameter on "=" and this should give you then pairs of parameter name and value. Something like this should do the trick. This function will return true if the license is valid for the addon and false if not. function checkAddon($addons,$addonName) { $addonsArray=explode("|",$addons); foreach ($addonsArray as $addon) { $pairs=explode(";",$addon); $name=$status=''; foreach ($pairs as $i => $pair) { list($id,$value)=explode("=",$addon); if ($id=="name") $name=$id; elseif ($id=="status") $status=$value; } if ($addonName == $name && $status=='Active') return true; elseif ($addonName == $name && $status!='Active') return false; } return false; } 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.