X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=extlib%2Flibomb%2Fhelper.php;h=08e6e7ab4460cfe75c53d993d2068d29ea2f9987;hb=382756a6ada508131ab1408a94daf7617a8fa0fc;hp=a1f21f2680e7093ee8c0d0baf3a2da8032cd9f27;hpb=c5047fd90ac8f6f057780a34065e320883c7a31f;p=quix0rs-gnu-social.git diff --git a/extlib/libomb/helper.php b/extlib/libomb/helper.php index a1f21f2680..08e6e7ab44 100644 --- a/extlib/libomb/helper.php +++ b/extlib/libomb/helper.php @@ -1,11 +1,6 @@ . * - * @package OMB - * @author Adrian Lang - * @copyright 2009 Adrian Lang - * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0 - **/ + * @package OMB + * @author Adrian Lang + * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0 + * @version 0.1a-20090828 + * @link http://adrianlang.de/libomb + */ -class OMB_Helper { +require_once 'Validate.php'; - /** - * Non-scalar constants - * - * The set of OMB and OAuth Services an OMB Server has to implement. - */ +/** + * Helper functions for libomb + * + * This class contains helper functions for libomb. + */ +class OMB_Helper +{ - public static $OMB_SERVICES = - array(OMB_ENDPOINT_UPDATEPROFILE, OMB_ENDPOINT_POSTNOTICE); - public static $OAUTH_SERVICES = - array(OAUTH_ENDPOINT_REQUEST, OAUTH_ENDPOINT_AUTHORIZE, OAUTH_ENDPOINT_ACCESS); + /** + * Non-scalar constants + * + * The set of OMB and OAuth Services an OMB Server has to implement. + */ - /** - * Validate URL - * - * Basic URL validation. Currently http, https, ftp and gopher are supported - * schemes. - * - * @param string $url The URL which is to be validated. - * - * @return bool Whether URL is valid. - * - * @access public - */ - public static function validateURL($url) { - return Validate::uri($url, array('allowed_schemes' => array('http', 'https', - 'gopher', 'ftp'))); - } + public static $OMB_SERVICES = array(OMB_ENDPOINT_UPDATEPROFILE, + OMB_ENDPOINT_POSTNOTICE); + public static $OAUTH_SERVICES = array(OAUTH_ENDPOINT_REQUEST, + OAUTH_ENDPOINT_AUTHORIZE, + OAUTH_ENDPOINT_ACCESS); - /** - * Validate Media type - * - * Basic Media type validation. Checks for valid maintype and correct format. - * - * @param string $mediatype The Media type which is to be validated. - * - * @return bool Whether media type is valid. - * - * @access public - */ - public static function validateMediaType($mediatype) { - if (0 === preg_match('/^(\w+)\/([\w\d-+.]+)$/', $mediatype, $subtypes)) { - return false; + /** + * Validate URL + * + * Basic URL validation. Currently http, https, ftp and gopher are supported + * schemes. + * + * @param string $url The URL which is to be validated. + * + * @return bool Whether URL is valid. + * + * @access public + */ + public static function validateURL($url) + { + return Validate::uri($url, array('allowed_schemes' => array('http', + 'https', 'gopher', 'ftp'))); } - if (!in_array(strtolower($subtypes[1]), array('application', 'audio', 'image', - 'message', 'model', 'multipart', 'text', 'video'))) { - return false; + + /** + * Validate Media type + * + * Basic Media type validation. Checks for valid maintype and correct + * format. + * + * @param string $mediatype The Media type which is to be validated. + * + * @return bool Whether media type is valid. + * + * @access public + */ + public static function validateMediaType($mediatype) + { + return preg_match('/^(\w+)\/([\w\d-+.]+)$/', $mediatype, $subtypes) > 0 + && + in_array(strtolower($subtypes[1]), array('application', 'audio', + 'image', 'message', 'model', 'multipart', 'text', 'video')); } - return true; - } - /** - * Remove escaping from request parameters - * - * Neutralise the evil effects of magic_quotes_gpc in the current request. - * This is used before handing a request off to OAuthRequest::from_request. - * Many thanks to Ciaran Gultnieks for this fix. - * - * @access public - */ - public static function removeMagicQuotesFromRequest() { - if(get_magic_quotes_gpc() == 1) { - $_POST = array_map('stripslashes', $_POST); - $_GET = array_map('stripslashes', $_GET); + /** + * Remove escaping from request parameters + * + * Neutralise the evil effects of magic_quotes_gpc in the current request. + * This is used before handing a request off to OAuthRequest::from_request. + * Many thanks to Ciaran Gultnieks for this fix. + * + * @access public + */ + public static function removeMagicQuotesFromRequest() + { + if (get_magic_quotes_gpc() === 1) { + $_POST = array_map('stripslashes', $_POST); + $_GET = array_map('stripslashes', $_GET); + } } - } } ?>