/**
 * Get a netlink block / direct to a netlink site.
 *
 * @param  URLPATH		The URL we grab our netlink from. If this is not blank, instead of getting a netlink block, we direct to a netlink site.
 * @return tempcode		The netlink block
 */
function do_netlink($redir_url = '')
{
    header('Content-type: text/plain; charset=' . get_charset());
    // If we are redirecting
    if ($redir_url != '') {
        if (strpos($redir_url, chr(10)) !== false || strpos($redir_url, chr(13)) !== false) {
            log_hack_attack_and_exit('HEADER_SPLIT_HACK');
        }
        header('Location: ' . $redir_url);
        exit;
    }
    // Ok we're displaying a netlink, which will be dumped right into the body of the reading site
    //  - this isn't actually a weburl that is actually displayed, its loaded by ocPortal and embedded-inline
    // For all the names in our network
    require_code('textfiles');
    $lines = explode(chr(10), read_text_file('netlink', NULL, true));
    if (count($lines) == 0) {
        return new ocp_tempcode();
    }
    $content = new ocp_tempcode();
    foreach ($lines as $line) {
        $parts = explode('=', $line, 2);
        if (count($parts) != 2) {
            continue;
        }
        $name = rtrim($parts[0]);
        $url = trim($parts[1]);
        // Are we looking at the source site in the network?
        $selected = strtolower($url) == strtolower(get_param('source', ''));
        $content->attach(form_input_list_entry(base64_encode($url), $selected, $name));
    }
    return do_template('NETLINK', array('_GUID' => '180321222dc5dc99a231597c803f0726', 'CONTENT' => $content));
}
Example #2
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_code('textfiles');
     $file = array_key_exists('param', $map) ? $map['param'] : 'admin_notes';
     $title = array_key_exists('title', $map) ? $map['title'] : do_lang('NOTES');
     $lang_none = array_key_exists('lang_none', $map) ? $map['lang_none'] : '0';
     $scrolls = array_key_exists('scrolls', $map) ? $map['scrolls'] : '0';
     $lang = $lang_none == '1' ? NULL : '';
     $file = filter_naughty($file, true);
     $new = post_param('new', NULL);
     if (!is_null($new)) {
         $hooks = find_all_hooks('blocks', 'main_notes');
         foreach (array_keys($hooks) as $hook) {
             require_code('hooks/blocks/main_notes/' . filter_naughty_harsh($hook));
             $ob = object_factory('Hook_notes_' . filter_naughty_harsh($hook), true);
             if (is_null($ob)) {
                 continue;
             }
             $ob->run($file);
         }
         write_text_file($file, $lang, $new);
         log_it('NOTES', $file);
         attach_message(do_lang_tempcode('SUCCESS'), 'inform');
     }
     $contents = read_text_file($file, $lang, true);
     $post_url = get_self_url();
     $map_comcode = '';
     foreach ($map as $key => $val) {
         $map_comcode .= ' ' . $key . '="' . addslashes($val) . '"';
     }
     return do_template('BLOCK_MAIN_NOTES', array('_GUID' => 'f737053505de3bd8ccfe806ec014b8fb', 'TITLE' => $title, 'BLOCK_NAME' => 'main_notes', 'MAP' => $map_comcode, 'CONTENTS' => $contents, 'SCROLLS' => array_key_exists('scrolls', $map) && $map['scrolls'] == '1', 'URL' => $post_url));
 }
Example #3
0
function comcode_white_listed($tag, $marker, $comcode)
{
    $start_pos = strrpos(substr($comcode, 0, $marker), '[' . $tag);
    $end_pos = $marker - $start_pos;
    $comcode_portion_at_and_after = substr($comcode, $start_pos);
    $comcode_portion = substr($comcode_portion_at_and_after, 0, $end_pos);
    require_code('textfiles');
    $whitelists = explode(chr(10), read_text_file('comcode_whitelist'));
    if (in_array($comcode_portion, $whitelists)) {
        return true;
    }
    foreach ($whitelists as $whitelist) {
        if (substr($whitelist, 0, 1) == '/' && substr($whitelist, -1) == '/' && preg_match($whitelist, $comcode_portion) != 0) {
            return true;
        }
    }
    return false;
}
Example #4
0
        $output[] = $buf;
    }
    fclose($file);
    unlink($in_filename);
    return $output[0];
}
$ip = $_SERVER['REMOTE_ADDR'];
$ip = str_replace('.', '_', $ip);
$namefile = $_SERVER['PHP_SELF'];
//$rootPath = realpath(realpath($namefile));
//while(!file_exists($rootPath.'/components'))
//{
//	$rootPath = dirname($rootPath);
//}
$fileName = 'images/security_code/sercu_' . $ip . '.txt';
$securityCode = read_text_file($fileName);
$securityCodeInput = $_POST['osolCatchaTxt'];
if ($securityCodeInput != $securityCode) {
    echo "Wrong_code";
    exit;
}
require 'configuration.php';
$conf = new JConfig();
$conn = mysql_connect($conf->host, $conf->user, $conf->password);
mysql_select_db($conf->db, $conn);
$obj = $_POST['id'];
$comp = $_POST['component_name'];
$title = $_POST['title'];
$comment = $_POST['comment'];
$name = $_POST['name'];
$email = $_POST['email'];
Example #5
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_quotes($db, $table_prefix, $old_base_dir)
 {
     require_code('textfiles');
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'quotes');
     $out = read_text_file('quotes', get_site_default_lang(), true);
     foreach ($rows as $row) {
         $out .= $row['quote'] . chr(10);
     }
     write_text_file('quotes', get_site_default_lang(), $out);
 }
Example #6
0
/**
 * Sets the meta information for the specified resource, by auto-summarisation from the given parameters.
 *
 * @param  ID_TEXT		The type of resource (e.g. download)
 * @param  ID_TEXT		The ID of the resource
 * @param  array			Array of content strings to summarise from
 * @param  SHORT_TEXT	The description to use
 * @return SHORT_TEXT	Keyword string generated (it's also saved in the DB, so usually you won't want to collect this)
 */
function seo_meta_set_for_implicit($type, $id, $keyword_sources, $description)
{
    if (!is_null(post_param('meta_keywords', NULL)) && (post_param('meta_keywords') != '' || post_param('meta_description') != '')) {
        seo_meta_set_for_explicit($type, $id, post_param('meta_keywords'), post_param('meta_description'));
        return '';
    }
    if (get_value('no_auto_meta') === '1') {
        return '';
    }
    if (get_option('automatic_meta_extraction') == '0') {
        return '';
    }
    // These characters are considered to be word-characters
    require_code('textfiles');
    $word_chars = explode(chr(10), read_text_file('word_characters', ''));
    $strip_chars = array('\'');
    // These present problems so will be entirely stripped
    foreach ($word_chars as $i => $word_char) {
        $word_chars[$i] = trim($word_char);
    }
    $common_words = explode(chr(10), read_text_file('too_common_words', ''));
    foreach ($common_words as $i => $common_word) {
        $common_words[$i] = trim($common_word);
    }
    $keywords = array();
    // This will be filled
    foreach ($keyword_sources as $source) {
        $source = strip_comcode($source);
        foreach ($strip_chars as $strip_char) {
            $source = strtolower(str_replace($strip_char, '', $source));
        }
        $source = preg_replace('#\\-+#', ' ', $source);
        $i = 0;
        $len = strlen($source);
        $from = 0;
        $in_word = false;
        while ($i < $len) {
            $at = $source[$i];
            $word_char = in_array($at, $word_chars);
            if ($in_word) {
                // Exiting word
                if (!$word_char) {
                    if ($i - $from >= 3) {
                        $this_word = substr($source, $from, $i - $from);
                        if (!in_array($this_word, $common_words)) {
                            if (!array_key_exists($this_word, $keywords)) {
                                $keywords[$this_word] = 0;
                            }
                            $keywords[$this_word]++;
                        }
                    }
                    $in_word = false;
                }
            } else {
                // Entering word
                if ($word_char) {
                    $from = $i;
                    $in_word = true;
                }
            }
            $i++;
        }
        // Finalise
        if ($in_word && $i - $from >= 3) {
            $this_word = substr($source, $from, $i - $from);
            if (!in_array($this_word, $common_words)) {
                if (!array_key_exists($this_word, $keywords)) {
                    $keywords[$this_word] = 0;
                }
                $keywords[$this_word]++;
            }
        }
    }
    arsort($keywords);
    $imp = '';
    foreach (array_keys($keywords) as $i => $keyword) {
        if ($imp != '') {
            $imp .= ',';
        }
        $imp .= $keyword;
        if ($i == 15) {
            break;
        }
    }
    require_code('xhtml');
    $description = strip_comcode($description);
    $description = trim(preg_replace('#\\s+---+\\s+#', ' ', $description));
    seo_meta_set_for_explicit($type, $id, $imp, strlen($description) > 1000 ? substr($description, 0, 1000) . '...' : $description);
    if (function_exists('decache')) {
        decache('side_tag_cloud');
    }
    return $imp;
}
Example #7
0
 /**
  * Get Comcode to save as the rules.
  *
  * @param  ID_TEXT		A code relating to which rules set to get
  * @return string			The Comcode
  */
 function get_rules_file($code)
 {
     require_code('textfiles');
     return read_text_file('rules_' . $code, '');
 }
Example #8
0
 /**
  * The actualiser of a search.
  *
  * @param  ID_TEXT		Codename for what's being searched (blank: mixed search)
  * @param  string			Author name
  * @param  ?AUTO_LINK	Author ID (NULL: none given)
  * @param  integer		Days to search
  * @param  ID_TEXT		Sort key
  * @param  ID_TEXT		Sort direction
  * @set    ASC DESC
  * @param  boolean		Whether to only search titles
  * @param  string			Comma-separated list of categories to search under
  * @return array			A triple: The results, results browser, the number of results
  */
 function results($id, $author, $author_id, $days, $sort, $direction, $only_titles, $search_under)
 {
     $title = get_page_title('RESULTS');
     cache_module_installed_status();
     $cutoff = $days == -1 ? NULL : time() - $days * 24 * 60 * 60;
     // What we're searching for
     $content = get_param('content', false, true);
     // Search keyword highlighting in any loaded Comcode
     global $SEARCH__CONTENT_BITS;
     $_content_bits = explode(' ', str_replace('"', '', preg_replace('#(^|\\s)\\+#', '', preg_replace('#(^|\\s)\\-#', '', $content))));
     $SEARCH__CONTENT_BITS = array();
     require_code('textfiles');
     $too_common_words = explode(chr(10), read_text_file('too_common_words', '', true));
     foreach ($_content_bits as $content_bit) {
         $content_bit = trim($content_bit);
         if ($content_bit == '') {
             continue;
         }
         if (!in_array(strtolower($content_bit), $too_common_words)) {
             $SEARCH__CONTENT_BITS[] = $content_bit;
         }
     }
     $start = get_param_integer('start', 0);
     $default_max = 10;
     if (ini_get('memory_limit') != '-1' && ini_get('memory_limit') != '0') {
         if (intval(preg_replace('#M$#', '', ini_get('memory_limit'))) < 20) {
             $default_max = 5;
         }
     }
     $max = get_param_integer('max', $default_max);
     // Also see get_search_rows
     $save_title = get_param('save_title', '');
     if (!is_guest() && $save_title != '' && $start == 0) {
         static $saved_search = false;
         if (!$saved_search) {
             $GLOBALS['SITE_DB']->query_insert('searches_saved', array('s_title' => $save_title, 's_member_id' => get_member(), 's_time' => time(), 's_primary' => $content, 's_auxillary' => serialize(array_merge($_POST, $_GET))));
             $saved_search = true;
         }
     }
     $boolean_operator = get_param('conjunctive_operator', 'OR');
     $boolean_search = $this->_is_boolean_search();
     $content_where = build_content_where($content, $boolean_search, $boolean_operator);
     disable_php_memory_limit();
     // Search under all hooks we've asked to search under
     $results = array();
     $_hooks = find_all_hooks('modules', 'search');
     foreach (array_keys($_hooks) as $hook) {
         require_code('hooks/modules/search/' . filter_naughty_harsh($hook));
         $object = object_factory('Hook_search_' . filter_naughty_harsh($hook), true);
         if (is_null($object)) {
             continue;
         }
         $info = $object->info();
         if (is_null($info)) {
             continue;
         }
         $test = get_param_integer('search_' . $hook, 0);
         if (($test == 1 || get_param_integer('all_defaults', 0) == 1 && $info['default'] || $id == $hook) && ($id == '' || $id == $hook)) {
             // Category filter
             if ($search_under != '!' && $search_under != '-1' && array_key_exists('category', $info)) {
                 $cats = explode(',', $search_under);
                 $where_clause = '(';
                 foreach ($cats as $cat) {
                     if (trim($cat) == '') {
                         continue;
                     }
                     if ($where_clause != '(') {
                         $where_clause .= ' OR ';
                     }
                     if ($info['integer_category']) {
                         $where_clause .= (strpos($info['category'], '.') !== false ? '' : 'r.') . $info['category'] . '=' . strval((int) $cat);
                     } else {
                         $where_clause .= db_string_equal_to((strpos($info['category'], '.') !== false ? '' : 'r.') . $info['category'], $cat);
                     }
                 }
                 $where_clause .= ')';
             } else {
                 $where_clause = '';
             }
             $only_search_meta = get_param_integer('only_search_meta', 0) == 1;
             $direction = get_param('direction', 'ASC');
             if (function_exists('set_time_limit')) {
                 @set_time_limit(5);
             }
             // Prevent errant search hooks (easily written!) taking down a server. Each call given 5 seconds (calling set_time_limit resets the timer).
             $hook_results = $object->run($content, $only_search_meta, $direction, $max, $start, $only_titles, $content_where, $author, $author_id, $cutoff, $sort, $max, $boolean_operator, $where_clause, $search_under, $boolean_search ? 1 : 0);
             if (is_null($hook_results)) {
                 continue;
             }
             foreach ($hook_results as $i => $result) {
                 $result['object'] = $object;
                 $hook_results[$i] = $result;
             }
             $results = sort_search_results($hook_results, $results, $direction);
         }
     }
     if (function_exists('set_time_limit')) {
         @set_time_limit(15);
     }
     global $EXTRA_HEAD;
     $EXTRA_HEAD->attach('<meta name="robots" content="noindex,nofollow" />');
     // XHTMLXHTML
     // Now glue our templates together
     $out = build_search_results_interface($results, $start, $max, $direction, $id == '');
     if ($out->is_empty()) {
         if ($days != -1 && $GLOBALS['TOTAL_RESULTS'] == 0) {
             $ret_maybe = $this->results($id, $author, $author_id, -1, $sort, $direction, $only_titles, $search_under);
             if (!$ret_maybe[0]->is_empty()) {
                 attach_message(do_lang_tempcode('NO_RESULTS_DAYS', escape_html(integer_format($days))), 'notice');
                 return $ret_maybe;
             }
         }
         return array(new ocp_tempcode(), new ocp_tempcode(), 0);
     }
     require_code('templates_results_browser');
     $results_browser = results_browser(do_lang_tempcode('RESULTS'), NULL, $start, 'start', $max, 'max', $GLOBALS['TOTAL_RESULTS'], NULL, 'results', true, true);
     if ($start == 0) {
         $GLOBALS['SITE_DB']->query_insert('searches_logged', array('s_member_id' => get_member(), 's_time' => time(), 's_primary' => substr($content, 0, 255), 's_auxillary' => serialize(array_merge($_POST, $_GET)), 's_num_results' => count($results)));
     }
     return array($out, $results_browser, $GLOBALS['TOTAL_RESULTS']);
 }