<?php // Processes text if (isset($parameter)) { if (is_array($parameter)) { $run_result .= nl2br(trim($parameter[0])); $addrelnofollow = isset($parameter[1]) ? (bool) $parameter[1] : false; } else { $run_result .= nl2br(trim($parameter)); $addrelnofollow = false; } $cachekey = sha1($addrelnofollow . "_" . $run_result); if ($cached = elggcache_get("weblogs_text_process:weblogs", $cachekey)) { $run_result = $cached; } else { //check for mismatched <>s and force escaping if necessary $numlt = substr_count($run_result, "<"); $numgt = substr_count($run_result, ">"); if ($numlt != $numgt) { $run_result = htmlspecialchars($run_result, ENT_COMPAT, 'utf-8'); } if (run("video:text:process", $run_result) != null) { $run_result = run("video:text:process", $run_result); } // URLs to links $run_result = run("weblogs:html_activate_urls", $run_result); // Remove the evil font tag $run_result = preg_replace("/<font[^>]*>/i", "", $run_result); $run_result = preg_replace("/<\\/font>/i", "", $run_result); // add rel="nofollow" to any links if ($addrelnofollow) {
/** * Get a single record as an object * * @uses $CFG * @param string $table The table to select from. * @param string $field1 the first field to check (optional). * @param string $value1 the value field1 must have (requred if field1 is given, else optional). * @param string $field2 the second field to check (optional). * @param string $value2 the value field2 must have (requred if field2 is given, else optional). * @param string $field3 the third field to check (optional). * @param string $value3 the value field3 must have (requred if field3 is given, else optional). * @return mixed a fieldset object containing the first mathcing record, or false if none found. */ function get_record($table, $field1 = null, $value1 = null, $field2 = null, $value2 = null, $field3 = null, $value3 = null, $fields = '*') { global $CFG; $trycache = false; //just cache things by primary key for now if ($field1 == "ident" && $value1 == intval($value1) && empty($field2) && empty($value2) && empty($field3) && empty($value3) && $fields == "*") { $trycache = true; $cacheval = elggcache_get($table, $field1 . "_" . intval($value1)); if (!is_null($cacheval)) { return $cacheval; } else { } } $select = where_clause_prepared($field1, $field2, $field3); $values = where_values_prepared($value1, $value2, $value3); $returnvalue = get_record_sql('SELECT ' . $fields . ' FROM ' . $CFG->prefix . $table . ' ' . $select, $values); if ($trycache) { $setres = elggcache_set($table, $field1 . "_" . $value1, $returnvalue); } return $returnvalue; }