? mollom-client-api.pdf ? mollom.temp.inc ? mollom.token.inc ? mollom.token.inc.txt ? molstats ? xmlrpc calls.txt ? translations/th.po Index: mollom.admin.inc =================================================================== RCS file: mollom.admin.inc diff -N mollom.admin.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ mollom.admin.inc 10 Jun 2009 02:36:42 -0000 @@ -0,0 +1,130 @@ + 'fieldset', + '#title' => t('Site usage statistics'), + '#collapsible' => TRUE, + ); + $form['statistics']['message'] = array( + '#value' => '
', + ); + + $form['spam'] = array( + '#type' => 'fieldset', + '#title' => t('Spam protection settings'), + '#description' => + ''. t("Mollom can be used to block all types of spam received on your website's protected forms. Each form can be set to one of the following options:") .'
'. + ''. t("Data is processsed and stored as explained in our Web Service Privacy Policy. It is your responsibility to provide any necessary notices and obtain the appropriate consent regarding Mollom's use of your data. For more information, see How Mollom Works and the Mollom FAQ.", array('@mollom-privacy' => 'http://mollom.com/service-agreement-free-subscriptions', '@mollom-works' => 'http://mollom.com/how-mollom-works', '@mollom-faq' => 'http://mollom.com/faq')) .'
', + '#collapsible' => TRUE, + ); + + $forms = _mollom_protectable_forms(); + foreach ($forms as $form_id => $details) { + $mode = _mollom_get_mode($form_id); + $name = 'mollom_'. $form_id; + + $options = array_slice(array( + MOLLOM_MODE_DISABLED => t('No protection'), + MOLLOM_MODE_CAPTCHA => t('CAPTCHA only'), + MOLLOM_MODE_ANALYSIS => t('Text analysis and CAPTCHA backup'), + ), 0, $details['mode'] + 1); + + $form['spam'][$name] = array( + '#type' => 'select', + '#title' => t('Protect @name', array('@name' => $details['name'])), + '#options' => $options, + '#default_value' => $mode, + ); + } + + $form['server'] = array( + '#type' => 'fieldset', + '#title' => t('Server settings'), + '#collapsible' => TRUE, + '#collapsed' => $keys, + ); + $form['server']['mollom_fallback'] = array( + '#type' => 'radios', + '#title' => t('Fallback strategy'), + '#default_value' => variable_get('mollom_fallback', MOLLOM_FALLBACK_BLOCK), // we default to treating everything as inappropriate + '#options' => array( + MOLLOM_FALLBACK_BLOCK => t('Block all submissions of protected forms until the server problems are resolved'), + MOLLOM_FALLBACK_ACCEPT => t('Leave all forms unprotected and accept all submissions'), + ), + '#description' => t('When the Mollom servers are down or otherwise unreachable, no text analysis is performed and no CAPTCHAs are generated. If this occurs, your Drupal site will use the configured fallback strategy, and will either accept all submissions without spam checking, or block all submissions until the server or connection problems are resolved. Subscribers to Mollom Plus receive access to Mollom\'s high-availability backend infrastructure, not available to free users, reducing potential downtime.', array('@pricing' => 'http://mollom.com/pricing', '@sla' => 'http://mollom.com/standard-service-level-agreement')), + ); + } + + $form['access-keys'] = array( + '#type' => 'fieldset', + '#title' => t('Mollom access keys'), + '#description' => t('In order to use Mollom, you need both a public and private key. To obtain your keys, simply create a user account on mollom.com, login to mollom.com, and create a subscription for your site. Once you created a subscription, your private and public access keys will be available from the site manager on mollom.com. Copy-paste them in the form below, and you are ready to go.', array('@mollom-user' => 'http://mollom.com/user', '@mollom-site-add' => 'http://mollom.com/site-manager/add', '@mollom-sites' => 'http://mollom.com/site-manager')), + '#collapsible' => TRUE, + '#collapsed' => $keys, + ); + $form['access-keys']['mollom_public_key'] = array( + '#type' => 'textfield', + '#title' => t('Public key'), + '#default_value' => variable_get('mollom_public_key', ''), + '#description' => t('The public key is used to uniquely identify you.'), + '#required' => TRUE, + ); + $form['access-keys']['mollom_private_key'] = array( + '#type' => 'textfield', + '#title' => t('Private key'), + '#default_value' => variable_get('mollom_private_key', ''), + '#description' => t('The private key is used to prevent someone from hijacking your requests. Similar to a password, it should never be shared with anyone.'), + '#required' => TRUE, + ); + + return system_settings_form($form); +} + +/** + * This function contacts Mollom to verify the configured key pair. + */ +function _mollom_verify_key() { + $status = mollom('mollom.verifyKey'); + + if ($status === NETWORK_ERROR) { + drupal_set_message(t('We tried to contact the Mollom servers but we encountered a network error. Please make sure that your web server can make outgoing HTTP requests.'), 'error'); + } + else if ($status === MOLLOM_ERROR) { + drupal_set_message(t('We contacted the Mollom servers to verify your keys: your keys do not exist or are no longer valid. Please visit the Manage sites page on the Mollom website again: @mollom-user.', array('@mollom-user' => 'http://mollom.com/user')), 'error'); + } + else { + drupal_set_message(t('We contacted the Mollom servers to verify your keys: the Mollom services are operating correctly. We are now blocking spam.')); + } +} Index: mollom.inc =================================================================== RCS file: mollom.inc diff -N mollom.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ mollom.inc 10 Jun 2009 02:36:42 -0000 @@ -0,0 +1,74 @@ + xmlrpc_errno(), '%server' => $server, '%message' => xmlrpc_error_msg()), WATCHDOG_ERROR); + } + } + + return array(); +} Index: mollom.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v retrieving revision 1.2.2.62 diff -u -p -r1.2.2.62 mollom.module --- mollom.module 25 May 2009 12:57:54 -0000 1.2.2.62 +++ mollom.module 10 Jun 2009 02:36:45 -0000 @@ -72,6 +72,7 @@ function mollom_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('mollom_report_comment'), 'access arguments' => array('administer comments'), + 'file' => 'mollom.pages.inc', 'type' => MENU_CALLBACK, ); $items['mollom/node'] = array( @@ -79,6 +80,7 @@ function mollom_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('mollom_report_node'), 'access arguments' => array('administer nodes'), + 'file' => 'mollom.pages.inc', 'type' => MENU_CALLBACK, ); $items['mollom/contact'] = array( @@ -86,6 +88,7 @@ function mollom_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('mollom_report_contact'), 'access arguments' => array(TRUE), // Everyone can report contact form feedback. + 'file' => 'mollom.pages.inc', 'type' => MENU_CALLBACK, ); $items['admin/settings/mollom'] = array( @@ -94,6 +97,7 @@ function mollom_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('mollom_admin_settings'), 'access arguments' => array('administer mollom'), + 'file' => 'mollom.admin.inc', ); // Menu callback used for AJAX purposes: @@ -102,6 +106,7 @@ function mollom_menu() { 'page callback' => 'mollom_captcha_js', 'page arguments' => array(2, 3), 'access callback' => TRUE, + 'file' => 'mollom.pages.inc', 'type' => MENU_CALLBACK, ); @@ -119,36 +124,6 @@ function mollom_perm() { } /** - * AJAX callback to retrieve a CAPTCHA. - */ -function mollom_captcha_js($type, $session_id) { - - // TODO: add error handling. - $output = ''; - - if ($type == 'audio') { - $response = mollom('mollom.getAudioCaptcha', array('author_ip' => ip_address(), 'session_id' => $session_id)); - - if ($response) { - $output = ''; - $output .= ' ('. t('use image CAPTCHA') .')'; - } - } - - if ($type == 'image') { - $response = mollom('mollom.getImageCaptcha', array('author_ip' => ip_address(), 'session_id' => $session_id)); - - if ($response) { - $output = ''. t("Mollom can be used to block all types of spam received on your website's protected forms. Each form can be set to one of the following options:") .'
'. - ''. t("Data is processsed and stored as explained in our Web Service Privacy Policy. It is your responsibility to provide any necessary notices and obtain the appropriate consent regarding Mollom's use of your data. For more information, see How Mollom Works and the Mollom FAQ.") .'
', - '#collapsible' => TRUE, - ); - - $forms = _mollom_protectable_forms(); - foreach ($forms as $form_id => $details) { - $mode = _mollom_get_mode($form_id); - $name = 'mollom_'. $form_id; - - $options = array_slice(array( - MOLLOM_MODE_DISABLED => t('No protection'), - MOLLOM_MODE_CAPTCHA => t('CAPTCHA only'), - MOLLOM_MODE_ANALYSIS => t('Text analysis and CAPTCHA backup'), - ), 0, $details['mode'] + 1); - - $form['spam'][$name] = array( - '#type' => 'select', - '#title' => t('Protect @name', array('@name' => $details['name'])), - '#options' => $options, - '#default_value' => $mode, - ); - } - - $form['server'] = array( - '#type' => 'fieldset', - '#title' => t('Server settings'), - '#collapsible' => TRUE, - '#collapsed' => $keys, - ); - $form['server']['mollom_fallback'] = array( - '#type' => 'radios', - '#title' => t('Fallback strategy'), - '#default_value' => variable_get('mollom_fallback', MOLLOM_FALLBACK_BLOCK), // we default to treating everything as inappropriate - '#options' => array( - MOLLOM_FALLBACK_BLOCK => t('Block all submissions of protected forms until the server problems are resolved'), - MOLLOM_FALLBACK_ACCEPT => t('Leave all forms unprotected and accept all submissions'), - ), - '#description' => t('When the Mollom servers are down or otherwise unreachable, no text analysis is performed and no CAPTCHAs are generated. If this occurs, your Drupal site will use the configured fallback strategy, and will either accept all submissions without spam checking, or block all submissions until the server or connection problems are resolved. Subscribers to Mollom Plus receive access to Mollom\'s high-availability backend infrastructure, not available to free users, reducing potential downtime.', array('@pricing' => 'http://mollom.com/pricing', '@sla' => 'http://mollom.com/standard-service-level-agreement')), - ); - } - - $form['access-keys'] = array( - '#type' => 'fieldset', - '#title' => t('Mollom access keys'), - '#description' => t('In order to use Mollom, you need both a public and private key. To obtain your keys, simply create a user account on mollom.com, login to mollom.com, and create a subscription for your site. Once you created a subscription, your private and public access keys will be available from the site manager on mollom.com. Copy-paste them in the form below, and you are ready to go.'), - '#collapsible' => TRUE, - '#collapsed' => $keys, - ); - $form['access-keys']['mollom_public_key'] = array( - '#type' => 'textfield', - '#title' => t('Public key'), - '#default_value' => variable_get('mollom_public_key', ''), - '#description' => t('The public key is used to uniquely identify you.'), - '#required' => TRUE, - ); - $form['access-keys']['mollom_private_key'] = array( - '#type' => 'textfield', - '#title' => t('Private key'), - '#default_value' => variable_get('mollom_private_key', ''), - '#description' => t('The private key is used to prevent someone from hijacking your requests. Similar to a password, it should never be shared with anyone.'), - '#required' => TRUE, - ); - - return system_settings_form($form); -} - /** * A helper function that returns the OpenID identifiers associated with the specified user account. */ @@ -1047,53 +814,16 @@ function _mollom_insert_captcha(&$mollom } /** - * This function contacts Mollom to verify the configured key pair. - */ -function _mollom_verify_key() { - $status = mollom('mollom.verifyKey'); - - if ($status === NETWORK_ERROR) { - drupal_set_message(t('We tried to contact the Mollom servers but we encountered a network error. Please make sure that your web server can make outgoing HTTP requests.'), 'error'); - } - else if ($status === MOLLOM_ERROR) { - drupal_set_message(t('We contacted the Mollom servers to verify your keys: your keys do not exist or are no longer valid. Please visit the Manage sites page on the Mollom website again: @mollom-user.', array('@mollom-user' => 'http://mollom.com/user')), 'error'); - } - else { - drupal_set_message(t('We contacted the Mollom servers to verify your keys: the Mollom services are operating correctly. We are now blocking spam.')); - } -} - -/** - * This function refreshes the list of servers that can be used to contact Mollom. - */ -function _mollom_retrieve_server_list() { - // Start from a hard coded list of servers: - $servers = array('http://xmlrpc1.mollom.com', 'http://xmlrpc2.mollom.com', 'http://xmlrpc3.mollom.com'); - - // Use the list of servers to retrieve a list of servers from mollom.com: - foreach ($servers as $server) { - $result = xmlrpc($server .'/'. MOLLOM_API_VERSION, 'mollom.getServerList', _mollom_authentication()); - if (!xmlrpc_error()) { - return $result; - } - else { - watchdog('mollom', 'Error @errno: %server - %message - mollom.getServerList', array('@errno' => xmlrpc_errno(), '%server' => $server, '%message' => xmlrpc_error_msg()), WATCHDOG_ERROR); - } - } - - return array(); -} - -/** * Call a remote procedure at the Mollom server. This function * automatically adds the information required to authenticate against * Mollom. - * + * * TODO: currently this function's return value mixes actual values and - * error values. We should rewrite the error handling so that calling + * error values. We should rewrite the error handling so that calling * functions can properly handle error situations. */ function mollom($method, $data = array()) { + module_load_include('inc', 'mollom'); // Initialize refresh variable: $refresh = FALSE; @@ -1177,54 +907,8 @@ function mollom($method, $data = array() // Report this error: watchdog('mollom', 'No Mollom servers could be reached or all servers returned an error -- the server list was emptied.', NULL, WATCHDOG_ERROR); - - return NETWORK_ERROR; -} -/** - * This function generates an array with all information required to - * authenticate against Mollom. To prevent forged requests where you are - * impersonated, each request is signed with a hash based on a private - * key and a timestamp. - * - * Both the client and the server share the secret key used to create - * the authentication hash. They both hash a timestamp with the secret - * key, and if the hashes match, the authenticity of the message is - * validated. - * - * To avoid someone intercepting a (hash, timestamp)-pair and using it - * to impersonate a client, Mollom reject any request where the timestamp - * is more than 15 minutes off. - * - * Make sure your server's time is synchronized with the world clocks, - * and that you don't share your private key with anyone else. - */ -function _mollom_authentication() { - - $public_key = variable_get('mollom_public_key', ''); - $private_key = variable_get('mollom_private_key', ''); - - // Generate a timestamp according to the dateTime format (http://www.w3.org/TR/xmlschema-2/#dateTime): - $time = gmdate("Y-m-d\TH:i:s.\\0\\0\\0O", time()); - - // Generate a random number: - $nonce = md5(mt_rand()); - - // Calculate a HMAC-SHA1 according to RFC2104 (http://www.ietf.org/rfc/rfc2104.txt): - $hash = base64_encode( - pack('H*', sha1((str_pad($private_key, 64, chr(0x00)) ^ (str_repeat(chr(0x5c), 64))) . - pack('H*', sha1((str_pad($private_key, 64, chr(0x00)) ^ (str_repeat(chr(0x36), 64))) . - $time .':'. $nonce .':'. $private_key)))) - ); - - // Store everything in an array. Elsewhere in the code, we'll add the - // actual data before we pass it onto the XML-RPC library: - $data['public_key'] = $public_key; - $data['time'] = $time; - $data['hash'] = $hash; - $data['nonce'] = $nonce; - - return $data; + return NETWORK_ERROR; } /** Index: mollom.pages.inc =================================================================== RCS file: mollom.pages.inc diff -N mollom.pages.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ mollom.pages.inc 10 Jun 2009 02:36:45 -0000 @@ -0,0 +1,118 @@ + ip_address(), 'session_id' => $session_id)); + + if ($response) { + $output = ''; + $output .= ' ('. t('use image CAPTCHA') .')'; + } + } + + if ($type == 'image') { + $response = mollom('mollom.getImageCaptcha', array('author_ip' => ip_address(), 'session_id' => $session_id)); + + if ($response) { + $output = '