Changeset 228
- Timestamp:
- 04/13/08 21:03:27 (7 months ago)
- Files:
-
- trunk/Phergie/Plugin/Tld.php (modified) (1 diff)
- trunk/Phergie/Plugin/Url.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Plugin/Tld.php
r223 r228 186 186 187 187 $target = $this->event->getNick(); 188 if (preg_match('#^(?:'.preg_quote($this->getIni('nick')).'\s*[:,>]?\s+)?\.([a-z]{2,10})$#i', $this->event->getArgument(1), $m) && 189 $description = self::getTld($m[1])) { 188 $prefix = preg_quote(trim($this->getIni('command_prefix'))); 189 if (preg_match('#^(?:' . preg_quote($this->getIni('nick')) . '\s*[:,>]?\s+)?(?:' . $prefix . 'tld\s+\.?([a-z]{2,10})|\.([a-z]{2,10}))$#i', $this->event->getArgument(1), $m) && 190 $description = self::getTld((!empty($m[1]) ? $m[1] : $m[2]))) { 190 191 $this->doPrivmsg($this->event->getSource(), 191 $target . ': ' . $m[0]. ' -> ' . ($description ? ucfirst($description) : 'Unknown TLD'));192 $target . ': .' . (!empty($m[1]) ? $m[1] : $m[2]) . ' -> ' . ($description ? ucfirst($description) : 'Unknown TLD')); 192 193 } 193 194 } trunk/Phergie/Plugin/Url.php
r227 r228 116 116 * @var array 117 117 */ 118 protected $tldList; 119 120 /** 121 * Initializes settings 122 * 123 * @return void 124 */ 125 public function init() 126 { 127 // Get a list of valid TLDs 128 $this->tldList = array(); 129 if ($this->pluginLoaded('Tld')) { 130 $this->tldList = Phergie_Plugin_Tld::getTlds(); 131 if (is_array($this->tldList)) { 132 $this->tldList = array_keys($this->tldList); 133 } 134 } 135 unset($plugins); 136 if (!is_array($this->tldList) || count($this->tldList) <= 0) { 137 $this->tldList = array('com', 'org', 'net'); 138 } 139 rsort($this->tldList); 140 } 118 protected $tldList = array(); 141 119 142 120 /** … … 164 142 $this->updateSetting('title_length', 'titleLength', true); 165 143 $this->updateSetting('show_errors', 'showErrors'); 144 // Update the valid TLD list 145 $this->updateTldList(); 166 146 167 147 $responses = array(); … … 564 544 } 565 545 546 /** 547 * Updates the list of TLDs from the TLD plugin 548 * 549 * @return void 550 */ 551 protected function updateTldList() 552 { 553 // Get a list of valid TLDs 554 if (!is_array($this->tldList) || count($this->tldList) <= 6) { 555 if ($this->pluginLoaded('Tld')) { 556 $this->tldList = Phergie_Plugin_Tld::getTlds(); 557 if (is_array($this->tldList)) { 558 $this->tldList = array_keys($this->tldList); 559 } 560 } 561 if (!is_array($this->tldList) || count($this->tldList) <= 0) { 562 $this->tldList = array('com', 'org', 'net', 'gov', 'us', 'uk'); 563 } 564 rsort($this->tldList); 565 } 566 } 567 566 568 /* 567 * Updates the given variable with the setting 568 */ 569 * Updates the given variable with the setting 570 * 571 * @return void 572 */ 569 573 protected function updateSetting($setting, $var, $integer = false) 570 574 {