| 1 |
<?php |
<?php |
| 2 |
// $Id: urllist.module,v 1.12.2.1 2007/03/08 17:07:32 deekayen Exp $ |
// $Id: urllist.module,v 1.14 2007/10/08 17:51:09 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.12.2.1 2007/03/08 17:07:32 deekayen Exp $ |
* @version $Id: urllist.module,v 1.14 2007/10/08 17:51:09 deekayen Exp $ |
| 9 |
* @author David Kent Norman |
* @author David Kent Norman |
| 10 |
* @link http://deekayen.net/ |
* @link http://deekayen.net/ |
| 11 |
*/ |
*/ |
| 34 |
); |
); |
| 35 |
$items['admin/settings/urllist'] = array( |
$items['admin/settings/urllist'] = array( |
| 36 |
'title' => 'URL list', |
'title' => 'URL list', |
| 37 |
'description' => t('Toggle access log for URL list.'), |
'description' => 'Toggle access log for URL list and edit Yahoo! API information.', |
| 38 |
'page callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 39 |
'page arguments' => array('urllist_admin_settings'), |
'page arguments' => array('urllist_admin_settings'), |
| 40 |
'access callback' => 'user_access', |
'access callback' => 'user_access', |
| 41 |
'access arguments' => array('administer site configuration'), |
'access arguments' => array('administer site configuration'), |
| 42 |
'type' => MENU_NORMAL_ITEM, |
'type' => MENU_NORMAL_ITEM |
| 43 |
); |
); |
| 44 |
|
|
| 45 |
|
/* since this would get skipped on during the module install |
| 46 |
|
a _submit() hook was added to the settings form to force |
| 47 |
|
a menu rebuild so this can be captured if a Yahoo verification |
| 48 |
|
URL was added. */ |
| 49 |
if ($yahoo_link = variable_get('urllist_yahoo_auth_link', '')) { |
if ($yahoo_link = variable_get('urllist_yahoo_auth_link', '')) { |
| 50 |
$items[$yahoo_link] = array( |
$items[$yahoo_link] = array( |
| 51 |
'title' => 'Yahoo! authentication', |
'title' => 'Yahoo! authentication', |
| 52 |
'page callback' => 'urllist_verify_yahoo', |
'page callback' => 'urllist_verify_yahoo', |
| 53 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 54 |
'access callback' => 'user_access', |
'access callback' => 'user_access', |
| 55 |
'access arguments' => array('access content') |
'access arguments' => array('access content') |
| 56 |
); |
); |
| 57 |
} |
} |
| 58 |
|
|
| 65 |
* @return array |
* @return array |
| 66 |
*/ |
*/ |
| 67 |
function urllist_admin_settings() { |
function urllist_admin_settings() { |
| 68 |
|
$form = array(); |
| 69 |
$form['urllist_logacc'] = array( |
$form['urllist_logacc'] = array( |
| 70 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 71 |
'#title' => 'Log accesses', |
'#title' => 'Log accesses', |
| 129 |
'#default_value' => variable_get('urllist_yahoo_auth_content', ''), |
'#default_value' => variable_get('urllist_yahoo_auth_content', ''), |
| 130 |
'#description' => t('The authentication file has a specific string of random characters Yahoo! will look for inside the above file name when it revalidates your site ownership.'), |
'#description' => t('The authentication file has a specific string of random characters Yahoo! will look for inside the above file name when it revalidates your site ownership.'), |
| 131 |
); |
); |
| 132 |
return system_settings_form($form); |
|
| 133 |
|
/* While it is cleaner in the code to just add the extra |
| 134 |
|
submit handler first and return system_settings_form($form), |
| 135 |
|
the system_settings_form() information needs to be first |
| 136 |
|
so the information is saved to the urllist_yahoo_auth_link |
| 137 |
|
variable before menu_rebuild() is called so hook_menu() can |
| 138 |
|
add it to the menu tables in the database since hook_menu() |
| 139 |
|
is no longer called on every page load as of Drupal 6. */ |
| 140 |
|
$form = system_settings_form($form); |
| 141 |
|
$form['#submit'][] = 'urllist_admin_settings_submit'; |
| 142 |
|
|
| 143 |
|
return $form; |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
/** |
| 147 |
|
* Capture any Yahoo! verification link URLs so |
| 148 |
|
* the menu can know to react to them when requested. |
| 149 |
|
*/ |
| 150 |
|
function urllist_admin_settings_submit() { |
| 151 |
|
menu_rebuild(); |
| 152 |
|
drupal_set_message(t('The URL List module re-built the menu information to check for a URL for Yahoo! authentication.'), 'status'); |
| 153 |
} |
} |
| 154 |
|
|
| 155 |
/** |
/** |
| 156 |
* Implmentation of hook_nodeapi(). |
* Implmentation of hook_nodeapi(). |
| 157 |
*/ |
*/ |
| 158 |
function urllist_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
function urllist_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
| 159 |
switch($op) { |
switch ($op) { |
| 160 |
case 'insert': |
case 'insert': |
| 161 |
case 'delete': |
case 'delete': |
| 162 |
if (variable_get('urllist_yahoo_submit', 0) && $node->status) { |
if (variable_get('urllist_yahoo_submit', 0) && $node->status) { |
| 182 |
|
|
| 183 |
/** |
/** |
| 184 |
* Print list of URLs in plaintext format |
* Print list of URLs in plaintext format |
|
* |
|
| 185 |
*/ |
*/ |
| 186 |
function theme_urllist() { |
function theme_urllist() { |
| 187 |
if (!ini_get('safe_mode')) { |
if (!ini_get('safe_mode')) { |
| 188 |
set_time_limit(240); |
set_time_limit(240); |
| 189 |
} |
} |
| 190 |
header('Content-type: text/plain'); |
header('Content-type: text/plain'); |
| 191 |
print url('', array('absolute' => TRUE)) . "\n"; |
print url('', array('absolute' => TRUE)) ."\n"; |
| 192 |
$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/',n.nid)"); |
$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/',n.nid)"); |
| 193 |
while ($node = db_fetch_object($result)) { |
while ($node = db_fetch_object($result)) { |
| 194 |
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 |
| 195 |
if (isset($node->dst)) { // alias is named |
if (isset($node->dst)) { // alias is named |
| 196 |
print url($node->dst, array('absolute' => TRUE)) . "\n"; |
print url($node->dst, array('absolute' => TRUE)) ."\n"; |
| 197 |
} |
} |
| 198 |
else { |
else { |
| 199 |
print url('node/' . $node->nid, array('absolute' => TRUE)) . "\n"; |
print url('node/'. $node->nid, array('absolute' => TRUE)) ."\n"; |
| 200 |
} |
} |
| 201 |
} |
} |
| 202 |
} |
} |
| 203 |
if (module_exists('taxonomy')) { |
if (module_exists('taxonomy')) { |
| 204 |
$result = db_query('SELECT d.tid FROM {term_data} d'); |
$result = db_query('SELECT d.tid FROM {term_data} d'); |
| 205 |
while ($topic = db_fetch_object($result)) { |
while ($topic = db_fetch_object($result)) { |
| 206 |
print url('taxonomy/term/' . $topic->tid, array('absolute' => TRUE)) . "\n"; |
print url('taxonomy/term/'. $topic->tid, array('absolute' => TRUE)) ."\n"; |
| 207 |
} |
} |
| 208 |
} |
} |
| 209 |
if (module_exists('search')) { |
if (module_exists('search')) { |
| 210 |
print url('search', array('absolute' => TRUE)) . "\n"; |
print url('search', array('absolute' => TRUE)) ."\n"; |
| 211 |
} |
} |
| 212 |
if (module_exists('image')) { |
if (module_exists('image')) { |
| 213 |
print url('image', array('absolute' => TRUE)) . "\n"; |
print url('image', array('absolute' => TRUE)) ."\n"; |
| 214 |
} |
} |
| 215 |
if (module_exists('randomizer')) { |
if (module_exists('randomizer')) { |
| 216 |
print url('randomizer', array('absolute' => TRUE)) . "\n"; |
print url('randomizer', array('absolute' => TRUE)) ."\n"; |
| 217 |
} |
} |
| 218 |
if (module_exists('blog')) { |
if (module_exists('blog')) { |
| 219 |
print url('blog', array('absolute' => TRUE)) . "\n"; |
print url('blog', array('absolute' => TRUE)) ."\n"; |
| 220 |
} |
} |
| 221 |
if (variable_get('urllist_logacc',0)) { |
if (variable_get('urllist_logacc', 0)) { |
| 222 |
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); |
| 223 |
} |
} |
| 224 |
} |
} |
| 225 |
|
|
| 227 |
* Prints a string for Yahoo Site Explorer authentication |
* Prints a string for Yahoo Site Explorer authentication |
| 228 |
*/ |
*/ |
| 229 |
function urllist_verify_yahoo() { |
function urllist_verify_yahoo() { |
| 230 |
echo variable_get('urllist_yahoo_auth_content', ''); |
die(variable_get('urllist_yahoo_auth_content', '')); |
| 231 |
} |
} |
| 232 |
|
|
| 233 |
/** |
/** |
| 257 |
} |
} |
| 258 |
|
|
| 259 |
/** |
/** |
| 260 |
* registry |
* Implementation of hook_theme(). |
| 261 |
* |
* |
| 262 |
* @return array |
* @return array |
| 263 |
*/ |
*/ |