idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
49,800 | public function rebuildCache ( ) { $ themes = $ this -> scanJsonFiles ( ) ; $ stub = file_get_contents ( __DIR__ . '/stubs/cache.stub' ) ; $ contents = str_replace ( '[CACHE]' , var_export ( $ themes , true ) , $ stub ) ; file_put_contents ( $ this -> cachePath , $ contents ) ; } | Rebuilds the cache file |
49,801 | public function loadCache ( ) { if ( ! file_exists ( $ this -> cachePath ) ) { $ this -> rebuildCache ( ) ; } $ data = include $ this -> cachePath ; if ( $ data === null ) { throw new \ Exception ( "Invalid theme cache json file [{$this->cachePath}]" ) ; } return $ data ; } | Loads themes from the cache |
49,802 | public function scanJsonFiles ( ) { $ themes = [ ] ; foreach ( glob ( $ this -> themes_path ( '*' ) , GLOB_ONLYDIR ) as $ themeFolder ) { $ themeFolder = realpath ( $ themeFolder ) ; if ( file_exists ( $ jsonFilename = $ themeFolder . '/' . 'theme.json' ) ) { $ folders = explode ( DIRECTORY_SEPARATOR , $ themeFolder ) ... | Scans theme folders for theme . json files and returns an array of themes |
49,803 | public function url ( $ filename ) { if ( ! $ this -> current ( ) ) { return "/" . ltrim ( $ filename , '/' ) ; } return $ this -> current ( ) -> url ( $ filename ) ; } | Return url of current theme |
49,804 | public function img ( $ src , $ alt = '' , $ class = '' , $ attributes = [ ] ) { return sprintf ( '<img src="%s" alt="%s" class="%s" %s>' , $ this -> url ( $ src ) , $ alt , $ class , $ this -> HtmlAttributes ( $ attributes ) ) ; } | Return img tag |
49,805 | private function HtmlAttributes ( $ attributes ) { $ formatted = join ( ' ' , array_map ( function ( $ key ) use ( $ attributes ) { if ( is_bool ( $ attributes [ $ key ] ) ) { return $ attributes [ $ key ] ? $ key : '' ; } return $ key . '="' . $ attributes [ $ key ] . '"' ; } , array_keys ( $ attributes ) ) ) ; return... | Return attributes in html format |
49,806 | public function request ( $ url , array $ parameters = [ ] , $ method = SocialConnectClient :: GET , array $ headers = [ ] , array $ options = [ ] ) { switch ( $ method ) { case SocialConnectClient :: GET : $ response = $ this -> _client -> get ( $ url , $ parameters , [ 'headers' => $ headers ] ) ; break ; case Social... | Request specify url . |
49,807 | protected function _handleLoginAction ( ServerRequest $ request , Response $ response ) { $ request -> allowMethod ( $ this -> getConfig ( 'requestMethod' ) ) ; $ providerName = $ request -> getParam ( 'provider' ) ; $ provider = $ this -> _getService ( $ request ) -> getProvider ( $ providerName ) ; $ authUrl = $ prov... | Handle login action initiate authentication process . |
49,808 | protected function _handleCallbackAction ( ServerRequest $ request , Response $ response ) { $ this -> _setupModelInstances ( ) ; $ config = $ this -> getConfig ( ) ; $ providerName = $ request -> getParam ( 'provider' ) ; $ profile = $ this -> _getProfile ( $ providerName , $ request ) ; if ( ! $ profile ) { return $ ... | Handle callback action . |
49,809 | protected function _setupModelInstances ( ) { $ this -> _profileModel = $ this -> loadModel ( $ this -> getConfig ( 'profileModel' ) ) ; $ this -> _profileModel -> belongsTo ( $ this -> getConfig ( 'userModel' ) ) ; $ this -> _userModel = $ this -> loadModel ( $ this -> getConfig ( 'userModel' ) ) ; } | Setup model instances . |
49,810 | protected function _getProfile ( $ providerName , ServerRequest $ request ) { try { $ provider = $ this -> _getService ( $ request ) -> getProvider ( $ providerName ) ; $ accessToken = $ provider -> getAccessTokenByRequestParameters ( $ request -> getQueryParams ( ) ) ; $ identity = $ provider -> getIdentity ( $ access... | Get social profile record . |
49,811 | protected function _getUser ( $ profile ) { $ user = null ; if ( $ profile -> get ( 'user_id' ) ) { $ userPkField = $ this -> _userModel -> aliasField ( ( string ) $ this -> _userModel -> getPrimaryKey ( ) ) ; $ user = $ this -> _userModel -> find ( ) -> where ( [ $ userPkField => $ profile -> get ( 'user_id' ) , ] ) -... | Get user record . |
49,812 | protected function _patchProfile ( $ providerName , SocialConnectUser $ identity , AccessTokenInterface $ accessToken , EntityInterface $ profile = null ) { if ( $ profile === null ) { $ profile = $ this -> _profileModel -> newEntity ( [ 'provider' => $ providerName , ] ) ; } $ data = [ 'access_token' => $ accessToken ... | Get social profile entity . |
49,813 | protected function _getService ( ServerRequest $ request ) { if ( $ this -> _service !== null ) { return $ this -> _service ; } $ serviceConfig = $ this -> getConfig ( 'serviceConfig' ) ; if ( empty ( $ serviceConfig ) ) { Configure :: load ( 'social_auth' ) ; $ serviceConfig = Configure :: consume ( 'SocialAuth' ) ; }... | Get social connect service instance . |
49,814 | protected function _setRedirectUrl ( ServerRequest $ request ) { $ request -> getSession ( ) -> delete ( 'SocialAuth.redirectUrl' ) ; $ redirectUrl = $ request -> getQuery ( static :: QUERY_STRING_REDIRECT ) ; if ( empty ( $ redirectUrl ) || substr ( $ redirectUrl , 0 , 1 ) !== '/' || substr ( $ redirectUrl , 0 , 2 ) =... | Save URL to redirect to after authentication to session . |
49,815 | protected function _getRedirectUrl ( ServerRequest $ request ) { $ redirectUrl = $ request -> getSession ( ) -> read ( 'SocialAuth.redirectUrl' ) ; if ( $ redirectUrl ) { $ request -> getSession ( ) -> delete ( 'SocialAuth.redirectUrl' ) ; return $ redirectUrl ; } return $ this -> getConfig ( 'loginRedirect' ) ; } | Get URL to redirect to after authentication . |
49,816 | public function toDatabase ( $ value , Driver $ driver ) { if ( $ value === null || is_string ( $ value ) ) { return $ value ; } return serialize ( $ value ) ; } | Convert a value data into a serialized string . |
49,817 | public function toStatement ( $ value , Driver $ driver ) { if ( $ value === null ) { return PDO :: PARAM_NULL ; } return PDO :: PARAM_LOB ; } | Get the correct PDO binding type for string data . |
49,818 | public function jsonCompile ( $ data , $ policie ) { $ passed = call_user_func_array ( [ new JsonRules ( ) , $ policie ] , [ $ data ] ) ; if ( $ passed !== true ) { Handler :: set ( $ this -> messages [ $ policie ] , 'json' ) ; } } | Compile Json . |
49,819 | public function databaseCompile ( $ data , $ table ) { $ rule = 'unique' ; $ passed = call_user_func_array ( [ new databaseRules ( ) , $ rule ] , [ $ data [ 'field' ] , $ data [ 'value' ] , $ table ] ) ; if ( $ passed !== true ) { Handler :: set ( str_replace ( ':field' , $ data [ 'field' ] , $ this -> messages [ $ rul... | Compile Database Unique . |
49,820 | public function open ( ) { $ url = $ this -> url ; $ headers = [ ] ; if ( count ( $ this -> fields ) > 0 ) { if ( $ this -> method == 'GET' ) { $ url = $ this -> options [ CURLOPT_URL ] . '?' . $ this -> getQuery ( ) ; $ this -> setOption ( CURLOPT_URL , $ url ) ; } else { if ( isset ( $ this -> requestHeaders [ 'Conte... | Create and open cURL resource . |
49,821 | public function setOption ( $ option , $ value ) { $ this -> options [ $ option ] = $ value ; curl_setopt ( $ this -> resource , $ option , $ value ) ; return $ this ; } | Set curl session option . |
49,822 | public function setOptios ( $ options ) { foreach ( $ options as $ option => $ value ) { $ this -> setOption ( $ option , $ value ) ; } curl_setopt_array ( $ this -> resource , $ options ) ; return $ this ; } | Set curl session options . |
49,823 | public function getInfo ( $ option = null ) { return ( $ option !== null ) ? curl_getinfo ( $ this -> resource , $ option ) : curl_getinfo ( $ this -> resource ) ; } | Get curl last session info . |
49,824 | public function send ( ) { $ this -> open ( ) ; if ( $ this -> response === false ) { throw new \ Exception ( 'Error: ' . curl_errno ( $ this -> resource ) . ' => ' . curl_error ( $ this -> resource ) . '.' ) ; } if ( isset ( $ this -> options [ CURLOPT_RETURNTRANSFER ] ) && ( $ this -> options [ CURLOPT_RETURNTRANSFER... | Method to send the request and get the response . |
49,825 | protected function parseResponseHeaders ( ) { if ( $ this -> responseHeader !== null ) { $ headers = explode ( "\n" , $ this -> responseHeader ) ; foreach ( $ headers as $ header ) { if ( strpos ( $ header , 'HTTP' ) !== false ) { $ this -> version = substr ( $ header , 0 , strpos ( $ header , ' ' ) ) ; $ this -> versi... | Parse headers . |
49,826 | public function getImgResource ( $ string , $ size = '' , $ color = '' , $ bg = '' ) { return $ this -> setHashString ( $ string ) -> setSize ( $ size ) -> setColor ( $ color ) -> setBgColor ( $ bg ) -> genImage ( ) ; } | Get Image resource data . |
49,827 | public function update ( $ key , $ value ) { if ( ! empty ( $ this -> get ( $ this -> normalizeKey ( $ key ) ) ) ) { $ this -> headers [ $ this -> normalizeKey ( $ key ) ] = $ value ; } } | Update existing header . |
49,828 | public function has ( $ key ) { return ( isset ( $ this -> headers [ $ this -> normalizeKey ( $ key ) ] ) ) ? true : false ; } | Get the header by key . |
49,829 | public function writer ( $ level , $ message ) { ( ! empty ( $ this -> file ) ) ? $ fileName = $ this -> file : $ fileName = '.logs' ; $ fileHandling = new FileHandling ( ) ; $ text = 'Date/time: ' . date ( 'Y-m-d h:i:s A' ) . " , Level: $level , message: " . $ message . "\n" ; $ file = route ( ) -> storage -> log . $ ... | Write the log message in files . |
49,830 | public function logException ( $ level , $ message , array $ context = [ ] , $ exception = null ) { $ this -> log ( $ level , $ message , array_merge ( $ context , [ 'exception' => $ exception ] ) ) ; } | Log an Exception . |
49,831 | public function interpolate ( $ string , array $ params , $ level ) { foreach ( $ params as $ placeholder => $ value ) { $ params [ '{' . ( string ) $ placeholder . '}' ] = ( string ) $ value ; unset ( $ params [ $ placeholder ] ) ; } $ message = strtr ( $ string , $ params ) ; $ this -> writer ( $ level , $ message ) ... | Interpolate string with parameters . |
49,832 | public static function renderTemplate ( $ file , $ args = [ ] ) { if ( ! empty ( $ file ) ) { self :: setFile ( $ file ) ; extract ( $ args , EXTR_SKIP ) ; if ( file_exists ( self :: $ file ) ) { ob_start ( ) ; require_once self :: $ file ; } else { throw new \ Exception ( "Sorry, view file {$file} not exists" , 404 ) ... | Render a view template . |
49,833 | public function elapsedTime ( int $ round = null ) { $ time = $ this -> end - $ this -> start ; if ( ! is_null ( $ round ) ) { $ time = round ( $ time , $ round ) ; } return ( float ) $ time ; } | Get the elapsed time . |
49,834 | public function delete ( $ name ) { if ( file_exists ( route ( ) -> com . $ name ) ) { ( new Files ( ) ) -> deleteDir ( route ( ) -> com . $ name ) ; } } | Delete component by name . |
49,835 | public function install ( $ archive , $ name ) { $ exploadName = explode ( '.' , $ name ) ; $ name = $ exploadName [ 0 ] ; $ storageData = route ( ) -> storage_data ; $ file = $ storageData . $ archive ; $ files = new Files ( ) ; $ files -> mkdir ( $ storageData . 'tmp/' ) ; $ files -> mkdir ( $ storageData . 'tmp/' . ... | Install the component . |
49,836 | public function enableOrDisable ( $ name , $ status ) { $ file = route ( ) -> com . $ name . '/component.json' ; if ( file_exists ( $ file ) ) { $ fileHandling = new FileHandling ( ) ; $ c = $ fileHandling -> open ( $ file , 'readOnly' ) -> read ( ) ; $ config = json_decode ( $ c , true ) ; $ config [ 'status' ] = $ st... | Activate or Disable component . |
49,837 | public function getConponentConfigByName ( $ name ) { $ file = route ( ) -> com . $ name . '/component.json' ; if ( file_exists ( $ file ) ) { $ fileHandling = new FileHandling ( ) ; $ c = $ fileHandling -> open ( $ file , 'readOnly' ) -> read ( ) ; return json_decode ( $ c , true ) ; } return false ; } | Get the component json file configuration . |
49,838 | public function isSupported ( $ zVersion , $ comparator ) { if ( version_compare ( $ zVersion , Version :: VERSION , $ comparator ) === true ) { return true ; } return false ; } | Determine whether the component is supported with current version of Zest . |
49,839 | public function moveToTrash ( $ name ) { if ( file_exists ( route ( ) -> com . $ name ) ) { ( new Files ( ) ) -> moveDir ( route ( ) -> com , route ( ) -> storage_data . 'com' , $ name ) ; } } | Move to trash component by name . |
49,840 | public function restoreFromTrash ( $ name ) { if ( file_exists ( route ( ) -> storage_data . 'com/' . $ name ) ) { ( new Files ( ) ) -> moveDir ( route ( ) -> storage_data . 'com' , route ( ) -> com , $ name ) ; } } | Restore from trash component by name . |
49,841 | public function mergeDependencies ( $ dependency = [ ] ) { $ this -> dependencies = array_merge ( ( array ) $ dependency , ( array ) $ this -> getDependencies ( ) ) ; $ this -> dependencies = Conversion :: arrayObject ( $ this -> dependencies ) ; } | Merge to container . |
49,842 | public function update ( $ params , $ id ) { if ( is_array ( $ params ) ) { foreach ( array_keys ( $ params ) as $ key => $ value ) { $ paramsRules = [ $ value => [ 'required' => true ] ] ; } $ paramsValidate = new Validation ( $ params , $ paramsRules ) ; if ( $ paramsValidate -> fail ( ) ) { Error :: set ( $ paramsVa... | Update the users . |
49,843 | public function updatePassword ( $ password , $ repeat , $ id ) { if ( $ password !== $ repeat ) { Error :: set ( __printl ( 'auth:error:password:confirm' ) , 'password' ) ; } elseif ( __config ( ) -> auth -> sticky_password === true ) { if ( ! ( new PasswordManipulation ( ) ) -> isValid ( $ password ) ) { Error :: set... | Check is username is exists or not . |
49,844 | public function phpOs ( ) { $ os = PHP_OS ; switch ( $ os ) { case 'WINNT' : case 'WINNT32' : case 'WINNT64' : case 'Windows' : $ c_os = 'Windows' ; break ; case 'DragonFly' : case 'FreeBSD' : case 'NetBSD' : case 'OpenBSD' : $ c_os = 'BSD' ; break ; case 'Linux' : $ c_os = 'Linux' ; break ; case 'SunOS' : $ c_os = 'So... | Get the operating system name . |
49,845 | public function resolve ( $ concrete , $ params ) { if ( $ concrete instanceof \ Closure ) { return $ concrete ( $ this , $ params ) ; } $ reflector = new \ ReflectionClass ( $ concrete ) ; if ( ! $ reflector -> isInstantiable ( ) ) { throw new \ Exception ( "Class {$concrete} is not instantiable" , 500 ) ; } $ constru... | Resolve single . |
49,846 | public function getResolveDependencies ( $ parameters , $ params ) { $ dependencies = [ ] ; foreach ( $ parameters as $ parameter ) { $ dependency = $ parameter -> getClass ( ) ; if ( $ dependency === null ) { if ( $ parameter -> isDefaultValueAvailable ( ) ) { $ dependencies [ ] = $ parameter -> getDefaultValue ( ) ; ... | Get all dependencies resolved . |
49,847 | public function imageSave ( $ params ) { if ( is_array ( $ params ) ) { imagejpeg ( $ params [ 'image' ] , $ params [ 'target' ] , 100 ) ; imagedestroy ( $ params [ 'image' ] ) ; return true ; } else { return false ; } } | Save the Image . |
49,848 | public function imageExtension ( $ image ) { $ filename = $ image ; $ extension = explode ( '.' , $ filename ) ; $ ext = strtolower ( end ( $ extension ) ) ; return $ ext ; } | Extension of image . |
49,849 | public function imageFlip ( $ params ) { if ( is_array ( $ params ) ) { $ filename = $ params [ 'source' ] ; $ ext = $ this -> imageExtension ( $ filename ) ; if ( $ ext === 'png' ) { $ image = imagecreatefromstring ( file_get_contents ( $ filename ) ) ; } elseif ( $ ext === 'jpeg' ) { $ image = imagecreatefromjpeg ( $... | Flip the image . |
49,850 | public function imageBorder ( $ params ) { if ( is_array ( $ params ) ) { $ filename = $ params [ 'source' ] ; $ ext = $ this -> imageExtension ( $ filename ) ; if ( $ ext === 'png' ) { $ image = imagecreatefromstring ( file_get_contents ( $ filename ) ) ; } elseif ( $ ext === 'jpeg' ) { $ image = imagecreatefromjpeg (... | Add Border to the image . |
49,851 | public function removeField ( $ name ) { if ( isset ( $ this -> fields [ $ name ] ) ) { unset ( $ this -> fields [ $ name ] ) ; } $ this -> prepareQuery ( ) ; return $ this ; } | Remove a field . |
49,852 | public function getQueryLength ( $ mb = true ) { return ( $ mb ) ? mb_strlen ( $ this -> query ) : strlen ( $ this -> query ) ; } | Get HTTP query length . |
49,853 | public function getRequestHeader ( $ name ) { return ( isset ( $ this -> requestHeaders [ $ name ] ) ) ? $ this -> requestHeaders [ $ name ] : null ; } | Get a request header . |
49,854 | public function htmlMinify ( $ file , $ type = 'file' ) { $ file = $ this -> getFile ( $ file , $ type ) ; $ file = $ this -> cleanSpaces ( $ file ) ; $ file = $ this -> fixMaster ( $ file ) ; $ file = $ this -> removeComments ( $ file ) ; return $ file ; } | Minify html . |
49,855 | public function cssMinify ( $ file , $ type = 'file' ) { $ file = $ this -> getFile ( $ file , $ type ) ; $ file = $ this -> cleanSpaces ( $ file ) ; $ file = $ this -> fixMaster ( $ file ) ; $ file = $ this -> removeComments ( $ file ) ; return preg_replace ( [ '/;[\s\r\n\t]*?}[\s\r\n\t]*/ims' , '/;[\s\r\n\t]/ims' , '... | Minify CSS . |
49,856 | public function javascriptMinify ( $ file , $ type = 'file' ) { $ file = $ this -> getFile ( $ file , $ type ) ; $ file = preg_replace ( [ "/\/\/(.*\s+)/" , "/;+\}/" ] , [ '' , '}' ] , $ file ) ; $ file = $ this -> cleanSpaces ( $ file ) ; $ file = $ this -> removeComments ( $ file ) ; return $ file ; } | Minify Js . |
49,857 | public function set ( string $ name , $ value , $ expire = 0 , $ path = null , $ domain = null , bool $ secure = false , bool $ httponly = true ) { $ name = preg_match ( '/[=,; \t\r\n\013\014]/' , $ name ) ? rand ( 1 , 25 ) : $ name ; if ( $ expire instanceof \ DateTime ) { $ expire = $ expire -> format ( 'U' ) ; } els... | Set the cookie value . |
49,858 | public function setMultiple ( array $ array ) { foreach ( $ array as $ key ) { $ this -> set ( $ key [ 0 ] , $ key [ 1 ] , $ key [ 2 ] , $ key [ 3 ] , $ key [ 4 ] , $ key [ 5 ] , $ key [ 6 ] ) ; } return $ this ; } | Set the multiple cookies value . |
49,859 | public function has ( $ name ) { if ( isset ( $ name ) && ! empty ( $ name ) ) { if ( isset ( $ _COOKIE [ $ name ] ) ) { return true ; } else { return false ; } } else { return false ; } } | Determine if cookie set or not . |
49,860 | public function get ( $ name , $ default = null ) { if ( isset ( $ name ) && ! empty ( $ name ) ) { if ( $ this -> has ( $ name ) ) { return $ _COOKIE [ $ name ] ; } else { return $ default ; } } else { return false ; } } | Get the cookie value . |
49,861 | public function getMultiple ( $ keys , $ default = null ) { $ value = [ ] ; foreach ( $ keys as $ key ) { $ this -> has ( $ key ) ? $ value [ $ key ] = $ this -> get ( $ key , $ default ) : null ; } return $ value ; } | Get multiple values from cookie . |
49,862 | public function delete ( $ name , $ path = null , $ domain = null ) { $ this -> set ( $ name , null , - 2628000 , $ path , $ domain ) ; } | Delete the cookie . |
49,863 | public static function timestampToGmt ( $ time = null ) { $ time = $ time ?? time ( ) ; $ dateTime = new \ DateTime ( ) ; $ dateTime -> setTimestamp ( $ time ) -> modify ( '+2 hours' ) ; return $ dateTime -> format ( 'd/m/Y H:i:s' ) ; } | Converts a timestamp to GMT . |
49,864 | private static function timestampToDate ( $ time = null ) { $ time = $ time ?? time ( ) ; $ time = self :: formatTime ( $ time ) ; $ dateTime = new \ DateTime ( ) ; $ dateTime -> setTimestamp ( $ time ) ; return $ dateTime -> format ( 'd-m-Y H:i:s' ) ; } | Converts a timestamp to DateTime . |
49,865 | public static function ago ( $ dateTime , $ full = false ) { $ dateTime = self :: timestampToDate ( $ dateTime ) ; $ now = new \ DateTime ( ) ; $ ago = new \ DateTime ( $ dateTime ) ; $ diff = $ now -> diff ( $ ago ) ; $ diff -> w = floor ( $ diff -> d / 7 ) ; $ diff -> d -= $ diff -> w * 7 ; $ string = [ 'y' => ':year... | Converts the timestamp in to ago form . |
49,866 | public function addItem ( $ url , $ lastMod = null ) : void { if ( $ this -> has ( $ this -> file ) ) { $ this -> appendItem ( $ url , $ lastMod ) ; } else { $ this -> create ( 'create' , $ url , $ lastMod ) ; } } | Add item to sitemap . |
49,867 | public static function loadComponents ( ) { $ com = new Component ( ) ; $ file = new FileHandling ( ) ; $ diskScan = array_diff ( scandir ( route ( ) -> com ) , [ '..' , '.' ] ) ; foreach ( $ diskScan as $ scans ) { $ configFile = route ( ) -> com . $ scans . '/component.json' ; if ( file_exists ( $ configFile ) ) { $ ... | Load the components . |
49,868 | public function isMaintain ( ) { if ( file_exists ( route ( ) -> root . 'maintained' ) ) { return true ; } elseif ( __config ( ) -> config -> maintenance ) { return true ; } else { return false ; } } | Check is the site maintaince mode is enable . |
49,869 | public function updataMaintenance ( bool $ status ) { if ( $ status ) { if ( ! file_exists ( route ( ) -> root . 'maintained' ) ) { $ fh = fopen ( route ( ) -> root . 'maintained' , 'w' ) ; fwrite ( $ fh , 'maintained' ) ; fclose ( $ fh ) ; } } elseif ( ! $ status ) { if ( file_exists ( route ( ) -> root . 'maintained'... | Upgrade the maintaince mode dynamically . |
49,870 | public function verify ( $ token ) { $ user = new User ( ) ; if ( $ token === 'NULL' || $ user -> isToken ( $ token ) !== true ) { Error :: set ( __printl ( 'auth:error:token' ) , 'token' ) ; } if ( $ this -> fail ( ) !== true ) { if ( ! ( new User ( ) ) -> isLogin ( ) ) { $ id = $ user -> getByWhere ( 'token' , $ toke... | Verify the user base on token . |
49,871 | public static function set ( $ error , $ key = null ) { if ( isset ( $ key ) ) { static :: $ errors [ $ key ] = $ error ; } else { static :: $ errors = $ error ; } } | Set the error msg . |
49,872 | public function extract ( $ file , $ target , $ delete = false ) { $ zip = new \ ZipArchive ( ) ; $ x = $ zip -> open ( $ file ) ; if ( $ x === true ) { $ zip -> extractTo ( $ target ) ; $ zip -> close ( ) ; if ( $ delete === true ) { unlink ( $ file ) ; } return true ; } } | Open zip extract zip . |
49,873 | public function validate ( $ value ) { if ( $ this -> notBeEmpty ( $ value ) ) { $ value = json_decode ( $ value ) ; if ( $ value !== null ) { return true ; } else { return false ; } } else { return false ; } } | Evaulate Json . |
49,874 | public function addBcc ( $ bcc ) { if ( $ this -> isValidEmail ( $ bcc ) === true ) { if ( is_array ( $ bcc , $ this -> bcc ) === false ) { $ this -> bcc [ ] = $ bcc ; } } return false ; } | For add a new BCC . |
49,875 | public function addCc ( $ cc ) { if ( $ this -> isValidEmail ( $ cc ) === true ) { if ( is_array ( $ cc , $ this -> cc ) === false ) { $ this -> cc [ ] = $ cc ; } } return false ; } | For adding a new cc . |
49,876 | public function addReceiver ( $ email ) { if ( $ this -> isValidEmail ( $ email ) === true ) { if ( @ is_array ( $ email , $ this -> receivers ) === false ) { $ this -> receivers [ ] = $ email ; } } return false ; } | For adding a receiver . |
49,877 | public function prepareAttachment ( $ attachment ) { if ( $ this -> isFile ( $ attachment ) !== true ) { return false ; } $ fileInfo = new \ finfo ( FILEINFO_MIME_TYPE ) ; $ fileType = $ fileInfo -> file ( $ attachment ) ; $ file = fopen ( $ attachment , 'r' ) ; $ fileContent = fread ( $ file , filesize ( $ attachment ... | For preparing an attachment to send with mail . |
49,878 | public function isValidEmail ( $ email ) { if ( filter_var ( $ email , FILTER_VALIDATE_EMAIL ) !== false ) { return true ; } if ( filter_var ( $ email , FILTER_SANITIZE_EMAIL ) !== false ) { return true ; } else { return false ; } } | Check is email is valid . |
49,879 | public function isSMTP ( bool $ status = false ) { if ( $ status === true ) { $ this -> smtp [ 'status' ] = $ status ; } else { $ this -> smtp [ 'status' ] = $ status ; } } | Set SMPT status . |
49,880 | public function sendSMTP ( $ to , $ from , $ message ) { $ host = __config ( ) -> email -> smtp_host ; $ user = __config ( ) -> email -> smtp_user ; $ pass = __config ( ) -> email -> smtp_pass ; $ port = __config ( ) -> email -> smtp_port ; if ( $ h = fsockopen ( $ host , $ port ) ) { $ data = [ 0 , "EHLO $host" , 'AUT... | Send mail over SMTP . |
49,881 | public function setReplyTo ( $ email ) { if ( $ this -> isValidEmail ( $ email ) === true ) { $ this -> reply_to = $ email ; } else { return false ; } } | For set reply_to in mail . |
49,882 | public function setSender ( $ email ) { if ( $ this -> isValidEmail ( $ email ) === true ) { $ this -> sender = $ email ; } else { return false ; } } | For set sender in mail . |
49,883 | public function clear ( ) { unset ( $ this -> cc ) ; unset ( $ this -> bcc ) ; unset ( $ this -> receivers ) ; unset ( $ this -> attachments ) ; unset ( $ this -> contentHTML ) ; unset ( $ this -> contentPlain ) ; } | Clear all the information . |
49,884 | public function add ( $ params ) { if ( is_array ( $ params ) ) { if ( ! empty ( $ params [ 'msg' ] ) ) { if ( isset ( $ params [ 'type' ] ) && ! empty ( $ params [ 'type' ] ) ) { $ this -> type ( $ params [ 'type' ] ) ; } else { $ this -> type = 'light' ; } Session :: set ( 'sys_msg' , [ 'msg' => $ params [ 'msg' ] , ... | Add the system message . |
49,885 | protected function type ( $ type ) { $ type = strtolower ( $ type ) ; switch ( $ type ) { case 'success' : $ type = 'success' ; break ; case 'error' : $ type = 'danger' ; break ; case 'information' : $ type = 'info' ; break ; case 'warning' : $ type = 'warning' ; break ; case 'primary' : $ type = 'primary' ; break ; ca... | Set the type of message . |
49,886 | public function view ( ) { $ sys_msg = Session :: get ( 'sys_msg' ) ; $ msg = ( isset ( $ sys_msg [ 'msg' ] ) ) ? $ sys_msg [ 'msg' ] : null ; $ type = ( isset ( $ sys_msg [ 'type' ] ) ) ? $ sys_msg [ 'type' ] : null ; if ( isset ( $ msg ) && isset ( $ type ) ) { $ msg = "<div class='alert alert-" . $ type . "'>" . '<a... | View the system message . |
49,887 | public static function pushMsgs ( ) { static :: $ msgs = [ 'string' => __printl ( 'string:validation' ) , 'required' => __printl ( 'required:validation' ) , 'int' => __printl ( 'int:validation' ) , 'float' => __printl ( 'float:validation' ) , 'email' => __printl ( 'email:validation' ) , 'ip' => __printl ( 'ip:validatio... | Push the messages . |
49,888 | public function operatingSystem ( ) { $ UserAgent = self :: agent ( ) ; if ( preg_match_all ( '/windows/i' , $ UserAgent ) ) { $ PlatForm = 'Windows' ; } elseif ( preg_match_all ( '/linux/i' , $ UserAgent ) ) { $ PlatForm = 'Linux' ; } elseif ( preg_match ( '/macintosh|mac os x/i' , $ UserAgent ) ) { $ PlatForm = 'Maci... | Get OperatingSystem name . |
49,889 | public function browser ( ) { $ UserAgent = self :: agent ( ) ; if ( preg_match_all ( '/Edge/i' , $ UserAgent ) ) { $ Browser = 'Microsoft Edge' ; $ B_Agent = 'Edge' ; } elseif ( preg_match_all ( '/MSIE/i' , $ UserAgent ) ) { $ Browser = 'Mozilla Firefox' ; $ B_Agent = 'Firefox' ; } elseif ( preg_match_all ( '/OPR/i' ,... | Get Browser Name . |
49,890 | public function oSVersion ( ) { $ UserAgent = self :: agent ( ) ; if ( preg_match_all ( '/windows nt 10/i' , $ UserAgent ) ) { $ OsVersion = 'Windows 10' ; } elseif ( preg_match_all ( '/windows nt 6.3/i' , $ UserAgent ) ) { $ OsVersion = 'Windows 8.1' ; } elseif ( preg_match_all ( '/windows nt 6.2/i' , $ UserAgent ) ) ... | Get Os version . |
49,891 | public function browserVersion ( ) { $ UserAgent = self :: agent ( ) ; $ B_Agent = self :: Browser ( ) [ 'agent' ] ; if ( $ B_Agent !== null ) { $ known = [ 'Version' , $ B_Agent , 'other' ] ; $ pattern = '#(?<browser>' . implode ( '|' , $ known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#' ; if ( ! preg_match_all ( $ patte... | Get Browser version . |
49,892 | public function ip ( ) { if ( ! empty ( $ _SERVER [ 'HTTP_CLIENT_IP' ] ) ) { $ ip_add = $ _SERVER [ 'HTTP_CLIENT_IP' ] ; } elseif ( ! empty ( $ _SERVER [ 'HTTP_X_FORWADED_FOR' ] ) ) { $ ip_add = $ _SERVER [ 'HTTP_X_FORWADED_FOR' ] ; } else { $ ip_add = $ _SERVER [ 'REMOTE_ADDR' ] ; } return $ ip_add ; } | Get The user ip . |
49,893 | public function setUri ( $ scheme , $ host , $ port = null , $ path = '/' , $ query = '' , $ fragment = '' , $ user = '' , $ password = '' ) { $ this -> scheme = $ this -> filterScheme ( $ scheme ) ; $ this -> host = $ host ; $ this -> port = $ this -> filterPort ( $ port ) ; $ this -> path = empty ( $ path ) ? '/' : $... | Set the Uri . |
49,894 | public function createFormUrl ( $ url ) { $ urlParts = parse_url ( $ url ) ; $ scheme = isset ( $ urlParts [ 'scheme' ] ) ? $ urlParts [ 'scheme' ] : '' ; $ user = isset ( $ urlParts [ 'user' ] ) ? $ urlParts [ 'user' ] : '' ; $ password = isset ( $ urlParts [ 'pass' ] ) ? $ urlParts [ 'pass' ] : '' ; $ host = isset ( ... | Get the scheme component of the URL . |
49,895 | public function filterScheme ( $ scheme ) { $ valids = [ '' => true , 'http' => true , 'https' => true , ] ; $ scheme = str_replace ( '://' , '' , strtolower ( ( string ) $ scheme ) ) ; if ( ! isset ( $ valids [ $ scheme ] ) ) { throw new \ InvalidArgumentException ( 'Uri scheme must be one of: "", "https", "http"' ) ;... | Filter the url scheme component . |
49,896 | public function getAuthority ( ) { return ( $ this -> getUserInfo ( ) !== '' ) ? $ this -> getUserInfo ( ) . '@' : '' . $ this -> getHost ( ) . ( $ this -> getPort ( ) !== '' ) ? ':' . $ this -> getPort ( ) : '' ; } | Get the authority component of the URL . |
49,897 | public function reset ( $ email ) { $ rules = [ 'email' => [ 'required' => true , 'email' => true ] , ] ; $ input = [ 'email' => $ email , ] ; $ requireValidate = new Validation ( $ input , $ rules ) ; if ( $ requireValidate -> fail ( ) ) { Error :: set ( $ requireValidate -> error ( ) -> get ( ) ) ; } $ user = new Use... | Add the reset password request . |
49,898 | public function resetUpdate ( $ token ) { $ user = new User ( ) ; if ( $ token === 'NULL' || $ user -> isResetToken ( $ token ) !== true ) { Error :: set ( __printl ( 'auth:error:token' ) , 'token' ) ; } if ( $ this -> fail ( ) !== true ) { Success :: set ( true ) ; } } | check token is exists or not . |
49,899 | public static function siteUrl ( ) { $ base_url = self :: requestInstance ( ) -> getDeterminedScheme ( ) . '://' . self :: requestInstance ( ) -> getServerName ( ) . ':' . self :: requestInstance ( ) -> getServerPort ( ) . self :: getUri ( ) ; return $ base_url ; } | Return site URL . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.