@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | return $mime; |
48 | 48 | } |
49 | - return lang('%1 file',strtoupper($ext)).' ('.$mime.')'; |
|
49 | + return lang('%1 file', strtoupper($ext)).' ('.$mime.')'; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | { |
64 | 64 | if (empty($_ext)) |
65 | 65 | { |
66 | - return 'text/plain';//assume no extension is a text file |
|
66 | + return 'text/plain'; //assume no extension is a text file |
|
67 | 67 | } |
68 | 68 | $ext = strtolower($_ext); |
69 | 69 | if (!array_key_exists($ext, self::$mime_extension_map)) |
@@ -188,24 +188,24 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public static function analyze_data($data) |
190 | 190 | { |
191 | - if(!is_writeable(@$GLOBALS['egw_info']['server']['temp_dir'])) |
|
191 | + if (!is_writeable(@$GLOBALS['egw_info']['server']['temp_dir'])) |
|
192 | 192 | { |
193 | 193 | //nothing we can do but bail out |
194 | 194 | return false; |
195 | 195 | } |
196 | 196 | |
197 | 197 | mt_srand(time()); |
198 | - $filename = $GLOBALS['egw_info']['server']['temp_dir'] . '/' |
|
199 | - . md5( time() + mt_rand() ) . '.tmp'; |
|
198 | + $filename = $GLOBALS['egw_info']['server']['temp_dir'].'/' |
|
199 | + . md5(time() + mt_rand()).'.tmp'; |
|
200 | 200 | |
201 | 201 | $fp = @fopen($filename, 'ab'); |
202 | - if(!$fp || !$data) |
|
202 | + if (!$fp || !$data) |
|
203 | 203 | { |
204 | 204 | //houston we have a problem - bail out |
205 | 205 | return false; |
206 | 206 | } |
207 | 207 | |
208 | - if(!fwrite($fp, $data)) |
|
208 | + if (!fwrite($fp, $data)) |
|
209 | 209 | { |
210 | 210 | //bail out again |
211 | 211 | return false; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | $mime = self::analyze_file($filename); |
217 | 217 | |
218 | - unlink($filename);//remove the temp file |
|
218 | + unlink($filename); //remove the temp file |
|
219 | 219 | |
220 | 220 | return $mime; |
221 | 221 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @var array of extenstion to mime mappings |
234 | 234 | */ |
235 | 235 | static $mime_extension_map = array( |
236 | - 'txt' => 'text/plain', // should be first, so text/plain maps back to .txt |
|
236 | + 'txt' => 'text/plain', // should be first, so text/plain maps back to .txt |
|
237 | 237 | '3dml' => 'text/vnd.in3d.3dml', |
238 | 238 | '3ds' => 'image/x-3ds', |
239 | 239 | '3g2' => 'video/3gpp2', |
@@ -106,7 +106,10 @@ |
||
106 | 106 | public static function mime2ext($_type) |
107 | 107 | { |
108 | 108 | $type = strtolower($_type); |
109 | - if (isset(self::$mime_alias_map[$type])) $type = self::$mime_alias_map[$type]; |
|
109 | + if (isset(self::$mime_alias_map[$type])) |
|
110 | + { |
|
111 | + $type = self::$mime_alias_map[$type]; |
|
112 | + } |
|
110 | 113 | $key = array_search($type, self::$mime_extension_map); |
111 | 114 | if (empty($type) || $key === false) |
112 | 115 | { |
@@ -29,7 +29,7 @@ |
||
29 | 29 | class Exception extends \Exception |
30 | 30 | { |
31 | 31 | // nothing fancy yet |
32 | - function __construct($msg=null,$code=100,\Exception $previous=null) |
|
32 | + function __construct($msg = null, $code = 100, \Exception $previous = null) |
|
33 | 33 | { |
34 | 34 | return parent::__construct($msg, $code, $previous); |
35 | 35 | } |
@@ -54,26 +54,26 @@ discard block |
||
54 | 54 | * @throws Exception if connection to backend could not be established |
55 | 55 | * @param array $params eg. array('localhost'[,'localhost:11211',...]) |
56 | 56 | */ |
57 | - function __construct(array $params=null) |
|
57 | + function __construct(array $params = null) |
|
58 | 58 | { |
59 | - check_load_extension('memcache',true); |
|
59 | + check_load_extension('memcache', true); |
|
60 | 60 | $this->memcache = new \Memcache(); |
61 | 61 | |
62 | - if (!$params) $params = array('localhost'); // some reasonable default |
|
62 | + if (!$params) $params = array('localhost'); // some reasonable default |
|
63 | 63 | |
64 | 64 | $ok = false; |
65 | - foreach($params as $host_port) |
|
65 | + foreach ($params as $host_port) |
|
66 | 66 | { |
67 | - $parts = explode(':',$host_port); |
|
67 | + $parts = explode(':', $host_port); |
|
68 | 68 | $host = array_shift($parts); |
69 | - $port = $parts ? array_shift($parts) : 11211; // default port |
|
69 | + $port = $parts ? array_shift($parts) : 11211; // default port |
|
70 | 70 | |
71 | - $ok = $this->memcache->addServer($host,$port) || $ok; |
|
71 | + $ok = $this->memcache->addServer($host, $port) || $ok; |
|
72 | 72 | //error_log(__METHOD__."(".array2string($params).") memcache->addServer('$host',$port) = ".(int)$ok); |
73 | 73 | } |
74 | 74 | if (!$ok) |
75 | 75 | { |
76 | - throw new Exception (__METHOD__.'('.array2string($params).") Can't open connection to any memcached server!"); |
|
76 | + throw new Exception(__METHOD__.'('.array2string($params).") Can't open connection to any memcached server!"); |
|
77 | 77 | } |
78 | 78 | $this->igbinary_available = function_exists('igbinary_serialize') && function_exists('igbinary_unserialize'); |
79 | 79 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param int $expiration =0 |
87 | 87 | * @return boolean true on success, false on error, incl. key already exists in cache |
88 | 88 | */ |
89 | - function add(array $keys,$data,$expiration=0) |
|
89 | + function add(array $keys, $data, $expiration = 0) |
|
90 | 90 | { |
91 | 91 | return $this->memcache->add(self::key($keys), |
92 | 92 | $this->igbinary_available ? igbinary_serialize($data) : serialize($data), |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @param int $expiration =0 |
102 | 102 | * @return boolean true on success, false on error |
103 | 103 | */ |
104 | - function set(array $keys,$data,$expiration=0) |
|
104 | + function set(array $keys, $data, $expiration = 0) |
|
105 | 105 | { |
106 | 106 | return $this->memcache->set(self::key($keys), |
107 | 107 | $this->igbinary_available ? igbinary_serialize($data) : serialize($data), |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | function get(array $keys) |
118 | 118 | { |
119 | - if (($data = $this->memcache->get($key=self::key($keys))) === false) |
|
119 | + if (($data = $this->memcache->get($key = self::key($keys))) === false) |
|
120 | 120 | { |
121 | 121 | //error_log(__METHOD__."(".array2string($keys).") key='$key' NOT found!"); |
122 | 122 | return null; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | { |
136 | 136 | $locations = array_pop($keys); |
137 | 137 | $prefix = self::key($keys); |
138 | - foreach($locations as &$location) |
|
138 | + foreach ($locations as &$location) |
|
139 | 139 | { |
140 | 140 | $location = $prefix.'::'.$location; |
141 | 141 | } |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | return array(); |
145 | 145 | } |
146 | 146 | $ret = array(); |
147 | - $prefix_len = strlen($prefix)+2; |
|
148 | - foreach($multiple as $location => $data) |
|
147 | + $prefix_len = strlen($prefix) + 2; |
|
148 | + foreach ($multiple as $location => $data) |
|
149 | 149 | { |
150 | - $key = substr($location,$prefix_len); |
|
150 | + $key = substr($location, $prefix_len); |
|
151 | 151 | //error_log(__METHOD__."(".array2string($locations).") key='$key' found ".bytes($data)." bytes)."); |
152 | 152 | $ret[$key] = $this->igbinary_available && $data[1] !== ':' ? igbinary_unserialize($data) : unserialize($data); |
153 | 153 | } |
@@ -175,6 +175,6 @@ discard block |
||
175 | 175 | */ |
176 | 176 | private function key(array $keys) |
177 | 177 | { |
178 | - return implode('::',$keys); |
|
178 | + return implode('::', $keys); |
|
179 | 179 | } |
180 | 180 | } |
@@ -59,7 +59,11 @@ |
||
59 | 59 | check_load_extension('memcache',true); |
60 | 60 | $this->memcache = new \Memcache(); |
61 | 61 | |
62 | - if (!$params) $params = array('localhost'); // some reasonable default |
|
62 | + if (!$params) |
|
63 | + { |
|
64 | + $params = array('localhost'); |
|
65 | + } |
|
66 | + // some reasonable default |
|
63 | 67 | |
64 | 68 | $ok = false; |
65 | 69 | foreach($params as $host_port) |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param boolean $verbose =false true: echo failed checks |
29 | 29 | * @return int number of failed checks |
30 | 30 | */ |
31 | - function check($verbose=false) |
|
31 | + function check($verbose = false) |
|
32 | 32 | { |
33 | 33 | // set us up as provider for Api\Cache class |
34 | 34 | $GLOBALS['egw_info']['server']['install_id'] = md5(microtime(true)); |
@@ -37,27 +37,27 @@ discard block |
||
37 | 37 | Api\Cache::$default_provider = get_class($this); |
38 | 38 | |
39 | 39 | $failed = 0; |
40 | - foreach(array( |
|
40 | + foreach (array( |
|
41 | 41 | Api\Cache::TREE => 'tree', |
42 | 42 | Api\Cache::INSTANCE => 'instance', |
43 | 43 | ) as $level => $label) |
44 | 44 | { |
45 | 45 | $locations = array(); |
46 | - foreach(array('string',123,true,false,null,array(),array(1,2,3)) as $data) |
|
46 | + foreach (array('string', 123, true, false, null, array(), array(1, 2, 3)) as $data) |
|
47 | 47 | { |
48 | 48 | $location = md5(microtime(true).$label.serialize($data)); |
49 | - $get_before_set = $this->get(array($level,__CLASS__,$location)); |
|
49 | + $get_before_set = $this->get(array($level, __CLASS__, $location)); |
|
50 | 50 | if (!is_null($get_before_set)) |
51 | 51 | { |
52 | 52 | if ($verbose) echo "$label: get_before_set=".array2string($get_before_set)." != NULL\n"; |
53 | 53 | ++$failed; |
54 | 54 | } |
55 | - if (($set = $this->set(array($level,__CLASS__,$location), $data, 10)) !== true) |
|
55 | + if (($set = $this->set(array($level, __CLASS__, $location), $data, 10)) !== true) |
|
56 | 56 | { |
57 | 57 | if ($verbose) echo "$label: set returned ".array2string($set)." !== TRUE\n"; |
58 | 58 | ++$failed; |
59 | 59 | } |
60 | - $get_after_set = $this->get(array($level,__CLASS__,$location)); |
|
60 | + $get_after_set = $this->get(array($level, __CLASS__, $location)); |
|
61 | 61 | if ($get_after_set !== $data) |
62 | 62 | { |
63 | 63 | if ($verbose) echo "$label: get_after_set=".array2string($get_after_set)." !== ".array2string($data)."\n"; |
@@ -65,25 +65,25 @@ discard block |
||
65 | 65 | } |
66 | 66 | if (is_a($this, 'EGroupware\Api\Cache\ProviderMultiple')) |
67 | 67 | { |
68 | - $mget_after_set = $this->mget(array($level,__CLASS__,array($location))); |
|
68 | + $mget_after_set = $this->mget(array($level, __CLASS__, array($location))); |
|
69 | 69 | if ($mget_after_set[$location] !== $data) |
70 | 70 | { |
71 | 71 | if ($verbose) echo "$label: mget_after_set['$location']=".array2string($mget_after_set[$location])." !== ".array2string($data)."\n"; |
72 | 72 | ++$failed; |
73 | 73 | } |
74 | 74 | } |
75 | - $add_after_set = $this->add(array($level,__CLASS__,$location), 'other-data'); |
|
75 | + $add_after_set = $this->add(array($level, __CLASS__, $location), 'other-data'); |
|
76 | 76 | if ($add_after_set !== false) |
77 | 77 | { |
78 | 78 | if ($verbose) echo "$label: add_after_set=".array2string($add_after_set)."\n"; |
79 | 79 | ++$failed; |
80 | 80 | } |
81 | - if (($delete = $this->delete(array($level,__CLASS__,$location))) !== true) |
|
81 | + if (($delete = $this->delete(array($level, __CLASS__, $location))) !== true) |
|
82 | 82 | { |
83 | 83 | if ($verbose) echo "$label: delete returned ".array2string($delete)." !== TRUE\n"; |
84 | 84 | ++$failed; |
85 | 85 | } |
86 | - $get_after_delete = $this->get(array($level,__CLASS__,$location)); |
|
86 | + $get_after_delete = $this->get(array($level, __CLASS__, $location)); |
|
87 | 87 | if (!is_null($get_after_delete)) |
88 | 88 | { |
89 | 89 | if ($verbose) echo "$label: get_after_delete=".array2string($get_after_delete)." != NULL\n"; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | if (is_a($this, 'EGroupware\Api\Cache\ProviderMultiple')) |
94 | 94 | { |
95 | 95 | $locations[$location] = $data; |
96 | - $mget_after_delete = $this->mget(array($level,__CLASS__,array($location))); |
|
96 | + $mget_after_delete = $this->mget(array($level, __CLASS__, array($location))); |
|
97 | 97 | if (isset($mget_after_delete[$location])) |
98 | 98 | { |
99 | 99 | if ($verbose) echo "$label: mget_after_delete['$location']=".array2string($mget_after_delete[$location])." != NULL\n"; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | { |
105 | 105 | $locations[$location] = $data; |
106 | 106 | } |
107 | - $add_after_delete = $this->add(array($level,__CLASS__,$location), $data, 10); |
|
107 | + $add_after_delete = $this->add(array($level, __CLASS__, $location), $data, 10); |
|
108 | 108 | if ($add_after_delete !== true) |
109 | 109 | { |
110 | 110 | if ($verbose) echo "$label: add_after_delete=".array2string($add_after_delete)."\n"; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | else |
114 | 114 | { |
115 | - $get_after_add = $this->get(array($level,__CLASS__,$location)); |
|
115 | + $get_after_add = $this->get(array($level, __CLASS__, $location)); |
|
116 | 116 | if ($get_after_add !== $data) |
117 | 117 | { |
118 | 118 | if ($verbose) echo "$label: get_after_add=".array2string($get_after_add)." !== ".array2string($data)."\n"; |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | } |
123 | 123 | // get all above in one request |
124 | 124 | $keys = array_keys($locations); |
125 | - $keys_bogus = array_merge(array('not-set'),array_keys($locations),array('not-set-too')); |
|
125 | + $keys_bogus = array_merge(array('not-set'), array_keys($locations), array('not-set-too')); |
|
126 | 126 | if (is_a($this, 'EGroupware\Api\Cache\ProviderMultiple')) |
127 | 127 | { |
128 | - $mget = $this->mget(array($level,__CLASS__,$keys)); |
|
129 | - $mget_bogus = $this->mget(array($level,__CLASS__,$keys_bogus)); |
|
128 | + $mget = $this->mget(array($level, __CLASS__, $keys)); |
|
129 | + $mget_bogus = $this->mget(array($level, __CLASS__, $keys_bogus)); |
|
130 | 130 | /* Api\Cache::getCache() gives a different result, as it does NOT use $level direkt |
131 | 131 | } |
132 | 132 | else |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | function flush(array $keys) |
162 | 162 | { |
163 | - unset($keys); // required by function signature |
|
163 | + unset($keys); // required by function signature |
|
164 | 164 | return false; |
165 | 165 | } |
166 | 166 | } |
@@ -49,18 +49,27 @@ discard block |
||
49 | 49 | $get_before_set = $this->get(array($level,__CLASS__,$location)); |
50 | 50 | if (!is_null($get_before_set)) |
51 | 51 | { |
52 | - if ($verbose) echo "$label: get_before_set=".array2string($get_before_set)." != NULL\n"; |
|
52 | + if ($verbose) |
|
53 | + { |
|
54 | + echo "$label: get_before_set=".array2string($get_before_set)." != NULL\n"; |
|
55 | + } |
|
53 | 56 | ++$failed; |
54 | 57 | } |
55 | 58 | if (($set = $this->set(array($level,__CLASS__,$location), $data, 10)) !== true) |
56 | 59 | { |
57 | - if ($verbose) echo "$label: set returned ".array2string($set)." !== TRUE\n"; |
|
60 | + if ($verbose) |
|
61 | + { |
|
62 | + echo "$label: set returned ".array2string($set)." !== TRUE\n"; |
|
63 | + } |
|
58 | 64 | ++$failed; |
59 | 65 | } |
60 | 66 | $get_after_set = $this->get(array($level,__CLASS__,$location)); |
61 | 67 | if ($get_after_set !== $data) |
62 | 68 | { |
63 | - if ($verbose) echo "$label: get_after_set=".array2string($get_after_set)." !== ".array2string($data)."\n"; |
|
69 | + if ($verbose) |
|
70 | + { |
|
71 | + echo "$label: get_after_set=".array2string($get_after_set)." !== ".array2string($data)."\n"; |
|
72 | + } |
|
64 | 73 | ++$failed; |
65 | 74 | } |
66 | 75 | if (is_a($this, 'EGroupware\Api\Cache\ProviderMultiple')) |
@@ -68,25 +77,37 @@ discard block |
||
68 | 77 | $mget_after_set = $this->mget(array($level,__CLASS__,array($location))); |
69 | 78 | if ($mget_after_set[$location] !== $data) |
70 | 79 | { |
71 | - if ($verbose) echo "$label: mget_after_set['$location']=".array2string($mget_after_set[$location])." !== ".array2string($data)."\n"; |
|
80 | + if ($verbose) |
|
81 | + { |
|
82 | + echo "$label: mget_after_set['$location']=".array2string($mget_after_set[$location])." !== ".array2string($data)."\n"; |
|
83 | + } |
|
72 | 84 | ++$failed; |
73 | 85 | } |
74 | 86 | } |
75 | 87 | $add_after_set = $this->add(array($level,__CLASS__,$location), 'other-data'); |
76 | 88 | if ($add_after_set !== false) |
77 | 89 | { |
78 | - if ($verbose) echo "$label: add_after_set=".array2string($add_after_set)."\n"; |
|
90 | + if ($verbose) |
|
91 | + { |
|
92 | + echo "$label: add_after_set=".array2string($add_after_set)."\n"; |
|
93 | + } |
|
79 | 94 | ++$failed; |
80 | 95 | } |
81 | 96 | if (($delete = $this->delete(array($level,__CLASS__,$location))) !== true) |
82 | 97 | { |
83 | - if ($verbose) echo "$label: delete returned ".array2string($delete)." !== TRUE\n"; |
|
98 | + if ($verbose) |
|
99 | + { |
|
100 | + echo "$label: delete returned ".array2string($delete)." !== TRUE\n"; |
|
101 | + } |
|
84 | 102 | ++$failed; |
85 | 103 | } |
86 | 104 | $get_after_delete = $this->get(array($level,__CLASS__,$location)); |
87 | 105 | if (!is_null($get_after_delete)) |
88 | 106 | { |
89 | - if ($verbose) echo "$label: get_after_delete=".array2string($get_after_delete)." != NULL\n"; |
|
107 | + if ($verbose) |
|
108 | + { |
|
109 | + echo "$label: get_after_delete=".array2string($get_after_delete)." != NULL\n"; |
|
110 | + } |
|
90 | 111 | ++$failed; |
91 | 112 | } |
92 | 113 | // prepare for mget of everything |
@@ -96,18 +117,27 @@ discard block |
||
96 | 117 | $mget_after_delete = $this->mget(array($level,__CLASS__,array($location))); |
97 | 118 | if (isset($mget_after_delete[$location])) |
98 | 119 | { |
99 | - if ($verbose) echo "$label: mget_after_delete['$location']=".array2string($mget_after_delete[$location])." != NULL\n"; |
|
120 | + if ($verbose) |
|
121 | + { |
|
122 | + echo "$label: mget_after_delete['$location']=".array2string($mget_after_delete[$location])." != NULL\n"; |
|
123 | + } |
|
100 | 124 | ++$failed; |
101 | 125 | } |
102 | 126 | } |
103 | - elseif (!is_null($data)) // emulation can NOT distinquish between null and not set |
|
127 | + elseif (!is_null($data)) |
|
128 | + { |
|
129 | + // emulation can NOT distinquish between null and not set |
|
104 | 130 | { |
105 | 131 | $locations[$location] = $data; |
106 | 132 | } |
133 | + } |
|
107 | 134 | $add_after_delete = $this->add(array($level,__CLASS__,$location), $data, 10); |
108 | 135 | if ($add_after_delete !== true) |
109 | 136 | { |
110 | - if ($verbose) echo "$label: add_after_delete=".array2string($add_after_delete)."\n"; |
|
137 | + if ($verbose) |
|
138 | + { |
|
139 | + echo "$label: add_after_delete=".array2string($add_after_delete)."\n"; |
|
140 | + } |
|
111 | 141 | ++$failed; |
112 | 142 | } |
113 | 143 | else |
@@ -115,7 +145,10 @@ discard block |
||
115 | 145 | $get_after_add = $this->get(array($level,__CLASS__,$location)); |
116 | 146 | if ($get_after_add !== $data) |
117 | 147 | { |
118 | - if ($verbose) echo "$label: get_after_add=".array2string($get_after_add)." !== ".array2string($data)."\n"; |
|
148 | + if ($verbose) |
|
149 | + { |
|
150 | + echo "$label: get_after_add=".array2string($get_after_add)." !== ".array2string($data)."\n"; |
|
151 | + } |
|
119 | 152 | ++$failed; |
120 | 153 | } |
121 | 154 | } |
@@ -136,12 +169,18 @@ discard block |
||
136 | 169 | }*/ |
137 | 170 | if ($mget !== $locations) |
138 | 171 | { |
139 | - if ($verbose) echo "$label: mget=\n".array2string($mget)." !==\n".array2string($locations)."\n"; |
|
172 | + if ($verbose) |
|
173 | + { |
|
174 | + echo "$label: mget=\n".array2string($mget)." !==\n".array2string($locations)."\n"; |
|
175 | + } |
|
140 | 176 | ++$failed; |
141 | 177 | } |
142 | 178 | if ($mget_bogus !== $locations) |
143 | 179 | { |
144 | - if ($verbose) echo "$label: mget(".array2string($keys_bogus).")=\n".array2string($mget_bogus)." !==\n".array2string($locations)."\n"; |
|
180 | + if ($verbose) |
|
181 | + { |
|
182 | + echo "$label: mget(".array2string($keys_bogus).")=\n".array2string($mget_bogus)." !==\n".array2string($locations)."\n"; |
|
183 | + } |
|
145 | 184 | ++$failed; |
146 | 185 | } |
147 | 186 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param int $expiration =0 |
39 | 39 | * @return boolean true on success, false on error, incl. key already exists in cache |
40 | 40 | */ |
41 | - function add(array $keys,$data,$expiration=0); |
|
41 | + function add(array $keys, $data, $expiration = 0); |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Stores some data in the cache |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param int $expiration =0 |
49 | 49 | * @return boolean true on success, false on error |
50 | 50 | */ |
51 | - function set(array $keys,$data,$expiration=0); |
|
51 | + function set(array $keys, $data, $expiration = 0); |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Get some data from the cache |
@@ -22,7 +22,7 @@ |
||
22 | 22 | /** |
23 | 23 | * Constructor |
24 | 24 | */ |
25 | - function __construct($primary='mail', $fallback='sql') |
|
25 | + function __construct($primary = 'mail', $fallback = 'sql') |
|
26 | 26 | { |
27 | 27 | parent::__construct($primary, $fallback); |
28 | 28 | } |
@@ -26,22 +26,22 @@ discard block |
||
26 | 26 | * @param string $passwd_type ='text' 'text' for cleartext passwords (default) |
27 | 27 | * @return boolean true if successful authenticated, false otherwise |
28 | 28 | */ |
29 | - function authenticate($username, $passwd, $passwd_type='text') |
|
29 | + function authenticate($username, $passwd, $passwd_type = 'text') |
|
30 | 30 | { |
31 | - unset($passwd_type); // not used but required by interface |
|
31 | + unset($passwd_type); // not used but required by interface |
|
32 | 32 | |
33 | 33 | $domain = yp_get_default_domain(); |
34 | - if(!empty($GLOBALS['egw_info']['server']['nis_domain'])) |
|
34 | + if (!empty($GLOBALS['egw_info']['server']['nis_domain'])) |
|
35 | 35 | { |
36 | 36 | $domain = $GLOBALS['egw_info']['server']['nis_domain']; |
37 | 37 | } |
38 | 38 | |
39 | 39 | $map = "passwd.byname"; |
40 | - if(!empty($GLOBALS['egw_info']['server']['nis_map'])) |
|
40 | + if (!empty($GLOBALS['egw_info']['server']['nis_map'])) |
|
41 | 41 | { |
42 | 42 | $map = $GLOBALS['egw_info']['server']['nis_map']; |
43 | 43 | } |
44 | - $entry = yp_match( $domain, $map, $username ); |
|
44 | + $entry = yp_match($domain, $map, $username); |
|
45 | 45 | |
46 | 46 | /* |
47 | 47 | * we assume that the map is structured in the usual |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | * @param int $account_id =0 account id of user whose passwd should be changed |
64 | 64 | * @return boolean true if password successful changed, false otherwise |
65 | 65 | */ |
66 | - function change_password($old_passwd, $new_passwd, $account_id=0) |
|
66 | + function change_password($old_passwd, $new_passwd, $account_id = 0) |
|
67 | 67 | { |
68 | - unset($old_passwd, $new_passwd, $account_id); // not used but required by interface |
|
68 | + unset($old_passwd, $new_passwd, $account_id); // not used but required by interface |
|
69 | 69 | |
70 | 70 | // can't change passwords unless server runs as root (bad idea) |
71 | - return( False ); |
|
71 | + return(False); |
|
72 | 72 | } |
73 | 73 | } |
@@ -29,21 +29,21 @@ discard block |
||
29 | 29 | * @param string $passwd_type ='text' 'text' for cleartext passwords (default) |
30 | 30 | * @return boolean true if successful authenticated, false otherwise |
31 | 31 | */ |
32 | - function authenticate($username, $passwd, $passwd_type='text') |
|
32 | + function authenticate($username, $passwd, $passwd_type = 'text') |
|
33 | 33 | { |
34 | - unset($passwd_type); // not used but required by interface |
|
34 | + unset($passwd_type); // not used but required by interface |
|
35 | 35 | |
36 | 36 | $local_debug = False; |
37 | 37 | |
38 | - if($local_debug) |
|
38 | + if ($local_debug) |
|
39 | 39 | { |
40 | 40 | echo "<b>Debug SQL: uid - $username passwd - $passwd</b>"; |
41 | 41 | } |
42 | - if (!($row = $this->db->select($this->table,'account_lid,account_pwd',array( |
|
42 | + if (!($row = $this->db->select($this->table, 'account_lid,account_pwd', array( |
|
43 | 43 | 'account_lid' => $username, |
44 | 44 | 'account_status' => 'A', |
45 | 45 | 'account_type' => 'u', |
46 | - ),__LINE__,__FILE__)->fetch()) || $GLOBALS['egw_info']['server']['case_sensitive_username'] && $row['account_lid'] != $username) |
|
46 | + ), __LINE__, __FILE__)->fetch()) || $GLOBALS['egw_info']['server']['case_sensitive_username'] && $row['account_lid'] != $username) |
|
47 | 47 | { |
48 | 48 | return false; |
49 | 49 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | # Apache + mod_ssl provide the data in the environment |
52 | 52 | # Certificate (chain) verification occurs inside mod_ssl |
53 | 53 | # see http://www.modssl.org/docs/2.8/ssl_howto.html#ToC6 |
54 | - if(!isset($_SERVER['SSL_CLIENT_S_DN'])) |
|
54 | + if (!isset($_SERVER['SSL_CLIENT_S_DN'])) |
|
55 | 55 | { |
56 | 56 | # if we're not doing SSL authentication, behave like auth_sql |
57 | 57 | return Api\Auth::compare_password($passwd, $row['account_pwd'], 'md5', strtolower($username)); |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | * @param int $account_id =0 account id of user whose passwd should be changed |
68 | 68 | * @return boolean true if password successful changed, false otherwise |
69 | 69 | */ |
70 | - function change_password($old_passwd, $new_passwd, $account_id=0) |
|
70 | + function change_password($old_passwd, $new_passwd, $account_id = 0) |
|
71 | 71 | { |
72 | - unset($old_passwd, $new_passwd, $account_id); // not used but required by interface |
|
72 | + unset($old_passwd, $new_passwd, $account_id); // not used but required by interface |
|
73 | 73 | |
74 | 74 | // deny password changes. |
75 | 75 | return False; |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | * @param string $passwd_type ='text' 'text' for cleartext passwords (default) |
31 | 31 | * @return boolean true if successful authenticated, false otherwise |
32 | 32 | */ |
33 | - function authenticate($username, $passwd, $passwd_type='text') |
|
33 | + function authenticate($username, $passwd, $passwd_type = 'text') |
|
34 | 34 | { |
35 | - unset($passwd_type); // not used but required by interface |
|
35 | + unset($passwd_type); // not used but required by interface |
|
36 | 36 | |
37 | 37 | if (pam_auth($username, get_magic_quotes_gpc() ? stripslashes($passwd) : $passwd)) |
38 | 38 | { |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | if (!$GLOBALS['egw']->accounts->name2id($username) && |
41 | 41 | function_exists('posix_getpwnam') && ($data = posix_getpwnam($username))) |
42 | 42 | { |
43 | - list($fullname) = explode(',',$data['gecos']); |
|
44 | - $parts = explode(' ',$fullname); |
|
43 | + list($fullname) = explode(',', $data['gecos']); |
|
44 | + $parts = explode(' ', $fullname); |
|
45 | 45 | if (count($parts) > 1) |
46 | 46 | { |
47 | 47 | $lastname = array_pop($parts); |
48 | - $firstname = implode(' ',$parts); |
|
48 | + $firstname = implode(' ', $parts); |
|
49 | 49 | $email = Api\Accounts::email($firstname, $lastname, $username); |
50 | 50 | |
51 | 51 | $GLOBALS['auto_create_acct'] = array( |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * @param int $account_id =0 account id of user whose passwd should be changed |
70 | 70 | * @return boolean true if password successful changed, false otherwise |
71 | 71 | */ |
72 | - function change_password($old_passwd, $new_passwd, $account_id=0) |
|
72 | + function change_password($old_passwd, $new_passwd, $account_id = 0) |
|
73 | 73 | { |
74 | - unset($old_passwd, $new_passwd, $account_id); // not used but required by interface |
|
74 | + unset($old_passwd, $new_passwd, $account_id); // not used but required by interface |
|
75 | 75 | |
76 | 76 | // deny password changes. |
77 | 77 | return False; |