idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
26,100 | public function setKernel ( KernelInterface $ kernel ) { $ this -> kernel = $ kernel ; $ this -> container = $ kernel -> getContainer ( ) ; } | Sets Kernel instance . |
26,101 | public function createClient ( ) { $ this -> client = $ this -> getKernel ( ) -> getContainer ( ) -> get ( 'test.client' ) ; $ client = $ this -> client ; return $ client ; } | Crea un cliente para hacer peticiones |
26,102 | public function parseScenarioParameters ( array & $ parameters , $ checkExp = false ) { foreach ( $ parameters as $ key => $ value ) { if ( $ this -> isScenarioParameter ( $ value , $ checkExp ) ) { $ parameters [ $ key ] = $ this -> getScenarioParameter ( $ value ) ; } } return $ parameters ; } | Busca los parametros dentro de un array por su indice y le hace el parse a su valor final . |
26,103 | public function isScenarioParameter ( $ value , $ checkExp = false ) { if ( $ this -> scenarioParameters === null ) { $ this -> initParameters ( ) ; } $ result = isset ( $ this -> scenarioParameters [ $ value ] ) ; if ( ! $ result ) { if ( substr ( $ value , 0 , 1 ) === "%" && substr ( $ value , strlen ( $ value ) - 1 , 1 ) === "%" ) { $ result = true ; } } if ( ! $ result && $ checkExp === true ) { foreach ( $ this -> scenarioParameters as $ key => $ v ) { if ( preg_match ( "/" . $ key . "/" , $ value ) ) { $ result = true ; break ; } } } return $ result ; } | Verifica si el texto es un parametro |
26,104 | public function getScenarioParameter ( $ key , $ checkExp = false ) { $ parameters = $ this -> getScenarioParameters ( ) ; $ user = null ; if ( $ this -> currentUser ) { $ user = $ this -> find ( $ this -> userClass , $ this -> currentUser -> getId ( ) ) ; } $ value = null ; if ( empty ( $ key ) ) { xdebug_print_function_stack ( ) ; throw new Exception ( "The scenario parameter can not be empty." ) ; } if ( isset ( $ parameters [ $ key ] ) ) { if ( is_callable ( $ parameters [ $ key ] ) ) { $ value = call_user_func_array ( $ parameters [ $ key ] , [ $ user , $ this ] ) ; } else { $ value = $ parameters [ $ key ] ; } } else { $ found = false ; if ( $ checkExp === true ) { foreach ( $ parameters as $ k => $ v ) { if ( preg_match ( "/" . $ k . "/" , $ key ) ) { $ value = str_replace ( $ k , $ this -> getScenarioParameter ( $ k ) , $ key ) ; $ found = true ; break ; } } } if ( ! $ found ) { throw new Exception ( sprintf ( "The scenario parameter '%s' is not defined" , $ key ) ) ; } } return $ value ; } | Obtiene el valor de un parametro en el escenario |
26,105 | public function iSetConfigurationKeyWithValue ( $ wrapperName , $ key , $ value ) { if ( $ value === "false" ) { $ value = false ; } else if ( $ value === "true" ) { $ value = true ; } $ configurationManager = $ this -> container -> get ( $ this -> container -> getParameter ( "tecnocreaciones_tools.configuration_manager.name" ) ) ; $ wrapper = $ configurationManager -> getWrapper ( $ wrapperName ) ; $ success = false ; if ( $ this -> accessor -> isWritable ( $ wrapper , $ key ) === true ) { $ success = $ this -> accessor -> setValue ( $ wrapper , $ key , $ value ) ; } else { $ success = $ configurationManager -> set ( $ key , $ value , $ wrapperName , null , true ) ; } if ( $ success === false ) { throw new Exception ( sprintf ( "The value of '%s' can not be update with value '%s'." , $ key , $ value ) ) ; } $ configurationManager -> flush ( true ) ; if ( $ this -> accessor -> isReadable ( $ wrapper , $ key ) ) { $ newValue = $ this -> accessor -> getValue ( $ wrapper , $ key ) ; } else { $ newValue = $ configurationManager -> get ( $ key , $ wrapperName , null ) ; } if ( $ value != $ newValue ) { throw new Exception ( sprintf ( "Failed to update '%s' key '%s' with '%s' configuration." , $ wrapperName , $ key , $ value ) ) ; } } | Actualiza la configuracion del sistema |
26,106 | public function aClearEntityTable ( $ className , $ andWhere = null ) { $ doctrine = $ this -> getDoctrine ( ) ; $ em = $ doctrine -> getManager ( ) ; if ( $ em -> getFilters ( ) -> isEnabled ( 'softdeleteable' ) ) { $ em -> getFilters ( ) -> disable ( 'softdeleteable' ) ; } if ( $ className === \ Pandco \ Bundle \ AppBundle \ Entity \ User \ DigitalAccount \ TimeWithdraw :: class ) { $ query = $ em -> createQuery ( "UPDATE " . \ Pandco \ Bundle \ AppBundle \ Entity \ App \ User \ DigitalAccount \ DigitalAccountConfig :: class . " dac SET dac.timeWithdraw = null" ) ; $ query -> execute ( ) ; } $ query = $ em -> createQuery ( "DELETE FROM " . $ className . " " . $ andWhere ) ; $ query -> execute ( ) ; $ em -> flush ( ) ; $ em -> clear ( ) ; } | Limia una tabla de la base de datos |
26,107 | public function theQuantityOfElementInEntityIs ( $ className , $ expresion ) { $ doctrine = $ this -> getDoctrine ( ) ; $ em = $ doctrine -> getManager ( ) ; $ query = $ em -> createQuery ( 'SELECT COUNT(u.id) FROM ' . $ className . ' u' ) ; $ count = $ query -> getSingleScalarResult ( ) ; $ expAmount = explode ( " " , $ expresion ) ; $ amount2 = \ Pandco \ Bundle \ AppBundle \ Service \ Util \ CurrencyUtil :: fotmatToNumber ( $ expAmount [ 1 ] ) ; if ( version_compare ( $ count , $ amount2 , $ expAmount [ 0 ] ) === false ) { throw new Exception ( sprintf ( "Expected '%s' but there quantity is '%s'." , $ expresion , $ count ) ) ; } } | Cuenta la cantidad de elementos de una tabla |
26,108 | public function findOneElement ( $ class , UserInterface $ user = null ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ alias = "o" ; $ qb = $ em -> createQueryBuilder ( ) -> select ( $ alias ) -> from ( $ class , $ alias ) ; if ( $ user !== null ) { $ qb -> andWhere ( "o.user = :user" ) -> setParameter ( "user" , $ user ) ; } $ qb -> orderBy ( "o.createdAt" , "DESC" ) ; $ entity = $ qb -> setMaxResults ( 1 ) -> getQuery ( ) -> getOneOrNullResult ( ) ; return $ entity ; } | Devuelve el primer elemento que encuentr de la base de datos |
26,109 | private function arrayReplaceRecursiveValue ( & $ array , $ parameters ) { foreach ( $ array as $ key => $ value ) { if ( ! isset ( $ array [ $ key ] ) || ( isset ( $ array [ $ key ] ) && ! is_array ( $ array [ $ key ] ) ) ) { $ array [ $ key ] = array ( ) ; } if ( is_array ( $ value ) ) { $ value = $ this -> arrayReplaceRecursiveValue ( $ array [ $ key ] , $ parameters ) ; } else { $ value = $ this -> parseParameter ( $ value , $ parameters ) ; } $ array [ $ key ] = $ value ; } return $ array ; } | Reemplaza recursivamente los parametros en un array |
26,110 | public function aExecuteCommandTo ( $ command ) { $ this -> restartKernel ( ) ; $ kernel = $ this -> getKernel ( ) ; $ application = new \ Symfony \ Bundle \ FrameworkBundle \ Console \ Application ( $ kernel ) ; $ application -> setAutoExit ( false ) ; $ exploded = explode ( " " , $ command ) ; $ commandsParams = [ ] ; foreach ( $ exploded as $ value ) { if ( ! isset ( $ commandsParams [ "command" ] ) ) { $ commandsParams [ "command" ] = $ value ; } else { $ e2 = explode ( "=" , $ value ) ; if ( count ( $ e2 ) == 1 ) { $ commandsParams [ ] = $ e2 [ 0 ] ; } else if ( count ( $ e2 ) == 2 ) { $ commandsParams [ $ e2 [ 0 ] ] = $ e2 [ 1 ] ; } } } foreach ( $ commandsParams as $ key => $ value ) { $ commandsParams [ $ key ] = $ value ; } $ input = new \ Symfony \ Component \ Console \ Input \ ArrayInput ( $ commandsParams ) ; if ( $ output === null ) { $ output = new \ Symfony \ Component \ Console \ Output \ ConsoleOutput ( ) ; } $ application -> run ( $ input , $ output ) ; } | Executa un comando |
26,111 | public function detect ( $ number ) { foreach ( self :: $ cardPatterns as $ name => $ pattern ) { if ( preg_match ( $ pattern , $ number ) ) { return $ name ; } } return false ; } | Detect card brand from card number |
26,112 | public function load ( ) { $ exists = is_file ( $ this -> file ) ; if ( $ this -> autoCreate == false && ! $ exists ) { throw new RuntimeException ( 'File does not exist' ) ; } else if ( $ this -> autoCreate == true && ! $ exists ) { touch ( $ this -> file ) ; $ this -> loaded = true ; return array ( ) ; } $ content = file_get_contents ( $ this -> file ) ; $ content = $ this -> serializer -> unserialize ( $ content ) ; if ( ! $ content ) { $ content = array ( ) ; } $ this -> content = $ content ; $ this -> loaded = true ; } | Loads content from a file |
26,113 | public function save ( array $ data ) { return ( bool ) file_put_contents ( $ this -> file , $ this -> serializer -> serialize ( $ data ) ) ; } | Writes data to the file |
26,114 | public function getAccounts ( ) { if ( $ output = $ this -> execute ( 'icacls' , $ this -> path ) ) { $ output [ 0 ] = str_replace ( $ this -> path , '' , $ output [ 0 ] ) ; array_pop ( $ output ) ; $ output = array_filter ( $ output ) ; return $ this -> newParser ( $ output ) -> parse ( ) ; } return false ; } | Returns an array of accounts with their permissions on the current directory . |
26,115 | public function getId ( ) { if ( $ output = $ this -> execute ( 'fsutil file queryfileid' , $ this -> path ) ) { if ( ( bool ) preg_match ( '/(\d{1}[x].*)/' , $ output [ 0 ] , $ matches ) ) { return $ matches [ 0 ] ; } } } | Returns the current paths unique ID . |
26,116 | public static function calculateNewCoordinates ( float $ initialLatitude , float $ initialLongitude , float $ distance , int $ bearing ) { $ bearing = deg2rad ( $ bearing ) ; $ latitude = deg2rad ( $ initialLatitude ) ; $ longitude = deg2rad ( $ initialLongitude ) ; $ earth = self :: EARTH_RADIUS_METERS / 1000 ; $ newLatitude = asin ( sin ( $ latitude ) * cos ( $ distance / $ earth ) + cos ( $ latitude ) * sin ( $ distance / $ earth ) * cos ( $ bearing ) ) ; $ newLongitude = $ longitude + atan2 ( sin ( $ bearing ) * sin ( $ distance / $ earth ) * cos ( $ latitude ) , cos ( $ distance / $ earth ) - sin ( $ latitude ) * sin ( $ newLatitude ) ) ; return [ rad2deg ( $ newLatitude ) , rad2deg ( $ newLongitude ) ] ; } | Calculate new coordinates based on distance and bearing |
26,117 | public static function calculateDistance ( float $ sourceLatitude , float $ sourceLongitude , float $ targetLatitude , float $ targetLongitude ) : float { $ radSourceLat = deg2rad ( $ sourceLatitude ) ; $ radSourceLon = deg2rad ( $ sourceLongitude ) ; $ radTargetLat = deg2rad ( $ targetLatitude ) ; $ radTargetLon = deg2rad ( $ targetLongitude ) ; $ latitudeDelta = $ radTargetLat - $ radSourceLat ; $ longitudeDelta = $ radTargetLon - $ radSourceLon ; $ angle = 2 * asin ( sqrt ( pow ( sin ( $ latitudeDelta / 2 ) , 2 ) + cos ( $ radSourceLat ) * cos ( $ radTargetLat ) * pow ( sin ( $ longitudeDelta / 2 ) , 2 ) ) ) ; return $ angle * Geo :: EARTH_RADIUS_METERS ; } | Calculate distance in meters between two points |
26,118 | private function createHiddenNode ( array $ attrs ) { $ attrs = array ( 'type' => 'hidden' , 'name' => $ attrs [ 'name' ] , 'value' => '0' ) ; $ node = new NodeElement ( ) ; $ node -> openTag ( 'input' ) -> addAttributes ( $ attrs ) -> finalize ( true ) ; return $ node ; } | Creates hidden node |
26,119 | private function createCheckboxNode ( array $ attrs ) { $ defaults = array ( 'type' => 'checkbox' , 'value' => '1' ) ; $ attrs = array_merge ( $ defaults , $ attrs ) ; $ node = new NodeElement ( ) ; $ node -> openTag ( 'input' ) -> addAttributes ( $ attrs ) ; if ( $ this -> active == $ defaults [ 'value' ] || $ this -> active === true ) { $ node -> addProperty ( 'checked' ) ; } $ node -> finalize ( true ) ; return $ node ; } | Creates checkbox node |
26,120 | public function has ( $ needle , bool $ strict = true ) : bool { foreach ( $ this -> values as $ value ) { if ( $ strict && $ value === $ needle ) { return true ; } if ( $ strict && $ value == $ needle ) { return true ; } } return false ; } | Check if value presented in array . |
26,121 | protected function addValues ( $ values ) { if ( ! is_array ( $ values ) && ! $ values instanceof \ Traversable ) { return ; } foreach ( $ values as $ value ) { $ value = $ this -> filterValue ( $ value ) ; if ( ! is_null ( $ value ) ) { $ this -> values [ ] = $ value ; } } } | Add values matched with filter . |
26,122 | public static function generate_script_dependencies ( $ maybe_dependencies ) { $ dependencies = [ ] ; foreach ( $ maybe_dependencies as $ dependency ) { if ( ! wp_script_is ( $ dependency , 'enqueued' ) && ! wp_script_is ( $ dependency , 'registered' ) ) { continue ; } $ dependencies [ ] = $ dependency ; } return $ dependencies ; } | Generate script dependencies |
26,123 | public static function generate_style_dependencies ( $ maybe_dependencies ) { $ dependencies = [ ] ; foreach ( $ maybe_dependencies as $ dependency ) { if ( ! wp_style_is ( $ dependency , 'enqueued' ) && ! wp_style_is ( $ dependency , 'registered' ) ) { continue ; } $ dependencies [ ] = $ dependency ; } return $ dependencies ; } | Generate style dependencies |
26,124 | private function createArgs ( ) { $ args = array ( $ this -> db ) ; if ( is_object ( $ this -> paginator ) ) { array_push ( $ args , $ this -> paginator ) ; } array_push ( $ args , $ this -> prefix ) ; return $ args ; } | Return arguments for a mapper |
26,125 | public function loadLabels ( $ locale , $ force = false ) { if ( ! $ this -> labelsLoaded || $ force ) { if ( file_exists ( \ Nf \ Registry :: get ( 'applicationPath' ) . '/labels/' . $ locale . '.ini' ) ) { $ this -> labels = parse_ini_file ( \ Nf \ Registry :: get ( 'applicationPath' ) . '/labels/' . $ locale . '.ini' , true ) ; $ this -> labelsLoaded = true ; } else { throw new \ Exception ( 'Cannot load labels for this locale (' . $ locale . ')' ) ; } } } | load the labels |
26,126 | public static function fromYamlString ( $ yml , $ config_yml = null ) { $ parser = new sfYamlParser ( ) ; $ yml_tree = $ parser -> parse ( $ yml ) ; if ( $ config_yml ) { $ yml_config_tree = $ parser -> parse ( $ config_yml ) ; self :: mergeDefaultsIntoYml ( $ yml_tree , $ yml_config_tree ) ; } $ cmd = self :: ymlToCmd ( $ yml_tree ) ; $ cmd = self :: ymlParseOptions ( $ yml_tree , $ cmd ) ; $ cmd = self :: ymlParseArguments ( $ yml_tree , $ cmd ) ; $ cmd = self :: ymlParseCommands ( $ yml_tree , $ cmd ) ; return $ cmd ; } | Read Console_CommandLine_Command from yml strings one with all arguments and one with configuration options to overwrite default values set in the first one . |
26,127 | public function toArgs ( $ notation ) { $ target = $ this -> toClassPath ( $ notation ) ; return explode ( self :: ROUTE_SYNTAX_SEPARATOR , $ target ) ; } | Converts short controller action into parameters that can be passed to call_user_func_array |
26,128 | public function toCompliant ( $ notation ) { $ chunks = explode ( self :: ROUTE_SYNTAX_SEPARATOR , $ notation ) ; $ action = $ chunks [ 1 ] ; $ parts = explode ( ':' , $ chunks [ 0 ] ) ; $ module = array_shift ( $ parts ) ; $ path = sprintf ( '/%s/%s/%s' , $ module , self :: ROUTE_CONTROLLER_DIR , implode ( '/' , $ parts ) ) ; return array ( $ path => $ action ) ; } | Converts route notation syntax back to PSR - 0 compliant |
26,129 | public function toClassPath ( $ class ) { $ parts = explode ( self :: ROUTE_SYNTAX_DELIMITER , $ class ) ; $ module = $ parts [ 0 ] ; unset ( $ parts [ 0 ] ) ; $ path = sprintf ( '/%s/%s/%s' , $ module , self :: ROUTE_CONTROLLER_DIR , implode ( '/' , $ parts ) ) ; return $ path ; } | Converts notated syntax to compliant |
26,130 | public function hashPassword ( $ password ) { if ( $ this -> mode == self :: MODE_BCRYPT ) { return $ this -> hashModeBcrypt ( $ password ) ; } elseif ( $ this -> mode == self :: MODE_PBKDF2 ) { return $ this -> hashModePbkdf2 ( $ password ) ; } $ this -> error = 'You have to set the mode...' ; $ this -> cwsDebug -> error ( $ this -> error ) ; } | Create a password hash . |
26,131 | private function hashModePbkdf2 ( $ password ) { $ this -> cwsDebug -> titleH2 ( 'Create password hash using PBKDF2' ) ; $ this -> cwsDebug -> labelValue ( 'Password' , $ password ) ; $ salt = $ this -> random ( self :: PBKDF2_RANDOM_BYTES ) ; $ this -> cwsDebug -> labelValue ( 'Salt' , $ salt ) ; $ algorithm = $ this -> encode ( self :: PBKDF2_ALGORITHM ) ; $ this -> cwsDebug -> labelValue ( 'Algorithm' , self :: PBKDF2_ALGORITHM ) ; $ ite = rand ( self :: PBKDF2_MIN_ITE , self :: PBKDF2_MAX_ITE ) ; $ this -> cwsDebug -> labelValue ( 'Iterations' , $ ite ) ; $ ite = $ this -> encode ( rand ( self :: PBKDF2_MIN_ITE , self :: PBKDF2_MAX_ITE ) ) ; $ params = $ algorithm . self :: PBKDF2_SEPARATOR ; $ params .= $ ite . self :: PBKDF2_SEPARATOR ; $ params .= $ salt . self :: PBKDF2_SEPARATOR ; $ hash = $ this -> getPbkdf2 ( $ algorithm , $ password , $ salt , $ ite , self :: PBKDF2_HASH_BYTES , true ) ; $ this -> cwsDebug -> labelValue ( 'Hash' , $ hash ) ; $ this -> cwsDebug -> labelValue ( 'Length' , strlen ( $ hash ) ) ; $ finalHash = $ params . base64_encode ( $ hash ) ; $ this -> cwsDebug -> dump ( 'Encoded hash (length : ' . strlen ( $ finalHash ) . ')' , $ finalHash ) ; if ( strlen ( $ finalHash ) == self :: PBKDF2_LENGTH ) { return $ finalHash ; } $ this -> error = 'Cannot generate the PBKDF2 password hash...' ; $ this -> cwsDebug -> error ( $ this -> error ) ; } | Create a password hash using PBKDF2 mode . |
26,132 | public function checkPassword ( $ password , $ hash ) { if ( $ this -> mode == self :: MODE_BCRYPT ) { return $ this -> checkModeBcrypt ( $ password , $ hash ) ; } elseif ( $ this -> mode == self :: MODE_PBKDF2 ) { return $ this -> checkModePbkdf2 ( $ password , $ hash ) ; } $ this -> error = 'You have to set the mode...' ; $ this -> cwsDebug -> error ( $ this -> error ) ; return false ; } | Check a hash with the password given . |
26,133 | private function checkModeBcrypt ( $ password , $ hash ) { $ this -> cwsDebug -> titleH2 ( 'Check password hash in BCRYPT mode' ) ; $ this -> cwsDebug -> labelValue ( 'Password' , $ password ) ; $ this -> cwsDebug -> labelValue ( 'Hash' , $ hash ) ; $ checkHash = crypt ( $ password , $ hash ) ; $ this -> cwsDebug -> labelValue ( 'Check hash' , $ checkHash ) ; $ result = $ this -> slowEquals ( $ hash , $ checkHash ) ; $ this -> cwsDebug -> labelValue ( 'Valid?' , ( $ result ? 'YES!' : 'NO...' ) ) ; return $ result ; } | Check a hash with the password given using BCRYPT mode . |
26,134 | private function checkModePbkdf2 ( $ password , $ hash ) { $ this -> cwsDebug -> titleH2 ( 'Check password hash in PBKDF2 mode' ) ; $ this -> cwsDebug -> labelValue ( 'Password' , $ password ) ; $ this -> cwsDebug -> dump ( 'Hash' , $ hash ) ; $ params = explode ( self :: PBKDF2_SEPARATOR , $ hash ) ; if ( count ( $ params ) < self :: PBKDF2_SECTIONS ) { return false ; } $ algorithm = $ params [ self :: PBKDF2_ALGORITHM_INDEX ] ; $ salt = $ params [ self :: PBKDF2_SALT_INDEX ] ; $ ite = $ params [ self :: PBKDF2_ITE_INDEX ] ; $ hash = base64_decode ( $ params [ self :: PBKDF2_HASH_INDEX ] ) ; $ this -> cwsDebug -> labelValue ( 'Decoded hash' , $ hash ) ; $ checkHash = $ this -> getPbkdf2 ( $ algorithm , $ password , $ salt , $ ite , strlen ( $ hash ) , true ) ; $ this -> cwsDebug -> labelValue ( 'Check hash' , $ checkHash ) ; $ result = $ this -> slowEquals ( $ hash , $ checkHash ) ; $ this -> cwsDebug -> labelValue ( 'Valid?' , ( $ result ? 'YES!' : 'NO...' ) ) ; return $ result ; } | Check a hash with the password given using PBKDF2 mode . |
26,135 | public function encrypt ( $ data ) { $ this -> cwsDebug -> titleH2 ( 'Encrypt data' ) ; if ( empty ( $ this -> encryptionKey ) ) { $ this -> error = 'You have to set the encryption key...' ; $ this -> cwsDebug -> error ( $ this -> error ) ; return ; } if ( empty ( $ data ) ) { $ this -> error = 'Data empty...' ; $ this -> cwsDebug -> error ( $ this -> error ) ; return ; } $ this -> cwsDebug -> labelValue ( 'Encryption key' , $ this -> encryptionKey ) ; $ this -> cwsDebug -> dump ( 'Data' , $ data ) ; $ td = mcrypt_module_open ( MCRYPT_BLOWFISH , '' , MCRYPT_MODE_CFB , '' ) ; $ ivsize = mcrypt_enc_get_iv_size ( $ td ) ; $ iv = mcrypt_create_iv ( $ ivsize , MCRYPT_DEV_URANDOM ) ; $ key = $ this -> validateKey ( $ this -> encryptionKey , mcrypt_enc_get_key_size ( $ td ) ) ; mcrypt_generic_init ( $ td , $ key , $ iv ) ; $ encryptedData = mcrypt_generic ( $ td , $ this -> encode ( $ data ) ) ; mcrypt_generic_deinit ( $ td ) ; $ result = $ iv . $ encryptedData ; $ this -> cwsDebug -> dump ( 'Encrypted data' , $ result ) ; return $ result ; } | Generate a symectric encryption string with the blowfish algorithm and an encryption key in CFB mode . Please be advised that you should not use this method for truly sensitive data . |
26,136 | public function decrypt ( $ data ) { $ this -> cwsDebug -> titleH2 ( 'Decrypt data' ) ; if ( empty ( $ this -> encryptionKey ) ) { $ this -> error = 'You have to set the encryption key...' ; $ this -> cwsDebug -> error ( $ this -> error ) ; return ; } if ( empty ( $ data ) ) { $ this -> error = 'Data empty...' ; $ this -> cwsDebug -> error ( $ this -> error ) ; return ; } $ this -> cwsDebug -> labelValue ( 'Encryption key' , $ this -> encryptionKey ) ; $ this -> cwsDebug -> dump ( 'Encrypted data' , strval ( $ data ) ) ; $ result = null ; $ td = mcrypt_module_open ( MCRYPT_BLOWFISH , '' , MCRYPT_MODE_CFB , '' ) ; $ ivsize = mcrypt_enc_get_iv_size ( $ td ) ; $ iv = substr ( $ data , 0 , $ ivsize ) ; $ key = $ this -> validateKey ( $ this -> encryptionKey , mcrypt_enc_get_key_size ( $ td ) ) ; if ( $ iv ) { $ data = substr ( $ data , $ ivsize ) ; mcrypt_generic_init ( $ td , $ key , $ iv ) ; $ decryptData = mdecrypt_generic ( $ td , $ data ) ; $ result = $ this -> decode ( $ decryptData ) ; } $ this -> cwsDebug -> dump ( 'Data' , $ result ) ; return $ result ; } | Return the decrypted string generated from the encrypt method . |
26,137 | private function encode ( $ data ) { $ rdm = $ this -> random ( ) ; $ data = base64_encode ( $ data ) ; $ startIndex = rand ( 1 , strlen ( $ rdm ) ) ; $ params = base64_encode ( $ startIndex ) . self :: ENC_SEPARATOR ; $ params .= base64_encode ( strlen ( $ data ) ) . self :: ENC_SEPARATOR ; return $ params . substr_replace ( $ rdm , $ data , $ startIndex , 0 ) ; } | Encode data inside a random string . |
26,138 | private function decode ( $ encData ) { $ params = explode ( self :: ENC_SEPARATOR , $ encData ) ; if ( count ( $ params ) < self :: ENC_SECTIONS ) { return false ; } $ startIndex = intval ( base64_decode ( $ params [ self :: ENC_STARTINDEX_INDEX ] ) ) ; $ dataLength = intval ( base64_decode ( $ params [ self :: ENC_DATALENGTH_INDEX ] ) ) ; if ( empty ( $ startIndex ) || empty ( $ dataLength ) ) { return false ; } $ data = $ params [ self :: ENC_DATA_INDEX ] ; return base64_decode ( substr ( $ data , $ startIndex , $ dataLength ) ) ; } | Decode and extract data from encoded one . |
26,139 | private static function validateKey ( $ key , $ size ) { $ length = strlen ( $ key ) ; if ( $ length < $ size ) { $ key = str_pad ( $ key , $ size , $ key ) ; } elseif ( $ length > $ size ) { $ key = substr ( $ key , 0 , $ size ) ; } return $ key ; } | Validate a key relative to maximum supported keysize of the opened mode . |
26,140 | public function getData ( $ key , $ default = false ) { if ( $ this -> sessionBag -> has ( $ key ) ) { return $ this -> sessionBag -> get ( $ key ) ; } else { return $ default ; } } | Returns session data |
26,141 | private function loggenIn ( ) { if ( ! $ this -> has ( ) ) { if ( ! ( $ this -> authService instanceof UserAuthServiceInterface ) ) { return false ; } if ( $ this -> reAuth -> isStored ( ) && ( ! $ this -> has ( ) ) ) { $ userBag = $ this -> reAuth -> getUserBag ( ) ; } if ( ( $ this -> has ( ) && $ this -> reAuth -> isStored ( ) ) || $ this -> has ( ) ) { $ data = $ this -> sessionBag -> get ( self :: AUTH_NAMESPACE ) ; $ userBag = new UserBag ( ) ; $ userBag -> setLogin ( $ data [ 'login' ] ) -> setPasswordHash ( $ data [ 'passwordHash' ] ) ; } if ( ! isset ( $ userBag ) ) { return false ; } $ authResult = $ this -> authService -> authenticate ( $ userBag -> getLogin ( ) , $ userBag -> getPasswordHash ( ) , false , false ) ; if ( $ authResult == true ) { $ this -> login ( $ userBag -> getLogin ( ) , $ userBag -> getPasswordHash ( ) ) ; return true ; } return false ; } else { return true ; } } | Checks whether user is logged in |
26,142 | public function login ( $ login , $ passwordHash , $ remember = false ) { if ( ( bool ) $ remember == true ) { $ this -> reAuth -> store ( $ login , $ passwordHash ) ; } $ this -> sessionBag -> set ( self :: AUTH_NAMESPACE , array ( 'login' => $ login , 'passwordHash' => $ passwordHash ) ) ; } | Logins a user |
26,143 | public function logout ( ) { if ( $ this -> has ( ) ) { $ this -> sessionBag -> remove ( self :: AUTH_NAMESPACE ) ; } if ( $ this -> reAuth -> isStored ( ) ) { $ this -> reAuth -> clear ( ) ; } } | Erases all credentials |
26,144 | public function generateRoute ( $ method , array $ path ) : ? Route { $ pathPartsSize = sizeof ( $ path ) ; $ controllerClassName = $ this -> namespace ; if ( $ pathPartsSize > 1 ) { for ( $ i = 0 ; $ i < $ pathPartsSize - 1 ; $ i ++ ) { if ( ! empty ( $ controllerClassName ) ) { $ controllerClassName .= '\\' ; } $ requestPathPart = $ path [ $ i ] ; $ requestPathPart = str_replace ( ' ' , '' , ucwords ( str_replace ( '_' , ' ' , $ requestPathPart ) ) ) ; $ controllerClassName .= $ requestPathPart ; } } else { if ( ! empty ( $ controllerClassName ) ) { $ controllerClassName .= '\\' ; } $ controllerClassName .= 'Main' ; } $ controllerClassName .= get_property ( 'routes.controllers_suffix' , 'Controller' ) ; $ route = null ; if ( class_exists ( $ controllerClassName ) ) { $ controllerAction = ( empty ( $ path ) || empty ( $ path [ $ pathPartsSize - 1 ] ) ) ? 'index' : $ path [ $ pathPartsSize - 1 ] ; $ controllerAction = str_replace ( ' ' , '' , ucwords ( str_replace ( '_' , ' ' , $ controllerAction ) ) ) ; $ controllerAction .= get_property ( 'routes.actions_suffix' , 'Action' ) ; $ controllerAction [ 0 ] = strtolower ( $ controllerAction [ 0 ] ) ; $ action = $ controllerClassName . '@' . $ controllerAction ; $ route = new Route ( $ action ) ; } return $ route ; } | Generates a route for accessing controllers |
26,145 | public static function convertToDynamicLoader ( ChoiceListFactoryInterface $ choiceListFactory , Options $ options , $ value ) { if ( $ value instanceof DynamicChoiceLoaderInterface ) { return $ value ; } if ( ! \ is_array ( $ options [ 'choices' ] ) ) { throw new InvalidConfigurationException ( 'The "choice_loader" option must be an instance of DynamicChoiceLoaderInterface or the "choices" option must be an array' ) ; } if ( $ options [ 'select2' ] [ 'ajax' ] ) { return new AjaxChoiceLoader ( self :: getChoices ( $ options , $ value ) , $ choiceListFactory ) ; } return new DynamicChoiceLoader ( self :: getChoices ( $ options , $ value ) , $ choiceListFactory ) ; } | Convert the array to the ajax choice loader . |
26,146 | public function parameterFields ( ) { $ return = FieldList :: create ( $ title = TextField :: create ( 'Title' , _t ( 'CommentReport.NEWSSEARCHTITLE' , 'Search newsitem' ) ) , $ count = DropdownField :: create ( 'Comment' , _t ( 'CommentReport.COUNTFILTER' , 'Comment count filter' ) , array ( '' => _t ( 'CommentReport.ANY' , 'All' ) , 'SPAMCOUNT' => _t ( 'CommentReport.SPAMCOUNT' , 'One or more spam comments' ) , 'HIDDENCOUNT' => _t ( 'CommentReport.HIDDENCOUNT' , 'One or more hidden comments' ) , ) ) ) ; return $ return ; } | Setup the searchform . |
26,147 | public static function get_related_posts_query ( $ post_id ) { $ _post = get_post ( $ post_id ) ; if ( ! isset ( $ _post -> ID ) ) { return ; } $ tax_query = [ ] ; $ taxonomies = get_object_taxonomies ( get_post_type ( $ post_id ) , 'object' ) ; foreach ( $ taxonomies as $ taxonomy ) { if ( false === $ taxonomy -> public || false === $ taxonomy -> show_ui ) { continue ; } $ term_ids = wp_get_object_terms ( $ post_id , $ taxonomy -> name , [ 'fields' => 'ids' ] ) ; if ( ! $ term_ids ) { continue ; } $ tax_query [ ] = [ 'taxonomy' => $ taxonomy -> name , 'field' => 'term_id' , 'terms' => $ term_ids , 'operator' => 'IN' , ] ; } $ related_posts_args = [ 'post_type' => get_post_type ( $ post_id ) , 'posts_per_page' => 4 , 'orderby' => 'rand' , 'post__not_in' => [ $ post_id ] , 'tax_query' => array_merge ( [ 'relation' => 'AND' , ] , $ tax_query ) , ] ; $ related_posts_args = apply_filters ( 'mimizuku_related_posts_args' , $ related_posts_args ) ; return new \ WP_Query ( array_merge ( $ related_posts_args , [ 'ignore_sticky_posts' => true , 'no_found_rows' => true , 'suppress_filters' => true , ] ) ) ; } | Return related posts |
26,148 | public function prepare ( ) { if ( ! $ this -> sessionBag -> has ( self :: CSRF_TKN_NAME ) ) { $ this -> sessionBag -> set ( self :: CSRF_TKN_NAME , $ this -> generateToken ( ) ) ; $ this -> sessionBag -> set ( self :: CSRF_TKN_TIME , time ( ) ) ; } $ this -> prepared = true ; } | Prepares to run |
26,149 | public function isExpired ( ) { $ this -> validatePrepared ( ) ; if ( ! $ this -> sessionBag -> has ( self :: CSRF_TKN_TIME ) ) { return true ; } else { $ age = time ( ) - $ this -> sessionBag -> get ( self :: CSRF_TKN_TIME ) ; return $ age >= $ this -> ttl ; } } | Checks whether token is expired |
26,150 | public function isValid ( $ token ) { $ this -> validatePrepared ( ) ; return $ this -> sessionBag -> has ( self :: CSRF_TKN_NAME ) && $ this -> sessionBag -> has ( self :: CSRF_TKN_TIME ) && $ this -> sessionBag -> get ( self :: CSRF_TKN_NAME ) === $ token ; } | Check whether coming token is valid |
26,151 | public function getQuery ( ) { $ properties = array ( 'data' => $ this , ) ; $ wrapper = new \ stdClass ( ) ; $ collection = new \ StdClass ( ) ; foreach ( $ properties as $ name => $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as & $ val ) { if ( is_object ( $ val ) ) { $ val = $ val -> output ( ) ; } } } if ( is_object ( $ value ) && ! $ value instanceof \ StdClass ) { $ value = $ value -> output ( ) ; } $ collection -> $ name = $ value ; } $ wrapper -> template = $ collection ; return json_encode ( $ wrapper ) ; } | Get the query json |
26,152 | public function importItem ( Item $ item ) { foreach ( $ this -> data as $ templateData ) { foreach ( $ item -> getData ( ) as $ itemData ) { if ( $ itemData -> getName ( ) === $ templateData -> getName ( ) ) { $ templateData -> setName ( $ itemData -> getName ( ) ) ; $ templateData -> setValue ( $ itemData -> getValue ( ) ) ; $ templateData -> setPrompt ( $ itemData -> getPrompt ( ) ) ; } } } return $ this ; } | Import Item object into template |
26,153 | public static function roundCollection ( array $ data , $ precision = 2 ) { $ output = array ( ) ; foreach ( $ data as $ key => $ value ) { $ output [ $ key ] = round ( $ value , $ precision ) ; } return $ output ; } | Rounds a collection |
26,154 | public static function average ( $ values ) { $ sum = array_sum ( $ values ) ; $ count = count ( $ values ) ; if ( $ count == 0 ) { return 0 ; } return $ sum / $ count ; } | Finds the average |
26,155 | public static function percentage ( $ total , $ actual , $ round = 1 ) { if ( $ total == 0 || $ actual == 0 ) { return 0 ; } $ value = 100 * $ actual / $ total ; if ( is_integer ( $ round ) ) { $ value = round ( $ value , $ round ) ; } return $ value ; } | Counts a percentage |
26,156 | public function get ( $ key = null , $ default = null ) { if ( is_null ( $ key ) ) { return Config :: get ( $ this -> configKey ( ) ) ; } return Config :: get ( $ this -> configKey ( ) . '.' . $ key , $ default ) ; } | Retreives config values using the config key property as a prefix to all keys given . |
26,157 | public function episode ( $ tvdbId , $ season , $ episode , $ fullPath = 0 ) { $ uri = 'episode' ; $ uriData = [ 'tvdbid' => $ tvdbId , 'season' => $ season , 'episode' => $ episode , 'full_path' => $ fullPath ] ; try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody ( ) -> getContents ( ) ; } | Displays the information of a specific episode matching the corresponding tvdbid season and episode number . |
26,158 | public function episodeSetStatus ( $ tvdbId , $ season , $ status , $ episode = null , $ force = 0 ) { $ uri = 'episode.setstatus' ; $ uriData = [ 'tvdbid' => $ tvdbId , 'season' => $ season , 'status' => $ status , 'force' => $ force ] ; if ( $ episode ) { $ uriData [ 'episode' ] = $ episode ; } try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody ( ) -> getContents ( ) ; } | Set the status of an epsiode or season . |
26,159 | public function future ( $ sort = 'date' , $ type = 'missed|today|soon|later' , $ paused = null ) { $ uri = 'future' ; $ uriData = [ 'sort' => $ sort , 'type' => $ type ] ; if ( $ paused ) { $ uriData [ 'paused' ] = $ paused ; } try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody ( ) -> getContents ( ) ; } | Display the upcoming episodes for the shows currently added in the users database . |
26,160 | public function logs ( $ minLevel = 'error' ) { $ uri = 'history.trim' ; $ uriData = [ 'min_level' => $ minLevel ] ; try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody ( ) -> getContents ( ) ; } | View SickRage s log . |
26,161 | public function showAddExisting ( $ tvdbId , $ location , $ flattenFolders = null , $ initial = null , $ archive = null ) { $ uri = 'show.addexisting' ; $ uriData = [ 'tvdbid' => $ tvdbId , 'location' => $ location ] ; if ( $ flattenFolders ) { $ uriData [ 'flatten_folders' ] = $ flattenFolders ; } if ( $ initial ) { $ uriData [ 'initial' ] = $ initial ; } if ( $ archive ) { $ uriData [ 'archive' ] = $ archive ; } try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody ( ) -> getContents ( ) ; } | Add a show to SickRage using an existing folder . |
26,162 | public function showSeasons ( $ tvdbId , $ season = null ) { $ uri = 'show.seasons' ; $ uriData = [ 'tvdbid' => $ tvdbId ] ; if ( is_numeric ( $ season ) ) { $ uriData [ 'season' ] = $ season ; } try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody ( ) -> getContents ( ) ; } | Display a listing of episodes for all or a given season . |
26,163 | public function showSetQuality ( $ tvdbId , $ initial = null , $ archive = null ) { $ uri = 'show.setquality' ; $ uriData = [ 'tvdbid' => $ tvdbId ] ; if ( $ initial ) { $ uriData [ 'initial' ] = $ initial ; } if ( $ archive ) { $ uriData [ 'archive' ] = $ archive ; } try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody ( ) -> getContents ( ) ; } | Set desired quality of a show in SickRage . |
26,164 | public function sbCheckScheduler ( ) { $ uri = 'sb.checkscheduler' ; try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => [ ] ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody ( ) -> getContents ( ) ; } | Query the SickBeard scheduler . |
26,165 | public function sbPauseBacklog ( $ pause = 0 ) { $ uri = 'sb.pausebacklog' ; $ uriData = [ 'pause' => $ pause ] ; try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody ( ) -> getContents ( ) ; } | Pause the backlog search . |
26,166 | public function sbSearchTvdb ( $ name = null , $ tvdbId = null , $ lang = 'en' ) { $ uri = 'sb.searchtvdb' ; $ uriData = [ 'lang' => $ lang ] ; if ( $ name ) { $ uriData [ 'name' ] = $ name ; } if ( $ tvdbId ) { $ uriData [ 'tvdbid' ] = $ tvdbId ; } try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody ( ) -> getContents ( ) ; } | Search TVDB for a show with a given string or tvdbid . |
26,167 | public function sbSetDefaults ( $ futureShowPaused = null , $ status = null , $ flattenFolders = null , $ initial = null , $ archive = null ) { $ uri = 'sb.setdefaults' ; $ uriData = [ ] ; if ( $ futureShowPaused ) { $ uriData [ 'future_show_paused' ] = $ futureShowPaused ; } if ( $ status ) { $ uriData [ 'status' ] = $ status ; } if ( $ flattenFolders ) { $ uriData [ 'flatten_folders' ] = $ flattenFolders ; } if ( $ initial ) { $ uriData [ 'initial' ] = $ initial ; } if ( $ archive ) { $ uriData [ 'archive' ] = $ archive ; } try { $ response = $ this -> _request ( [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ) ; } catch ( \ Exception $ e ) { throw new InvalidException ( $ e -> getMessage ( ) ) ; } return $ response -> getBody ( ) -> getContents ( ) ; } | Set default settings for SickRage . |
26,168 | public function isValid ( SessionBagInterface $ sessionBag ) { return $ sessionBag -> get ( self :: PARAM_REMOTE_ADDR ) === $ this -> hash ( $ this -> getRemoteAddr ( ) ) && $ sessionBag -> get ( self :: PARAM_USER_AGENT ) === $ this -> hash ( $ this -> getUserAgent ( ) ) ; } | Checks whether current session is valid |
26,169 | public function write ( SessionBagInterface $ sessionBag ) { if ( $ this -> hasRequiredParams ( ) ) { $ sessionBag -> set ( self :: PARAM_REMOTE_ADDR , $ this -> hash ( $ this -> getRemoteAddr ( ) ) ) ; $ sessionBag -> set ( self :: PARAM_USER_AGENT , $ this -> hash ( $ this -> getUserAgent ( ) ) ) ; } } | Writes validation data to the session |
26,170 | private function hasRequiredParams ( ) { return array_key_exists ( self :: PARAM_REMOTE_ADDR , $ this -> container ) && array_key_exists ( self :: PARAM_USER_AGENT , $ this -> container ) ; } | Checks whether container data has required keys |
26,171 | protected function convertToArray ( $ value ) { if ( \ is_string ( $ value ) ) { $ value = [ $ value ] ; } elseif ( null === $ value ) { $ value = [ ] ; } return $ value ; } | Convert value to array . |
26,172 | protected function getParams ( $ type , $ value ) { if ( false === strpos ( $ value , '-' ) ) { throw new InvalidConfigurationException ( sprintf ( 'The "%s" option must be configured with "{prefix}-{size}"' , $ type ) ) ; } list ( $ prefix , $ size ) = explode ( '-' , $ value ) ; if ( ! \ in_array ( $ prefix , $ this -> validPrefix ) ) { throw new InvalidConfigurationException ( sprintf ( 'The "%s" prefix option does not exist. Known options are: "' . implode ( '", "' , $ this -> validPrefix ) . '"' , $ type ) ) ; } if ( ! ( int ) $ size ) { throw new InvalidConfigurationException ( sprintf ( 'The "%s" size option must be an integer' , $ type ) ) ; } return [ $ prefix , $ size ] ; } | Get the option params . |
26,173 | public function quit ( $ redirection = null ) { if ( ! $ this -> response -> getAjax ( ) ) { if ( $ redirection ) { $ this -> redirection ( $ redirection ) ; } $ this -> shareMessages ( ) ; if ( ! GL_TESTING ) { Bootstrap :: dispatch ( $ this -> response ) ; exit ; } } return true ; } | Redirige y despacha la respuesta |
26,174 | public function addMessage ( $ message , $ type = 'success' ) { Events :: dispatch ( 'onMessageDisplay' , array ( 'message' => $ message , 'type' => $ type ) ) ; $ this -> messages [ ] = array ( 'message' => $ message , 'type' => $ type ) ; } | Muestra un mesaje en pantalla con el estilo indicado |
26,175 | public function getLink ( $ controller , $ params = array ( ) , $ fullPath = false ) { if ( $ controller instanceof Controller ) { $ controller = get_class ( $ controller ) ; } $ controller = ( string ) $ controller ; if ( substr ( $ controller , 0 , 1 ) === "\\" ) { $ controller = substr ( $ controller , 1 ) ; } try { $ url = Bootstrap :: getSingleton ( ) -> getManager ( ) -> getRouter ( ) -> generate ( $ controller , $ params ) ; if ( $ fullPath ) { $ protocol = 'http' ; if ( strpos ( $ _SERVER [ 'SCRIPT_URI' ] , 'https' ) !== false ) { $ protocol = 'https' ; } return $ protocol . '://' . $ _SERVER [ 'HTTP_HOST' ] . $ url ; } return $ url ; } catch ( \ Exception $ ex ) { } return "" ; } | Genera un enlace al controlador indicado puede ser un objeto un un string |
26,176 | public function remove ( $ key ) { if ( $ this -> has ( $ key ) ) { return wincache_ucache_delete ( $ key ) ; } else { throw new RuntimeException ( sprintf ( 'Attempted to delete non-existing key "%s"' , $ key ) ) ; } } | Deletes data associated with a key |
26,177 | public function getInfo ( ) { return array ( 'ucache_meminfo' => wincache_ucache_meminfo ( ) , 'ucache_info' => wincache_ucache_info ( ) , 'session_cache_info' => wincache_scache_info ( ) , 'session_cache_meminfo' => wincache_scache_meminfo ( ) , 'rp_meminfo' => wincache_rplist_meminfo ( ) , 'rp_fileinfo' => wincache_rplist_fileinfo ( ) , 'opcode_fileinfo' => wincache_ocache_fileinfo ( ) , 'opcode_meminfo' => wincache_ocache_meminfo ( ) , 'filecache_meminfo' => wincache_fcache_fileinfo ( ) , 'filecache_fileinfo' => wincache_fcache_meminfo ( ) ) ; } | Retrieves information about user cache memory usage |
26,178 | public function isValid ( $ target ) { if ( mb_strlen ( $ target , $ this -> charset ) < $ this -> length ) { $ this -> violate ( sprintf ( $ this -> message , $ this -> length ) ) ; return false ; } else { return true ; } } | Checks whether target is valid |
26,179 | public function call ( $ class , $ action , array $ params = array ( ) , array $ options = array ( ) ) { $ controller = $ this -> controllerFactory -> build ( $ class , $ action , $ options ) ; if ( method_exists ( $ controller , $ action ) ) { return call_user_func_array ( array ( $ controller , $ action ) , $ params ) ; } else { throw new LogicException ( sprintf ( 'A %s controller must implement %s() method, because it has been defined in the map' , $ class , $ action ) ) ; } } | Calls a controller providing a service locator as its dependency |
26,180 | public function forward ( $ notation , array $ args = array ( ) ) { $ data = $ this -> mapManager -> toCompliant ( $ notation ) ; $ controller = array_keys ( $ data ) ; $ controller = $ controller [ 0 ] ; $ action = array_values ( $ data ) ; $ action = $ action [ 0 ] ; return $ this -> call ( $ controller , $ action , $ args ) ; } | Forwards to another controller from notation |
26,181 | public function render ( $ matchedURITemplate , array $ params = array ( ) ) { $ options = $ this -> mapManager -> getDataByUriTemplate ( $ matchedURITemplate ) ; $ class = $ this -> mapManager -> getControllerByURITemplate ( $ matchedURITemplate ) ; $ action = $ this -> mapManager -> getActionByURITemplate ( $ matchedURITemplate ) ; return $ this -> call ( $ class , $ action , $ params , $ options ) ; } | Dispatches a controller according to the request |
26,182 | public function build ( $ dir , $ quality , array $ options = array ( ) ) { if ( ! isset ( $ options [ 'prefix' ] ) ) { $ options [ 'prefix' ] = 'original' ; } $ maxWidth = 0 ; $ maxHeight = 0 ; if ( isset ( $ options [ 'max_width' ] ) && isset ( $ options [ 'max_height' ] ) ) { $ maxWidth = $ options [ 'max_width' ] ; $ maxHeight = $ options [ 'max_height' ] ; } return new OriginalSize ( $ dir , $ options [ 'prefix' ] , $ quality , $ maxWidth , $ maxHeight ) ; } | Builds original size uploader |
26,183 | public function setContacts ( array $ contacts ) : SecurityTxt { if ( ! $ this -> validContacts ( $ contacts , true ) ) { throw new Exception ( 'Contacts array must contain well-formed e-mails and/or URLs.' ) ; } $ this -> contacts = $ contacts ; return $ this ; } | Set the contacts . |
26,184 | public function validContact ( string $ contact ) : bool { return filter_var ( $ contact , FILTER_VALIDATE_EMAIL ) !== false || filter_var ( $ contact , FILTER_VALIDATE_URL ) !== false ; } | Validates a contact . |
26,185 | public function validContacts ( array $ contacts , bool $ use_keys = false ) : bool { if ( $ use_keys ) { $ contacts = array_keys ( $ contacts ) ; } foreach ( $ contacts as $ contact ) { if ( ! $ this -> validContact ( $ contact ) ) { return false ; } } return true ; } | Validates an array of contacts . |
26,186 | public function hasContacts ( array $ contacts ) : bool { foreach ( $ contacts as $ contact ) { if ( ! $ this -> hasContact ( $ contact ) ) { return false ; } } return true ; } | Determines if an array of contacts exists . |
26,187 | public static function filterAttribute ( $ value ) { $ isEncoded = TextUtils :: strModified ( $ value , function ( $ target ) { return self :: escape ( $ target ) ; } ) ; if ( $ isEncoded ) { $ value = self :: charsDecode ( $ value ) ; } $ value = self :: specialChars ( $ value ) ; return $ value ; } | Filters attribute value |
26,188 | public static function stripTags ( $ text , array $ allowed = array ( ) ) { $ allowed = array_map ( 'strtolower' , $ allowed ) ; return preg_replace_callback ( '/<\/?([^>\s]+)[^>]*>/i' , function ( $ matches ) use ( & $ allowed ) { return in_array ( strtolower ( $ matches [ 1 ] ) , $ allowed ) ? $ matches [ 0 ] : '' ; } , $ text ) ; } | Strip the tags even malformed ones |
26,189 | public function remove ( $ target , $ abort = true ) { $ entity = $ this -> find ( $ target ) ; if ( $ abort ) { $ this -> isUsedByEntitys ( $ entity ) ; } $ this -> em ( ) -> remove ( $ entity ) ; return $ entity ; } | Marcar um registro como deletado . |
26,190 | protected function formattedCommand ( $ command ) { $ structure = [ $ this -> getEnvVariable ( ) , $ this -> executable , $ this -> getOptions ( ) , $ command ] ; return implode ( ' ' , array_filter ( $ structure ) ) ; } | Formatted command . |
26,191 | public function getTypeByExtension ( $ extension ) { if ( $ this -> isValidExtension ( $ extension ) ) { $ list = $ this -> getList ( true ) ; return $ list [ $ extension ] ; } else { return 'application/octet-stream' ; } } | Finds associated type by its extension |
26,192 | public function getExtensionByType ( $ type ) { if ( $ this -> isValidType ( $ type ) ) { return $ this -> mime [ $ type ] ; } else { throw new RuntimeException ( sprintf ( 'Invalid type "%s" supplied' , $ type ) ) ; } } | Finds associated extension by its type |
26,193 | public function getList ( $ flip = false ) { if ( $ flip !== false ) { return array_flip ( $ this -> mime ) ; } else { return $ this -> mime ; } } | Returns full list |
26,194 | public function append ( array $ pair ) { foreach ( $ pair as $ key => $ value ) { $ this -> mime [ $ key ] = $ value ; } } | Appends pair to the end of the stack |
26,195 | protected function getGroupArgument ( ) { $ groups = explode ( ',' , preg_replace ( '/\s+/' , '' , $ this -> argument ( 'group' ) ) ) ; return array_map ( function ( $ group ) { return preg_replace ( '/\\.[^.\\s]{3,4}$/' , '' , $ group ) ; } , $ groups ) ; } | Get group argument . |
26,196 | public function addMerchantPayment ( $ application , \ DateTime $ effectiveDate , $ amount , $ token ) { return $ this -> postDocument ( '/v4/applications/' . $ application . '/merchant-payments' , [ 'amount' => $ amount , 'effective_date' => $ effectiveDate -> format ( 'Y-m-d' ) , ] , $ token , 'Add Merchant Payment' ) ; } | Add a Merchant Payment to the given application . Amount should be supplied in pence . |
26,197 | public function get ( string $ name ) { $ name = $ this -> getDefinitiveName ( $ name ) ; if ( ! $ this -> has ( $ name ) ) { $ instance = $ this -> build ( $ name ) ; $ this -> store ( $ instance ) ; } return $ this -> instances [ $ name ] ; } | Returns a stored instance or creates a new one and stores it . |
26,198 | public function has ( string $ name ) : bool { $ name = $ this -> getDefinitiveName ( $ name ) ; return isset ( $ this -> instances [ $ name ] ) ; } | Returns whether an instance is currently stored or not . |
26,199 | protected function createInstance ( string $ name , int $ useStoredDependencies ) { $ name = $ this -> getDefinitiveName ( $ name ) ; if ( interface_exists ( $ name ) ) { throw new ContainerException ( sprintf ( "Cannot create instance for interface `%s`." , $ name ) ) ; } try { $ dependencies = $ this -> getDependenciesFor ( $ name , $ useStoredDependencies ) ; } catch ( Throwable $ e ) { throw new ContainerException ( $ e -> getMessage ( ) ) ; } return new $ name ( ... $ dependencies ) ; } | Create an instance with either new or existing dependencies . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.