This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Captcha module patch, to support those with textish browsers

This is a patch I made for the captcha module.

Since the captcha can only be read using graphical browsers, I thought of this idea to enable users with textish browsers to read the captcha code too.

It's not secure though.
Since the captcha code gets printed in a HTML tag (that's how textish browsers can read it), a script can read the code and bypass your captcha protection.
I don't recommend applying the patch if you are going to use captcha in anything other than fighting spam comments :).

- Amr

trying to develop a link manager module

I've been fighting with this off and on for a while now. I've looked through the existing modules, and none of them seem to fit my needs, so I started developing my own (which I plan to submit as a module once finished).

I need to automate the addition of user-submitted external links to a database. Essentially, I have 4 or 5 types initially, but it could be extended later. (For an example of what the base content looks like, please view: http://www.industrialnation.com/Bands/a.shtml )

weather.module hacked to use rssweather.com

As a great fan of the weather module, I was sad to see it continually fail as weatherroom.com failed...

I have updated the module code to use rssweather.com.

Someone with greater xml parsing skills may be able to do a more beautiful job.

Long live regular expressions!!

The main change between the two feeds, is that rssweather.com provides the data in a 'content:encoded' tag. I had to use regular expressions to extract the relevant information from the data as such:


case "CONTENT:ENCODED":
$stuff = preg_replace("/(.*)\

(.*)/i", "$1$2", $data);
while (preg_match("/(.*)\<[^>]+\>(.*)/i", $stuff)) {
$stuff = preg_replace("/(.*)\<[^>]+\>(.*)/i", "$1$2", $stuff);
}
if (strpos($data, "humidity")) {
$this->weather["humidity"] = $stuff;
} else if (strpos($data, "windspeed")) {
$this->weather["wind"] = $this->weather["wind"] . $stuff;
} else if (strpos($data, "winddir")) {
$this->weather["wind"] = $stuff . $this->weather["wind"];
} else if (strpos($data, "pressure")) {
$this->weather["barometer"] = $stuff;
} else if (strpos($data, "dewpoint")) {
$this->weather["dewpoint"] = $stuff;
} else if (strpos($data, "heatindex")) {

Extendable search module

I was wondering if it would be possible the create a search module that can be extended with 'plugins', to allow searches from other search-engines to be included in the results (Google, Yahoo, Phone directories, e-mail searchers, whois, ...)? The point would be to give visistors of a site the possibility to search for people on the internet, but still provide the flexibility to use the module as a simple search engine for either the site only, or the net.

Is it technicly possible?

Everything Module

This is a module which might be regarded as a bit odd as it specifically avoids displaying any of the site/theme stuff. I use a Drupal based site as a collection point for a lot of notes and writing which I do, with mailhandler pulling in emails which I send using a Nokia Communicator. As I travel a lot, this is a great way for me to keep all my writing in one place. I wrote this module as a way to extract ALL nodes form the site in a form which can be directly put into a word processor or saved as a PDF document. I'm not a programmer, so it's probably very rough, but I offer it here just in case anyone else is looking for something similar.


# Module to display all the nodes in the site, 

# Standard module help function - how it appears in admin/modules

function everything_help($section) {
  switch($section) {
    case "admin/system/modules#name":
      $output = "everything";
      break;
    case "admin/system/modules#description":
      $output = "Display all the nodes in the system, in a form suitable for printing or moving to a word processor or PDF file.";
      break;
    default:
      $output = "";
      break;
  }
  return $output;
}

# Standard module description function

function everything_system($field){
  $system["name"] = t("Everything");
  $system["description"] = t("Displays all the nodes in the system");
  return $system[$field];
}

# Link the function into the system

function everything_link($type, $node=0) {
  if (($type == "system")) {
    // URL, page title, func called for page content, arg, 1 = don't disp menu
    menu("everything", t("Everything"), "everything_all", 1, 0);
  }
}

function everything_settings() {
   $output = form_select(t("Body font"), "everything_bfont", variable_get("everything_bfont", "Arial, Verdana, Sans-Serif"),drupal_map_assoc(array("Arial, Verdana, Sans-Serif", "Couier New, Courier")), t("Enter name of the font you want to use"));
   $output .= form_select(t("Body font size"), "everything_bfontsize", variable_get("everything_bfontsize", "4"), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7)), t("Enter font size, between 1 and 7, 3 is normal"));
   $output .= form_select(t("Title font size"), "everything_tfontsize", variable_get("everything_tfontsize", "6"), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7)), t("Enter font size, between 1 and 7, 3 is normal body text"));
   return $output;
}


# The everything function which selects and displays the nodes

function everything_all() {
    $tfontstr = "<font face=\"".variable_get("everything_bfont", 0)."\" size=\"".variable_get("everything_tfontsize", 0)."\">";
    $bfontstr = "<font face=\"".variable_get("everything_bfont", 0)."\" size=\"".variable_get("everything_bfontsize", 0)."\">";
    $efontstr = "</font>";
    $page_content = '';
    $query = "SELECT nid, type FROM {node} WHERE status = 1 ORDER BY nid";
    $result = db_query($query);
    while ($node = db_fetch_object($result)) {
      #$page_content .= node_view(node_load(array('nid' => $node->nid, 'type' => $node->type)), 0);
      $node = node_load(array('nid' => $node->nid));
      $title = check_output($node->title);
      $body = check_output($node->body);
      $page_content .= "<b>".$tfontstr.$title.$efontstr."</b><br><br>".$bfontstr.$body.$efontstr."<br><br>";   
    }
    #print theme("page", $page_content);
    print $page_content;
    }

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions