Code improvements and fixes (mostly unused variables and methods)
| | |
| | | $out = $seen = array(); |
| | | |
| | | // iterate over the current configuration |
| | | foreach ($this->config as $prop => $value) { |
| | | foreach (array_keys($this->config) as $prop) { |
| | | if ($replacement = $this->replaced_config[$prop]) { |
| | | $out['replaced'][] = array('prop' => $prop, 'replacement' => $replacement); |
| | | $seen[$replacement] = true; |
| | |
| | | |
| | | if (!function_exists('idn_to_utf8')) |
| | | { |
| | | function idn_to_utf8($domain, $flags=null) |
| | | function idn_to_utf8($domain) |
| | | { |
| | | static $idn, $loaded; |
| | | |
| | |
| | | |
| | | if (!function_exists('idn_to_ascii')) |
| | | { |
| | | function idn_to_ascii($domain, $flags=null) |
| | | function idn_to_ascii($domain) |
| | | { |
| | | static $idn, $loaded; |
| | | |
| | |
| | | */ |
| | | public static function absolute_url($path, $base_url) |
| | | { |
| | | $host_url = $base_url; |
| | | $abs_path = $path; |
| | | |
| | | // check if path is an absolute URL |
| | | if (preg_match('/^[fhtps]+:\/\//', $path)) { |
| | | return $path; |
| | |
| | | if (strpos($path, 'cid:') === 0) { |
| | | return $path; |
| | | } |
| | | |
| | | $host_url = $base_url; |
| | | $abs_path = $path; |
| | | |
| | | // cut base_url to the last directory |
| | | if (strrpos($base_url, '/') > 7) { |
| | |
| | | $path = preg_replace('/^\.\//', '', $path); |
| | | |
| | | if (preg_match_all('/\.\.\//', $path, $matches, PREG_SET_ORDER)) { |
| | | foreach ($matches as $a_match) { |
| | | $cnt = count($matches); |
| | | while ($cnt--) { |
| | | if ($pos = strrpos($base_url, '/')) { |
| | | $base_url = substr($base_url, 0, $pos); |
| | | } |
| | |
| | | static $iconv_options = null; |
| | | static $mbstring_list = null; |
| | | static $mbstring_sch = null; |
| | | static $conv = null; |
| | | |
| | | $to = empty($to) ? RCUBE_CHARSET : $to; |
| | | $from = self::parse_charset($from); |
| | |
| | | $name, $gid, $this->user_id |
| | | ); |
| | | |
| | | return $this->db->affected_rows() ? $name : false; |
| | | return $this->db->affected_rows($sql_result) ? $name : false; |
| | | } |
| | | |
| | | |
| | |
| | | $group_id |
| | | ); |
| | | |
| | | return $this->db->affected_rows(); |
| | | return $this->db->affected_rows($sql_result); |
| | | } |
| | | |
| | | |
| | |
| | | return true; |
| | | } |
| | | |
| | | function filter($in, $out, &$consumed, $closing) |
| | | function filter($in, $out, &$consumed) |
| | | { |
| | | while ($bucket = stream_bucket_make_writeable($in)) { |
| | | $this->buffer .= $bucket->data; |
| | |
| | | $mode = $this->in_transaction ? OCI_NO_AUTO_COMMIT : OCI_COMMIT_ON_SUCCESS; |
| | | |
| | | if ($result) { |
| | | foreach ($args as $param => $arg) { |
| | | foreach (array_keys($args) as $param) { |
| | | oci_bind_by_name($result, $param, $args[$param], -1, SQLT_LNG); |
| | | } |
| | | } |
| | |
| | | |
| | | $this->debug('ROLLBACK TRANSACTION'); |
| | | |
| | | if ($result = @oci_rollback($this->dbh)) { |
| | | if (@oci_rollback($this->dbh)) { |
| | | $this->in_transaction = false; |
| | | } |
| | | else { |
| | |
| | | if (!is_array($items) && ($pos = strpos($response, '(')) !== false) { |
| | | $response = substr($response, $pos); |
| | | $items = $this->tokenizeResponse($response, 1); |
| | | |
| | | if (!is_array($items)) { |
| | | return $result; |
| | | } |
| | |
| | | $encoding = $encoding ? trim($encoding) : 'US-ASCII'; |
| | | $algorithm = $algorithm ? trim($algorithm) : 'REFERENCES'; |
| | | $criteria = $criteria ? 'ALL '.trim($criteria) : 'ALL'; |
| | | $data = ''; |
| | | |
| | | list($code, $response) = $this->execute($return_uid ? 'UID THREAD' : 'THREAD', |
| | | array($algorithm, $encoding, $criteria)); |
| | |
| | | private $charset; |
| | | private $sort_field; |
| | | private $threading; |
| | | private $searchset; |
| | | private $result; |
| | | private $pagesize = 100; |
| | | |
| | | public function __construct($folder, $str, $charset = null, $sort_field = null, $threading=false) |
| | | { |
| | |
| | | |
| | | private $base_dn = ''; |
| | | private $groups_base_dn = ''; |
| | | private $group_url; |
| | | private $group_data; |
| | | private $group_search_cache; |
| | | private $cache; |
| | |
| | | |
| | | // get all entries of this page and post-filter those that really match the query |
| | | $search = mb_strtolower($value); |
| | | foreach ($ldap_data as $i => $entry) { |
| | | foreach ($ldap_data as $entry) { |
| | | $rec = $this->_ldap2result($entry); |
| | | foreach ($fields as $f) { |
| | | foreach ((array)$rec[$f] as $val) { |
| | |
| | | return $ldap_data; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns unified attribute name (resolving aliases) |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Prints debug info to the log |
| | | */ |
| | | private function _debug($str) |
| | | { |
| | | if ($this->debug) { |
| | | rcube::write_log('ldap', $str); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Activate/deactivate debug mode |
| | | * |
| | | * @param boolean $dbg True if LDAP commands should be logged |
| | |
| | | $this->ldap->config_set('debug', $dbg); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Setter for the current group |
| | |
| | | $filter = strtr("(|(member=$contact_dn)(uniqueMember=$contact_dn)$add_filter)", array('\\' => '\\\\')); |
| | | |
| | | $ldap_data = $this->ldap->search($base_dn, $filter, 'sub', array('dn', $name_attr)); |
| | | if ($res === false) { |
| | | if ($ldap_data === false) { |
| | | return array(); |
| | | } |
| | | |
| | |
| | | else if ($mimetype == 'multipart/alternative' |
| | | && is_array($structure->parts) && count($structure->parts) > 1 |
| | | ) { |
| | | $plain_part = null; |
| | | $html_part = null; |
| | | $print_part = null; |
| | | $related_part = null; |
| | | $attach_part = null; |
| | | |
| | | // get html/plaintext parts, other add to attachments list |
| | | foreach ($structure->parts as $p => $sub_part) { |
| | | $sub_mimetype = $sub_part->mimetype; |
| | |
| | | $result = new SimpleXMLElement($response); |
| | | } |
| | | catch (Exception $e) { |
| | | $thid->error = "Unexpected response from server: " . $store; |
| | | $this->error = "Unexpected response from server: " . $response; |
| | | return array(); |
| | | } |
| | | |
| | |
| | | * Find index with the '$type' attribute |
| | | * |
| | | * @param string Field name |
| | | * |
| | | * @return int Field index having $type set |
| | | */ |
| | | private function get_type_index($field, $type = 'pref') |
| | | private function get_type_index($field) |
| | | { |
| | | $result = 0; |
| | | if ($this->raw[$field]) { |
| | |
| | | |
| | | $this->assertSame('<A href="http://shouldbethislink.com">Test URL</A>', $response); |
| | | } |
| | | |
| | | /** |
| | | * Data for absolute_url() test |
| | | */ |
| | | function data_absolute_url() |
| | | { |
| | | return array( |
| | | array('', 'http://test', 'http://test/'), |
| | | array('http://test', 'http://anything', 'http://test'), |
| | | array('cid:test', 'http://anything', 'cid:test'), |
| | | array('/test', 'http://test', 'http://test/test'), |
| | | array('./test', 'http://test', 'http://test/test'), |
| | | array('../test1', 'http://test/test2', 'http://test1'), |
| | | array('../test1', 'http://test/test2/', 'http://test/test1'), |
| | | ); |
| | | } |
| | | |
| | | /** |
| | | * Test absolute_url() |
| | | * @dataProvider data_absolute_url |
| | | */ |
| | | function test_absolute_url($path, $base, $expected) |
| | | { |
| | | $replacer = new rcube_base_replacer('test'); |
| | | $result = $replacer->absolute_url($path, $base); |
| | | |
| | | $this->assertSame($expected, $result); |
| | | } |
| | | } |