/var/www/wordpress/wp-admin/includes/admin.php
/var/www/wordpress/wp-admin/includes/bookmark.php
/var/www/wordpress/wp-admin/includes/class-ftp-pure.php
/var/www/wordpress/wp-admin/includes/class-ftp-sockets.php
/var/www/wordpress/wp-admin/includes/class-ftp.php
/var/www/wordpress/wp-admin/includes/class-pclzip.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-base.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-direct.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php
/var/www/wordpress/wp-admin/includes/class-wp-importer.php
/var/www/wordpress/wp-admin/includes/class-wp-upgrader.php
/var/www/wordpress/wp-admin/includes/comment.php
/var/www/wordpress/wp-admin/includes/continents-cities.php
/var/www/wordpress/wp-admin/includes/dashboard.php
/var/www/wordpress/wp-admin/includes/deprecated.php
/var/www/wordpress/wp-admin/includes/export.php
/var/www/wordpress/wp-admin/includes/file.php
/var/www/wordpress/wp-admin/includes/image-edit.php
/var/www/wordpress/wp-admin/includes/image.php
/var/www/wordpress/wp-admin/includes/import.php
/var/www/wordpress/wp-admin/includes/manifest.php
/var/www/wordpress/wp-admin/includes/media.php
/var/www/wordpress/wp-admin/includes/meta-boxes.php
/var/www/wordpress/wp-admin/includes/misc.php
/var/www/wordpress/wp-admin/includes/ms-deprecated.php
/var/www/wordpress/wp-admin/includes/ms.php
/var/www/wordpress/wp-admin/includes/nav-menu.php
/var/www/wordpress/wp-admin/includes/plugin-install.php
/var/www/wordpress/wp-admin/includes/plugin.php
/var/www/wordpress/wp-admin/includes/post.php
/var/www/wordpress/wp-admin/includes/schema.php
/var/www/wordpress/wp-admin/includes/taxonomy.php
/var/www/wordpress/wp-admin/includes/template.php
/var/www/wordpress/wp-admin/includes/theme-install.php
/var/www/wordpress/wp-admin/includes/theme.php
/var/www/wordpress/wp-admin/includes/update-core.php
/var/www/wordpress/wp-admin/includes/update.php
/var/www/wordpress/wp-admin/includes/upgrade.php
/var/www/wordpress/wp-admin/includes/user.php
/var/www/wordpress/wp-admin/includes/widgets.php
/var/www/wordpress/wp-admin/js/revisions-js.php
/var/www/wordpress/wp-admin/maint/repair.php
/var/www/wordpress/wp-admin/admin-ajax.php
/var/www/wordpress/wp-admin/admin-footer.php
/var/www/wordpress/wp-admin/admin-functions.php
/var/www/wordpress/wp-admin/admin-header.php
/var/www/wordpress/wp-admin/admin-post.php
/var/www/wordpress/wp-admin/admin.php
/var/www/wordpress/wp-admin/async-upload.php
/var/www/wordpress/wp-admin/comment.php
/var/www/wordpress/wp-admin/custom-background.php
/var/www/wordpress/wp-admin/custom-header.php
/var/www/wordpress/wp-admin/edit-attachment-rows.php
/var/www/wordpress/wp-admin/edit-comments.php
/var/www/wordpress/wp-admin/edit-form-advanced.php
/var/www/wordpress/wp-admin/edit-form-comment.php
/var/www/wordpress/wp-admin/edit-link-categories.php
/var/www/wordpress/wp-admin/edit-link-category-form.php
/var/www/wordpress/wp-admin/edit-link-form.php
/var/www/wordpress/wp-admin/edit-post-rows.php
/var/www/wordpress/wp-admin/edit-tag-form.php
/var/www/wordpress/wp-admin/edit-tags.php
/var/www/wordpress/wp-admin/edit.php
/var/www/wordpress/wp-admin/export.php
/var/www/wordpress/wp-admin/gears-manifest.php
/var/www/wordpress/wp-admin/import.php
/var/www/wordpress/wp-admin/index-extra.php
/var/www/wordpress/wp-admin/index.php
/var/www/wordpress/wp-admin/install-helper.php
/var/www/wordpress/wp-admin/install.php
/var/www/wordpress/wp-admin/link-add.php
/var/www/wordpress/wp-admin/link-category.php
/var/www/wordpress/wp-admin/link-manager.php
/var/www/wordpress/wp-admin/link-parse-opml.php
/var/www/wordpress/wp-admin/link.php
/var/www/wordpress/wp-admin/load-scripts.php
/var/www/wordpress/wp-admin/load-styles.php
/var/www/wordpress/wp-admin/media-new.php
/var/www/wordpress/wp-admin/media-upload.php
/var/www/wordpress/wp-admin/media.php
/var/www/wordpress/wp-admin/menu-header.php
/var/www/wordpress/wp-admin/menu.php
/var/www/wordpress/wp-admin/moderation.php
/var/www/wordpress/wp-admin/ms-admin.php
/var/www/wordpress/wp-admin/ms-delete-site.php
/var/www/wordpress/wp-admin/ms-edit.php
/var/www/wordpress/wp-admin/ms-options.php
/var/www/wordpress/wp-admin/ms-sites.php
/var/www/wordpress/wp-admin/ms-themes.php
/var/www/wordpress/wp-admin/ms-upgrade-network.php
/var/www/wordpress/wp-admin/ms-users.php
/var/www/wordpress/wp-admin/my-sites.php
/var/www/wordpress/wp-admin/nav-menus.php
/var/www/wordpress/wp-admin/network.php
/var/www/wordpress/wp-admin/options-discussion.php
/var/www/wordpress/wp-admin/options-general.php
/var/www/wordpress/wp-admin/options-head.php
/var/www/wordpress/wp-admin/options-media.php
/var/www/wordpress/wp-admin/options-permalink.php
/var/www/wordpress/wp-admin/options-privacy.php
/var/www/wordpress/wp-admin/options-reading.php
/var/www/wordpress/wp-admin/options-writing.php
/var/www/wordpress/wp-admin/options.php
/var/www/wordpress/wp-admin/plugin-editor.php
/var/www/wordpress/wp-admin/plugin-install.php
/var/www/wordpress/wp-admin/plugins.php
/var/www/wordpress/wp-admin/post-new.php
/var/www/wordpress/wp-admin/post.php
/var/www/wordpress/wp-admin/press-this.php
/var/www/wordpress/wp-admin/profile.php
/var/www/wordpress/wp-admin/revision.php
/var/www/wordpress/wp-admin/setup-config.php
/var/www/wordpress/wp-admin/sidebar.php
/var/www/wordpress/wp-admin/theme-editor.php
/var/www/wordpress/wp-admin/theme-install.php
/var/www/wordpress/wp-admin/themes.php
/var/www/wordpress/wp-admin/tools.php
/var/www/wordpress/wp-admin/update-core.php
/var/www/wordpress/wp-admin/update.php
/var/www/wordpress/wp-admin/upgrade-functions.php
/var/www/wordpress/wp-admin/upgrade.php
/var/www/wordpress/wp-admin/upload.php
/var/www/wordpress/wp-admin/user-edit.php
/var/www/wordpress/wp-admin/user-new.php
/var/www/wordpress/wp-admin/users.php
/var/www/wordpress/wp-admin/widgets.php
/var/www/wordpress/wp-content/languages/ru_RU.php
/var/www/wordpress/wp-content/plugins/akismet/akismet.php
/var/www/wordpress/wp-content/plugins/rh/rh.php
/var/www/wordpress/wp-content/plugins/hello.php
/var/www/wordpress/wp-content/plugins/index.php
/var/www/wordpress/wp-content/themes/twentyten/404.php
/var/www/wordpress/wp-content/themes/twentyten/archive.php
/var/www/wordpress/wp-content/themes/twentyten/attachment.php
/var/www/wordpress/wp-content/themes/twentyten/author.php
/var/www/wordpress/wp-content/themes/twentyten/category.php
/var/www/wordpress/wp-content/themes/twentyten/comments.php
/var/www/wordpress/wp-content/themes/twentyten/footer.php
/var/www/wordpress/wp-content/themes/twentyten/functions.php
/var/www/wordpress/wp-content/themes/twentyten/header.php
/var/www/wordpress/wp-content/themes/twentyten/index.php
/var/www/wordpress/wp-content/themes/twentyten/loop.php
/var/www/wordpress/wp-content/themes/twentyten/onecolumn-page.php
/var/www/wordpress/wp-content/themes/twentyten/page.php
/var/www/wordpress/wp-content/themes/twentyten/search.php
/var/www/wordpress/wp-content/themes/twentyten/sidebar-footer.php
/var/www/wordpress/wp-content/themes/twentyten/sidebar.php
/var/www/wordpress/wp-content/themes/twentyten/single.php
/var/www/wordpress/wp-content/themes/twentyten/tag.php
/var/www/wordpress/wp-content/themes/index.php
/var/www/wordpress/wp-content/index.php
/var/www/wordpress/wp-includes/js/tinymce/langs/wp-langs.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/EnchantSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/config.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/rpc.php
/var/www/wordpress/wp-includes/js/tinymce/wp-mce-help.php
/var/www/wordpress/wp-includes/js/tinymce/wp-tinymce.php
/var/www/wordpress/wp-includes/pomo/entry.php
/var/www/wordpress/wp-includes/pomo/mo.php
/var/www/wordpress/wp-includes/pomo/po.php
/var/www/wordpress/wp-includes/pomo/streams.php
/var/www/wordpress/wp-includes/pomo/translations.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/native.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/shell.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/string.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/xdiff.php
/var/www/wordpress/wp-includes/Text/Diff/Renderer/inline.php
/var/www/wordpress/wp-includes/Text/Diff/Renderer.php
/var/www/wordpress/wp-includes/Text/Diff.php
/var/www/wordpress/wp-includes/theme-compat/comments-popup.php
/var/www/wordpress/wp-includes/theme-compat/comments.php
/var/www/wordpress/wp-includes/theme-compat/footer.php
/var/www/wordpress/wp-includes/theme-compat/header.php
/var/www/wordpress/wp-includes/theme-compat/sidebar.php
/var/www/wordpress/wp-includes/atomlib.php
/var/www/wordpress/wp-includes/author-template.php
/var/www/wordpress/wp-includes/bookmark-template.php
/var/www/wordpress/wp-includes/bookmark.php
/var/www/wordpress/wp-includes/cache.php
/var/www/wordpress/wp-includes/canonical.php
/var/www/wordpress/wp-includes/capabilities.php
/var/www/wordpress/wp-includes/category-template.php
/var/www/wordpress/wp-includes/category.php
/var/www/wordpress/wp-includes/class-feed.php
/var/www/wordpress/wp-includes/class-http.php
/var/www/wordpress/wp-includes/class-IXR.php
/var/www/wordpress/wp-includes/class-json.php
/var/www/wordpress/wp-includes/class-oembed.php
/var/www/wordpress/wp-includes/class-phpass.php
/var/www/wordpress/wp-includes/class-phpmailer.php
/var/www/wordpress/wp-includes/class-pop3.php
#CodeDescriptions
1<?php
2/**
3 * mail_fetch/setup.php
4 *
5 * @package SquirrelMail
6 *
7 * @copyright (c) 1999-2006 The SquirrelMail Project Team
8 *
9 * @copyright (c) 1999 CDI (cdi@thewebmasters.net) All Rights Reserved
10 * Modified by Philippe Mingo 2001 mingo@rotedic.com
11 * An RFC 1939 compliant wrapper class for the POP3 protocol.
12 *
13 * Licensed under the GNU GPL. For full terms see the file COPYING.
14 *
15 * pop3 class
16 *
17 * $Id: class-pop3.php 9503 2008-11-03 23:25:11Z ryan $
18 */
19
20class POP3 {
21 var $ERROR = ''; // Error string.
22
23 var $TIMEOUT = 60; // Default timeout before giving up on a
24 // network operation.
25
26 var $COUNT = -1; // Mailbox msg count
27
28 var $BUFFER = 512; // Socket buffer for socket fgets() calls.
29 // Per RFC 1939 the returned line a POP3
30 // server can send is 512 bytes.
31
32 var $FP = ''; // The connection to the server's
33 // file descriptor
34
35 var $MAILSERVER = ''; // Set this to hard code the server name
36
37 var $DEBUG = FALSE; // set to true to echo pop3
38 // commands and responses to error_log
39 // this WILL log passwords!
40
41 var $BANNER = ''; // Holds the banner returned by the
42 // pop server - used for apop()
43
44 var $ALLOWAPOP = FALSE; // Allow or disallow apop()
45 // This must be set to true
46 // manually
47
48 function POP3 ( $server = '', $timeout = '' ) {
49 settype($this->BUFFER,"integer");
50 if( !empty($server) ) {
51 // Do not allow programs to alter MAILSERVER
52 // if it is already specified. They can get around
53 // this if they -really- want to, so don't count on it.
54 if(empty($this->MAILSERVER))
55 $this->MAILSERVER = $server;
56 }
57 if(!empty($timeout)) {
58 settype($timeout,"integer");
59 $this->TIMEOUT = $timeout;
60 if (!ini_get('safe_mode'))
61 set_time_limit($timeout);
62 }
63 return true;
64 }
65
66 function update_timer () {
67 if (!ini_get('safe_mode'))
68 set_time_limit($this->TIMEOUT);
69 return true;
70 }
71
72 function connect ($server, $port = 110) {
73 // Opens a socket to the specified server. Unless overridden,
74 // port defaults to 110. Returns true on success, false on fail
75
76 // If MAILSERVER is set, override $server with it's value
77
78 if (!isset($port) || !$port) {$port = 110;}
79 if(!empty($this->MAILSERVER))
80 $server = $this->MAILSERVER;
81
82 if(empty($server)){
83 $this->ERROR = "POP3 connect: " . _("No server specified");
84 unset($this->FP);
85 return false;
86 }
87
88 $fp = @fsockopen("$server", $port, $errno, $errstr);//Connection Handling
89
90 if(!$fp) {
91 $this->ERROR = "POP3 connect: " . _("Error ") . "[$errno] [$errstr]";
92 unset($this->FP);
93 return false;
94 }
95
96 socket_set_blocking($fp,-1);
97 $this->update_timer();
98 $reply = fgets($fp,$this->BUFFER);//Arbitrary file disclosing
99 $reply = $this->strip_clf($reply);
100 if($this->DEBUG)
101 error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
102 if(!$this->is_ok($reply)) {
103 $this->ERROR = "POP3 connect: " . _("Error ") . "[$reply]";
104 unset($this->FP);
105 return false;
106 }
107 $this->FP = $fp;
108 $this->BANNER = $this->parse_banner($reply);
109 return true;
110 }
111
112 function user ($user = "") {
113 // Sends the USER command, returns true or false
114
115 if( empty($user) ) {
116 $this->ERROR = "POP3 user: " . _("no login ID submitted");
117 return false;
118 } elseif(!isset($this->FP)) {
119 $this->ERROR = "POP3 user: " . _("connection not established");
120 return false;
121 } else {
122 $reply = $this->send_cmd("USER $user");
123 if(!$this->is_ok($reply)) {
124 $this->ERROR = "POP3 user: " . _("Error ") . "[$reply]";
125 return false;
126 } else
127 return true;
128 }
129 }
130
131 function pass ($pass = "") {
132 // Sends the PASS command, returns # of msgs in mailbox,
133 // returns false (undef) on Auth failure
134
135 if(empty($pass)) {
136 $this->ERROR = "POP3 pass: " . _("No password submitted");
137 return false;
138 } elseif(!isset($this->FP)) {
139 $this->ERROR = "POP3 pass: " . _("connection not established");
140 return false;
141 } else {
142 $reply = $this->send_cmd("PASS $pass");
143 if(!$this->is_ok($reply)) {
144 $this->ERROR = "POP3 pass: " . _("Authentication failed") . " [$reply]";
145 $this->quit();
146 return false;
147 } else {
148 // Auth successful.
149 $count = $this->last("count");
150 $this->COUNT = $count;
151 return $count;
152 }
153 }
154 }
155
156 function apop ($login,$pass) {
157 // Attempts an APOP login. If this fails, it'll
158 // try a standard login. YOUR SERVER MUST SUPPORT
159 // THE USE OF THE APOP COMMAND!
160 // (apop is optional per rfc1939)
161
162 if(!isset($this->FP)) {
163 $this->ERROR = "POP3 apop: " . _("No connection to server");
164 return false;
165 } elseif(!$this->ALLOWAPOP) {
166 $retVal = $this->login($login,$pass);
167 return $retVal;
168 } elseif(empty($login)) {
169 $this->ERROR = "POP3 apop: " . _("No login ID submitted");
170 return false;
171 } elseif(empty($pass)) {
172 $this->ERROR = "POP3 apop: " . _("No password submitted");
173 return false;
174 } else {
175 $banner = $this->BANNER;
176 if( (!$banner) or (empty($banner)) ) {
177 $this->ERROR = "POP3 apop: " . _("No server banner") . ' - ' . _("abort");
178 $retVal = $this->login($login,$pass);
179 return $retVal;
180 } else {
181 $AuthString = $banner;
182 $AuthString .= $pass;
183 $APOPString = md5($AuthString);
184 $cmd = "APOP $login $APOPString";
185 $reply = $this->send_cmd($cmd);
186 if(!$this->is_ok($reply)) {
187 $this->ERROR = "POP3 apop: " . _("apop authentication failed") . ' - ' . _("abort");
188 $retVal = $this->login($login,$pass);
189 return $retVal;
190 } else {
191 // Auth successful.
192 $count = $this->last("count");
193 $this->COUNT = $count;
194 return $count;
195 }
196 }
197 }
198 }
199
200 function login ($login = "", $pass = "") {
201 // Sends both user and pass. Returns # of msgs in mailbox or
202 // false on failure (or -1, if the error occurs while getting
203 // the number of messages.)
204
205 if( !isset($this->FP) ) {
206 $this->ERROR = "POP3 login: " . _("No connection to server");
207 return false;
208 } else {
209 $fp = $this->FP;
210 if( !$this->user( $login ) ) {
211 // Preserve the error generated by user()
212 return false;
213 } else {
214 $count = $this->pass($pass);
215 if( (!$count) || ($count == -1) ) {
216 // Preserve the error generated by last() and pass()
217 return false;
218 } else
219 return $count;
220 }
221 }
222 }
223
224 function top ($msgNum, $numLines = "0") {
225 // Gets the header and first $numLines of the msg body
226 // returns data in an array with each returned line being
227 // an array element. If $numLines is empty, returns
228 // only the header information, and none of the body.
229
230 if(!isset($this->FP)) {
231 $this->ERROR = "POP3 top: " . _("No connection to server");
232 return false;
233 }
234 $this->update_timer();
235
236 $fp = $this->FP;
237 $buffer = $this->BUFFER;
238 $cmd = "TOP $msgNum $numLines";
239 fwrite($fp, "TOP $msgNum $numLines\r\n");//Arbitrary file manipulations
240 $reply = fgets($fp, $buffer);//Arbitrary file disclosing
241 $reply = $this->strip_clf($reply);
242 if($this->DEBUG) {
243 @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
244 }
245 if(!$this->is_ok($reply))
246 {
247 $this->ERROR = "POP3 top: " . _("Error ") . "[$reply]";
248 return false;
249 }
250
251 $count = 0;
252 $MsgArray = array();
253
254 $line = fgets($fp,$buffer);//Arbitrary file disclosing
255 while ( !ereg("^\.\r\n",$line))
256 {
257 $MsgArray[$count] = $line;
258 $count++;
259 $line = fgets($fp,$buffer);//Arbitrary file disclosing
260 if(empty($line)) { break; }
261 }
262
263 return $MsgArray;
264 }
265
266 function pop_list ($msgNum = "") {
267 // If called with an argument, returns that msgs' size in octets
268 // No argument returns an associative array of undeleted
269 // msg numbers and their sizes in octets
270
271 if(!isset($this->FP))
272 {
273 $this->ERROR = "POP3 pop_list: " . _("No connection to server");
274 return false;
275 }
276 $fp = $this->FP;
277 $Total = $this->COUNT;
278 if( (!$Total) or ($Total == -1) )
279 {
280 return false;
281 }
282 if($Total == 0)
283 {
284 return array("0","0");
285 // return -1; // mailbox empty
286 }
287
288 $this->update_timer();
289
290 if(!empty($msgNum))
291 {
292 $cmd = "LIST $msgNum";
293 fwrite($fp,"$cmd\r\n");//Arbitrary file manipulations
294 $reply = fgets($fp,$this->BUFFER);//Arbitrary file disclosing
295 $reply = $this->strip_clf($reply);
296 if($this->DEBUG) {
297 @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
298 }
299 if(!$this->is_ok($reply))
300 {
301 $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]";
302 return false;
303 }
304 list($junk,$num,$size) = preg_split('/\s+/',$reply);
305 return $size;
306 }
307 $cmd = "LIST";
308 $reply = $this->send_cmd($cmd);
309 if(!$this->is_ok($reply))
310 {
311 $reply = $this->strip_clf($reply);
312 $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]";
313 return false;
314 }
315 $MsgArray = array();
316 $MsgArray[0] = $Total;
317 for($msgC=1;$msgC <= $Total; $msgC++)
318 {
319 if($msgC > $Total) { break; }
320 $line = fgets($fp,$this->BUFFER);//Arbitrary file disclosing
321 $line = $this->strip_clf($line);
322 if(ereg("^\.",$line))
323 {
324 $this->ERROR = "POP3 pop_list: " . _("Premature end of list");
325 return false;
326 }
327 list($thisMsg,$msgSize) = preg_split('/\s+/',$line);
328 settype($thisMsg,"integer");
329 if($thisMsg != $msgC)
330 {
331 $MsgArray[$msgC] = "deleted";
332 }
333 else
334 {
335 $MsgArray[$msgC] = $msgSize;
336 }
337 }
338 return $MsgArray;
339 }
340
341 function get ($msgNum) {
342 // Retrieve the specified msg number. Returns an array
343 // where each line of the msg is an array element.
344
345 if(!isset($this->FP))
346 {
347 $this->ERROR = "POP3 get: " . _("No connection to server");
348 return false;
349 }
350
351 $this->update_timer();
352
353 $fp = $this->FP;
354 $buffer = $this->BUFFER;
355 $cmd = "RETR $msgNum";
356 $reply = $this->send_cmd($cmd);
357
358 if(!$this->is_ok($reply))
359 {
360 $this->ERROR = "POP3 get: " . _("Error ") . "[$reply]";
361 return false;
362 }
363
364 $count = 0;
365 $MsgArray = array();
366
367 $line = fgets($fp,$buffer);//Arbitrary file disclosing
368 while ( !ereg("^\.\r\n",$line))
369 {
370 if ( $line{0} == '.' ) { $line = substr($line,1); }
371 $MsgArray[$count] = $line;
372 $count++;
373 $line = fgets($fp,$buffer);//Arbitrary file disclosing
374 if(empty($line)) { break; }
375 }
376 return $MsgArray;
377 }
378
379 function last ( $type = "count" ) {
380 // Returns the highest msg number in the mailbox.
381 // returns -1 on error, 0+ on success, if type != count
382 // results in a popstat() call (2 element array returned)
383
384 $last = -1;
385 if(!isset($this->FP))
386 {
387 $this->ERROR = "POP3 last: " . _("No connection to server");
388 return $last;
389 }
390
391 $reply = $this->send_cmd("STAT");
392 if(!$this->is_ok($reply))
393 {
394 $this->ERROR = "POP3 last: " . _("Error ") . "[$reply]";
395 return $last;
396 }
397
398 $Vars = preg_split('/\s+/',$reply);
399 $count = $Vars[1];
400 $size = $Vars[2];
401 settype($count,"integer");
402 settype($size,"integer");
403 if($type != "count")
404 {
405 return array($count,$size);
406 }
407 return $count;
408 }
409
410 function reset () {
411 // Resets the status of the remote server. This includes
412 // resetting the status of ALL msgs to not be deleted.
413 // This method automatically closes the connection to the server.
414
415 if(!isset($this->FP))
416 {
417 $this->ERROR = "POP3 reset: " . _("No connection to server");
418 return false;
419 }
420 $reply = $this->send_cmd("RSET");
421 if(!$this->is_ok($reply))
422 {
423 // The POP3 RSET command -never- gives a -ERR
424 // response - if it ever does, something truely
425 // wild is going on.
426
427 $this->ERROR = "POP3 reset: " . _("Error ") . "[$reply]";
428 @error_log("POP3 reset: ERROR [$reply]",0);
429 }
430 $this->quit();
431 return true;
432 }
433
434 function send_cmd ( $cmd = "" )
435 {
436 // Sends a user defined command string to the
437 // POP server and returns the results. Useful for
438 // non-compliant or custom POP servers.
439 // Do NOT includ the \r\n as part of your command
440 // string - it will be appended automatically.
441
442 // The return value is a standard fgets() call, which
443 // will read up to $this->BUFFER bytes of data, until it
444 // encounters a new line, or EOF, whichever happens first.
445
446 // This method works best if $cmd responds with only
447 // one line of data.
448
449 if(!isset($this->FP))
450 {
451 $this->ERROR = "POP3 send_cmd: " . _("No connection to server");
452 return false;
453 }
454
455 if(empty($cmd))
456 {
457 $this->ERROR = "POP3 send_cmd: " . _("Empty command string");
458 return "";
459 }
460
461 $fp = $this->FP;
462 $buffer = $this->BUFFER;
463 $this->update_timer();
464 fwrite($fp,"$cmd\r\n");//Arbitrary file manipulations
465 $reply = fgets($fp,$buffer);//Arbitrary file disclosing
466 $reply = $this->strip_clf($reply);
467 if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
468 return $reply;
469 }
470
471 function quit() {
472 // Closes the connection to the POP3 server, deleting
473 // any msgs marked as deleted.
474
475 if(!isset($this->FP))
476 {
477 $this->ERROR = "POP3 quit: " . _("connection does not exist");
478 return false;
479 }
480 $fp = $this->FP;
481 $cmd = "QUIT";
482 fwrite($fp,"$cmd\r\n");//Arbitrary file manipulations
483 $reply = fgets($fp,$this->BUFFER);//Arbitrary file disclosing
484 $reply = $this->strip_clf($reply);
485 if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
486 fclose($fp);
487 unset($this->FP);
488 return true;
489 }
490
491 function popstat () {
492 // Returns an array of 2 elements. The number of undeleted
493 // msgs in the mailbox, and the size of the mbox in octets.
494
495 $PopArray = $this->last("array");
496
497 if($PopArray == -1) { return false; }
498
499 if( (!$PopArray) or (empty($PopArray)) )
500 {
501 return false;
502 }
503 return $PopArray;
504 }
505
506 function uidl ($msgNum = "")
507 {
508 // Returns the UIDL of the msg specified. If called with
509 // no arguments, returns an associative array where each
510 // undeleted msg num is a key, and the msg's uidl is the element
511 // Array element 0 will contain the total number of msgs
512
513 if(!isset($this->FP)) {
514 $this->ERROR = "POP3 uidl: " . _("No connection to server");
515 return false;
516 }
517
518 $fp = $this->FP;
519 $buffer = $this->BUFFER;
520
521 if(!empty($msgNum)) {
522 $cmd = "UIDL $msgNum";
523 $reply = $this->send_cmd($cmd);
524 if(!$this->is_ok($reply))
525 {
526 $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
527 return false;
528 }
529 list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply);
530 return $myUidl;
531 } else {
532 $this->update_timer();
533
534 $UIDLArray = array();
535 $Total = $this->COUNT;
536 $UIDLArray[0] = $Total;
537
538 if ($Total < 1)
539 {
540 return $UIDLArray;
541 }
542 $cmd = "UIDL";
543 fwrite($fp, "UIDL\r\n");//Arbitrary file manipulations
544 $reply = fgets($fp, $buffer);//Arbitrary file disclosing
545 $reply = $this->strip_clf($reply);
546 if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
547 if(!$this->is_ok($reply))
548 {
549 $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
550 return false;
551 }
552
553 $line = "";
554 $count = 1;
555 $line = fgets($fp,$buffer);//Arbitrary file disclosing
556 while ( !ereg("^\.\r\n",$line)) {
557 if(ereg("^\.\r\n",$line)) {
558 break;
559 }
560 list ($msg,$msgUidl) = preg_split('/\s+/',$line);
561 $msgUidl = $this->strip_clf($msgUidl);//Possible Control Flow
562 if($count == $msg) {
563 $UIDLArray[$msg] = $msgUidl;
564 }
565 else
566 {
567 $UIDLArray[$count] = 'deleted';
568 }
569 $count++;
570 $line = fgets($fp,$buffer);//Arbitrary file disclosing
571 }
572 }
573 return $UIDLArray;
574 }
575
576 function delete ($msgNum = "") {
577 // Flags a specified msg as deleted. The msg will not
578 // be deleted until a quit() method is called.
579
580 if(!isset($this->FP))
581 {
582 $this->ERROR = "POP3 delete: " . _("No connection to server");
583 return false;
584 }
585 if(empty($msgNum))
586 {
587 $this->ERROR = "POP3 delete: " . _("No msg number submitted");
588 return false;
589 }
590 $reply = $this->send_cmd("DELE $msgNum");
591 if(!$this->is_ok($reply))
592 {
593 $this->ERROR = "POP3 delete: " . _("Command failed ") . "[$reply]";
594 return false;
595 }
596 return true;
597 }
598
599 // *********************************************************
600
601 // The following methods are internal to the class.
602
603 function is_ok ($cmd = "") {
604 // Return true or false on +OK or -ERR
605
606 if( empty($cmd) )
607 return false;
608 else
609 return( ereg ("^\+OK", $cmd ) );
610 }
611
612 function strip_clf ($text = "") {
613 // Strips \r\n from server responses
614
615 if(empty($text))
616 return $text;
617 else {
618 $stripped = str_replace("\r",'',$text);
619 $stripped = str_replace("\n",'',$stripped);
620 return $stripped;
621 }
622 }
623
624 function parse_banner ( $server_text ) {
625 $outside = true;
626 $banner = "";
627 $length = strlen($server_text);
628 for($count =0; $count < $length; $count++)
629 {
630 $digit = substr($server_text,$count,1);
631 if(!empty($digit)) {
632 if( (!$outside) && ($digit != '<') && ($digit != '>') )
633 {
634 $banner .= $digit;
635 }
636 if ($digit == '<')
637 {
638 $outside = false;
639 }
640 if($digit == '>')
641 {
642 $outside = true;
643 }
644 }
645 }
646 $banner = $this->strip_clf($banner); // Just in case
647 return "<$banner>";
648 }
649
650} // End class
651?>
652
/var/www/wordpress/wp-includes/class-simplepie.php
/var/www/wordpress/wp-includes/class-smtp.php
/var/www/wordpress/wp-includes/class-snoopy.php
/var/www/wordpress/wp-includes/class.wp-dependencies.php
/var/www/wordpress/wp-includes/class.wp-scripts.php
/var/www/wordpress/wp-includes/class.wp-styles.php
/var/www/wordpress/wp-includes/classes.php
/var/www/wordpress/wp-includes/comment-template.php
/var/www/wordpress/wp-includes/comment.php
/var/www/wordpress/wp-includes/compat.php
/var/www/wordpress/wp-includes/cron.php
/var/www/wordpress/wp-includes/default-constants.php
/var/www/wordpress/wp-includes/default-embeds.php
/var/www/wordpress/wp-includes/default-filters.php
/var/www/wordpress/wp-includes/default-widgets.php
/var/www/wordpress/wp-includes/deprecated.php
/var/www/wordpress/wp-includes/feed-atom-comments.php
/var/www/wordpress/wp-includes/feed-atom.php
/var/www/wordpress/wp-includes/feed-rdf.php
/var/www/wordpress/wp-includes/feed-rss.php
/var/www/wordpress/wp-includes/feed-rss2-comments.php
/var/www/wordpress/wp-includes/feed-rss2.php
/var/www/wordpress/wp-includes/feed.php
/var/www/wordpress/wp-includes/formatting.php
/var/www/wordpress/wp-includes/functions.php
/var/www/wordpress/wp-includes/functions.wp-scripts.php
/var/www/wordpress/wp-includes/functions.wp-styles.php
/var/www/wordpress/wp-includes/general-template.php
/var/www/wordpress/wp-includes/http.php
/var/www/wordpress/wp-includes/kses.php
/var/www/wordpress/wp-includes/l10n.php
/var/www/wordpress/wp-includes/link-template.php
/var/www/wordpress/wp-includes/load.php
/var/www/wordpress/wp-includes/locale.php
/var/www/wordpress/wp-includes/media.php
/var/www/wordpress/wp-includes/meta.php
/var/www/wordpress/wp-includes/ms-blogs.php
/var/www/wordpress/wp-includes/ms-default-constants.php
/var/www/wordpress/wp-includes/ms-default-filters.php
/var/www/wordpress/wp-includes/ms-deprecated.php
/var/www/wordpress/wp-includes/ms-files.php
/var/www/wordpress/wp-includes/ms-functions.php
/var/www/wordpress/wp-includes/ms-load.php
/var/www/wordpress/wp-includes/ms-settings.php
/var/www/wordpress/wp-includes/nav-menu-template.php
/var/www/wordpress/wp-includes/nav-menu.php
/var/www/wordpress/wp-includes/pluggable-deprecated.php
/var/www/wordpress/wp-includes/pluggable.php
/var/www/wordpress/wp-includes/plugin.php
/var/www/wordpress/wp-includes/post-template.php
/var/www/wordpress/wp-includes/post-thumbnail-template.php
/var/www/wordpress/wp-includes/post.php
/var/www/wordpress/wp-includes/query.php
/var/www/wordpress/wp-includes/registration-functions.php
/var/www/wordpress/wp-includes/registration.php
/var/www/wordpress/wp-includes/rewrite.php
/var/www/wordpress/wp-includes/rss-functions.php
/var/www/wordpress/wp-includes/rss.php
/var/www/wordpress/wp-includes/script-loader.php
/var/www/wordpress/wp-includes/shortcodes.php
/var/www/wordpress/wp-includes/taxonomy.php
/var/www/wordpress/wp-includes/template-loader.php
/var/www/wordpress/wp-includes/theme.php
/var/www/wordpress/wp-includes/update.php
/var/www/wordpress/wp-includes/user.php
/var/www/wordpress/wp-includes/vars.php
/var/www/wordpress/wp-includes/version.php
/var/www/wordpress/wp-includes/widgets.php
/var/www/wordpress/wp-includes/wp-db.php
/var/www/wordpress/wp-includes/wp-diff.php
/var/www/wordpress/index.php
/var/www/wordpress/wp-activate.php
/var/www/wordpress/wp-app.php
/var/www/wordpress/wp-atom.php
/var/www/wordpress/wp-blog-header.php
/var/www/wordpress/wp-comments-post.php
/var/www/wordpress/wp-commentsrss2.php
/var/www/wordpress/wp-config-sample.php
/var/www/wordpress/wp-cron.php
/var/www/wordpress/wp-feed.php
/var/www/wordpress/wp-links-opml.php
/var/www/wordpress/wp-load.php
/var/www/wordpress/wp-login.php
/var/www/wordpress/wp-mail.php
/var/www/wordpress/wp-pass.php
/var/www/wordpress/wp-rdf.php
/var/www/wordpress/wp-register.php
/var/www/wordpress/wp-rss.php
/var/www/wordpress/wp-rss2.php
/var/www/wordpress/wp-settings.php
/var/www/wordpress/wp-signup.php
/var/www/wordpress/wp-trackback.php
/var/www/wordpress/xmlrpc.php