| 1 |
<?php |
<?php |
| 2 |
// $Id: urllist.module,v 1.15 2008/02/15 16:16:25 deekayen Exp $ |
// $Id: urllist.module,v 1.16 2009/01/13 05:08:06 deekayen Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 6 |
* Creates a list of URLs for search engines to index. |
* Creates a list of URLs for search engines to index. |
| 7 |
* |
* |
| 8 |
* @version $Id: urllist.module,v 1.15 2008/02/15 16:16:25 deekayen Exp $ |
* @version $Id: urllist.module,v 1.16 2009/01/13 05:08:06 deekayen Exp $ |
| 9 |
* @author David Kent Norman |
* @author David Kent Norman |
| 10 |
* @link http://deekayen.net/ |
* @link http://deekayen.net/ |
| 11 |
*/ |
*/ |
| 67 |
function urllist_admin_settings() { |
function urllist_admin_settings() { |
| 68 |
$form = array(); |
$form = array(); |
| 69 |
$form['urllist_logacc'] = array( |
$form['urllist_logacc'] = array( |
| 70 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 71 |
'#title' => 'Log accesses', |
'#title' => 'Log accesses', |
| 72 |
'#default_value' => variable_get('urllist_logacc', 0), |
'#default_value' => variable_get('urllist_logacc', 0), |
| 73 |
'#description' => t('If enabled, a watchdog entry will be made each time the URL list is accessed, containing information about the requestor.') |
'#description' => t('If enabled, a watchdog entry will be made each time the URL list is accessed, containing information about the requestor.') |
| 74 |
); |
); |
|
|
|
| 75 |
$form['url_submit_yahoo'] = array( |
$form['url_submit_yahoo'] = array( |
| 76 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 77 |
'#title' => t('Yahoo! Update Notification API'), |
'#title' => t('Yahoo! Update Notification API'), |
| 106 |
'#return value' => '', |
'#return value' => '', |
| 107 |
'#default_value' => variable_get('urllist_yahoo_appid', '') |
'#default_value' => variable_get('urllist_yahoo_appid', '') |
| 108 |
); |
); |
|
|
|
| 109 |
$form['auth'] = array( |
$form['auth'] = array( |
| 110 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 111 |
'#title' => t('Yahoo! Site Explorer Authentication'), |
'#title' => t('Yahoo! Site Explorer Authentication'), |
| 151 |
} |
} |
| 152 |
|
|
| 153 |
/** |
/** |
| 154 |
* Implmentation of hook_nodeapi(). |
* Implmentation of hook_nodeapi_insert(). |
| 155 |
*/ |
*/ |
| 156 |
function urllist_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
function urllist_nodeapi_insert(&$node, $teaser = NULL, $page = NULL) { |
| 157 |
switch ($op) { |
if (variable_get('urllist_yahoo_submit', 0) && $node->status) { |
| 158 |
case 'insert': |
watchdog('urllist', "Submitting URL list to Yahoo! because node %node_id was inserted or deleted.", array('%node_id' => $node->nid), WATCHDOG_DEBUG); |
| 159 |
case 'delete': |
_urllist_submit_yahoo(); |
| 160 |
if (variable_get('urllist_yahoo_submit', 0) && $node->status) { |
} |
| 161 |
watchdog('urllist', "Submitting URL list to Yahoo! because node %node_id was inserted or deleted.", array('%node_id' => $node->nid), WATCHDOG_DEBUG); |
} |
| 162 |
_urllist_submit_yahoo(); |
|
| 163 |
} |
/** |
| 164 |
break; |
* Implmentation of hook_nodeapi_delete(). |
| 165 |
case 'update': |
*/ |
| 166 |
if (variable_get('urllist_yahoo_submit', 0) && ($node->status || $oldnode->status)) { |
function urllist_nodeapi_delete(&$node, $teaser = NULL, $page = NULL) { |
| 167 |
watchdog('urllist', "Submitting URL list to Yahoo! because node %node_id was updated.", array('%node_id' => $node->nid), WATCHDOG_DEBUG); |
urllist_nodeapi_insert($node, $teaser, $page); |
| 168 |
_urllist_submit_yahoo(); |
} |
| 169 |
} |
|
| 170 |
break; |
/** |
| 171 |
|
* Implmentation of hook_nodeapi_update(). |
| 172 |
|
*/ |
| 173 |
|
function urllist_nodeapi_update(&$node, $teaser = NULL, $page = NULL) { |
| 174 |
|
if (variable_get('urllist_yahoo_submit', 0) && ($node->status || $oldnode->status)) { |
| 175 |
|
watchdog('urllist', "Submitting URL list to Yahoo! because node %node_id was updated.", array('%node_id' => $node->nid), WATCHDOG_DEBUG); |
| 176 |
|
_urllist_submit_yahoo(); |
| 177 |
} |
} |
| 178 |
} |
} |
| 179 |
|
|
| 192 |
set_time_limit(240); |
set_time_limit(240); |
| 193 |
} |
} |
| 194 |
header('Content-type: text/plain'); |
header('Content-type: text/plain'); |
| 195 |
print url('', array('absolute' => TRUE)) ."\n"; |
print url('', array('absolute' => TRUE)) . "\n"; |
| 196 |
$result = db_query("SELECT n.nid, n.type, n.status, n.promote, n.changed, u.dst FROM {node} n LEFT JOIN {url_alias} u ON u.src=CONCAT('node/',CAST(n.nid as CHAR))"); |
$result = db_query("SELECT n.nid, n.type, n.status, n.promote, n.changed, u.dst FROM {node} n LEFT JOIN {url_alias} u ON u.src=CONCAT('node/',CAST(n.nid as CHAR))"); |
| 197 |
while ($node = db_fetch_object($result)) { |
while ($node = $result->fetchObject()) { |
| 198 |
if ($node->status) { // add check for if the node type is disabled or not |
if ($node->status) { // add check for if the node type is disabled or not |
| 199 |
if (isset($node->dst)) { // alias is named |
if (isset($node->dst)) { // alias is named |
| 200 |
print url($node->dst, array('absolute' => TRUE)) ."\n"; |
print url($node->dst, array('absolute' => TRUE)) . "\n"; |
| 201 |
} |
} |
| 202 |
else { |
else { |
| 203 |
print url('node/'. $node->nid, array('absolute' => TRUE)) ."\n"; |
print url('node/' . $node->nid, array('absolute' => TRUE)) . "\n"; |
| 204 |
} |
} |
| 205 |
} |
} |
| 206 |
} |
} |
| 207 |
if (module_exists('taxonomy')) { |
if (module_exists('taxonomy')) { |
| 208 |
$result = db_query('SELECT d.tid FROM {term_data} d'); |
$result = db_query('SELECT d.tid FROM {taxonomy_term_data} d'); |
| 209 |
while ($topic = db_fetch_object($result)) { |
while ($topic = $result->fetchObject()) { |
| 210 |
print url('taxonomy/term/'. $topic->tid, array('absolute' => TRUE)) ."\n"; |
print url('taxonomy/term/' . $topic->tid, array('absolute' => TRUE)) . "\n"; |
| 211 |
} |
} |
| 212 |
} |
} |
| 213 |
if (module_exists('search')) { |
if (module_exists('search')) { |
| 214 |
print url('search', array('absolute' => TRUE)) ."\n"; |
print url('search', array('absolute' => TRUE)) . "\n"; |
| 215 |
} |
} |
| 216 |
if (module_exists('image')) { |
if (module_exists('image')) { |
| 217 |
print url('image', array('absolute' => TRUE)) ."\n"; |
print url('image', array('absolute' => TRUE)) . "\n"; |
| 218 |
} |
} |
| 219 |
if (module_exists('randomizer')) { |
if (module_exists('randomizer')) { |
| 220 |
print url('randomizer', array('absolute' => TRUE)) ."\n"; |
print url('randomizer', array('absolute' => TRUE)) . "\n"; |
| 221 |
} |
} |
| 222 |
if (module_exists('blog')) { |
if (module_exists('blog')) { |
| 223 |
print url('blog', array('absolute' => TRUE)) ."\n"; |
print url('blog', array('absolute' => TRUE)) . "\n"; |
| 224 |
} |
} |
| 225 |
if (variable_get('urllist_logacc', 0)) { |
if (variable_get('urllist_logacc', 0)) { |
| 226 |
watchdog('urllist', 'URL list downloaded by '. getenv('HTTP_USER_AGENT') .' at '. getenv('REMOTE_ADDR') .'.', NULL, WATCHDOG_INFO); |
watchdog('urllist', 'URL list downloaded by ' . getenv('HTTP_USER_AGENT') . ' at ' . getenv('REMOTE_ADDR') . '.', NULL, WATCHDOG_INFO); |
| 227 |
} |
} |
| 228 |
} |
} |
| 229 |
|
|
| 242 |
* @link https://developer.yahoo.com/wsregapp/index.php?view |
* @link https://developer.yahoo.com/wsregapp/index.php?view |
| 243 |
*/ |
*/ |
| 244 |
function _urllist_submit_yahoo() { |
function _urllist_submit_yahoo() { |
| 245 |
$result = drupal_http_request('http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid='. variable_get('urllist_yahoo_appid', '') .'&url='. url('urllist.txt', array('absolute' => TRUE))); |
$result = drupal_http_request('http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=' . variable_get('urllist_yahoo_appid', '') . '&url=' . url('urllist.txt', array('absolute' => TRUE))); |
| 246 |
if ($result->code == 200) { |
if ($result->code == 200) { |
| 247 |
watchdog('urllist', 'URL list successfully submitted to Yahoo!', NULL, WATCHDOG_INFO); |
watchdog('urllist', 'URL list successfully submitted to Yahoo!', NULL, WATCHDOG_INFO); |
| 248 |
} |
} |
| 250 |
watchdog('urllist', 'Error occurred submitting URL list to Yahoo!: @code: @data', array('@code' => $result->code, '@data' => $result->data), WATCHDOG_ERROR); |
watchdog('urllist', 'Error occurred submitting URL list to Yahoo!: @code: @data', array('@code' => $result->code, '@data' => $result->data), WATCHDOG_ERROR); |
| 251 |
} |
} |
| 252 |
if (variable_get('urllist_yahoo_rss_submit', 0)) { |
if (variable_get('urllist_yahoo_rss_submit', 0)) { |
| 253 |
$result = drupal_http_request('http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid='. variable_get('urllist_yahoo_appid', '') .'&url='. url('rss.xml', array('absolute' => TRUE))); |
$result = drupal_http_request('http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=' . variable_get('urllist_yahoo_appid', '') . '&url=' . url('rss.xml', array('absolute' => TRUE))); |
| 254 |
if ($result->code == 200) { |
if ($result->code == 200) { |
| 255 |
watchdog('urllist', 'RSS feed successfully submitted to Yahoo!.', NULL, WATCHDOG_INFO); |
watchdog('urllist', 'RSS feed successfully submitted to Yahoo!.', NULL, WATCHDOG_INFO); |
| 256 |
} |
} |