|
uCoz Community Additional Services PHP and API on uCoz Simple authentication script for uCoz with PHP and API |
![]()
Simple authentication script for uCoz with PHP and API
|
The script blocks access of people who are not administrators group PHP script.
Remember: You must be logged in on the site to be allowed. How to use auth.php Code <?php /* * Developed by Ennio Sousa http://uid.me/shzlot * 20/08/2015 */ /* * You need allow API usage in Common settings * Screenshot https://goo.gl/W5EBw9 */ $apikey = '';// Optional - If you choosed use API key if(ucoz_getinfo("SITEUSERID")){// users not logged in is 0 (or false) $host = $_SERVER["HTTP_HOST"]; $userid = ucoz_getinfo("SITEUSERID"); $url = "http://$host/api/index/8-$userid?apikey=$apikey"; $context = stream_context_create(array('http' => array('method' => "GET", 'header' => "Content-Type: text/xml",))); $file = file_get_contents($url, false, $context); $response = xmlrpc_decode($file,"utf8"); if ($response && xmlrpc_is_fault($response)) { $___error = "Can't receive data, try again later or contact."; exit; } //USER_GROUPID if( $response['USER_GROUPID'] != 4 ){// 4 is admin group ID $___error = "User does not have permission."; exit; } } else{ $___error = "User does not have permission."; exit; } ?> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 script.php Code <?php include 'auth.php'; /* * Pen you code here */ 1 2 3 4 Hello! I am Ennio Sousa
Post edited by BraziluCoz - Friday, 2015-08-21, 5:13 AM
|
| |||
| |||
Need help? Contact our support team via
the contact form
or email us at support@ucoz.com.