idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
41,500
private function filter ( $ plugin ) { return ( $ plugin -> noajax && ! ( is_object ( $ this -> output ) && $ this -> output -> type == 'html' ) ) || ( $ plugin -> task && ! preg_match ( '/^(' . $ plugin -> task . ')$/i' , $ this -> task ) ) || ( $ plugin -> noframe && ! empty ( $ _REQUEST [ '_framed' ] ) ) ; }
check if we should prevent this plugin from initialising
41,501
public function register_hook ( $ hook , $ callback ) { if ( is_callable ( $ callback ) ) { if ( isset ( $ this -> deprecated_hooks [ $ hook ] ) ) { rcube :: raise_error ( array ( 'code' => 522 , 'type' => 'php' , 'file' => __FILE__ , 'line' => __LINE__ , 'message' => "Deprecated hook name. " . $ hook . ' -> ' . $ this...
Allows a plugin object to register a callback for a certain hook
41,502
public function unregister_hook ( $ hook , $ callback ) { $ callback_id = array_search ( $ callback , ( array ) $ this -> handlers [ $ hook ] ) ; if ( $ callback_id !== false ) { array_splice ( $ this -> handlers [ $ hook ] , $ callback_id , 1 ) ; } }
Allow a plugin object to unregister a callback .
41,503
public function exec_hook ( $ hook , $ args = array ( ) ) { if ( ! is_array ( $ args ) ) { $ args = array ( 'arg' => $ args ) ; } $ args += array ( 'abort' => false ) ; array_push ( $ this -> exec_stack , $ hook ) ; if ( ! empty ( $ this -> handlers [ $ hook ] ) ) { for ( $ i = 0 ; $ i < count ( $ this -> handlers [ $ ...
Triggers a plugin hook . This is called from the application and executes all registered handlers
41,504
public function register_action ( $ action , $ owner , $ callback , $ task = null ) { if ( $ task ) $ action = $ task . '.' . $ action ; else if ( strpos ( $ action , 'plugin.' ) !== 0 ) $ action = 'plugin.' . $ action ; if ( ! isset ( $ this -> actionmap [ $ action ] ) || $ this -> actionmap [ $ action ] == $ owner ) ...
Let a plugin register a handler for a specific request
41,505
public function exec_action ( $ action ) { if ( isset ( $ this -> actions [ $ action ] ) ) { call_user_func ( $ this -> actions [ $ action ] ) ; } else if ( rcube :: get_instance ( ) -> action != 'refresh' ) { rcube :: raise_error ( array ( 'code' => 524 , 'type' => 'php' , 'file' => __FILE__ , 'line' => __LINE__ , 'me...
This method handles requests like _task = mail&_action = plugin . foo It executes the callback function that was registered with the given action .
41,506
public function register_handler ( $ name , $ owner , $ callback ) { if ( strpos ( $ name , 'plugin.' ) !== 0 ) { $ name = 'plugin.' . $ name ; } if ( is_object ( $ this -> output ) && ( ! isset ( $ this -> objectsmap [ $ name ] ) || $ this -> objectsmap [ $ name ] == $ owner ) ) { $ this -> output -> add_handler ( $ n...
Register a handler function for template objects
41,507
public function is_processing ( $ hook = null ) { return count ( $ this -> exec_stack ) > 0 && ( ! $ hook || in_array ( $ hook , $ this -> exec_stack ) ) ; }
Check if a plugin hook is currently processing . Mainly used to prevent loops and recursion .
41,508
public function include_script ( $ fn ) { if ( is_object ( $ this -> output ) && $ this -> output -> type == 'html' ) { $ src = $ this -> resource_url ( $ fn ) ; $ this -> output -> add_header ( html :: tag ( 'script' , array ( 'type' => "text/javascript" , 'src' => $ src ) ) ) ; } }
Include a plugin script file in the current HTML page
41,509
public function include_stylesheet ( $ fn ) { if ( is_object ( $ this -> output ) && $ this -> output -> type == 'html' ) { $ src = $ this -> resource_url ( $ fn ) ; $ this -> output -> include_css ( $ src ) ; } }
Include a plugin stylesheet in the current HTML page
41,510
protected function get_cache ( ) { if ( ! $ this -> cache ) { $ this -> load_config ( ) ; $ rcmail = rcube :: get_instance ( ) ; $ ttl = 12 * 60 * 60 ; $ ttl = $ rcmail -> config -> get ( 'database_attachments_cache_ttl' , $ ttl ) ; $ type = $ rcmail -> config -> get ( 'database_attachments_cache' , 'db' ) ; $ prefix =...
Initialize and return cache object
41,511
public function sendOutput ( ) { if ( $ this -> binary ) { $ rcmail = rcmail :: get_instance ( ) ; $ rcmail -> output -> future_expire_header ( 10 * 60 ) ; header ( 'Content-Type: ' . $ this -> mimetype ) ; header ( 'Content-Size: ' . strlen ( $ this -> binary ) ) ; echo $ this -> binary ; return true ; } return false ...
Sends the image to the browser
41,512
private function generateGD ( ) { $ color = $ this -> toRGB ( $ this -> color ) ; $ bgcolor = $ this -> toRGB ( $ this -> bgcolor ) ; $ image = imagecreate ( $ this -> width , $ this -> height ) ; $ color = imagecolorallocate ( $ image , $ color [ 0 ] , $ color [ 1 ] , $ color [ 2 ] ) ; $ bgcolor = imagecolorallocate (...
GD - based icon generation worker
41,513
function email2user ( $ p ) { $ r = $ this -> findinvirtual ( '/^' . preg_quote ( $ p [ 'email' ] , '/' ) . '\s/' ) ; for ( $ i = 0 ; $ i < count ( $ r ) ; $ i ++ ) { $ arr = preg_split ( '/\s+/' , trim ( $ r [ $ i ] ) ) ; if ( count ( $ arr ) > 0 ) { $ p [ 'user' ] = trim ( $ arr [ count ( $ arr ) - 1 ] ) ; break ; } ...
Email > User
41,514
private function findinvirtual ( $ pattern ) { $ result = array ( ) ; $ virtual = null ; if ( $ this -> file ) $ virtual = file ( $ this -> file ) ; if ( empty ( $ virtual ) ) return $ result ; foreach ( $ virtual as $ line ) { $ line = trim ( $ line ) ; if ( empty ( $ line ) || $ line [ 0 ] == '#' ) continue ; if ( pr...
Find matches of the given pattern in virtuser file
41,515
function init ( ) { $ rcube = rcube :: get_instance ( ) ; $ this -> add_hook ( 'message_part_after' , array ( $ this , 'message_part_after' ) ) ; $ this -> add_hook ( 'message_outgoing_body' , array ( $ this , 'message_outgoing_body' ) ) ; $ this -> add_hook ( 'html2text' , array ( $ this , 'html2text' ) ) ; $ this -> ...
Plugin initilization .
41,516
function message_outgoing_body ( $ args ) { if ( $ args [ 'type' ] == 'html' ) { $ this -> load_config ( ) ; $ rcube = rcube :: get_instance ( ) ; if ( ! $ rcube -> config -> get ( 'emoticons_compose' , true ) ) { return $ args ; } require_once __DIR__ . '/emoticons_engine.php' ; $ images = emoticons_engine :: replace ...
message_outgoing_body hook handler to replace image emoticons from TinyMCE editor with image attachments .
41,517
function html2text ( $ args ) { $ rcube = rcube :: get_instance ( ) ; if ( $ rcube -> action == 'html2text' || $ rcube -> action == 'send' ) { $ this -> load_config ( ) ; if ( ! $ rcube -> config -> get ( 'emoticons_compose' , true ) ) { return $ args ; } require_once __DIR__ . '/emoticons_engine.php' ; $ args [ 'body'...
html2text hook handler to replace image emoticons from TinyMCE editor with plain text emoticons .
41,518
function html_editor ( $ args ) { $ rcube = rcube :: get_instance ( ) ; $ this -> load_config ( ) ; if ( $ rcube -> config -> get ( 'emoticons_compose' , true ) ) { $ args [ 'extra_plugins' ] [ ] = 'emoticons' ; $ args [ 'extra_buttons' ] [ ] = 'emoticons' ; } return $ args ; }
html_editor hook handler where we enable emoticons in TinyMCE
41,519
function preferences_list ( $ args ) { $ rcube = rcube :: get_instance ( ) ; $ dont_override = $ rcube -> config -> get ( 'dont_override' , array ( ) ) ; if ( $ args [ 'section' ] == 'mailview' && ! in_array ( 'emoticons_display' , $ dont_override ) ) { $ this -> load_config ( ) ; $ this -> add_texts ( 'localization' )...
preferences_list hook handler
41,520
function preferences_save ( $ args ) { $ rcube = rcube :: get_instance ( ) ; $ dont_override = $ rcube -> config -> get ( 'dont_override' , array ( ) ) ; if ( $ args [ 'section' ] == 'mailview' && ! in_array ( 'emoticons_display' , $ dont_override ) ) { $ args [ 'prefs' ] [ 'emoticons_display' ] = rcube_utils :: get_in...
preferences_save hook handler
41,521
public function get ( $ name , $ decode = true ) { $ name = strtolower ( $ name ) ; if ( isset ( $ this -> obj_headers [ $ name ] ) ) { $ value = $ this -> { $ this -> obj_headers [ $ name ] } ; } else { $ value = $ this -> others [ $ name ] ; } if ( $ decode ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ key...
Returns header value
41,522
public function set ( $ name , $ value ) { $ name = strtolower ( $ name ) ; if ( isset ( $ this -> obj_headers [ $ name ] ) ) { $ this -> { $ this -> obj_headers [ $ name ] } = $ value ; } else { $ this -> others [ $ name ] = $ value ; } }
Sets header value
41,523
public static function from_array ( $ arr ) { $ obj = new rcube_message_header ; foreach ( $ arr as $ k => $ v ) $ obj -> set ( $ k , $ v ) ; return $ obj ; }
Factory method to instantiate headers from a data array
41,524
function set_base_url ( $ url = '' ) { if ( empty ( $ url ) ) { if ( ! empty ( $ _SERVER [ 'HTTP_HOST' ] ) ) { $ this -> url = 'http://' . $ _SERVER [ 'HTTP_HOST' ] ; } else { $ this -> url = '' ; } } else { if ( substr ( $ url , - 1 ) == '/' ) { $ url = substr ( $ url , 0 , - 1 ) ; } $ this -> url = $ url ; } }
Sets a base URL to handle relative links .
41,525
public function blockquote_citation_callback ( $ m ) { $ line = ltrim ( $ m [ 2 ] ) ; $ space = $ line [ 0 ] == '>' ? '' : ' ' ; return $ m [ 1 ] . '>' . $ space . $ line ; }
Callback function to correctly add citation markers for blockquote contents
41,526
public function props ( ) { if ( function_exists ( 'getimagesize' ) && ( $ imsize = @ getimagesize ( $ this -> image_file ) ) ) { $ width = $ imsize [ 0 ] ; $ height = $ imsize [ 1 ] ; $ gd_type = $ imsize [ 2 ] ; $ type = image_type_to_extension ( $ gd_type , false ) ; $ channels = $ imsize [ 'channels' ] ; } if ( ! $...
Get image properties .
41,527
public static function is_convertable ( $ mimetype = null ) { $ rcube = rcube :: get_instance ( ) ; return class_exists ( 'Imagick' , false ) || $ rcube -> config -> get ( 'im_convert_path' ) ; }
Checks if image format conversion is supported
41,528
private function identify ( ) { $ rcube = rcube :: get_instance ( ) ; if ( $ cmd = $ rcube -> config -> get ( 'im_identify_path' ) ) { $ args = array ( 'in' => $ this -> image_file , 'format' => "%m %[fx:w] %[fx:h]" ) ; $ id = rcube :: exec ( $ cmd . ' 2>/dev/null -format {format} {in}' , $ args ) ; if ( $ id ) { retur...
ImageMagick based image properties read .
41,529
private function mem_check ( $ props ) { if ( ! $ props [ 'width' ] ) { return true ; } $ multip = ( $ props [ 'channels' ] ? : 3 ) + 1 ; $ size = $ props [ 'width' ] * $ props [ 'height' ] * $ multip ; return rcube_utils :: mem_check ( $ size ) ; }
Check if we have enough memory to load specified image
41,530
private function wash_style ( $ style ) { $ result = array ( ) ; $ style = preg_replace ( '/[\n\r\s\t]+/' , ' ' , $ style ) ; $ style = rcube_utils :: xss_entity_decode ( $ style ) ; foreach ( explode ( ';' , $ style ) as $ declaration ) { if ( preg_match ( '/^\s*([a-z\\\-]+)\s*:\s*(.*)\s*$/i' , $ declaration , $ match...
Check CSS style
41,531
private function wash_uri ( $ uri , $ blocked_source = false ) { if ( ( $ src = $ this -> config [ 'cid_map' ] [ $ uri ] ) || ( $ src = $ this -> config [ 'cid_map' ] [ $ this -> config [ 'base_url' ] . $ uri ] ) ) { return $ src ; } if ( $ uri [ 0 ] == '#' ) { return $ uri ; } if ( preg_match ( '/^(http|https|ftp):.+/...
Wash URI value
41,532
private function cleanup ( $ html ) { $ html = trim ( $ html ) ; $ html_search = array ( '/(<\/nobr>)(\s+)(<nobr>)/i' , '/<title[^>]*>[^<]*<\/title>/i' , '/<\!doctype[^>]+>[^<]*/im' , '/^(\0\0\xFE\xFF|\xFF\xFE\0\0|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/' , '/<html\s[^>]+>/i' , ) ; $ html_replace = array ( '\\1' . ' &nbsp; ' ....
Clean HTML input
41,533
public static function html_tag_callback ( $ matches ) { if ( substr ( $ matches [ 3 ] , - 2 ) == '--' ) { $ matches [ 0 ] = '' ; return implode ( '' , $ matches ) ; } $ tagname = $ matches [ 2 ] ; $ tagname = preg_replace ( array ( '/:.*$/' , '/[^a-z0-9_\[\]\!?-]/i' , ) , '' , $ tagname ) ; if ( $ matches [ 1 ] == '</...
Callback function for HTML tags fixing
41,534
protected function explode_style ( $ style ) { $ pos = 0 ; while ( ( $ pos = strpos ( $ style , '/*' , $ pos ) ) !== false ) { $ end = strpos ( $ style , '*/' , $ pos + 2 ) ; if ( $ end === false ) { $ style = substr ( $ style , 0 , $ pos ) ; } else { $ style = substr_replace ( $ style , '' , $ pos , $ end - $ pos + 2 ...
Explode css style value
41,535
public function set_env ( $ name , $ value , $ addtojs = true ) { $ this -> env [ $ name ] = $ value ; if ( $ addtojs || isset ( $ this -> js_env [ $ name ] ) ) { $ this -> js_env [ $ name ] = $ value ; } }
Set environment variable
41,536
public function set_assets_path ( $ path , $ fs_dir = null ) { if ( empty ( $ path ) ) { return ; } $ path = rtrim ( $ path , '/' ) . '/' ; if ( ! preg_match ( '|^https?://|' , $ path ) && $ path [ 0 ] != '/' ) { $ this -> assets_dir = $ path ; $ base = preg_replace ( '/[?#&].*$/' , '' , $ _SERVER [ 'REQUEST_URI' ] ) ;...
Parse and set assets path
41,537
protected function get_pagetitle ( ) { if ( ! empty ( $ this -> pagetitle ) ) { $ title = $ this -> pagetitle ; } else if ( $ this -> env [ 'task' ] == 'login' ) { $ title = $ this -> app -> gettext ( array ( 'name' => 'welcome' , 'vars' => array ( 'product' => $ this -> config -> get ( 'product_name' ) ) ) ) ; } else ...
Getter for the current page title
41,538
private function load_skin ( $ skin_path ) { $ this -> skin_paths [ ] = $ skin_path ; $ meta = @ file_get_contents ( RCUBE_INSTALL_PATH . $ skin_path . '/meta.json' ) ; $ meta = @ json_decode ( $ meta , true ) ; $ meta [ 'path' ] = $ skin_path ; $ path_elements = explode ( '/' , $ skin_path ) ; $ skin_id = end ( $ path...
Helper method to recursively read skin meta files and register search paths
41,539
public function template_exists ( $ name ) { foreach ( $ this -> skin_paths as $ skin_path ) { $ filename = RCUBE_INSTALL_PATH . $ skin_path . '/templates/' . $ name . '.html' ; if ( ( is_file ( $ filename ) && is_readable ( $ filename ) ) || ( $ this -> deprecated_templates [ $ name ] && $ this -> template_exists ( $ ...
Check if a specific template exists
41,540
public function get_skin_file ( $ file , & $ skin_path = null , $ add_path = null ) { $ skin_paths = $ this -> skin_paths ; if ( $ add_path ) { array_unshift ( $ skin_paths , $ add_path ) ; } foreach ( $ skin_paths as $ skin_path ) { $ path = realpath ( RCUBE_INSTALL_PATH . $ skin_path . $ file ) ; if ( $ path && is_fi...
Find the given file in the current skin path stack
41,541
public function reset ( $ all = false ) { $ framed = $ this -> framed ; $ env = $ all ? null : array_intersect_key ( $ this -> env , array ( 'extwin' => 1 , 'framed' => 1 ) ) ; parent :: reset ( ) ; $ this -> env = $ this -> js_env = $ env ; $ this -> framed = $ framed || $ this -> env [ 'framed' ] ; $ this -> js_label...
Delete all stored env variables and commands
41,542
public function send ( $ templ = null , $ exit = true ) { if ( $ templ != 'iframe' ) { if ( $ exit != 'recur' && $ this -> app -> plugins -> is_processing ( 'render_page' ) ) { rcube :: raise_error ( array ( 'code' => 505 , 'type' => 'php' , 'file' => __FILE__ , 'line' => __LINE__ , 'message' => 'Recursion alert: ignor...
Send the request output to the client . This will either parse a skin tempalte or send an AJAX response
41,543
public function abs_url ( $ str , $ search_path = false ) { if ( $ str [ 0 ] == '/' ) { if ( $ search_path && ( $ file_url = $ this -> get_skin_file ( $ str , $ skin_path ) ) ) { return $ file_url ; } return $ this -> base_path . $ str ; } return $ str ; }
Make URLs starting with a slash point to skin directory
41,544
public function asset_url ( $ path ) { if ( ! $ this -> assets_path || in_array ( $ path [ 0 ] , array ( '?' , '/' , '.' ) ) || strpos ( $ path , '://' ) ) { return $ path ; } return $ this -> assets_path . $ path ; }
Modify path by adding URL prefix if configured
41,545
protected function file_mod ( $ file ) { $ fs = false ; $ ext = substr ( $ file , strrpos ( $ file , '.' ) + 1 ) ; if ( ! $ this -> devel_mode && ! preg_match ( '/\.min\.' . $ ext . '$/' , $ file ) ) { $ minified_file = substr ( $ file , 0 , strlen ( $ ext ) * - 1 ) . 'min.' . $ ext ; if ( $ fs = @ filemtime ( $ this -...
Modify file by adding mtime indicator
41,546
public function just_parse ( $ input ) { $ input = $ this -> parse_conditions ( $ input ) ; $ input = $ this -> parse_xml ( $ input ) ; $ input = $ this -> postrender ( $ input ) ; return $ input ; }
Public wrapper to dipp into template parsing .
41,547
protected function parse_conditions ( $ input ) { $ matches = preg_split ( '/<roundcube:(if|elseif|else|endif)\s+([^>]+)>\n?/is' , $ input , 2 , PREG_SPLIT_DELIM_CAPTURE ) ; if ( $ matches && count ( $ matches ) == 4 ) { if ( preg_match ( '/^(else|endif)$/i' , $ matches [ 1 ] ) ) { return $ matches [ 0 ] . $ this -> pa...
Parse for conditional tags
41,548
protected function alter_form_tag ( $ matches ) { $ out = $ matches [ 0 ] ; $ attrib = html :: parse_attrib_string ( $ matches [ 1 ] ) ; if ( strtolower ( $ attrib [ 'method' ] ) == 'post' ) { $ hidden = new html_hiddenfield ( array ( 'name' => '_token' , 'value' => $ this -> app -> get_request_token ( ) ) ) ; $ out .=...
Inserts hidden field with CSRF - prevention - token into POST forms
41,549
protected function postrender ( $ output ) { foreach ( $ this -> objects as $ key => $ val ) { $ output = str_replace ( $ key , $ val , $ output , $ count ) ; if ( $ count ) { $ this -> objects [ $ key ] = null ; } } $ output = preg_replace_callback ( '/<form\s+([^>]+)>/Ui' , array ( $ this , 'alter_form_tag' ) , $ out...
Put objects content back into template output
41,550
public function include_script ( $ file , $ position = 'head' ) { if ( ! preg_match ( '|^https?://|i' , $ file ) && $ file [ 0 ] != '/' ) { $ file = $ this -> file_mod ( $ this -> scripts_path . $ file ) ; } if ( ! is_array ( $ this -> script_files [ $ position ] ) ) { $ this -> script_files [ $ position ] = array ( ) ...
Link an external script file
41,551
public function add_script ( $ script , $ position = 'head' ) { if ( ! isset ( $ this -> scripts [ $ position ] ) ) { $ this -> scripts [ $ position ] = "\n" . rtrim ( $ script ) ; } else { $ this -> scripts [ $ position ] .= "\n" . rtrim ( $ script ) ; } }
Add inline javascript code
41,552
public function frame ( $ attrib , $ is_contentframe = false ) { static $ idcount = 0 ; if ( ! $ attrib [ 'id' ] ) { $ attrib [ 'id' ] = 'rcmframe' . ++ $ idcount ; } $ attrib [ 'name' ] = $ attrib [ 'id' ] ; $ attrib [ 'src' ] = $ attrib [ 'src' ] ? $ this -> abs_url ( $ attrib [ 'src' ] , true ) : 'program/resources/...
Returns iframe object registers some related env variables
41,553
public function form_tag ( $ attrib , $ content = null ) { if ( $ this -> env [ 'extwin' ] ) { $ hiddenfield = new html_hiddenfield ( array ( 'name' => '_extwin' , 'value' => '1' ) ) ; $ hidden = $ hiddenfield -> show ( ) ; } else if ( $ this -> framed || $ this -> env [ 'framed' ] ) { $ hiddenfield = new html_hiddenfi...
Create a form tag with the necessary hidden fields
41,554
public function request_form ( $ attrib , $ content = '' ) { $ hidden = new html_hiddenfield ( ) ; if ( $ attrib [ 'task' ] ) { $ hidden -> add ( array ( 'name' => '_task' , 'value' => $ attrib [ 'task' ] ) ) ; } if ( $ attrib [ 'action' ] ) { $ hidden -> add ( array ( 'name' => '_action' , 'value' => $ attrib [ 'actio...
Build a form tag with a unique request token
41,555
public function current_username ( $ attrib ) { static $ username ; if ( ! empty ( $ username ) ) { return $ username ; } if ( strpos ( $ _SESSION [ 'username' ] , '@' ) ) { $ username = $ _SESSION [ 'username' ] ; } else if ( $ sql_arr = $ this -> app -> user -> get_identity ( ) ) { $ username = $ sql_arr [ 'email' ] ...
GUI object username Showing IMAP username of the current session
41,556
protected function preloader ( $ attrib ) { $ images = preg_split ( '/[\s\t\n,]+/' , $ attrib [ 'images' ] , - 1 , PREG_SPLIT_NO_EMPTY ) ; $ images = array_map ( array ( $ this , 'abs_url' ) , $ images ) ; $ images = array_map ( array ( $ this , 'asset_url' ) , $ images ) ; if ( empty ( $ images ) || $ _REQUEST [ '_tas...
GUI object preloader Loads javascript code for images preloading
41,557
protected function search_form ( $ attrib ) { $ this -> add_label ( 'searching' ) ; $ attrib [ 'name' ] = '_q' ; if ( empty ( $ attrib [ 'id' ] ) ) { $ attrib [ 'id' ] = 'rcmqsearchbox' ; } if ( $ attrib [ 'type' ] == 'search' && ! $ this -> browser -> khtml ) { unset ( $ attrib [ 'type' ] , $ attrib [ 'results' ] ) ; ...
GUI object searchform Returns code for search function
41,558
protected function message_container ( $ attrib ) { if ( isset ( $ attrib [ 'id' ] ) === false ) { $ attrib [ 'id' ] = 'rcmMessageContainer' ; } $ this -> add_gui_object ( 'message' , $ attrib [ 'id' ] ) ; return html :: div ( $ attrib , '' ) ; }
Builder for GUI object message
41,559
public function load_config ( ) { if ( $ config = $ this -> load_config_file ( RCUBE_CONFIG_DIR . 'defaults.inc.php' ) ) { $ this -> config = ( array ) $ config ; $ this -> defaults = $ this -> config ; } $ config = null ; if ( $ config = $ this -> load_config_file ( RCUBE_CONFIG_DIR . 'config.inc.php' ) ) { $ this -> ...
Read the local config files and store properties
41,560
public function load_config_file ( $ file ) { if ( ! is_readable ( $ file ) ) { return ; } include $ file ; if ( function_exists ( 'token_get_all' ) ) { $ tokens = token_get_all ( file_get_contents ( $ file ) ) ; $ in_config = false ; $ buffer = '' ; for ( $ i = 0 ; $ i < count ( $ tokens ) ; $ i ++ ) { $ token = $ tok...
Read the default config file and store properties
41,561
public function getprop ( $ name , $ default = '' ) { $ value = $ this -> config [ $ name ] ; if ( $ name == 'des_key' && ! $ this -> configured && ! isset ( $ _REQUEST [ "_$name" ] ) ) { $ value = rcube_utils :: random_bytes ( 24 ) ; } return $ value !== null && $ value !== '' ? $ value : $ default ; }
Getter for a certain config property
41,562
public function check_config ( ) { $ this -> load_config ( ) ; if ( ! $ this -> configured ) { return ; } $ out = $ seen = array ( ) ; foreach ( array_keys ( $ this -> config ) as $ prop ) { if ( $ replacement = $ this -> replaced_config [ $ prop ] ) { $ out [ 'replaced' ] [ ] = array ( 'prop' => $ prop , 'replacement'...
Check the current configuration for missing properties and deprecated or obsolete settings
41,563
public function merge_config ( ) { $ current = $ this -> config ; $ this -> config = array ( ) ; foreach ( $ this -> replaced_config as $ prop => $ replacement ) { if ( isset ( $ current [ $ prop ] ) ) { if ( $ prop == 'skin_path' ) { $ this -> config [ $ replacement ] = preg_replace ( '#skins/(\w+)/?$#' , '\\1' , $ cu...
Merge the current configuration with the defaults and copy replaced values to the new options .
41,564
public function db_schema_check ( $ db ) { if ( ! $ this -> configured ) { return false ; } $ engine = $ db -> db_provider ; $ db_schema = $ this -> db_read_schema ( INSTALL_PATH . "SQL/$engine.initial.sql" ) ; $ errors = array ( ) ; $ existing_tables = $ db -> list_tables ( ) ; foreach ( $ db_schema as $ table => $ co...
Compare the local database schema with the reference schema required for this version of Roundcube
41,565
private function db_read_schema ( $ schemafile ) { $ lines = file ( $ schemafile ) ; $ table_block = false ; $ schema = array ( ) ; $ keywords = array ( 'PRIMARY' , 'KEY' , 'INDEX' , 'UNIQUE' , 'CONSTRAINT' , 'REFERENCES' , 'FOREIGN' ) ; foreach ( $ lines as $ line ) { if ( preg_match ( '/^\s*create table ([\S]+)/i' , ...
Utility function to read database schema from an . sql file
41,566
public function check_mime_detection ( ) { $ errors = array ( ) ; $ files = array ( 'program/resources/tinymce/video.png' => 'image/png' , 'program/resources/blank.tiff' => 'image/tiff' , 'program/resources/blocked.gif' => 'image/gif' , ) ; foreach ( $ files as $ path => $ expected ) { $ mimetype = rcube_mime :: file_c...
Try to detect some file s mimetypes to test the correct behavior of fileinfo
41,567
public function check_mime_extensions ( ) { $ errors = array ( ) ; $ types = array ( 'application/zip' => 'zip' , 'text/css' => 'css' , 'application/pdf' => 'pdf' , 'image/gif' => 'gif' , 'image/svg+xml' => 'svg' , ) ; foreach ( $ types as $ mimetype => $ expected ) { $ ext = rcube_mime :: get_mime_extensions ( $ mimet...
Check the correct configuration of the mime_types mapping option
41,568
public function get_hostlist ( ) { $ default_hosts = ( array ) $ this -> getprop ( 'default_host' ) ; $ out = array ( ) ; foreach ( $ default_hosts as $ key => $ name ) { if ( ! empty ( $ name ) ) { $ out [ ] = rcube_utils :: parse_host ( is_numeric ( $ key ) ? $ name : $ key ) ; } } return $ out ; }
Return a list with all imap hosts configured
41,569
public function list_skins ( ) { $ skins = array ( ) ; $ skindir = INSTALL_PATH . 'skins/' ; foreach ( glob ( $ skindir . '*' ) as $ path ) { if ( is_dir ( $ path ) && is_readable ( $ path ) ) { $ skins [ ] = substr ( $ path , strlen ( $ skindir ) ) ; } } return $ skins ; }
Return a list with available subfolders of the skin directory
41,570
public function fail ( $ name , $ message = '' , $ url = '' , $ optional = false ) { if ( ! $ optional ) { $ this -> failures ++ ; } echo rcube :: Q ( $ name ) . ':&nbsp; <span class="fail">NOT OK</span>' ; $ this -> _showhint ( $ message , $ url ) ; }
Display an error status and increase failure count
41,571
public function na ( $ name , $ message = '' , $ url = '' ) { echo rcube :: Q ( $ name ) . ':&nbsp; <span class="na">NOT AVAILABLE</span>' ; $ this -> _showhint ( $ message , $ url ) ; }
Display warning status
41,572
public function init_db ( $ db ) { $ engine = $ db -> db_provider ; $ fname = INSTALL_PATH . "SQL/$engine.initial.sql" ; if ( $ sql = @ file_get_contents ( $ fname ) ) { $ db -> set_option ( 'table_prefix' , $ this -> config [ 'db_prefix' ] ) ; $ db -> exec_script ( $ sql ) ; } else { $ this -> fail ( 'DB Schema' , "Ca...
Initialize the database with the according schema
41,573
function save ( $ currpass , $ newpass ) { $ rcmail = rcmail :: get_instance ( ) ; $ host = $ rcmail -> config -> get ( 'password_plesk_host' ) ; $ user = $ rcmail -> config -> get ( 'password_plesk_user' ) ; $ pass = $ rcmail -> config -> get ( 'password_plesk_pass' ) ; $ port = $ rcmail -> config -> get ( 'password_p...
this method is called from roundcube to change the password
41,574
function init ( $ host , $ port , $ path , $ user , $ pass ) { $ headers = array ( sprintf ( "HTTP_AUTH_LOGIN: %s" , $ user ) , sprintf ( "HTTP_AUTH_PASSWD: %s" , $ pass ) , "Content-Type: text/xml" ) ; $ url = sprintf ( "https://%s:%s/%s" , $ host , $ port , $ path ) ; $ this -> curl = curl_init ( ) ; curl_setopt ( $ ...
init plesk - rpc via curl
41,575
function send_request ( $ packet ) { curl_setopt ( $ this -> curl , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ this -> curl , CURLOPT_POSTFIELDS , $ packet ) ; $ retval = curl_exec ( $ this -> curl ) ; return $ retval ; }
send a request to the plesk
41,576
function domain_info ( $ domain ) { $ request = $ this -> get_request_obj ( ) ; $ site = $ request -> addChild ( "site" ) ; $ get = $ site -> addChild ( "get" ) ; $ filter = $ get -> addChild ( "filter" ) ; $ filter -> addChild ( "name" , utf8_encode ( $ domain ) ) ; $ dataset = $ get -> addChild ( "dataset" ) ; $ data...
Get all hosting - information of a domain
41,577
function get_domain_id ( $ domain ) { $ xml = $ this -> domain_info ( $ domain ) ; $ id = intval ( $ xml -> site -> get -> result -> id ) ; $ id = ( is_int ( $ id ) ) ? $ id : false ; return $ id ; }
Get psa - id of a domain
41,578
function change_mailbox_password ( $ mailbox , $ newpass ) { list ( $ user , $ domain ) = explode ( "@" , $ mailbox ) ; $ domain_id = $ this -> get_domain_id ( $ domain ) ; if ( ! $ domain_id ) { return false ; } $ request = $ this -> get_request_obj ( ) ; $ mail = $ request -> addChild ( "mail" ) ; $ update = $ mail -...
Change Password of a mailbox
41,579
function expunge ( ) { if ( $ this -> type == 'db' && $ this -> db && $ this -> ttl ) { $ this -> db -> query ( "DELETE FROM {$this->table}" . " WHERE `cache_key` LIKE ?" . " AND `expires` < " . $ this -> db -> now ( ) , $ this -> prefix . '.%' ) ; } }
Remove cache records older than ttl
41,580
function settings_actions ( $ args ) { $ this -> load_config ( ) ; $ vacation_mode = ( int ) $ this -> rc -> config -> get ( 'managesieve_vacation' ) ; if ( $ vacation_mode != 2 ) { $ args [ 'actions' ] [ ] = array ( 'action' => 'plugin.managesieve' , 'class' => 'filter' , 'label' => 'filters' , 'domain' => 'managesiev...
Adds Filters section in Settings
41,581
function mail_task_handler ( ) { if ( $ this -> rc -> output -> type != 'html' ) { return ; } $ this -> require_plugin ( 'jqueryui' ) ; $ this -> init_ui ( ) ; $ this -> api -> add_content ( html :: tag ( 'li' , null , $ this -> api -> output -> button ( array ( 'command' => 'managesieve-create' , 'label' => 'managesie...
Add UI elements to the mailbox view and show message UI .
41,582
function mail_headers ( $ args ) { if ( $ this -> mail_headers_done ) { return $ args ; } $ this -> mail_headers_done = true ; $ headers = $ this -> parse_headers ( $ args [ 'headers' ] ) ; if ( $ this -> rc -> action == 'preview' ) $ this -> rc -> output -> command ( 'parent.set_env' , array ( 'sieve_headers' => $ hea...
Get message headers for popup window
41,583
function managesieve_actions ( ) { $ uids = rcmail :: get_uids ( null , null , $ multifolder , rcube_utils :: INPUT_POST ) ; if ( ! empty ( $ uids ) ) { $ mailbox = key ( $ uids ) ; $ message = new rcube_message ( $ uids [ $ mailbox ] [ 0 ] , $ mailbox ) ; $ headers = $ this -> parse_headers ( $ message -> headers ) ; ...
Plugin action handler
41,584
function managesieve_save ( ) { $ this -> add_texts ( 'localization/' , array ( 'filters' , 'managefilters' ) ) ; if ( $ this -> api -> output -> type == 'html' ) { $ this -> include_script ( 'managesieve.js' ) ; } $ engine = $ this -> get_engine ( ) ; $ engine -> save ( ) ; }
Forms save action handler
41,585
function managesieve_saveraw ( ) { $ engine = $ this -> get_engine ( ) ; if ( ! $ this -> rc -> config -> get ( 'managesieve_raw_editor' , true ) ) { return ; } $ this -> add_texts ( 'localization/' , array ( 'filters' , 'managefilters' ) ) ; $ engine -> saveraw ( ) ; }
Raw form save action handler
41,586
public function get_engine ( $ type = null ) { if ( ! $ this -> engine ) { $ this -> load_config ( ) ; $ include_path = $ this -> home . '/lib' . PATH_SEPARATOR ; $ include_path .= ini_get ( 'include_path' ) ; set_include_path ( $ include_path ) ; $ class_name = 'rcube_sieve_' . ( $ type ? : 'engine' ) ; $ this -> engi...
Initializes engine object
41,587
private function parse_headers ( $ headers ) { $ result = array ( ) ; if ( $ headers -> subject ) $ result [ ] = array ( 'Subject' , rcube_mime :: decode_header ( $ headers -> subject ) ) ; foreach ( array ( 'From' , 'To' ) as $ h ) { $ hl = strtolower ( $ h ) ; if ( $ headers -> $ hl ) { $ list = rcube_mime :: decode_...
Extract mail headers for new filter form
41,588
protected function conn_configure ( $ dsn , $ dbh ) { if ( ! empty ( $ dsn [ 'database' ] ) && ! filesize ( $ dsn [ 'database' ] ) ) { $ data = file_get_contents ( RCUBE_INSTALL_PATH . 'SQL/sqlite.initial.sql' ) ; if ( strlen ( $ data ) ) { $ this -> debug ( 'INITIALIZE DATABASE' ) ; $ q = $ dbh -> exec ( $ data ) ; if...
Configure connection create database if not exists
41,589
function search_userdn ( $ rcmail ) { $ binddn = $ rcmail -> config -> get ( 'password_ldap_searchDN' ) ; $ bindpw = $ rcmail -> config -> get ( 'password_ldap_searchPW' ) ; $ ldapConfig = array ( 'basedn' => $ rcmail -> config -> get ( 'password_ldap_basedn' ) , 'host' => $ rcmail -> config -> get ( 'password_ldap_hos...
Bind with searchDN and searchPW and search for the user s DN . Use search_base and search_filter defined in config file . Return the found DN .
41,590
public function init ( $ data = null ) { $ this -> meta = array ( ) ; $ data = explode ( '*' , ( string ) $ data ) ; for ( $ i = 0 , $ len = count ( $ data ) ; $ i < $ len ; $ i ++ ) { if ( preg_match ( '/^ THREAD/i' , $ data [ $ i ] ) ) { $ this -> raw_data = '' ; $ data [ $ i ] = substr ( $ data [ $ i ] , 7 ) ; break...
Initializes object with IMAP command response
41,591
public function count_messages ( ) { if ( $ this -> meta [ 'messages' ] !== null ) return $ this -> meta [ 'messages' ] ; if ( empty ( $ this -> raw_data ) ) { $ this -> meta [ 'messages' ] = 0 ; } else { $ this -> meta [ 'messages' ] = 1 + substr_count ( $ this -> raw_data , self :: SEPARATOR_ELEMENT ) + substr_count ...
Returns number of all messages in the result
41,592
public function get ( ) { if ( empty ( $ this -> raw_data ) ) { return array ( ) ; } $ regexp = '/(' . preg_quote ( self :: SEPARATOR_ELEMENT , '/' ) . '|' . preg_quote ( self :: SEPARATOR_ITEM , '/' ) . '[0-9]+' . preg_quote ( self :: SEPARATOR_LEVEL , '/' ) . ')/' ; return preg_split ( $ regexp , $ this -> raw_data )...
Return IDs of all messages in the result . Threaded data will be flattened .
41,593
public function get_tree ( ) { $ datalen = strlen ( $ this -> raw_data ) ; $ result = array ( ) ; $ start = 0 ; while ( ( $ pos = @ strpos ( $ this -> raw_data , self :: SEPARATOR_ELEMENT , $ start ) ) || ( $ start < $ datalen && ( $ pos = $ datalen ) ) ) { $ len = $ pos - $ start ; $ elem = substr ( $ this -> raw_data...
Returns data as tree
41,594
public function get_thread_data ( ) { $ data = $ this -> get_tree ( ) ; $ depth = array ( ) ; $ children = array ( ) ; $ this -> build_thread_data ( $ data , $ depth , $ children ) ; return array ( $ depth , $ children ) ; }
Returns thread depth and children data
41,595
protected function build_thread_data ( $ data , & $ depth , & $ children , $ level = 0 ) { foreach ( ( array ) $ data as $ key => $ val ) { $ empty = empty ( $ val ) || ! is_array ( $ val ) ; $ children [ $ key ] = ! $ empty ; $ depth [ $ key ] = $ level ; if ( ! $ empty ) { $ this -> build_thread_data ( $ val , $ dept...
Creates depth and children arrays from stored thread tree data .
41,596
protected function build_thread ( $ items , $ level = 1 , & $ pos = 0 ) { $ result = array ( ) ; for ( $ len = count ( $ items ) ; $ pos < $ len ; $ pos ++ ) { list ( $ lv , $ id ) = explode ( self :: SEPARATOR_LEVEL , $ items [ $ pos ] ) ; if ( $ level == $ lv ) { $ pos ++ ; $ result [ $ id ] = $ this -> build_thread ...
Converts part of the raw thread into an array
41,597
protected function parse_thread ( $ str , $ begin = 0 , $ end = 0 , $ depth = 0 ) { $ node = '' ; if ( ! $ end ) { $ end = strlen ( $ str ) ; } if ( $ str [ $ begin ] != '(' ) { $ stop = $ begin + strcspn ( $ str , '()' , $ begin , $ end - $ begin ) ; $ messages = explode ( ' ' , trim ( substr ( $ str , $ begin , $ sto...
IMAP THREAD response parser
41,598
protected function startup ( ) { $ this -> init ( self :: INIT_WITH_DB | self :: INIT_WITH_PLUGINS ) ; if ( ( $ basename = basename ( $ _SERVER [ 'SCRIPT_FILENAME' ] ) ) && $ basename != 'index.php' ) { $ this -> filename = $ basename ; } $ plugins = ( array ) $ this -> config -> get ( 'plugins' , array ( ) ) ; $ requi...
Initial startup function to register session create database and imap connections
41,599
public function set_task ( $ task ) { if ( php_sapi_name ( ) == 'cli' ) { $ task = 'cli' ; } else if ( ! $ this -> user || ! $ this -> user -> ID ) { $ task = 'login' ; } else { $ task = asciiwords ( $ task , true ) ? : 'mail' ; } $ this -> task = $ task ; $ this -> comm_path = $ this -> url ( array ( 'task' => $ this ...
Setter for application task