Changeset 226
- Timestamp:
- 04/13/08 03:17:59 (6 months ago)
- Files:
-
- trunk/Phergie/Bot.php (modified) (1 diff)
- trunk/Phergie/Driver/Abstract.php (modified) (1 diff)
- trunk/Phergie/Plugin/Abstract/Base.php (modified) (1 diff)
- trunk/Phergie/Plugin/Quit.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Url.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Bot.php
r223 r226 17 17 */ 18 18 } elseif (version_compare('5.2', PHP_VERSION, '>')) { 19 trigger_error(' Warning:PHP 5.2+ is recommended, current version: ' . PHP_VERSION, E_USER_WARNING);19 trigger_error('PHP 5.2+ is recommended, current version: ' . PHP_VERSION, E_USER_WARNING); 20 20 } 21 21 trunk/Phergie/Driver/Abstract.php
r218 r226 117 117 * 118 118 * @param string $message Debugging message 119 * @return void 120 */ 121 public function debug($message) 119 * @param bool $displayDebug Toggle whether to display the message in the 120 * console or not 121 * @return void 122 */ 123 public function debug($message, $displayDebug = true) 122 124 { 123 125 if ($this->getIni('debug')) { 124 126 $message = '[' . date('H:i:s') . '] ' . $message . PHP_EOL; 125 echo $message; 127 if ($displayDebug) { 128 echo $message; 129 } 126 130 if ($log = $this->getIni('log') and !empty($log)) { 127 131 file_put_contents($log, $message, FILE_APPEND); trunk/Phergie/Plugin/Abstract/Base.php
r223 r226 204 204 * 205 205 * @param string $message Message to log 206 * @return void 207 */ 208 public function debug($message) 209 { 210 $this->client->debug('<' . strtolower($this->name) . '> ' . $message); 206 * @param bool $displayDebug Toggle whether to display the message in the 207 * console or not 208 * @return void 209 */ 210 public function debug($message, $displayDebug = true) 211 { 212 $this->client->debug('<' . strtolower($this->name) . '> ' . $message, $displayDebug); 211 213 } 212 214 trunk/Phergie/Plugin/Quit.php
r223 r226 146 146 $user = $this->event->getNick(); 147 147 if (empty($this->phpPath) or !is_file($this->phpPath)) { 148 trigger_error('Warning: Could not restart Phergie, make sure the setting "quit.php_path" is correct', E_USER_WARNING); 148 trigger_error('Could not restart Phergie, make sure the setting "quit.php_path" is correct', E_USER_WARNING); 149 $this->doNotice($user, 'Error: Couldn\'t restart Phergie.'); 150 return; 151 } 152 153 $exec = shell_exec(PHERGIE_PHP_PATH . ' -l ' . PHERGIE_DIR . 'Bot.php ' . PHERGIE_INI_PATH); 154 if (stripos($exec, 'No syntax errors') === false) { 155 trigger_error('Encountered an error while trying to restart.', E_USER_WARNING); 156 $this->debug('Restart Error: ' . trim($exec)); 149 157 $this->doNotice($user, 'Error: Couldn\'t restart Phergie.'); 150 158 return; … … 165 173 $this->handleQuit($message); 166 174 } else { 167 trigger_error(' Warning:Could not create another instance of Phergie.', E_USER_WARNING);175 trigger_error('Could not create another instance of Phergie.', E_USER_WARNING); 168 176 $this->doNotice($user, 'Error: Couldn\'t restart Phergie.'); 169 177 } trunk/Phergie/Plugin/Url.php
r225 r226 65 65 */ 66 66 protected $errorStatus = false; 67 protected $errorMessage = null; 67 68 68 69 /** … … 188 189 189 190 // Check to see if the URL has a valid TLD 190 if (is_array($this->tldList) && count($this->tldList) > 3 && 191 !in_array(strtolower($parsed['tld']), $this->tldList)) { 191 if (is_array($this->tldList) && !in_array(strtolower($parsed['tld']), $this->tldList)) { 192 192 continue; 193 193 } … … 267 267 if (empty($title)) { 268 268 if ($this->errorStatus) { 269 if (!$this->showErrors ) {269 if (!$this->showErrors || $this->errorStatus == 1) { 270 270 continue; 271 271 } 272 $title = 'Error: ' . $this->errorStatus;272 $title = $this->errorMessage; 273 273 $this->errorStatus = false; 274 $this->errorMessage = null; 274 275 } else { 275 276 $title = 'No Title'; … … 419 420 // Check to see if there was HTTP warning while connecting to the site 420 421 if (preg_match('{HTTP/1\.[01] ([0-9]{3})}i', $errstr, $m)) { 421 $this->errorStatus = (isset($this->httpErrors[$m[1]]) ? $this->httpErrors[$m[1]] : $m[1]); 422 $this->errorStatus = $m[1]; 423 $this->errorMessage = (isset($this->httpErrors[$m[1]]) ? $this->httpErrors[$m[1]] : $m[1]); 424 $this->debug('PHP Warning: ' . $errstr . 'in ' . $errfile . ' on line ' . $errline); 422 425 return true; 423 // Safely ignore these SSL warnings so they don't appear in the log426 // Safely ignore these SSL warnings so they don't appear in the log 424 427 } else if (stripos($errstr, 'SSL: fatal protocol error in') !== false || 425 428 stripos($errstr, 'failed to open stream') !== false || … … 430 433 stripos($errstr, 'SSL operation failed with code') !== false || 431 434 stripos($errstr, 'unable to connect to') !== false) { 435 $this->errorStatus = 1; 436 $this->debug('PHP Warning: ' . $errstr . 'in ' . $errfile . ' on line ' . $errline); 432 437 return true; 433 438 } … … 549 554 { 550 555 $temp = $this->getPluginIni($setting); 551 if (($integer && intval($temp) > 0) || (!$integer && !empty($temp))) {556 if (($integer && intval($temp) > 0) || (!$integer && isset($temp))) { 552 557 $this->{$var} = $temp; 553 558 }