array( "word_not_in_dict" => "hier heb ik geen woorden voor -- je kunt een betekenis toevoegen als je wilt.", "startword_not_set" => "Woord om mee te starten niet ingesteld", "default_title" => "dwaalboek", "mail_subject" => "Bericht van het dwaalboek", "added_by" => "Toegevoegd door", "button_add" => "voeg toe", "button_cancel" => "terug", ), "en" => array( "word_not_in_dict" => "words fail me -- you can add a description if you want.", "startword_not_set" => "Word to start with not set", "default_title" => "wanderwords", "mail_subject" => "Message from wanderwords", "added_by" => "Added by", "button_add" => "add", "button_cancel" => "back", ), ); ///////////////////////////////////////////////////////////////////////////// // if this file gets called with ?js, output the javascript for the widget // ///////////////////////////////////////////////////////////////////////////// if (array_key_exists('js', $_GET)) { ?> var LastWord; function assocGetWord(w) { assocSendRequest(widgetUrl() + "?w=" + w); } function assocSbm(frmObj) { assocSendRequest(widgetUrl() + "?nw=" + frmObj.w.value + "&d=" + frmObj.d.value); return false; } function assocCcl() { assocSendRequest(widgetUrl() + "?w=" + LastWord); } function widgetUrl() { return "wp-content/plugins/widgets/assoc_dict.php"; } function assocSendRequest(url) { assocReq = false; // branch for native XMLHttpRequest object if (window.XMLHttpRequest) { try { assocReq = new XMLHttpRequest(); assocReq.onreadystatechange = assocProcessReqChange; assocReq.open('GET', url, true); assocReq.send(null); } catch(e) { assocReq = false; } } else if (window.ActiveXObject) { // branch for IE/Windows ActiveX version try { assocReq = new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) { try { assocReq = new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) { assocReq = false; } } if (assocReq) { assocReq.onreadystatechange = assocProcessReqChange; assocReq.open('GET', url, true); assocReq.send(); } } } function assocProcessReqChange() { if (4 != assocReq.readyState) { return; } if (200 != assocReq.status) { return; } var parts, newwords, i, r, stripped, idx; parts = assocReq.responseText.split("#"); switch (parts[0]) { case "200": newwords = parts[2].split(" "); LastWord = parts[1]; r = "

" + parts[1] + ": "; for (i = 0; i < newwords.length; i++) { stripped = newwords[i]; idx = stripped.indexOf("'"); while (idx > -1) { stripped = stripped.replace("'", ""); idx = stripped.indexOf("'"); } r += "" + newwords[i] + " "; } document.getElementById("assoc_dict_word").innerHTML = r + "

"; break; case "404": r = '

' + parts[1] + ':


">" onclick="assocCcl();">

'; document.getElementById("assoc_dict_word").innerHTML = r; break; default: break; } } query("INSERT INTO widget_assoc_dict(woord, omschrijving, date_time, ip, useragent) VALUES('$_w', '$_d', '$_date', '" . $_ip . $_name . "', '" . $_useragent . "');"); if ("" != trim($assoc_dict_options["mail_address"])) { mail( $assoc_dict_options["mail_address"], $assoc_dict_lang[$assoc_dict_lang_pref]["mail_subject"] . " (" . $_w . ")", $_w . ":\n\n" . stripslashes($_d) . "\n\n\n\n" . $assoc_dict_lang[$assoc_dict_lang_pref]["added_by"] . " " . $_ip . $_name . "\n\n" . "(This mail has been generated by the Associative Dictionary widget for Wordpress)", "From: woorden@dirkie.nu\r\n" ."X-Mailer: PHP/" . phpversion()); } echo "200#" . $_w . "#" . $_d; exit; } if (array_key_exists('w', $_GET)) { $_w = ereg_replace("[^[:alpha:]]", "", $_GET['w']); if ('' != trim($_w)) { $woord = $wpdb->get_row("select * from widget_assoc_dict where woord = '" . $_w . "';"); if ($woord) { echo "200#" . $_w . "#" . str_replace(''', '\'', $woord->omschrijving); } else { echo "404#" . $_w; } } exit; } ///////////////////////////////////////////////////// // called by wordpress to include rss-feed in head // ///////////////////////////////////////////////////// function widget_assoc_dict_rss() { global $_siteurl; echo ''; } //////////////////////////////////////////////////////////// // generate rss feed when this file gets called with ?rss // //////////////////////////////////////////////////////////// if (array_key_exists('rss', $_GET)) { if ((stristr($_SERVER['HTTP_ACCEPT'], "application/xhtml+xml")) || (stristr($_SERVER['HTTP_USER_AGENT'], "Validator"))) { header("Content-Type: application/xhtml+xml; charset=utf-8"); } else { header("Content-Type: text/html; charset=utf-8"); } echo '<' . '?xml version="1.0" encoding="utf-8"?'; ?> > <?= $_blogtitle ?>: <?= $assoc_dict_options['title'] ?> Associative Dictionary Widget for Wordpress get_results("select woord, omschrijving, date_time, ip from widget_assoc_dict order by date_time DESC LIMIT 25") ) { foreach($words as $word) { ?> <?= $word->woord ?> omschrijving ?> ip ?> date_time . " +01:00" ?> get_row("select * from widget_assoc_dict order by rand() limit 1;"); if ($woord) { $startword = $woord->woord; } } echo $before_widget . $before_title . $title . $after_title; # do we have a word to start things off with? if ('' != trim($startword)) { echo '
 
'; echo ''; echo ''; } else { echo '
' . $assoc_dict_lang[$assoc_dict_lang_pref]["startword_not_set"] . '
'; } echo $after_widget; } function widget_assoc_dict_control() { // Get our options and see if we're handling a form submission. $options = get_option('widget_assoc_dict'); if ( !is_array($options) ) { $options = array('title' => $assoc_dict_lang[$assoc_dict_lang_pref]["default_title"], 'startword' => '', 'language' => 'en', 'mail_address' => '', 'random' => ''); } if ( $_POST['assocdict-submit'] ) { $options['title'] = strip_tags(stripslashes($_POST['assocdict-title'])); $options['startword'] = strip_tags(stripslashes($_POST['assocdict-startword'])); $options['language'] = $_POST['assocdict-language']; $options['mail_address'] = $_POST['assocdict-mail_address']; $options['random'] = $_POST['assocdict-random']; update_option('widget_assoc_dict', $options); // does the db exist? $testdb = $GLOBALS['wpdb']->get_row("show table status like 'widget_assoc_dict'"); if (!$testdb) { $GLOBALS['wpdb']->query("CREATE TABLE `widget_assoc_dict` (`woordid` int(11) NOT NULL auto_increment, `woord` varchar(255) NOT NULL default '', `omschrijving` text NOT NULL, `date_time` datetime NOT NULL default '0000-00-00 00:00:00', `ip` varchar(255) NOT NULL default '', `useragent` varchar(255) NOT NULL default '', PRIMARY KEY (`woordid`), KEY `wrd` (`woord`));"); } } // no need to display the 'random' option if there's less than 2 words in the db $woord = $GLOBALS['wpdb']->get_row("SELECT count(woord) as aantal FROM widget_assoc_dict;"); $_showRandom = false; if ($woord) { if (intval($woord->aantal) > 1) { $_showRandom = true; } } $title = htmlspecialchars($options['title'], ENT_QUOTES); $_checked = ""; $_displaySW = ""; if ($_showRandom && ("1" == $options['random'])) { $_checked = " selected"; $_displaySW = " display: none;"; } $startword = htmlspecialchars($options['startword'], ENT_QUOTES); $mail_address = $options['mail_address']; if ('en' == $options['language']) { $languageEN = ' selected'; $languageNL = ''; } else { $languageEN = ''; $languageNL = ' selected'; } ?>