コード例 #1
0
 /**
  * Get the products handled by this eCommerce hook.
  *
  * IMPORTANT NOTE TO PROGRAMMERS: This function may depend only on the database, and not on get_member() or any GET/POST values.
  *  Such dependencies will break IPN, which works via a Guest and no dependable environment variables. It would also break manual transactions from the Admin Zone.
  *
  * @param  boolean	Whether to make sure the language for item_name is the site default language (crucial for when we read/go to third-party sales systems and use the item_name as a key).
  * @param  ?ID_TEXT	Product being searched for (NULL: none).
  * @param  boolean 	Whether $search refers to the product name rather than the product_id.
  * @return array		A map of product name to list of product details.
  */
 function get_products($site_lang = false, $search = NULL, $search_titles_not_ids = false)
 {
     if (is_null($search)) {
         $cnt = $GLOBALS['SITE_DB']->query_value('catalogue_entries t1 LEFT JOIN ' . get_table_prefix() . 'catalogues t2 ON t1.c_name=t2.c_name', 'COUNT(*)', array('c_ecommerce' => 1));
         if ($cnt > 50) {
             return array();
         }
         // Too many to list
     }
     require_code('catalogues');
     $products = array();
     $where = array('c_ecommerce' => 1);
     if (!is_null($search)) {
         if (!$search_titles_not_ids) {
             if (!is_numeric($search)) {
                 return array();
             }
             $where['id'] = intval($search);
         } else {
             // Unfortunately no easy efficient solution due to inability to do easy querying on catalogue fields. However, practically speaking, this code path will not be called, as catalogue items are purchased as part of a card order rather than separately.
         }
     }
     if (function_exists('set_time_limit')) {
         @set_time_limit(0);
     }
     $start = 0;
     do {
         $items = $GLOBALS['SITE_DB']->query_select('catalogue_entries t1 LEFT JOIN ' . get_table_prefix() . 'catalogues t2 ON t1.c_name=t2.c_name', array('t1.id', 't1.c_name'), $where, '', 500, $start);
         foreach ($items as $ecomm_item) {
             $map = get_catalogue_entry_field_values($ecomm_item['c_name'], $ecomm_item['id'], NULL, NULL, true);
             $product_title = array_key_exists('effective_value_pure', $map[0]) ? $map[0]['effective_value_pure'] : $map[0]['effective_value'];
             if (!is_null($search) && $search_titles_not_ids) {
                 if ($product_title != $search) {
                     continue;
                 }
             }
             $item_price = '0.0';
             $tax = 0.0;
             $product_weight = 0.0;
             if (array_key_exists(2, $map)) {
                 $item_price = is_object($map[2]['effective_value']) ? $map[2]['effective_value']->evaluate() : $map[2]['effective_value'];
             }
             if (array_key_exists(6, $map)) {
                 $tax = floatval(is_object($map[6]['effective_value']) ? $map[6]['effective_value']->evaluate() : $map[6]['effective_value']);
             }
             if (array_key_exists(8, $map)) {
                 $product_weight = floatval(is_object($map[8]['effective_value']) ? $map[8]['effective_value']->evaluate() : $map[8]['effective_value']);
             }
             $price = float_to_raw_string($this->calculate_product_price(floatval($item_price), $tax, $product_weight));
             /* For catalogue items we make the numeric product ID the raw ID for the eCommerce item. This is unique to catalogue items (necessarily so, to avoid conflicts), and we do it for convenience */
             $products[strval($ecomm_item['id'])] = array(PRODUCT_CATALOGUE, $price, 'handle_catalogue_items', array('tax' => $tax), $product_title);
         }
         $start += 500;
     } while (count($items) == 500);
     return $products;
 }
コード例 #2
0
ファイル: classifieds.php プロジェクト: erico-deh/ocPortal
 /**
  * Get the products handled by this eCommerce hook.
  *
  * @return array		A map of product name to list of product details.
  */
 function get_products()
 {
     require_lang('classifieds');
     $prices = $GLOBALS['SITE_DB']->query_select('classifieds_prices', array('id', 'c_label', 'c_price'), NULL, 'ORDER BY c_price');
     $products = array();
     foreach ($prices as $price) {
         if ($price['c_price'] != 0.0) {
             $products['CLASSIFIEDS_ADVERT_' . strval($price['id'])] = array(PRODUCT_PURCHASE_WIZARD, float_to_raw_string($price['c_price']), 'handle_classifieds_advert', array(), do_lang('CLASSIFIED_ADVERT_BUY', get_translated_text($price['c_label'])));
         }
     }
     return $products;
 }
コード例 #3
0
 /**
  * This will get the XML file from ocportal.com.
  *
  * @param  ?ID_TEXT		The ID to do under (NULL: root)
  * @return string			The XML file
  */
 function get_file($id)
 {
     $stub = get_param_integer('localhost', 0) == 1 ? get_base_url() : 'http://ocportal.com';
     $v = 'Version ' . float_to_raw_string(ocp_version_number(), 1);
     if (!is_null($id)) {
         $v = $id;
     }
     $url = $stub . '/data/ajax_tree.php?hook=choose_download&id=' . rawurlencode($v) . '&file_type=tar';
     require_code('character_sets');
     $contents = http_download_file($url);
     $utf = $GLOBALS['HTTP_CHARSET'] == 'utf-8';
     // We have to use 'U' in the regexp to work around a Chrome parser bug (we can't rely on convert_to_internal_encoding being 100% correct)
     require_code('character_sets');
     $contents = convert_to_internal_encoding($contents);
     $contents = preg_replace('#^\\s*\\<' . '\\?xml version="1.0" encoding="[^"]*"\\?' . '\\>\\<request\\>#' . ($utf ? 'U' : ''), '', $contents);
     $contents = preg_replace('#</request>#' . ($utf ? 'U' : ''), '', $contents);
     $contents = preg_replace('#<category [^>]*has_children="false"[^>]*>[^>]*</category>#' . ($utf ? 'U' : ''), '', $contents);
     $contents = preg_replace('#<category [^>]*title="Manual install required"[^>]*>[^>]*</category>#' . ($utf ? 'U' : ''), '', $contents);
     return $contents;
 }
コード例 #4
0
ファイル: xmlrpc.php プロジェクト: erico-deh/ocPortal
/**
 * Convert some data to XML-RPC format.
 *
 * @param  mixed		Data
 * @return string		XML-RPC format version
 */
function _xml_rpc_type_convert($_value)
{
    switch (gettype($_value)) {
        case 'boolean':
            $value = '<boolean>' . ($_value ? '1' : '0') . '</boolean>';
            break;
        case 'array':
            $keys = array_keys($_value);
            if (count($_value) > 0 && !is_integer(array_pop($keys))) {
                $value = '<struct>';
                foreach ($_value as $k => $v) {
                    $value .= '<name>' . $k . '</name><value>' . _xml_rpc_type_convert($v) . '</value>';
                }
                $value .= '</struct>';
            } else {
                $value = '<array><data>';
                foreach ($_value as $v) {
                    $value .= '<value>' . _xml_rpc_type_convert($v) . '</value>';
                }
                $value .= '</data></array>';
            }
            break;
        case 'object':
            $value = '<string>' . xmlentities($_value->evaluate()) . '</string>';
            break;
        case 'integer':
            $value = '<i4>' . strval($_value) . '</i4>';
            break;
        case 'float':
            $value = '<double>' . float_to_raw_string($_value) . '</double>';
            break;
        case 'NULL':
            $value = '<nil/>';
            break;
        default:
            $value = '<string>' . xmlentities(strval($_value)) . '</string>';
            break;
    }
    return $value;
}
コード例 #5
0
ファイル: exif.php プロジェクト: erico-deh/ocPortal
/**
 * Work out canonical Latitude/Longitude details from complex EXIF bits.
 *
 * @param  array		EXIF data
 * @return array		Extra derived EXIF data
 */
function _get_simple_gps($exif)
{
    // Based on http://stackoverflow.com/questions/2526304/php-extract-gps-exif-data
    $result = array();
    if (!isset($exif['GPSLatitude'])) {
        return array();
    }
    if (!isset($exif['GPSLongitude'])) {
        return array();
    }
    // get the Hemisphere multiplier
    $lat_m = 1;
    $long_m = 1;
    if ($exif['GPSLatitudeRef'] == 'S') {
        $lat_m = -1;
    }
    if ($exif['GPSLongitudeRef'] == 'W') {
        $long_m = -1;
    }
    // get the GPS data
    $gps = array();
    if (!is_array($exif['GPSLatitude'])) {
        $result['Latitude'] = $exif['GPSLatitude'];
        $result['Latitude'] = $exif['GPSLatitude'];
        return $result;
    }
    $gps['LatDegree'] = $exif['GPSLatitude'][0];
    $gps['LatMinute'] = $exif['GPSLatitude'][1];
    $gps['LatgSeconds'] = isset($exif['GPSLatitude'][2]) ? $exif['GPSLatitude'][2] : 0;
    $gps['LongDegree'] = $exif['GPSLongitude'][0];
    $gps['LongMinute'] = $exif['GPSLongitude'][1];
    $gps['LongSeconds'] = isset($exif['GPSLongitude'][2]) ? $exif['GPSLongitude'][2] : 0;
    // calculate the decimal degree
    $result['Latitude'] = float_to_raw_string(floatval($lat_m) * ($gps['LatDegree'] + $gps['LatMinute'] / 60.0 + $gps['LatgSeconds'] / 3600.0));
    $result['Longitude'] = float_to_raw_string(floatval($long_m) * ($gps['LongDegree'] + $gps['LongMinute'] / 60.0 + $gps['LongSeconds'] / 3600.0));
    return $result;
}
コード例 #6
0
ファイル: ocp_merge.php プロジェクト: erico-deh/ocPortal
 /**
  * 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_catalogues($db, $table_prefix, $file_base)
 {
     require_code('catalogues2');
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'catalogues', NULL, NULL, true);
     if (is_null($rows)) {
         return;
     }
     foreach ($rows as $row) {
         if (import_check_if_imported('catalogue', $row['c_name'])) {
             continue;
         }
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => $row['c_name']));
         if (is_null($test)) {
             $row['c_title'] = insert_lang($this->get_lang_string($db, $row['c_title']), 2);
             $row['c_description'] = insert_lang($this->get_lang_string($db, $row['c_description']), 2);
             if (!array_key_exists('c_display_type', $row)) {
                 $row['c_display_type'] = $row['c_own_pages'];
                 unset($row['c_own_pages']);
             }
             if (!array_key_exists('c_ecommerce', $row)) {
                 $row['c_ecommerce'] = 0;
             }
             if (!array_key_exists('c_send_view_reports', $row)) {
                 $row['c_send_view_reports'] = 0;
             }
             unset($row['c_own_template']);
             $GLOBALS['SITE_DB']->query_insert('catalogues', $row);
             import_id_remap_put('catalogue', $row['c_name'], $row['c_name']);
             $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'catalogue_fields WHERE ' . db_string_equal_to('c_name', $row['c_name']));
             foreach ($rows2 as $row2) {
                 if (import_check_if_imported('catalogue_field', strval($row2['id']))) {
                     continue;
                 }
                 $row2['cf_name'] = insert_lang($this->get_lang_string($db, $row2['cf_name']), 2);
                 $row2['cf_description'] = insert_lang($this->get_lang_string($db, $row2['cf_description']), 2);
                 if (!array_key_exists('cf_put_in_category', $row2)) {
                     $row2['cf_put_in_category'] = 1;
                 }
                 if (!array_key_exists('cf_put_in_search', $row2)) {
                     $row2['cf_put_in_search'] = 1;
                 }
                 $old_id = $row2['id'];
                 unset($row2['id']);
                 $id_new = $GLOBALS['SITE_DB']->query_insert('catalogue_fields', $row2, true);
                 import_id_remap_put('catalogue_field', $old_id, $id_new);
             }
         } else {
             warn_exit(do_lang_tempcode('CANNOT_MERGE_CATALOGUES'));
         }
     }
     $this->_import_review_supplement($db, $table_prefix, 'catalogues', 'catalogue_entry');
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'catalogue_categories ORDER BY id');
     $id = mixed();
     foreach ($rows as $row) {
         if (import_check_if_imported('catalogue_category', strval($row['id']))) {
             continue;
         }
         if (is_null($row['cc_parent_id']) && $GLOBALS['SITE_DB']->query_value('catalogues', 'c_is_tree', array('c_name' => $row['c_name'])) == 1) {
             $real_root = $GLOBALS['SITE_DB']->query_value_null_ok('catalogue_categories', 'id', array('cc_parent_id' => NULL, 'c_name' => $row['c_name']));
             if (!is_null($real_root)) {
                 import_id_remap_put('catalogue_category', strval($row['id']), $real_root);
                 continue;
             }
         }
         $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id'];
         $rep_image = array_key_exists('cc_rep_image', $row) ? $row['cc_rep_image'] : '';
         $id_new = actual_add_catalogue_category($row['c_name'], $this->get_lang_string($db, $row['cc_title']), $this->get_lang_string($db, $row['cc_description']), $row['cc_notes'], is_null($row['cc_parent_id']) ? NULL : -$row['cc_parent_id'], $rep_image, array_key_exists('cc_move_days_lower', $row) ? $row['cc_move_days_lower'] : 30, array_key_exists('cc_move_days_higher', $row) ? $row['cc_move_days_higher'] : 60, array_key_exists('cc_move_target', $row) ? $row['cc_move_target'] : NULL, $row['cc_add_date'], $id);
         import_id_remap_put('catalogue_category', strval($row['id']), $id_new);
     }
     $rows = $GLOBALS['SITE_DB']->query('SELECT id,cc_parent_id FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'catalogue_categories WHERE cc_parent_id<0');
     foreach ($rows as $row) {
         $parent_id = import_id_remap_get('catalogue_category', -$row['cc_parent_id'], true);
         $GLOBALS['SITE_DB']->query_update('catalogue_categories', array('cc_parent_id' => $parent_id), array('id' => $row['id']), '', 1);
     }
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'catalogue_entries ORDER BY id');
     $on_same_msn = $this->on_same_msn($file_base);
     foreach ($rows as $row) {
         if (!is_null(import_id_remap_get('catalogue_entry', strval($row['id']), true))) {
             continue;
         }
         $category_id = import_id_remap_get('catalogue_category', $row['cc_id'], true);
         if (is_null($category_id)) {
             continue;
         }
         $map = array();
         // Tedious...
         foreach (array('long', 'short', 'float', 'integer') as $table) {
             $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'catalogue_efv_' . $table . ' WHERE ce_id=' . strval((int) $row['id']), NULL, NULL, true);
             if (!is_null($rows2)) {
                 foreach ($rows2 as $row2) {
                     $remapped = import_id_remap_get('catalogue_field', $row2['cf_id'], true);
                     if (is_null($remapped)) {
                         continue;
                     }
                     $value = $row2['cv_value'];
                     if (is_integer($value)) {
                         $value = strval($value);
                     } elseif (is_float($value)) {
                         $value = float_to_raw_string($value);
                     }
                     $map[$remapped] = $value;
                 }
             }
         }
         $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'catalogue_efv_long_trans WHERE ce_id=' . strval((int) $row['id']));
         foreach ($rows2 as $row2) {
             $remapped = import_id_remap_get('catalogue_field', $row2['cf_id'], true);
             if (is_null($remapped)) {
                 continue;
             }
             $map[$remapped] = $this->get_lang_string($db, $row2['cv_value']);
         }
         $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'catalogue_efv_short_trans WHERE ce_id=' . strval((int) $row['id']));
         foreach ($rows2 as $row2) {
             $remapped = import_id_remap_get('catalogue_field', $row2['cf_id'], true);
             if (is_null($remapped)) {
                 continue;
             }
             $map[$remapped] = $this->get_lang_string($db, $row2['cv_value']);
         }
         $submitter = $on_same_msn ? $row['ce_submitter'] : import_id_remap_get('member', $row['ce_submitter'], true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id();
         }
         $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id'];
         $id_new = actual_add_catalogue_entry($category_id, $row['ce_validated'], $row['notes'], $row['allow_rating'], $row['allow_comments'], $row['allow_trackbacks'], $map, $row['ce_add_date'], $submitter, $row['ce_edit_date'], $row['ce_views'], $id);
         import_id_remap_put('catalogue_entry', strval($row['id']), $id_new);
     }
     $this->_import_catalogue_entry_linkage($db, $table_prefix, 'catalogue', NULL);
     $this->_import_catalogue_entry_linkage($db, $table_prefix, 'catalogue_category', 'catalogue_category');
 }
コード例 #7
0
ファイル: caches.php プロジェクト: erico-deh/ocPortal
/**
 * Put data into the persistant cache.
 *
 * @param  mixed			Key
 * @param  mixed			The data
 * @param  boolean		Whether it is server-wide data
 * @param  ?integer		The expiration time in seconds. (NULL: Default expiry in 60 minutes, or never if it is server-wide).
 */
function persistant_cache_set($key, $data, $server_wide = false, $expire_secs = NULL)
{
    $server_wide = false;
    global $MEM_CACHE;
    if ($MEM_CACHE === NULL) {
        return NULL;
    }
    if ($expire_secs === NULL) {
        $expire_secs = $server_wide ? 0 : 60 * 60;
    }
    $MEM_CACHE->set(($server_wide ? 'ocp' . float_to_raw_string(ocp_version_number()) : get_file_base()) . serialize($key), $data, 0, $expire_secs);
}
コード例 #8
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_code('catalogues');
     require_lang('main_google_map');
     // Set up config/defaults
     if (!array_key_exists('title', $map)) {
         $map['title'] = '';
     }
     if (!array_key_exists('region', $map)) {
         $map['region'] = '';
     }
     if (!array_key_exists('latitude', $map)) {
         $map['latitude'] = '0';
     }
     if (!array_key_exists('longitude', $map)) {
         $map['longitude'] = '0';
     }
     $mapwidth = array_key_exists('width', $map) ? $map['width'] : '100%';
     $mapheight = array_key_exists('height', $map) ? $map['height'] : '300px';
     $api_key = array_key_exists('api_key', $map) ? $map['api_key'] : '';
     $set_zoom = array_key_exists('zoom', $map) ? $map['zoom'] : '3';
     $set_center = array_key_exists('center', $map) ? $map['center'] : '0';
     $set_show_links = array_key_exists('show_links', $map) ? $map['show_links'] : '1';
     $cluster = array_key_exists('cluster', $map) ? $map['cluster'] : '0';
     if (!array_key_exists('catalogue', $map)) {
         $map['catalogue'] = '';
     }
     if (!array_key_exists('longfield', $map)) {
         $map['longfield'] = 'Longitude';
     }
     if (!array_key_exists('latfield', $map)) {
         $map['latfield'] = 'Latitude';
     }
     $min_latitude = array_key_exists('min_latitude', $map) ? $map['min_latitude'] : '';
     $max_latitude = array_key_exists('max_latitude', $map) ? $map['max_latitude'] : '';
     $min_longitude = array_key_exists('min_longitude', $map) ? $map['min_longitude'] : '';
     $max_longitude = array_key_exists('max_longitude', $map) ? $map['max_longitude'] : '';
     $longitude_key = $map['longfield'];
     $latitude_key = $map['latfield'];
     $catalogue_name = $map['catalogue'];
     $star_entry = array_key_exists('star_entry', $map) ? $map['star_entry'] : '';
     $max_results = array_key_exists('max_results', $map) && $map['max_results'] != '' ? intval($map['max_results']) : 1000;
     $icon = array_key_exists('icon', $map) ? $map['icon'] : '';
     if (!array_key_exists('filter_category', $map)) {
         $map['filter_category'] = '';
     }
     if (!array_key_exists('filter_rating', $map)) {
         $map['filter_rating'] = '';
     }
     if (!array_key_exists('filter_term', $map)) {
         $map['filter_term'] = '';
     }
     if (!array_key_exists('filter_hours', $map)) {
         $map['filter_hours'] = '';
     }
     $data = array();
     if ($catalogue_name != '') {
         // Data query
         $query = 'SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'catalogue_entries WHERE ce_validated=1 AND ' . db_string_equal_to('c_name', $catalogue_name);
         // Filtering
         if ($map['filter_category'] != '') {
             require_code('ocfiltering');
             $query .= ' AND (' . ocfilter_to_sqlfragment($map['filter_category'], 'id', 'catalogue_categories', 'cc_parent_id', 'cc_id', 'id') . ')';
         }
         if ($map['filter_hours'] != '') {
             $query .= ' AND ce_add_date>' . strval(time() - 60 * 60 * intval($map['filter_hours']));
         }
         if ($map['filter_rating'] != '') {
             $query .= ' AND (SELECT AVG(rating) FROM rating WHERE ' . db_string_equal_to('rating_for_type', 'catalogue_entry') . ' AND rating_for_id=id)>' . strval(intval($map['filter_rating']));
         }
         // Info about our catalogue
         $catalogue_rows = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue_name), '', 1);
         if (!array_key_exists(0, $catalogue_rows)) {
             return paragraph('Could not find the catalogue named "' . escape_html($catalogue_name) . '".', '', 'nothing_here');
         }
         $catalogue_row = $catalogue_rows[0];
         // Get results
         $entries_to_show = array();
         if ($star_entry != '') {
             $entries_to_show = array_merge($entries_to_show, $GLOBALS['SITE_DB']->query($query . ' AND id=' . strval(intval($star_entry))));
             $query .= ' AND id<>' . strval(intval($star_entry));
         }
         $entries_to_show = array_merge($entries_to_show, $GLOBALS['SITE_DB']->query($query . ' ORDER BY ce_add_date DESC', $max_results));
         if (count($entries_to_show) == 0 && ($min_latitude == '' || $max_latitude == '' || $min_longitude == '' || $max_longitude == '')) {
             //return paragraph(do_lang_tempcode('NO_ENTRIES'),'','nothing_here');
         }
         // Make marker data Javascript-friendly
         foreach ($entries_to_show as $i => $entry_row) {
             $entry_row['allow_rating'] = 0;
             // Performance: So rating is not loaded
             $details = get_catalogue_entry_map($entry_row, $catalogue_row, 'CATEGORY', $catalogue_name, NULL);
             $two_d_list = $details['FIELDS_2D'];
             $longitude = NULL;
             $latitude = NULL;
             $entry_title = '';
             $all_output = '';
             foreach ($two_d_list as $index => $l) {
                 if ($l['NAME'] == $longitude_key) {
                     $longitude = $l['VALUE'];
                 }
                 if ($l['NAME'] == $latitude_key) {
                     $latitude = $l['VALUE'];
                 }
                 if ($index == 0) {
                     $entry_title = $l['VALUE'];
                 }
                 $all_output .= (is_object($l['VALUE']) ? $l['VALUE']->evaluate() : $l['VALUE']) . ' ';
             }
             if (is_object($longitude)) {
                 $longitude = $longitude->evaluate();
             }
             if (is_object($latitude)) {
                 $latitude = $latitude->evaluate();
             }
             if (is_object($entry_title)) {
                 $entry_title = $entry_title->evaluate();
             }
             if (is_numeric($longitude) && is_numeric($latitude)) {
                 if ($map['filter_term'] == '' || strpos(strtolower($all_output), strtolower($map['filter_term'])) !== false) {
                     $details['LONGITUDE'] = float_to_raw_string(floatval($longitude));
                     $details['LATITUDE'] = float_to_raw_string(floatval($latitude));
                     $details['ENTRY_TITLE'] = $entry_title;
                     $entry_content = do_template('CATALOGUE_googlemap_ENTRY_EMBED', $details, NULL, false, 'CATALOGUE_DEFAULT_ENTRY_EMBED');
                     //put_in_standard_box(hyperlink($url,do_lang_tempcode('VIEW')),do_lang_tempcode('CATALOGUE_ENTRY').' ('.do_lang_tempcode('IN',get_translated_text($catalogue['c_title'])).')');
                     $details['ENTRY_CONTENT'] = $entry_content;
                     $details['STAR'] = '0';
                     if ($star_entry != '') {
                         if ($entry_row['id'] == intval($star_entry)) {
                             $details['STAR'] = '1';
                         }
                     }
                     $details['CC_ID'] = strval($entry_row['cc_id']);
                     $details['ICON'] = '';
                     $data[] = $details;
                 }
             }
         }
     }
     $hooks_to_use = explode('|', array_key_exists('extra_sources', $map) ? $map['extra_sources'] : '');
     $hooks = find_all_hooks('blocks', 'main_google_map');
     foreach (array_keys($hooks) as $hook) {
         if (in_array($hook, $hooks_to_use)) {
             require_code('hooks/blocks/main_google_map/' . $hook);
             $ob = object_factory('Hook_Map_' . $hook);
             $data = array_merge($data, $ob->get_data($map, $max_results, $min_latitude, $max_latitude, $min_longitude, $max_longitude, $latitude_key, $longitude_key, $catalogue_row, $catalogue_name));
         }
     }
     $uniqid = uniqid('', true);
     $div_id = 'div_' . $catalogue_name . '_' . $uniqid;
     return do_template('BLOCK_MAIN_GOOGLE_MAP', array('TITLE' => $map['title'], 'ICON' => $icon, 'MIN_LATITUDE' => $min_latitude, 'MAX_LATITUDE' => $max_latitude, 'MIN_LONGITUDE' => $min_longitude, 'MAX_LONGITUDE' => $max_longitude, 'DATA' => $data, 'SHOW_LINKS' => $set_show_links, 'DIV_ID' => $div_id, 'CLUSTER' => $cluster, 'REGION' => $map['region'], 'WIDTH' => $mapwidth, 'HEIGHT' => $mapheight, 'LATITUDE' => $map['latitude'], 'LONGITUDE' => $map['longitude'], 'ZOOM' => $set_zoom, 'CENTER' => $set_center));
 }
コード例 #9
0
ファイル: admin_config.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if ($upgrade_from < 3 || is_null($upgrade_from)) {
         add_config_option('MOD_REWRITE', 'mod_rewrite', 'tick', 'return \'' . (in_array(ocp_srv('HTTP_HOST'), array('test.ocportal.com')) ? '1' : '0') . '\'; /*function_exists(\'apache_get_modules\')?\'1\':\'0\';*/', 'SITE', 'ADVANCED');
     }
     if ($upgrade_from < 4 || is_null($upgrade_from)) {
         add_config_option('SESSION_EXPIRY_TIME', 'session_expiry_time', 'integer', 'return \'1\';', 'SECURITY', 'GENERAL');
     }
     if ($upgrade_from < 5 || is_null($upgrade_from)) {
         add_config_option('TRACKBACKS', 'is_on_trackbacks', 'tick', 'return \'0\';', 'FEATURE', 'USER_INTERACTION');
         add_config_option('UNZIP_DIR', 'unzip_dir', 'line', 'return (DIRECTORY_SEPARATOR==\'/\')?\'/tmp/\':ocp_srv(\'TMP\');', 'SITE', 'ARCHIVES', 1);
         add_config_option('UNZIP_CMD', 'unzip_cmd', 'line', 'return \'/usr/bin/unzip -o @_SRC_@ -x -d @_DST_@\';', 'SITE', 'ARCHIVES', 1);
         add_config_option('ENABLED', 'smtp_sockets_use', 'tick', 'return \'0\';', 'SITE', 'SMTP', 1);
         add_config_option('HOST', 'smtp_sockets_host', 'line', 'return \'mail.yourispwhateveritis.net\';', 'SITE', 'SMTP', 1);
         add_config_option('PORT', 'smtp_sockets_port', 'line', 'return \'25\';', 'SITE', 'SMTP', 1);
         add_config_option('USERNAME', 'smtp_sockets_username', 'line', 'return \'\';', 'SITE', 'SMTP', 1);
         add_config_option('PASSWORD', 'smtp_sockets_password', 'line', 'return \'\';', 'SITE', 'SMTP', 1);
         add_config_option('EMAIL_ADDRESS', 'smtp_from_address', 'line', 'return \'\';', 'SITE', 'SMTP', 1);
         add_config_option('USE_SECURITY_IMAGES', 'use_security_images', 'tick', 'return addon_installed(\'captcha\')?\'1\':NULL;', 'SECURITY', 'GENERAL');
         add_config_option('HTTPS_SUPPORT', 'enable_https', 'tick', 'return \'0\';', 'SECURITY', 'GENERAL', 1);
         add_config_option('SEND_ERROR_EMAILS_OCPRODUCTS', 'send_error_emails_ocproducts', 'tick', 'return \'' . strval(post_param_integer('allow_reports_default', 0)) . '\';', 'SITE', 'ADVANCED', 1);
         add_config_option('LOW_DISK_SPACE_SUBJECT', 'low_space_check', 'integer', 'return \'20\';', 'SITE', 'GENERAL');
         // 20MB - very very low even for lame web hosts
         add_config_option('DETECT_LANG_FORUM', 'detect_lang_forum', 'tick', 'return \'1\';', 'SITE', 'ADVANCED');
         add_config_option('DETECT_LANG_BROWSER', 'detect_lang_browser', 'tick', 'return \'0\';', 'SITE', 'ADVANCED');
     }
     if ($upgrade_from < 7 && !is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->query_update('config', array('eval' => 'return has_no_forum()?NULL:do_template(\'COMMENTS_DEFAULT_TEXT\');'), array('the_name' => 'comment_text'), '', 1);
         if ($GLOBALS['OPTIONS']['comment_text']['c_set'] == 0) {
             $tpl = do_template('COMMENTS_DEFAULT_TEXT');
             set_option('comment_text', $tpl->evaluate());
         }
         delete_config_option('width_left');
         delete_config_option('width_right');
         set_option('welcome_message', '[html]' . get_option('welcome_message') . '[/html]');
         set_option('closed', '[html]' . get_option('closed') . '[/html]');
         delete_config_option('xhtml_validation');
     }
     if (is_null($upgrade_from) || $upgrade_from < 7) {
         add_config_option('ALLOW_AUDIO_VIDEOS', 'allow_audio_videos', 'tick', 'return \'1\';', 'SITE', 'ADVANCED');
         add_config_option('VALIDATION', 'validation', 'tick', 'return \'0\';', 'SITE', 'VALIDATION', 1);
         /*(((substr(ocp_srv('HTTP_HOST'),0,8)=='192.168.') || (substr(ocp_srv('HTTP_HOST'),0,7)=='10.0.0.') || (in_array(ocp_srv('HTTP_HOST'),array('localhost','test.ocportal.com'))))?'1':'0')*/
         // return (!function_exists(\'memory_get_usage()\') || (ini_get(\'memory_limit\')!=\'8M\'))?\'1\':\'0\';
         add_config_option('VALIDATION_XHTML', 'validation_xhtml', 'tick', 'return \'1\';', 'SITE', 'VALIDATION', 1);
         add_config_option('VALIDATION_WCAG', 'validation_wcag', 'tick', 'return \'1\';', 'SITE', 'VALIDATION', 1);
         add_config_option('VALIDATION_CSS', 'validation_css', 'tick', 'return \'0\';', 'SITE', 'VALIDATION', 1);
         add_config_option('VALIDATION_JAVASCRIPT', 'validation_javascript', 'tick', 'return \'0\';', 'SITE', 'VALIDATION', 1);
         add_config_option('VALIDATION_COMPAT', 'validation_compat', 'tick', 'return \'0\';', 'SITE', 'VALIDATION', 1);
         add_config_option('VALIDATION_EXT_FILES', 'validation_ext_files', 'tick', 'return \'0\';', 'SITE', 'VALIDATION', 1);
         add_config_option('MAX_SIZE', 'max_download_size', 'integer', 'return \'20000\';', 'SITE', 'UPLOAD');
     }
     if (is_null($upgrade_from) || $upgrade_from < 8) {
         // TODO: Move these into sms addon_registry hook, once these hooks support installation
         add_config_option('USERNAME', 'sms_username', 'line', 'return addon_installed(\'sms\')?\'\':NULL;', 'FEATURE', 'SMS');
         add_config_option('PASSWORD', 'sms_password', 'line', 'return addon_installed(\'sms\')?\'\':NULL;', 'FEATURE', 'SMS');
         add_config_option('API_ID', 'sms_api_id', 'integer', 'return addon_installed(\'sms\')?\'\':NULL;', 'FEATURE', 'SMS');
         add_config_option('SMS_LOW_LIMIT', 'sms_low_limit', 'integer', 'return addon_installed(\'sms\')?\'10\':NULL;', 'FEATURE', 'SMS');
         add_config_option('SMS_HIGH_LIMIT', 'sms_high_limit', 'integer', 'return addon_installed(\'sms\')?\'20\':NULL;', 'FEATURE', 'SMS');
         add_config_option('SMS_LOW_TRIGGER_LIMIT', 'sms_low_trigger_limit', 'integer', 'return addon_installed(\'sms\')?\'50\':NULL;', 'FEATURE', 'SMS');
         add_config_option('SMS_HIGH_TRIGGER_LIMIT', 'sms_high_trigger_limit', 'integer', 'return addon_installed(\'sms\')?\'100\':NULL;', 'FEATURE', 'SMS');
         add_config_option('ALLOWED_POST_SUBMITTERS', 'allowed_post_submitters', 'text', 'return \'\';', 'SECURITY', 'ADVANCED', 1);
         add_config_option('STRONG_FORUM_TIE', 'is_on_strong_forum_tie', 'tick', 'return \'0\';', 'FEATURE', 'USER_INTERACTION', 1);
         add_config_option('VALIDATION_ON_PREVIEW', 'is_on_preview_validation', 'tick', 'return \'1\';', 'SITE', 'VALIDATION', 1);
         add_config_option('SHOW_INLINE_STATS', 'show_inline_stats', 'tick', 'return \'1\';', 'SITE', 'GENERAL');
         add_config_option('SIMPLIFIED_DONEXT', 'simplified_donext', 'tick', 'return \'0\';', 'SITE', 'ADVANCED');
         add_config_option('ANTI_LEECH', 'anti_leech', 'tick', 'return \'0\';', 'SECURITY', 'GENERAL');
         add_config_option('SSW', 'ssw', 'tick', 'return \'0\';', 'SITE', 'GENERAL');
         add_config_option('ADMIN_MENU', 'bottom_show_admin_menu', 'tick', 'return \'1\';', 'FEATURE', 'BOTTOM_LINKS');
         add_config_option('TOP_LINK', 'bottom_show_top_button', 'tick', 'return \'0\';', 'FEATURE', 'BOTTOM_LINKS');
         add_config_option('FEEDBACK_LINK', 'bottom_show_feedback_link', 'tick', 'return \'1\';', 'FEATURE', 'BOTTOM_LINKS');
         add_config_option('PRIVACY_LINK', 'bottom_show_privacy_link', 'tick', 'return \'1\';', 'FEATURE', 'BOTTOM_LINKS');
         add_config_option('SITEMAP_LINK', 'bottom_show_sitemap_button', 'tick', 'return \'1\';', 'FEATURE', 'BOTTOM_LINKS');
         add_config_option('COUNT_POSTSCOUNT', 'forum_show_personal_stats_posts', 'tick', 'return has_no_forum()?NULL:\'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('COUNT_TOPICSCOUNT', 'forum_show_personal_stats_topics', 'tick', 'return ((has_no_forum()) || (get_forum_type()!=\'ocf\'))?NULL:\'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('ADMIN_ZONE_LINK', 'ocp_show_personal_adminzone_link', 'tick', 'return \'1\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('CONCEDED_MODE_LINK', 'ocp_show_conceded_mode_link', 'tick', 'return \'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('SU', 'ocp_show_su', 'tick', 'return (get_forum_type()==\'none\')?NULL:\'1\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('PAGE_ACTIONS', 'ocp_show_staff_page_actions', 'tick', 'return \'1\';', 'THEME', 'GENERAL');
         add_config_option('MY_PROFILE_LINK', 'ocf_show_profile_link', 'tick', 'return (get_forum_type()==\'none\')?NULL:\'1\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('_USERGROUP', 'ocp_show_personal_usergroup', 'tick', 'return (get_forum_type()==\'none\')?NULL:\'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('LAST_HERE', 'ocp_show_personal_last_visit', 'tick', 'return has_no_forum()?NULL:\'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('AVATAR', 'ocp_show_avatar', 'tick', 'return ((get_forum_type()==\'none\') || ((get_forum_type()==\'ocf\') && (!addon_installed(\'ocf_member_avatars\'))))?NULL:\'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('PANEL_WIDTH', 'panel_width', 'line', 'return \'13.3em\';', 'THEME', 'GENERAL');
         add_config_option('PANEL_WIDTH_SPACED', 'panel_width_spaced', 'line', 'return \'14.3em\';', 'THEME', 'GENERAL');
         add_config_option('ROOT_ZONE_LOGIN_THEME', 'root_zone_login_theme', 'tick', 'return \'0\';', 'THEME', 'GENERAL');
         add_config_option('USE_CUSTOM_ZONE_MENU', 'use_custom_zone_menu', 'tick', 'return \'1\';', 'THEME', 'GENERAL');
         add_config_option('TRAY_SUPPORT', 'tray_support', 'tick', 'return \'1\';', 'THEME', 'GENERAL');
         add_config_option('SHOW_DOCS', 'show_docs', 'tick', 'return \'1\';', 'SITE', 'ADVANCED');
         add_config_option('CAPTCHA_NOISE', 'captcha_noise', 'tick', 'return addon_installed(\'captcha\')?\'1\':NULL;', 'SECURITY', 'SECURITY_IMAGE');
         add_config_option('CAPTCHA_ON_FEEDBACK', 'captcha_on_feedback', 'tick', 'return addon_installed(\'captcha\')?\'0\':NULL;', 'SECURITY', 'SECURITY_IMAGE');
         add_config_option('SHOW_POST_VALIDATION', 'show_post_validation', 'tick', 'return \'1\';', 'SITE', 'ADVANCED');
         add_config_option('IP_FORWARDING', 'ip_forwarding', 'tick', 'return \'0\';', 'SITE', 'ENVIRONMENT');
         add_config_option('FORCE_META_REFRESH', 'force_meta_refresh', 'tick', 'return \'0\';', 'SITE', 'ENVIRONMENT');
         add_config_option('USE_CONTEXTUAL_DATES', 'use_contextual_dates', 'tick', 'return \'1\';', 'SITE', 'ADVANCED');
         add_config_option('EAGER_WYSIWYG', 'eager_wysiwyg', 'tick', 'return \'0\';', 'SITE', 'ADVANCED');
         add_config_option('WEBSITE_EMAIL', 'website_email', 'line', '$staff_address=get_option(\'staff_address\'); $website_email=\'website@\'.get_domain(); if (substr($staff_address,-strlen(get_domain())-1)==\'@\'.get_domain()) $website_email=$staff_address; return $website_email;', 'SITE', 'EMAIL');
         add_config_option('ENVELOPER_OVERRIDE', 'enveloper_override', 'tick', 'return \'0\';', 'SITE', 'EMAIL');
         add_config_option('BCC', 'bcc', 'tick', 'return \'1\';', 'SITE', 'EMAIL');
         add_config_option('ALLOW_EXT_IMAGES', 'allow_ext_images', 'tick', 'return \'0\';', 'SITE', 'EMAIL');
         add_config_option('HTM_SHORT_URLS', 'htm_short_urls', 'tick', 'return \'0\';', 'SITE', 'ADVANCED');
         add_config_option('IP_STRICT_FOR_SESSIONS', 'ip_strict_for_sessions', 'tick', 'return \'1\';', 'SECURITY', 'GENERAL');
         add_config_option('ENABLE_PREVIEWS', 'enable_previews', 'tick', 'return \'1\';', 'SITE', 'PREVIEW');
         add_config_option('ENABLE_KEYWORD_DENSITY_CHECK', 'enable_keyword_density_check', 'tick', 'return \'0\';', 'SITE', 'PREVIEW');
         add_config_option('ENABLE_SPELL_CHECK', 'enable_spell_check', 'tick', 'return function_exists(\'pspell_check\')?\'0\':NULL;', 'SITE', 'PREVIEW');
         add_config_option('ENABLE_MARKUP_VALIDATION', 'enable_markup_validation', 'tick', 'return \'0\';', 'SITE', 'PREVIEW');
         add_config_option('ENABLE_IMAGE_FADING', 'enable_image_fading', 'tick', 'return \'1\';', 'THEME', 'GENERAL');
     }
     if (is_null($upgrade_from) || $upgrade_from < 9) {
         add_config_option('AUTO_SUBMIT_SITEMAP', 'auto_submit_sitemap', 'tick', 'return \'0\';', 'SITE', 'GENERAL');
         add_config_option('USER_POSTSIZE_ERRORS', 'user_postsize_errors', 'tick', 'return is_null($old=get_value(\'no_user_postsize_errors\'))?\'1\':invert_value($old);', 'SITE', 'UPLOAD');
         add_config_option('AUTOMATIC_META_EXTRACTION', 'automatic_meta_extraction', 'tick', 'return is_null($old=get_value(\'no_auto_meta\'))?\'1\':invert_value($old);', 'SITE', 'GENERAL');
         add_config_option('IS_ON_EMOTICON_CHOOSERS', 'is_on_emoticon_choosers', 'tick', 'return is_null($old=get_value(\'no_emoticon_choosers\'))?\'1\':invert_value($old);', 'THEME', 'GENERAL');
         add_config_option('DEEPER_ADMIN_BREADCRUMBS', 'deeper_admin_breadcrumbs', 'tick', 'return is_null($old=get_value(\'no_admin_menu_assumption\'))?\'1\':invert_value($old);', 'SITE', 'ADVANCED');
         add_config_option('HAS_LOW_MEMORY_LIMIT', 'has_low_memory_limit', 'tick', 'return is_null($old=get_value(\'has_low_memory_limit\'))?((ini_get(\'memory_limit\')==\'-1\' || ini_get(\'memory_limit\')==\'0\' || ini_get(\'memory_limit\')==\'\')?\'0\':NULL):$old;', 'SITE', 'ADVANCED');
         add_config_option('IS_ON_COMCODE_PAGE_CHILDREN', 'is_on_comcode_page_children', 'tick', 'return is_null($old=get_value(\'disable_comcode_page_children\'))?\'1\':invert_value($old);', 'SITE', 'ADVANCED');
         add_config_option('GLOBAL_DONEXT_ICONS', 'global_donext_icons', 'tick', 'return is_null($old=get_value(\'disable_donext_global\'))?\'1\':invert_value($old);', 'SITE', 'ADVANCED');
         add_config_option('NO_STATS_WHEN_CLOSED', 'no_stats_when_closed', 'tick', 'return \'' . (substr(ocp_srv('HTTP_HOST'), 0, 8) == '192.168.' || substr(ocp_srv('HTTP_HOST'), 0, 7) == '10.0.0.' || in_array(ocp_srv('HTTP_HOST'), array('localhost', 'test.ocportal.com')) ? '0' : '1') . '\';', 'SITE', 'CLOSED_SITE');
         add_config_option('NO_BOT_STATS', 'no_bot_stats', 'tick', 'return \'0\';', 'SITE', 'GENERAL');
         add_config_option('FILE_SYSTEM_CACHING', 'filesystem_caching', 'tick', 'return \'0\';', 'SITE', 'CACHES');
         // Java/FTP upload
         add_config_option('ENABLE_JAVA_UPLOAD', 'java_upload', 'tick', 'return \'0\';', 'SITE', 'JAVA_UPLOAD');
         add_config_option('JAVA_FTP_HOST', 'java_ftp_host', 'line', 'return ocp_srv(\'HTTP_HOST\');', 'SITE', 'JAVA_UPLOAD');
         add_config_option('JAVA_FTP_USERNAME', 'java_username', 'line', 'return \'anonymous\';', 'SITE', 'JAVA_UPLOAD');
         add_config_option('JAVA_FTP_PASSWORD', 'java_password', 'line', 'return \'someone@example.com\';', 'SITE', 'JAVA_UPLOAD');
         add_config_option('JAVA_FTP_PATH', 'java_ftp_path', 'line', 'return \'/public_html/uploads/incoming/\';', 'SITE', 'JAVA_UPLOAD');
     }
     if (is_null($upgrade_from) || $upgrade_from < 10) {
         add_config_option('ADVANCED_ADMIN_CACHE', 'advanced_admin_cache', 'tick', 'return \'0\';', 'SITE', 'CACHES');
         add_config_option('COLLAPSE_USER_ZONES', 'collapse_user_zones', 'tick', 'return \'1\';', 'SITE', 'GENERAL');
         add_config_option('CHECK_BROKEN_URLS', 'check_broken_urls', 'tick', 'return \'1\';', 'SITE', '_COMCODE');
         add_config_option('GOOGLE_ANALYTICS', 'google_analytics', 'line', 'return \'\';', 'SITE', 'GENERAL');
         add_config_option('FIXED_WIDTH', 'fixed_width', 'tick', 'return \'1\';', 'THEME', 'GENERAL');
         add_config_option('SHOW_CONTENT_TAGGING', 'show_content_tagging', 'tick', 'return \'0\';', 'THEME', 'GENERAL');
         add_config_option('SHOW_CONTENT_TAGGING_INLINE', 'show_content_tagging_inline', 'tick', 'return \'0\';', 'THEME', 'GENERAL');
         add_config_option('SHOW_SCREEN_ACTIONS', 'show_screen_actions', 'tick', 'return \'1\';', 'THEME', 'GENERAL');
         add_config_option('PERSONAL_SUB_LINKS', 'ocp_show_personal_sub_links', 'tick', 'return \'1\';', 'BLOCKS', 'PERSONAL_BLOCK');
     }
     if (is_null($upgrade_from) || $upgrade_from < 11) {
         add_config_option('LONG_GOOGLE_COOKIES', 'long_google_cookies', 'tick', 'return \'0\';', 'SITE', 'GENERAL');
         add_config_option('REMEMBER_ME_BY_DEFAULT', 'remember_me_by_default', 'tick', 'return \'0\';', 'SITE', 'GENERAL');
         add_config_option('DETECT_JAVASCRIPT', 'detect_javascript', 'tick', 'return \'0\';', 'SITE', 'ADVANCED');
         add_config_option('MOBILE_SUPPORT', 'mobile_support', 'tick', 'return \'1\';', 'SITE', 'GENERAL');
     }
     if (is_null($upgrade_from) || $upgrade_from < 12) {
         add_config_option('MAIL_QUEUE', 'mail_queue', 'tick', 'return \'0\';', 'SITE', 'EMAIL');
         add_config_option('MAIL_QUEUE_DEBUG', 'mail_queue_debug', 'tick', 'return \'0\';', 'SITE', 'EMAIL');
         add_config_option('COMMENTS_TO_SHOW_IN_THREAD', 'comments_to_show_in_thread', 'integer', 'return \'30\';', 'FEATURE', 'USER_INTERACTION');
         add_config_option('MAX_THREAD_DEPTH', 'max_thread_depth', 'integer', 'return \'6\';', 'FEATURE', 'USER_INTERACTION');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 12) {
         foreach (array('send_error_emails', 'ocf_show_personal_myhome_link', 'twitter_login', 'twitter_password', 'facebook_api', 'facebook_appid', 'facebook_secret_code', 'facebook_uid', 'facebook_target_ids') as $option_to_delete) {
             delete_config_option($option_to_delete);
         }
     }
     if (is_null($upgrade_from) || $upgrade_from < 13) {
         add_config_option('COMPLEX_UPLOADER', 'complex_uploader', 'tick', 'return \'1\';', 'ACCESSIBILITY', 'GENERAL');
         add_config_option('ENABLE_WYSIWYG', 'wysiwyg', 'tick', 'return \'1\';', 'ACCESSIBILITY', 'GENERAL');
         add_config_option('EDITAREA', 'editarea', 'tick', 'return \'1\';', 'ACCESSIBILITY', 'GENERAL');
         add_config_option('JS_OVERLAYS', 'js_overlays', 'tick', 'return \'1\';', 'ACCESSIBILITY', 'GENERAL');
         add_config_option('TREE_LISTS', 'tree_lists', 'tick', 'return \'1\';', 'ACCESSIBILITY', 'GENERAL');
         add_config_option('CSS_CAPTCHA', 'css_captcha', 'tick', 'return addon_installed(\'captcha\')?\'1\':NULL;', 'SECURITY', 'SECURITY_IMAGE');
         add_config_option('CAPTCHA_SINGLE_GUESS', 'captcha_single_guess', 'tick', 'return addon_installed(\'captcha\')?\'1\':NULL;', 'SECURITY', 'SECURITY_IMAGE');
         add_config_option('ENABLE_AUTOBAN', 'autoban', 'tick', 'return \'1\';', 'SECURITY', 'GENERAL');
         add_config_option('ENABLE_LIKES', 'likes', 'tick', 'return \'0\';', 'FEATURE', 'USER_INTERACTION');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 8) {
         delete_config_option('logo_map');
         $GLOBALS['SITE_DB']->query('UPDATE ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'config SET the_type=\'forum\' WHERE the_name LIKE \'' . db_encode_like('%_forum_name') . '\'');
     }
     if (is_null($upgrade_from)) {
         set_value('version', float_to_raw_string(ocp_version_number()));
         set_value('ocf_version', float_to_raw_string(ocp_version_number()));
         // Site Configuration
         //  General
         add_config_option('SITE_NAME', 'site_name', 'line', 'return do_lang(\'UNNAMED\');', 'SITE', 'GENERAL');
         add_config_option('SITE_SCOPE', 'site_scope', 'transline', 'return \'???\';', 'SITE', 'GENERAL');
         add_config_option('DESCRIPTION', 'description', 'transline', 'return \'\';', 'SITE', 'GENERAL');
         add_config_option('COPYRIGHT', 'copyright', 'transline', 'return \'Copyright &copy; \'.get_site_name().\' \'.date(\'Y\').\'\';', 'SITE', 'GENERAL');
         add_config_option('WELCOME_MESSAGE', 'welcome_message', 'transtext', 'return \'\';', 'SITE', 'GENERAL');
         add_config_option('MAIN_FORUM_NAME', 'main_forum_name', 'forum', 'return has_no_forum()?NULL:do_lang(\'DEFAULT_FORUM_TITLE\',\'\',\'\',\'\',get_site_default_lang());', 'FEATURE', 'USER_INTERACTION');
         add_config_option('KEYWORDS', 'keywords', 'line', 'return \'\';', 'SITE', 'GENERAL');
         //  Advanced
         //add_config_option('LOGO_MAP','logo_map','text','$tpl=do_template(\'IMAGE_MAP\'); return $tpl->evaluate();','SITE','ADVANCED');
         add_config_option('GZIP_OUTPUT', 'gzip_output', 'tick', 'return \'0\';', 'SITE', 'ADVANCED', 1);
         //  Environment
         add_config_option('FORUM_IN_PORTAL', 'forum_in_portal', 'tick', 'return has_no_forum()?NULL:\'0\';', 'SITE', 'ENVIRONMENT', 1);
         add_config_option('EMAIL', 'staff_address', 'line', 'return \'staff@\'.get_domain();', 'SITE', 'EMAIL');
         add_config_option('GD', 'is_on_gd', 'tick', 'return function_exists(\'imagetypes\')?\'1\':\'0\';', 'SITE', 'ENVIRONMENT', 1);
         add_config_option('FOLDER_CREATE', 'is_on_folder_create', 'tick', 'return \'1\';', 'SITE', 'ENVIRONMENT', 1);
         //  Closed Site
         add_config_option('CLOSED_SITE', 'site_closed', 'tick', 'return \'' . (substr(ocp_srv('HTTP_HOST'), 0, 8) == '192.168.' || substr(ocp_srv('HTTP_HOST'), 0, 7) == '10.0.0.' || in_array(ocp_srv('HTTP_HOST'), array('localhost', 'test.ocportal.com')) ? '0' : '1') . '\';', 'SITE', 'CLOSED_SITE');
         add_config_option('MESSAGE', 'closed', 'transtext', 'return do_lang(\'BEING_INSTALLED\');', 'SITE', 'CLOSED_SITE');
         add_config_option('MAXIMUM_USERS', 'maximum_users', 'integer', 'return \'100\';', 'SITE', 'CLOSED_SITE', 1);
         //  Logging
         add_config_option('CC_ADDRESS', 'cc_address', 'line', 'return \'\';', 'SITE', 'EMAIL');
         // \'staff_cc@\'.get_domain()
         add_config_option('LOG_PHP_ERRORS', 'log_php_errors', 'tick', 'return \'1\';', 'SITE', 'LOGGING');
         add_config_option('DISPLAY_PHP_ERRORS', 'display_php_errors', 'tick', 'return \'0\';', 'SITE', 'LOGGING');
         // Security/Usergroup Options
         //  Uploading
         add_config_option('FILE_TYPES', 'valid_types', 'line', 'return \'swf,sql,odg,odp,odt,ods,pdf,pgp,dot,doc,ppt,csv,xls,docx,pptx,xlsx,pub,txt,log,psd,tga,tif,gif,png,ico,bmp,jpg,jpeg,flv,avi,mov,3gp,mpg,mpeg,mp4,webm,asf,wmv,zip,tar,rar,gz,wav,mp3,ogg,ogv,torrent,php,css,tpl,ini,eml,patch,diff,iso,dmg\';', 'SECURITY', 'UPLOADED_FILES');
         // fla,html,htm,svg,xml kept out for security reasons. NB: Can't add any more due to length limit.
         add_config_option('IMAGE_TYPES', 'valid_images', 'line', 'return \'jpg,jpeg,gif,png,ico\';', 'SECURITY', 'UPLOADED_FILES');
         // Feature Options
         //  User Interaction
         add_config_option('RATING', 'is_on_rating', 'tick', 'return \'1\';', 'FEATURE', 'USER_INTERACTION');
         add_config_option('COMMENTS', 'is_on_comments', 'tick', 'return has_no_forum()?NULL:\'1\';', 'FEATURE', 'USER_INTERACTION');
         add_config_option('COMMENTS_FORUM_NAME', 'comments_forum_name', 'forum', 'return has_no_forum()?NULL:do_lang(\'COMMENT_FORUM_NAME\',\'\',\'\',\'\',get_site_default_lang());', 'FEATURE', 'USER_INTERACTION');
         add_config_option('COMMENT_FORM_TEXT', 'comment_text', 'transtext', 'return has_no_forum()?NULL:static_evaluate_tempcode(do_template(\'COMMENTS_DEFAULT_TEXT\'));', 'FEATURE', 'USER_INTERACTION');
         //  Images
         add_config_option('THUMB_WIDTH', 'thumb_width', 'integer', 'return \'200\';', 'FEATURE', 'IMAGES');
         add_config_option('IMAGES', 'max_image_size', 'integer', 'return \'700\';', 'SITE', 'UPLOAD');
         add_config_option('USERS_ONLINE_TIME', 'users_online_time', 'integer', 'return \'5\';', 'SITE', 'LOGGING');
     }
 }
コード例 #10
0
ファイル: secpay.php プロジェクト: erico-deh/ocPortal
 /**
  * Make a subscription (payment) button.
  *
  * @param  ID_TEXT		The product codename.
  * @param  SHORT_TEXT	The human-readable product title.
  * @param  ID_TEXT		The purchase ID.
  * @param  float			A transaction amount.
  * @param  integer		The subscription length in the units.
  * @param  ID_TEXT		The length units.
  * @set    d w m y
  * @param  ID_TEXT		The currency to use.
  * @return tempcode		The button
  */
 function make_subscription_button($product, $item_name, $purchase_id, $amount, $length, $length_units, $currency)
 {
     $username = $this->_get_username();
     $ipn_url = $this->get_ipn_url();
     $trans_id = $this->generate_trans_id();
     $digest = md5($trans_id . float_to_raw_string($amount) . get_option('ipn_password'));
     list($length_units_2, $first_repeat) = $this->_translate_subscription_details($length, $length_units);
     $GLOBALS['SITE_DB']->query_insert('trans_expecting', array('id' => $trans_id, 'e_purchase_id' => $purchase_id, 'e_item_name' => $item_name, 'e_member_id' => get_member(), 'e_amount' => float_to_raw_string($amount), 'e_ip_address' => get_ip_address(), 'e_session_id' => get_session_id(), 'e_time' => time(), 'e_length' => $length, 'e_length_units' => $length_units));
     return do_template('ECOM_SUBSCRIPTION_BUTTON_VIA_SECPAY', array('_GUID' => 'e5e6d6835ee6da1a6cf02ff8c2476aa6', 'PRODUCT' => $product, 'DIGEST' => $digest, 'TEST' => ecommerce_test_mode(), 'TRANS_ID' => $trans_id, 'FIRST_REPEAT' => $first_repeat, 'LENGTH' => strval($length), 'LENGTH_UNITS_2' => $length_units_2, 'ITEM_NAME' => $item_name, 'PURCHASE_ID' => strval($purchase_id), 'AMOUNT' => float_to_raw_string($amount), 'CURRENCY' => $currency, 'USERNAME' => $username, 'IPN_URL' => $ipn_url));
 }
コード例 #11
0
ファイル: side_tag_cloud.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_lang('search');
     require_css('search');
     $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('search');
     $max_tags = array_key_exists('max', $map) ? intval($map['max']) : 30;
     $tags = array();
     $largest_num = 0;
     $smallest_num = mixed();
     $search_limiter = array('all_defaults' => '1');
     // Find all keywords, hence all tags
     $limit_to = array_key_exists('param', $map) ? $map['param'] : '';
     // HACKHACK: No correlation between meta keywords and search hook names, so we have to specify both in here
     if ($limit_to != '') {
         $where = '';
         foreach (explode(',', $limit_to) as $l) {
             if ($where != '') {
                 $where .= ' OR ';
             }
             $where .= db_string_equal_to('meta_for_type', $l);
             $search_limiter['search_' . $l] = 1;
         }
         $search_limiter['all_defaults'] = '0';
     } else {
         $where = '1=1';
     }
     $where .= ' AND ' . db_string_not_equal_to('text_original', '');
     $meta_rows = $GLOBALS['SITE_DB']->query('SELECT meta_for_type,meta_for_id,text_original AS meta_keywords_nice,meta_keywords FROM ' . get_table_prefix() . 'seo_meta m LEFT JOIN ' . get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND m.meta_keywords=t.id WHERE ' . $where . ' ORDER BY m.id DESC', 300);
     foreach ($meta_rows as $mr) {
         if ($GLOBALS['RECORD_LANG_STRINGS_CONTENT'] || is_null($mr['meta_keywords_nice'])) {
             $mr['meta_keywords_nice'] = get_translated_text($mr['meta_keywords']);
         }
         $keywords = explode(',', $mr['meta_keywords_nice']);
         foreach ($keywords as $keyword) {
             $keyword = trim($keyword);
             if ($keyword == '') {
                 continue;
             }
             if (strlen(is_numeric($keyword) ? strval(intval($keyword)) : $keyword) < 4) {
                 continue;
             }
             // Won't be indexed, plus will uglify the tag list
             if (!array_key_exists($keyword, $tags)) {
                 $tags[$keyword] = 0;
             }
             $tags[$keyword]++;
         }
     }
     arsort($tags);
     $_tags = $tags;
     $tags = array();
     foreach ($_tags as $tag => $count) {
         if (!is_string($tag)) {
             $tag = strval($tag);
         }
         $tags[$tag] = $count;
         if (count($tags) == $max_tags) {
             break;
         }
     }
     ksort($tags);
     if (count($tags) == 0) {
         return new ocp_tempcode();
     }
     // Work out variation in sizings
     foreach ($tags as $tag => $count) {
         if (is_null($smallest_num) || $count < $smallest_num) {
             $smallest_num = $count;
         }
         if ($count > $largest_num) {
             $largest_num = $count;
         }
     }
     // Scale tag sizings into em figures, and generally prepare for templating
     $max_em = 2.5;
     $min_em = 0.85;
     $tpl_tags = array();
     foreach ($tags as $tag => $count) {
         if (!is_string($tag)) {
             $tag = strval($tag);
         }
         if ($smallest_num == $largest_num) {
             $em = 1.0;
         } else {
             $fraction = floatval($count - $smallest_num) / floatval($largest_num);
             $em = $min_em + $fraction * ($max_em - $min_em);
         }
         $tpl_tags[] = array('TAG' => $tag, 'COUNT' => strval($count), 'EM' => float_to_raw_string($em), 'LINK' => build_url(array('page' => 'search', 'type' => 'results', 'content' => '"' . $tag . '"', 'days' => -1, 'only_search_meta' => '1') + $search_limiter, $zone));
     }
     $title = array_key_exists('title', $map) ? $map['title'] : do_lang('TAG_CLOUD');
     return do_template('BLOCK_SIDE_TAG_CLOUD', array('TAGS' => $tpl_tags, 'TITLE' => $title));
 }
コード例 #12
0
ファイル: purchase.php プロジェクト: erico-deh/ocPortal
 /**
  * Payment step.
  *
  * @param  tempcode	The page title.
  * @return tempcode	The result of execution.
  */
 function pay($title)
 {
     $product = get_param('product');
     $object = find_product($product);
     if (method_exists($object, 'is_available') && !$object->is_available($product, get_member())) {
         warn_exit(do_lang_tempcode('PRODUCT_UNAVAILABLE'));
     }
     $temp = $object->get_products(true, $product);
     $price = $temp[$product][1];
     $item_name = $temp[$product][4];
     if (method_exists($object, 'set_needed_fields')) {
         $purchase_id = $object->set_needed_fields($product);
     } else {
         $purchase_id = strval(get_member());
     }
     if ($temp[$product][0] == PRODUCT_SUBSCRIPTION) {
         $_purchase_id = $GLOBALS['SITE_DB']->query_value_null_ok('subscriptions', 'id', array('s_type_code' => $product, 's_member_id' => get_member(), 's_state' => 'new'));
         if (is_null($_purchase_id)) {
             $purchase_id = strval($GLOBALS['SITE_DB']->query_insert('subscriptions', array('s_type_code' => $product, 's_member_id' => get_member(), 's_state' => 'new', 's_amount' => $temp[$product][1], 's_special' => $purchase_id, 's_time' => time(), 's_auto_fund_source' => '', 's_auto_fund_key' => '', 's_via' => get_option('payment_gateway')), true));
         } else {
             $purchase_id = strval($_purchase_id);
         }
         $length = array_key_exists('length', $temp[$product][3]) ? $temp[$product][3]['length'] : 1;
         $length_units = array_key_exists('length_units', $temp[$product][3]) ? $temp[$product][3]['length_units'] : 'm';
     } else {
         $length = NULL;
         $length_units = '';
         //Add cataloue item order to shopping_orders
         if (method_exists($object, 'add_purchase_order')) {
             $purchase_id = strval($object->add_purchase_order($product, $temp[$product]));
         }
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PURCHASING'))));
     if ($price == '0') {
         $payment_status = 'Completed';
         $reason_code = '';
         $pending_reason = '';
         $mc_currency = get_option('currency');
         $txn_id = 'manual-' . substr(uniqid('', true), 0, 10);
         $parent_txn_id = '';
         $memo = 'Free';
         $mc_gross = '';
         handle_confirmed_transaction($purchase_id, $item_name, $payment_status, $reason_code, $pending_reason, $memo, $mc_gross, $mc_currency, $txn_id, $parent_txn_id);
         return inform_screen($title, do_lang_tempcode('FREE_PURCHASE'));
     }
     if (!array_key_exists(4, $temp[$product])) {
         $item_name = do_lang('CUSTOM_PRODUCT_' . $product, NULL, NULL, NULL, get_site_default_lang());
     }
     if (!perform_local_payment()) {
         if ($temp[$product][0] == PRODUCT_SUBSCRIPTION) {
             $transaction_button = make_subscription_button($product, $item_name, $purchase_id, floatval($price), $length, $length_units, get_option('currency'));
         } else {
             $transaction_button = make_transaction_button($product, $item_name, $purchase_id, floatval($price), get_option('currency'));
         }
         $tpl = $temp[$product][0] == PRODUCT_SUBSCRIPTION ? 'PURCHASE_WIZARD_STAGE_SUBSCRIBE' : 'PURCHASE_WIZARD_STAGE_PAY';
         $logos = method_exists($object, 'get_logos') ? $object->get_logos() : new ocp_tempcode();
         $result = do_template($tpl, array('LOGOS' => $logos, 'TRANSACTION_BUTTON' => $transaction_button, 'CURRENCY' => get_option('currency'), 'ITEM_NAME' => $item_name, 'TITLE' => $title, 'LENGTH' => is_null($length) ? '' : strval($length), 'LENGTH_UNITS' => $length_units, 'PURCHASE_ID' => $purchase_id, 'PRICE' => float_to_raw_string(floatval($price))));
     } else {
         if (!tacit_https() && !ecommerce_test_mode()) {
             warn_exit(do_lang_tempcode('NO_SSL_SETUP'));
         }
         $fields = get_transaction_form_fields(NULL, $purchase_id, $item_name, float_to_raw_string($price), $temp[$product][0] == PRODUCT_SUBSCRIPTION ? intval($length) : NULL, $temp[$product][0] == PRODUCT_SUBSCRIPTION ? $length_units : '');
         /*$via		=	get_option('payment_gateway');
         		require_code('hooks/systems/ecommerce_via/'.filter_naughty_harsh($via));
         		$object	=	object_factory('Hook_'.$via);
         		$ipn_url	=	$object->get_ipn_url();*/
         $finish_url = build_url(array('page' => '_SELF', 'type' => 'finish'), '_SELF');
         $result = do_template('PURCHASE_WIZARD_STAGE_TRANSACT', array('_GUID' => '15cbba9733f6ff8610968418d8ab527e', 'FIELDS' => $fields));
         return $this->wrap($result, $title, $finish_url);
     }
     return $this->wrap($result, $title, NULL);
 }
コード例 #13
0
ファイル: paypal.php プロジェクト: erico-deh/ocPortal
 /**
  * Handle IPN's. The function may produce output, which would be returned to the Payment Gateway. The function may do transaction verification.
  *
  * @return array	A long tuple of collected data.
  */
 function handle_transaction()
 {
     if (file_exists(get_file_base() . '/data_custom/ecommerce.log') && is_writable_wrap(get_file_base() . '/data_custom/ecommerce.log')) {
         $myfile = fopen(get_file_base() . '/data_custom/ecommerce.log', 'at');
         fwrite($myfile, serialize($_POST) . chr(10));
         fclose($myfile);
     }
     // assign posted variables to local variables
     $purchase_id = post_param_integer('custom', '-1');
     $txn_type = post_param('txn_type', NULL);
     if ($txn_type == 'cart') {
         require_lang('shopping');
         $item_name = do_lang('CART_ORDER', $purchase_id);
     } else {
         $item_name = substr(post_param('txn_type', ''), 0, 6) == 'subscr' ? '' : post_param('item_name', '');
     }
     $payment_status = post_param('payment_status', '');
     // May be blank for subscription
     $reason_code = post_param('reason_code', '');
     $pending_reason = post_param('pending_reason', '');
     $memo = post_param('memo', '');
     $mc_gross = post_param('mc_gross', '');
     // May be blank for subscription
     $tax = post_param('tax', '');
     if ($tax != '' && intval($tax) > 0 && $mc_gross != '') {
         $mc_gross = float_to_raw_string(floatval($mc_gross) - floatval($tax));
     }
     $mc_currency = post_param('mc_currency', '');
     // May be blank for subscription
     $txn_id = post_param('txn_id', '');
     // May be blank for subscription
     $parent_txn_id = post_param('parent_txn_id', '-1');
     $receiver_email = post_param('receiver_email');
     // post back to PayPal system to validate
     if (!ecommerce_test_mode()) {
         require_code('files');
         $pure_post = isset($GLOBALS['PURE_POST']) ? $GLOBALS['PURE_POST'] : $_POST;
         $x = 0;
         $res = mixed();
         do {
             $res = http_download_file('http://' . (ecommerce_test_mode() ? 'www.sandbox.paypal.com' : 'www.paypal.com') . '/cgi-bin/webscr', NULL, false, false, 'ocPortal', $pure_post + array('cmd' => '_notify-validate'));
             $x++;
         } while (is_null($res) && $x < 3);
         if (is_null($res)) {
             my_exit(do_lang('IPN_SOCKET_ERROR'));
         }
         if (!(strcmp($res, 'VERIFIED') == 0)) {
             if (post_param('txn_type', '') == 'send_money') {
                 exit('Unexpected');
             }
             // PayPal has been seen to mess up on send_money transactions, making the IPN unverifiable
             my_exit(do_lang('IPN_UNVERIFIED') . ' - ' . $res . ' - ' . flatten_slashed_array($pure_post), strpos($res, '<html') !== false);
         }
     }
     $txn_type = str_replace('-', '_', post_param('txn_type'));
     if ($txn_type == 'subscr-modify') {
         $payment_status = 'SModified';
         $txn_id = post_param('subscr_id') . '-m';
     } elseif ($txn_type == 'subscr_signup') {
         $payment_status = 'Completed';
         $mc_gross = post_param('mc_amount3');
         if (post_param_integer('recurring') != 1) {
             my_exit(do_lang('IPN_SUB_RECURRING_WRONG'));
         }
         $txn_id = post_param('subscr_id');
     } elseif ($txn_type == 'subscr_eot' || $txn_type == 'recurring_payment_suspended_due_to_max_failed_payment') {
         $payment_status = 'SCancelled';
         $txn_id = post_param('subscr_id') . '-c';
     } elseif ($txn_type == 'subscr_payment' || $txn_type == 'subscr_failed' || $txn_type == 'subscr_cancel') {
         exit;
     }
     $primary_paypal_email = get_value('primary_paypal_email');
     if (!is_null($primary_paypal_email)) {
         if ($receiver_email != $primary_paypal_email) {
             my_exit(do_lang('IPN_EMAIL_ERROR'));
         }
     } else {
         if ($receiver_email != $this->_get_payment_address()) {
             my_exit(do_lang('IPN_EMAIL_ERROR'));
         }
     }
     if (addon_installed('shopping')) {
         $this->store_shipping_address($purchase_id);
     }
     return array($purchase_id, $item_name, $payment_status, $reason_code, $pending_reason, $memo, $mc_gross, $mc_currency, $txn_id, $parent_txn_id);
 }
コード例 #14
0
ファイル: currency.php プロジェクト: erico-deh/ocPortal
/**
 * Perform a currency conversion.
 *
 * @param  mixed		The starting amount (integer or float).
 * @param  ID_TEXT	The start currency code.
 * @param  ?ID_TEXT  The end currency code (NULL: unknown, guess it).
 * @param  boolean	Whether to get as a string.
 * @return ?mixed		The new amount as float, or if $string then as a string (NULL: failed to do it).
 */
function currency_convert($amount, $from_currency, $to_currency = NULL, $string = false)
{
    // Check data
    $from_currency = strtoupper($from_currency);
    $map = get_currency_map();
    if (!array_key_exists($from_currency, $map)) {
        return NULL;
    }
    if (is_null($to_currency)) {
        // Perform a preferential guessing sequence
        // ========================================
        // keep_currency
        $to_currency = get_param('keep_currency', NULL);
        if (is_null($to_currency)) {
            // a specially named custom profile field for the currency.
            $to_currency = get_ocp_cpf('currency');
            if ($to_currency === '') {
                $to_currency = NULL;
            }
            if (is_null($to_currency)) {
                // keep_country
                $country = get_param('keep_country', NULL);
                if (!is_null($country)) {
                    $to_currency = country_to_currency($country);
                }
                if (is_null($to_currency)) {
                    // a specially named custom profile field for the country.
                    $country = get_ocp_cpf('country');
                    if ($country != '') {
                        $to_currency = country_to_currency($country);
                    }
                    if (is_null($to_currency)) {
                        // geolocation
                        $to_currency = ip_to_currency();
                        if (is_null($to_currency)) {
                            //							// Euros to the rescue (it's a reasonable guess based on the largest population using a single currency)
                            //							$to_currency='EUR';
                            $to_currency = get_option('currency');
                        }
                    }
                }
            }
        }
    }
    // (We now know $to_currency)
    // We'll use Google as a simple web service
    if ($from_currency == $to_currency) {
        $new_amount = is_integer($amount) ? floatval($amount) : $amount;
    } else {
        $cache_key = 'currency_' . $from_currency . '_' . $to_currency . (is_float($amount) ? float_to_raw_string($amount) : strval($amount));
        $_new_amount = get_long_value_newer_than($cache_key, time() - 60 * 60 * 24 * 2);
        $new_amount = is_null($_new_amount) ? NULL : floatval($_new_amount);
        if (is_null($new_amount)) {
            $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'long_values WHERE the_name LIKE \'' . db_encode_like('currency_%') . '\' AND date_and_time<' . strval(time() - 60 * 60 * 24 * 2));
            // Cleanup
            $google_url = 'http://www.google.com/finance/converter?a=' . (is_float($amount) ? float_to_raw_string($amount) : strval($amount)) . '&from=' . $from_currency . '&to=' . strtoupper($to_currency);
            $result = http_download_file($google_url, NULL, false);
            if (is_string($result)) {
                $matches = array();
                for ($i = 0; $i < strlen($result); $i++) {
                    if (ord($result[$i]) > 127) {
                        $result[$i] = ' ';
                    }
                }
                if (preg_match('#<span class=bld>([\\d\\., ]+) [A-Z]+</span>#U', $result, $matches) != 0) {
                    $new_amount = floatval(str_replace(',', '', str_replace(' ', '', $matches[1])));
                    set_long_value($cache_key, float_to_raw_string($new_amount));
                } else {
                    return NULL;
                }
            } else {
                $new_amount = is_integer($amount) ? floatval($amount) : $amount;
                $to_currency = $from_currency;
            }
        }
    }
    if ($string) {
        $ret = '';
        if (in_array($to_currency, array('USD', 'AUD', 'CAD', 'SRD', 'SBD', 'SGD', 'NZD', 'NAD', 'MXN', 'LRD', 'GYD', 'FJD', 'SVC', 'XCD', 'COP', 'CLP', 'KYD', 'BND', 'BMD', 'BBD', 'BSD', 'ARS'))) {
            $ret .= '$';
        } elseif (in_array($to_currency, array('GBP', 'SHP', 'LBP', 'JEP', 'GGP', 'GIP', 'FKP', 'EGP'))) {
            $ret .= '&pound;';
        } elseif (in_array($to_currency, array('JPY'))) {
            $ret .= '&yen;';
        } elseif (in_array($to_currency, array('EUR'))) {
            $ret .= '&euro;';
        }
        $ret .= escape_html(float_format($new_amount)) . '&nbsp;' . escape_html($to_currency);
        return $ret;
    }
    return $new_amount;
}
コード例 #15
0
ファイル: global2.php プロジェクト: erico-deh/ocPortal
/**
 * Standard code module initialisation function.
 */
function init__global2()
{
    global $BOOTSTRAPPING, $CHECKING_SAFEMODE, $BAD_WORD_CHARS, $FIXED_WORD_CHARS, $FIXED_WORD_CHARS_HTML, $BROWSER_DECACHEING, $CHARSET, $TEMP_CHARSET, $RELATIVE_PATH, $CURRENTLY_HTTPS, $RUNNING_SCRIPT_CACHE, $SERVER_TIMEZONE, $HAS_SET_ERROR_HANDLER, $DYING_BADLY, $XSS_DETECT, $SITE_INFO, $JAVASCRIPTS, $JAVASCRIPT, $CSSS, $IN_MINIKERNEL_VERSION, $EXITING, $FILE_BASE, $MOBILE, $CACHE_TEMPLATES, $BASE_URL_HTTP, $BASE_URL_HTTPS, $WORDS_TO_FILTER, $FIELD_RESTRICTIONS, $VALID_ENCODING, $CONVERTED_ENCODING, $MICRO_BOOTUP, $MICRO_AJAX_BOOTUP, $QUERY_LOG, $_CREATED_FILES, $CURRENT_SHARE_USER, $CACHE_FIND_SCRIPT;
    if (str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('output_buffering'))) == '1') {
        @ob_end_clean();
    }
    if (array_key_exists('HTTP_X_REWRITE_URL', $_SERVER)) {
        foreach ($_GET as $key => $val) {
            if ($key[0] == '?') {
                unset($_GET[$key]);
                $_GET[substr($key, 1)] = $val;
            }
        }
        $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
    } elseif (!array_key_exists('REQUEST_URI', $_SERVER) && !array_key_exists('REQUEST_URI', $_ENV)) {
        $_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF'];
        $first = true;
        foreach ($_GET as $key => $val) {
            $_SERVER['REQUEST_URI'] .= $first ? '?' : '&';
            $_SERVER['REQUEST_URI'] .= urlencode($key) . '=' . urlencode($val);
            $first = false;
        }
    }
    if (array_key_exists('SCRIPT_FILENAME', $_SERVER) && !array_key_exists('PHP_SELF', $_SERVER)) {
        $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_FILENAME'];
    } elseif (array_key_exists('SCRIPT_NAME', $_SERVER) && defined('HIPHOP_PHP')) {
        $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'];
    }
    @header('Expires: Mon, 20 Dec 1998 01:00:00 GMT');
    @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    @header('Cache-Control: no-cache, max-age=0');
    @header('Pragma: no-cache');
    // for proxies, and also IE
    if (is_file('closed.html') && get_param_integer('keep_force_open', 0) == 0) {
        if (strpos($_SERVER['PHP_SELF'], 'upgrader.php') === false && strpos($_SERVER['PHP_SELF'], 'execute_temp.php') === false && (!isset($SITE_INFO['no_extra_closed_file']) || $SITE_INFO['no_extra_closed_file'] == '0')) {
            if (@strpos($_SERVER['SERVER_SOFTWARE'], 'IIS') === false) {
                header('HTTP/1.0 503 Service Temporarily Unavailable');
            }
            header('Location: ' . (is_file($RELATIVE_PATH . 'closed.html') ? 'closed.html' : '../closed.html'));
            exit;
        }
    }
    // Cover up holes in old PHP versions functionality
    if (!function_exists('str_word_count')) {
        /**
         * Isolate the words in the input string.
         *
         * @param  string			String to count words in
         * @param  integer		The format
         * @set    0 1 2
         * @return mixed			Typically a list - the words of the input string
         */
        function str_word_count($input, $format = 0)
        {
            //count words
            $pattern = "/[^(\\w|\\d|\\'|\"|\\.|\\!|\\?|;|,|\\|\\/|\\-\\-|:|\\&|@)]+/";
            $all_words = trim(preg_replace($pattern, ' ', $input));
            $a = array();
            $pos = 0;
            while (true) {
                $old_pos = $pos;
                $pos = strpos($all_words, ' ', $pos);
                if ($pos === false) {
                    $a[$old_pos] = substr($all_words, $old_pos);
                    break;
                }
                $a[$old_pos] = substr($all_words, $old_pos, $pos - $old_pos);
            }
            if ($format == 0) {
                return count($a);
            }
            return $a;
        }
    }
    if (!function_exists('html_entity_decode')) {
        /**
         * Decode the HTML entitity encoded input string.
         *
         * @param  string			The text to decode
         * @param  integer		The quote style code
         * @param  ?string		Character set to decode to (NULL: default)
         * @return string			The decoded text
         */
        function html_entity_decode($input, $quote_style, $charset = NULL)
        {
            unset($quote_style);
            unset($charset);
            /*			// NB: &nbsp does not go to <space>. It's not something you use with html escaping, it's for hard-space-formatting. URL's don't contain spaces, but that's due to URL escaping (%20)
            			$replace_array=array(
            				'&amp;'=>'&',
            				'&gt;'=>'>',
            				'&lt;'=>'<',
            				'&#039;'=>'\'',
            				'&quot;'=>'"',
            			);
            
            			foreach ($replace_array as $from=>$to)
            			{
            				$input=str_replace($from,$to,$input);
            			}
            
            			return $input;*/
            $trans_tbl = get_html_translation_table(HTML_ENTITIES);
            $trans_tbl = array_flip($trans_tbl);
            return strtr($input, $trans_tbl);
        }
    }
    if (version_compare(phpversion(), '4.3.0') >= 0) {
        if (!function_exists('unichrm_hex')) {
            /**
             * Convert a unicode character number to a unicode string. Callback for preg_replace.
             *
             * @param  array					Regular expression match array.
             * @return ~string				Converted data (false: could not convert).
             */
            function unichrm_hex($matches)
            {
                return unichr(hexdec($matches[1]));
            }
        }
        if (!function_exists('unichrm')) {
            /**
             * Convert a unicode character number to a unicode string. Callback for preg_replace.
             *
             * @param  array					Regular expression match array.
             * @return ~string				Converted data (false: could not convert).
             */
            function unichrm($matches)
            {
                return unichr(intval($matches[1]));
            }
        }
        if (!function_exists('unichr')) {
            /**
             * Convert a unicode character number to a HTML-entity enabled string, using lower ASCII characters where possible.
             *
             * @param  integer				Character number.
             * @return ~string				Converted data (false: could not convert).
             */
            function unichr($c)
            {
                if ($c <= 0x7f) {
                    return chr($c);
                } else {
                    return '#&' . strval($c) . ';';
                }
            }
        }
    }
    $BOOTSTRAPPING = 1;
    $CHECKING_SAFEMODE = false;
    $BAD_WORD_CHARS = array(chr(128), chr(130), chr(131), chr(132), chr(133), chr(134), chr(135), chr(136), chr(137), chr(138), chr(139), chr(140), chr(142), chr(145), chr(146), chr(147), chr(148), chr(149), chr(150), chr(151), chr(152), chr(153), chr(154), chr(155), chr(156), chr(158), chr(159));
    $FIXED_WORD_CHARS = array('(EUR-)', ',', '{f.}', '"', '...', '-|-', '=|=', '^', '{%o}', '{~S}', '<', 'CE', '{~Z}', "'", "'", '"', '"', '-', '-', '--', '~', '(TM)', '{~s}', '>', 'ce', '{~z}', '{.Y.}');
    // some of these are Comcode shortcuts. We can't use entities as we can't assume we're converting into Comcode.
    $FIXED_WORD_CHARS_HTML = array('&#8364;', '&#8218;', '&#402;', '&#8222;', '&hellip;', '&#8224;', '&#8225;', '&#710;', '&#8240;', '&#352;', '&#8249;', '&#338;', '&#381;', "&lsquo;", "&rsquo;", '&ldquo;', '&rdquo;', '&bull;', '&ndash;', '&mdash;', '&#732;', '&trade;', '&#353;', '&#8250;', '&#339;', '&#382;', '&#376;');
    $RUNNING_SCRIPT_CACHE = array();
    $BROWSER_DECACHEING = NULL;
    $CHARSET = NULL;
    $TEMP_CHARSET = NULL;
    $CURRENTLY_HTTPS = NULL;
    $CACHE_FIND_SCRIPT = array();
    error_reporting(E_ALL);
    @ini_set('html_errors', '1');
    @ini_set('docref_root', 'http://www.php.net/manual/en/');
    @ini_set('docref_ext', '.php');
    $SERVER_TIMEZONE = function_exists('date_default_timezone_get') ? @date_default_timezone_get() : ini_get('date.timezone');
    @ini_set('date.timezone', 'UTC');
    if (function_exists('date_default_timezone_set')) {
        date_default_timezone_set('UTC');
    }
    // Needed for HPHP
    $HAS_SET_ERROR_HANDLER = false;
    $DYING_BADLY = false;
    // If ocPortal is bailing out uncontrollably, setting this will make sure the error hander does not try and suppress
    $XSS_DETECT = function_exists('ocp_mark_as_escaped');
    $GLOBALS['DEBUG_MODE'] = (!array_key_exists('debug_mode', $SITE_INFO) || $SITE_INFO['debug_mode'] == '1') && (is_dir(get_file_base() . '/.svn') || is_dir(get_file_base() . '/.git') || function_exists('ocp_mark_as_escaped')) && (!array_key_exists('keep_no_debug_mode', $_GET) || $_GET['keep_no_debug_mode'] == '0');
    $GLOBALS['SEMI_DEBUG_MODE'] = (!array_key_exists('debug_mode', $SITE_INFO) || $SITE_INFO['debug_mode'] == '1') && (is_dir(get_file_base() . '/.svn') || is_dir(get_file_base() . '/.git') || function_exists('ocp_mark_as_escaped'));
    if (function_exists('set_time_limit')) {
        @set_time_limit(60);
    }
    if ($GLOBALS['DEBUG_MODE']) {
        if (function_exists('set_time_limit')) {
            @set_time_limit(10);
        }
        @ini_set('ocproducts.type_strictness', '1');
        @ini_set('ocproducts.xss_detect', '1');
    }
    if ($GLOBALS['DEBUG_MODE']) {
        require_code('developer_tools');
    }
    $JAVASCRIPTS = array('javascript' => 1, 'javascript_thumbnails' => 1);
    if ($GLOBALS['CURRENT_SHARE_USER'] !== NULL || get_domain() == 'myocp.com') {
        $JAVASCRIPTS['javascript_ajax'] = 1;
    }
    $CSSS = array('no_cache' => 1, 'global' => 1);
    // Try and make the PHP environment as we need it
    if (function_exists('set_magic_quotes_runtime')) {
        @set_magic_quotes_runtime(0);
    }
    // @'d because it's deprecated and PHP 5.3 may give an error
    @ini_set('auto_detect_line_endings', '0');
    @ini_set('include_path', '');
    @ini_set('default_socket_timeout', '60');
    @ini_set('allow_url_fopen', '0');
    @ini_set('suhosin.executor.disable_emodifier', '1');
    // Extra security if suhosin is available
    @ini_set('suhosin.executor.multiheader', '1');
    // Extra security if suhosin is available
    @ini_set('suhosin.executor.disable_eval', '0');
    @ini_set('suhosin.executor.eval.whitelist', '');
    @ini_set('suhosin.executor.func.whitelist', '');
    // Load most basic config
    $IN_MINIKERNEL_VERSION = 0;
    $EXITING = 0;
    if (array_key_exists('use_ocf', $_GET) && running_script('upgrader')) {
        $SITE_INFO['forum_type'] = 'ocf';
        $SITE_INFO['ocf_table_prefix'] = $SITE_INFO['table_prefix'];
    }
    $CACHE_TEMPLATES = true;
    // The URL to our install (no trailing /)
    $BASE_URL_HTTP = NULL;
    $BASE_URL_HTTPS = NULL;
    $WORDS_TO_FILTER = NULL;
    $FIELD_RESTRICTIONS = NULL;
    $VALID_ENCODING = false;
    $CONVERTED_ENCODING = false;
    if (!isset($MICRO_BOOTUP)) {
        $MICRO_BOOTUP = 0;
    }
    if (!isset($MICRO_AJAX_BOOTUP)) {
        $MICRO_AJAX_BOOTUP = 0;
    }
    require_code_no_override('version');
    if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0) {
        //@header('X-Powered-By: ocPortal '.ocp_version_full().' (PHP '.phpversion().')');
        @header('X-Powered-By: ocPortal');
        // Better to keep it vague, for security reasons
        $QUERY_LOG = false;
        if (isset($_REQUEST['special_page_type']) && $_REQUEST['special_page_type'] == 'query') {
            $QUERY_LOG = true;
        }
    }
    // Most critical things
    require_code('support');
    // A lot of support code is present in this
    srand(make_seed());
    mt_srand(make_seed());
    if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0) {
        if (running_script('index') && count($_POST) == 0) {
            $bot_type = get_bot_type();
            if ($bot_type !== NULL && isset($SITE_INFO['fast_spider_cache']) && $SITE_INFO['fast_spider_cache'] != '0') {
                fast_spider_cache(true);
            }
        }
    }
    require_code('caches');
    // Recently taken out of 'support' so makes sense to load it here
    require_code('database');
    // There's nothing without the database
    if ((!isset($SITE_INFO['known_suexec']) || $SITE_INFO['known_suexec'] == '0') && !is_writable_wrap(get_file_base() . '/.htaccess')) {
        require_code('support2');
        if (ip_banned(get_ip_address())) {
            critical_error('BANNED');
        }
    }
    if (running_script('messages') && get_param('action', 'new') == 'new' && get_param_integer('routine_refresh', 0) == 0) {
        require_code('chat_poller');
        chat_poller();
    }
    if ($MICRO_BOOTUP == 0) {
        load_user_stuff();
    }
    // For any kind of niceness we need these. The order is chosen for complex dependency reasons - don't mess with it
    if ($MICRO_AJAX_BOOTUP == 0) {
        require_code('themes');
        // Output needs to know about themes
        require_code('templates');
        // So that we can do error templates
        require_code('tempcode');
        // Output is done with tempcode
        if ($MICRO_BOOTUP == 0) {
            require_code('comcode');
            // Much output goes through comcode
        }
    }
    require_code('zones');
    // Zone is needed because zones are where all ocPortal pages reside
    require_code('config');
    // Config is needed for much active stuff
    if (get_option('collapse_user_zones', true) === '1' && $RELATIVE_PATH == 'site') {
        get_base_url();
        /*force calculation first*/
        $RELATIVE_PATH = '';
    }
    require_code('users');
    // Users are important due to permissions
    if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0) {
        if (running_script('index') && count($_POST) == 0) {
            if (isset($SITE_INFO['any_guest_cached_too']) && $SITE_INFO['any_guest_cached_too'] == '1' && is_guest(NULL, true)) {
                fast_spider_cache(false);
            }
        }
    }
    $CACHE_TEMPLATES = (get_option('is_on_template_cache') == '1' || get_param_integer('keep_cache', 0) == 1 || get_param_integer('cache', 0) == 1) && get_param_integer('keep_cache', NULL) !== 0 && get_param_integer('cache', NULL) !== 0;
    if ($MICRO_AJAX_BOOTUP == 0) {
        require_code('temporal');
        // Date/time functions
        require_code('files');
        // Contains fix_permissions, needed for 'lang'
        require_code('lang');
        // So that we can do language stuff (e.g. errors)
        convert_data_encodings();
        if ($MICRO_BOOTUP == 0) {
            require_code('permissions');
            // So we can check access
        }
    }
    // At this point we can display errors nicely
    $GLOBALS['SUPPRESS_ERROR_DEATH'] = false;
    set_error_handler('ocportal_error_handler');
    if (function_exists('error_get_last')) {
        register_shutdown_function('catch_fatal_errors');
    }
    $HAS_SET_ERROR_HANDLER = true;
    if ($MICRO_BOOTUP == 0) {
        if (method_exists($GLOBALS['FORUM_DRIVER'], 'forum_layer_initialise')) {
            $GLOBALS['FORUM_DRIVER']->forum_layer_initialise();
        }
    }
    if ($MICRO_AJAX_BOOTUP == 0) {
        $JAVASCRIPT = new ocp_tempcode();
    }
    if ($MICRO_BOOTUP == 0) {
        if ($IN_MINIKERNEL_VERSION != 1 && $MICRO_AJAX_BOOTUP == 0) {
            has_cookies();
            // Will determine at early point whether we have cookie support
            get_num_users_site();
            // Will kill site if there are too many users
        }
    }
    require_code('urls');
    // URL building is crucial
    @header('Content-type: text/html; charset=' . get_charset());
    if ($MICRO_AJAX_BOOTUP == 0 && $MICRO_BOOTUP == 0) {
        // Before anything gets outputted
        handle_logins();
        require_code('site');
        // This powers the site (top level page generation)
        // Are we installed?
        get_option('site_name');
    }
    // Our logging (change false to true for temporarily changing it so staff get logging)
    if (get_option('log_php_errors') == '1') {
        @ini_set('log_errors', '1');
        if (addon_installed('errorlog')) {
            @ini_set('error_log', get_custom_file_base() . '/data_custom/errorlog.php');
        }
    }
    if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0 && (get_option('display_php_errors') == '1' || running_script('upgrader') || has_specific_permission(get_member(), 'see_php_errors'))) {
        @ini_set('display_errors', '1');
    } elseif (!$GLOBALS['DEBUG_MODE']) {
        @ini_set('display_errors', '0');
    }
    // G-zip?
    @ini_set('zlib.output_compression', get_option('gzip_output') == '1' ? 'On' : 'Off');
    if (function_exists('setlocale') && $MICRO_AJAX_BOOTUP == 0) {
        $locales = explode(',', do_lang('locale'));
        setlocale(LC_ALL, $locales[0]);
        @setlocale(LC_ALL, $locales);
        unset($locales);
    }
    if ($MICRO_AJAX_BOOTUP == 0 && $MICRO_BOOTUP == 0 && (!isset($SITE_INFO['no_installer_checks']) || $SITE_INFO['no_installer_checks'] == '0')) {
        if (is_file(get_file_base() . '/install.php') && !is_file(get_file_base() . '/install_ok') && running_script('index')) {
            warn_exit(do_lang_tempcode('MUST_DELETE_INSTALLER'));
        }
    }
    if ($MICRO_AJAX_BOOTUP == 0 && $MICRO_BOOTUP == 0) {
        $changed_base_url = !array_key_exists('base_url', $SITE_INFO) && get_long_value('last_base_url') !== get_base_url(false);
        if (running_script('index') && (is_browser_decacheing() || $changed_base_url)) {
            require_code('view_modes');
            erase_tempcode_cache();
            erase_cached_templates(!$changed_base_url);
            erase_comcode_cache();
            erase_cached_language();
            persistant_cache_empty();
            if ($changed_base_url) {
                require_lang('zones');
                require_code('zones3');
                erase_comcode_page_cache();
                set_long_value('last_base_url', get_base_url(false));
            }
        }
        if (has_zone_access(get_member(), 'adminzone')) {
            $JAVASCRIPTS['javascript_staff'] = 1;
            $JAVASCRIPTS['javascript_ajax'] = 1;
            if (addon_installed('occle')) {
                $JAVASCRIPTS['javascript_button_occle'] = 1;
            }
        }
        if (addon_installed('realtime_rain') && get_option('bottom_show_realtime_rain_button', true) === '1') {
            $JAVASCRIPTS['javascript_button_realtime_rain'] = 1;
        }
    }
    /*ocp_memory_profile('startup');
    	$func=get_defined_functions();
    	print_r($func['user']);*/
    if (tacit_https() || is_page_https(get_zone_name(), get_page_name())) {
        @header('Cache-Control: private');
        @header('Pragma: private');
    }
    $BOOTSTRAPPING = 0;
    if ($GLOBALS['SEMI_DEBUG_MODE'] && $MICRO_AJAX_BOOTUP == 0) {
        if ($GLOBALS['SEMI_DEBUG_MODE']) {
            /*if ((mt_rand(0,2)==1) && ($GLOBALS['DEBUG_MODE']) && (running_script('index')))	We know this works now, so let's stop messing up our development speed
            		{
            			require_code('view_modes');
            			erase_cached_templates(true); // Stop anything trying to read a template cache item (E.g. CSS, JS) that might not exist!
            		}*/
            if (strpos(ocp_srv('HTTP_REFERER'), ocp_srv('HTTP_HOST')) !== false && strpos(ocp_srv('HTTP_REFERER'), 'keep_devtest') !== false && !running_script('attachment') && !running_script('upgrader') && strpos(ocp_srv('HTTP_REFERER'), 'login') === false && is_null(get_param('keep_devtest', NULL))) {
                $_GET['keep_devtest'] = '1';
                fatal_exit('URL not constructed properly: development mode in use but keep_devtest was not specified. This indicates that links have been made without build_url (in PHP) or keep_stub (in Javascript). Whilst not fatal this time, failure to use these functions can cause problems when your site goes live. See the ocPortal codebook for more details.');
            } else {
                $_GET['keep_devtest'] = '1';
            }
        }
        if (browser_matches('true_xhtml') && get_value('html5') !== '1' && get_value('html5') !== '_true' && get_param_integer('keep_no_xhtml', 0) == 0 && !running_script('upgrader')) {
            @header('Content-type: application/xhtml+xml; charset=' . get_charset());
        }
        if (isset($_CREATED_FILES)) {
            /**
             * Run after-tests for debug mode, to make sure coding standards are met.
             */
            function debug_mode_aftertests()
            {
                global $_CREATED_FILES, $_MODIFIED_FILES;
                // Use the info from ocProduct's custom PHP version to make sure that all files that were created/modified got synched as they should have been.
                foreach ($_CREATED_FILES as $file) {
                    if (substr($file, 0, strlen(get_file_base())) == get_file_base() && substr($file, -4) != '.log' && basename($file) != 'permissioncheckslog.php') {
                        @exit(escape_html('File not permission-synched: ' . $file));
                    }
                }
                foreach ($_MODIFIED_FILES as $file) {
                    if (strpos($file, '_cache') === false && substr($file, 0, strlen(get_file_base())) == get_file_base() && substr($file, -4) != '.log' && basename($file) != 'permissioncheckslog.php') {
                        @exit(escape_html('File not change-synched: ' . $file));
                    }
                }
                global $TITLE_CALLED, $SCREEN_TEMPLATE_CALLED, $EXITING;
                if (is_null($SCREEN_TEMPLATE_CALLED) && $EXITING == 0 && strpos(ocp_srv('PHP_SELF'), 'index.php') !== false) {
                    @exit(escape_html('No screen template called.'));
                }
                if (!$TITLE_CALLED && (is_null($SCREEN_TEMPLATE_CALLED) || $SCREEN_TEMPLATE_CALLED != '') && $EXITING == 0 && strpos(ocp_srv('PHP_SELF'), 'index.php') !== false) {
                    @exit(escape_html('No title used on screen.'));
                }
            }
            register_shutdown_function('debug_mode_aftertests');
        }
        if (ocp_srv('SCRIPT_FILENAME') != '' && $GLOBALS['DEBUG_MODE'] && strpos(ocp_srv('SCRIPT_FILENAME'), 'data_custom') === false) {
            if (@strlen(file_get_contents(ocp_srv('SCRIPT_FILENAME'), FILE_TEXT)) > 4500) {
                fatal_exit('Entry scripts (front controllers) should not be shoved full of code.');
            }
        }
    }
    // FirePHP console support, only for administrators
    if ((get_param_integer('keep_firephp', 0) == 1 || get_param_integer('keep_queries', 0) == 1) && ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member()) || $GLOBALS['IS_ACTUALLY_ADMIN'])) {
        require_code('firephp');
    }
    $default_memory_limit = get_value('memory_limit');
    if (is_null($default_memory_limit) || $default_memory_limit == '' || $default_memory_limit == '0' || $default_memory_limit == '-1') {
        $default_memory_limit = '64M';
    }
    @ini_set('memory_limit', $default_memory_limit);
    if (isset($GLOBALS['FORUM_DRIVER']) && $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
        if (get_param_integer('keep_avoid_memory_limit', 0) == 1) {
            disable_php_memory_limit();
        }
        $memory_test = get_param_integer('keep_memory_limit_test', 0);
        if ($memory_test != 0 && $memory_test <= 32) {
            @ini_set('memory_limit', strval($memory_test) . 'M');
        }
    }
    if (get_option('sitewide_im', true) === '1' && running_script('index') && get_param('type', 'misc', true) != 'room') {
        require_code('chat');
        enter_chat_lobby();
    }
    // Startup hooks
    if (!running_script('upgrader')) {
        $startup_hooks = find_all_hooks('systems', 'startup');
        foreach (array_keys($startup_hooks) as $hook) {
            require_code('hooks/systems/startup/' . filter_naughty_harsh($hook));
            $ob = object_factory('Hook_startup_' . filter_naughty_harsh($hook), true);
            if ($ob === NULL) {
                continue;
            }
            $ob->run($MICRO_BOOTUP, $MICRO_AJAX_BOOTUP, 0);
        }
        if ($CURRENT_SHARE_USER !== NULL && float_to_raw_string(ocp_version_number()) != get_value('version')) {
            require_code('upgrade');
            clear_caches_2();
            version_specific();
            upgrade_modules();
            ocf_upgrade();
        }
    }
}
コード例 #16
0
ファイル: failure.php プロジェクト: erico-deh/ocPortal
/**
 * Lookup error on ocportal.com, to see if there is more information.
 *
 * @param  mixed				The error message (string or tempcode)
 * @return ?string			The result from the web service (NULL: no result)
 */
function get_webservice_result($error_message)
{
    if (get_domain() == 'ocportal.com') {
        return NULL;
    }
    if (!function_exists('has_zone_access') || !has_zone_access(get_member(), 'adminzone')) {
        return NULL;
    }
    require_code('files');
    global $DONE_ONE_WEB_SERVICE;
    if ($GLOBALS['DOWNLOAD_LEVEL'] > 0 || $DONE_ONE_WEB_SERVICE) {
        return NULL;
    }
    $DONE_ONE_WEB_SERVICE = true;
    if (is_object($error_message)) {
        $error_message = $error_message->evaluate();
    }
    if ($GLOBALS['HTTP_STATUS_CODE'] == '401') {
        return NULL;
    }
    // Get message IN ENGLISH
    if (user_lang() != fallback_lang()) {
        global $LANGUAGE;
        foreach ($LANGUAGE as $_) {
            foreach ($_ as $key => $val) {
                $regexp = preg_replace('#\\\\{\\d+\\\\}#', '.*', str_replace('#', '\\#', preg_quote($val)));
                if ($regexp != '.*') {
                    if (preg_match('#' . $regexp . '#', $error_message) != 0) {
                        $_error_message = do_lang($key, '', '', '', fallback_lang(), false);
                        if (!is_null($_error_message)) {
                            $error_message = $_error_message;
                        }
                        break;
                    }
                }
            }
        }
    }
    // Talk to web service
    $brand = get_value('rebrand_name');
    if (is_null($brand)) {
        $brand = 'ocPortal';
    }
    $result = http_download_file('http://ocportal.com/uploads/website_specific/ocportal.com/scripts/errorservice.php?version=' . float_to_raw_string(ocp_version_number()) . '&error_message=' . rawurlencode($error_message) . '&product=' . rawurlencode($brand), NULL, false);
    if ($GLOBALS['HTTP_DOWNLOAD_MIME_TYPE'] != 'text/plain') {
        return NULL;
    }
    if ($result == '') {
        return NULL;
    }
    if (function_exists('ocp_mark_as_escaped')) {
        ocp_mark_as_escaped($result);
    }
    return $result;
}
コード例 #17
0
/**
 * Function to process the file upload process
 */
function incoming_uploads_script()
{
    $is_uploaded = false;
    if (!file_exists(get_custom_file_base() . '/uploads/incoming')) {
        @mkdir(get_custom_file_base() . '/uploads/incoming', 0777);
        fix_permissions(get_custom_file_base() . '/uploads/incoming', 0777);
        sync_file(get_custom_file_base() . '/uploads/incoming');
    }
    $savename = 'uploads/incoming/' . uniqid('', true) . '.dat';
    if (array_key_exists('file', $_FILES)) {
        if (is_uploaded_file($_FILES['file']['tmp_name'])) {
            $is_uploaded = true;
        } else {
            header('HTTP/1.1 500 File Upload Error');
            @error_log('ocPortal: ' . do_lang('ERROR_UPLOADING_' . strval($_FILES['file']['error'])), 0);
            exit('ocPortal: ' . do_lang('ERROR_UPLOADING_' . strval($_FILES['file']['error'])));
        }
        $name = $_FILES['file']['name'];
        if ($is_uploaded) {
            @move_uploaded_file($_FILES['file']['tmp_name'], get_custom_file_base() . '/' . $savename) or intelligent_write_error(get_custom_file_base() . '/' . $savename);
        }
    } elseif (post_param('name', '') != '') {
        header("Cache-Control: no-cache, must-revalidate");
        // HTTP/1.1
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        // Date in the past
        $name = post_param('name');
        // Read binary input stream and append it to temp file
        $in = fopen('php://input', 'rb');
        if ($in !== false) {
            // Open temp file
            $out = fopen($savename, 'wb');
            if ($out !== false) {
                $is_uploaded = true;
                do {
                    $buff = fread($in, 4096);
                    fwrite($out, $buff);
                } while (!feof($out));
                fclose($out);
            }
            fclose($in);
        }
    }
    if ($is_uploaded) {
        $max_length = 255;
        $field_type_test = $GLOBALS['SITE_DB']->query_value('db_meta', 'm_type', array('m_name' => 'i_orig_filename'));
        if ($field_type_test == 'ID_TEXT') {
            $max_length = 80;
        }
        // Legacy
        $name = substr($name, max(0, strlen($name) - $max_length));
        header('Content-type: text/plain; charset=' . get_charset());
        require_code('files');
        if (get_param_integer('base64', 0) == 1) {
            $new = base64_decode(file_get_contents(get_custom_file_base() . '/' . $savename));
            $myfile = @fopen(get_custom_file_base() . '/' . $savename, 'wb') or intelligent_write_error(get_custom_file_base() . '/' . $savename);
            fwrite($myfile, $new);
            fclose($myfile);
        }
        fix_permissions(get_custom_file_base() . '/' . $savename);
        sync_file(get_custom_file_base() . '/' . $savename);
        $member_id = get_member();
        $file_db_id = $GLOBALS['SITE_DB']->query_insert('incoming_uploads', array('i_submitter' => $member_id, 'i_date_and_time' => time(), 'i_orig_filename' => $name, 'i_save_url' => $savename), true, false);
        // File is valid, and was successfully uploaded. Now see if there is any metadata to surface from the file.
        require_code('images');
        $outa = array();
        if (is_image($name)) {
            require_code('exif');
            $outa += get_exif_data(get_custom_file_base() . '/' . $savename);
        }
        $outa['upload_id'] = strval($file_db_id);
        $outa['upload_name'] = $name;
        $outa['upload_savename'] = $savename;
        @ini_set('ocproducts.xss_detect', '0');
        $outstr = '{';
        $done = 0;
        foreach ($outa as $key => $val) {
            if (is_float($val)) {
                $val = float_to_raw_string($val);
            } elseif (is_integer($val)) {
                $val = strval($val);
            }
            if (is_string($val) && $val != '') {
                $val = str_replace(chr(0), '', $val);
                if ($done != 0) {
                    $outstr .= ', ';
                }
                $outstr .= '"' . str_replace(chr(10), '\\n', addcslashes($key, "\\\\'\"&\n\r<>")) . '": "' . str_replace(chr(10), '\\n', addcslashes($val, "\\\\'\"&\n\r<>")) . '"';
                $done++;
            }
        }
        $outstr .= '}';
        echo $outstr;
    } else {
        //header('Content-type: text/plain'); @print('No file ('.serialize($_FILES).')');
        header('HTTP/1.1 500 File Upload Error');
        // Test harness
        $title = get_page_title('UPLOAD');
        $fields = new ocp_tempcode();
        require_code('form_templates');
        $fields->attach(form_input_upload(do_lang_tempcode('FILE'), '', 'file', true, NULL, NULL, false));
        $hidden = new ocp_tempcode();
        $out2 = globalise(do_template('FORM_SCREEN', array('TITLE' => $title, 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'), 'TEXT' => '', 'HIDDEN' => $hidden, 'URL' => find_script('incoming_uploads', true), 'FIELDS' => $fields)), NULL, '', true);
        $out2->evaluate_echo();
    }
    exit;
}
コード例 #18
0
                } else {
                    // Add
                    $GLOBALS['SITE_DB']->query_insert('classifieds_prices', array('c_catalogue_name' => $catalogue, 'c_days' => intval($days), 'c_label' => insert_lang($label, 2), 'c_price' => floatval($price)));
                }
            } else {
                if ($matches[1] == 'existing') {
                    // Delete
                    $GLOBALS['SITE_DB']->query_delete('classifieds_prices', array('id' => intval($matches[2])), '', 1);
                }
            }
        }
    }
    attach_message(do_lang_tempcode('SUCCESS', 'inform'));
}
$title = get_page_title('CLASSIFIEDS');
$_prices = $GLOBALS['SITE_DB']->query_select('classifieds_prices', array('*'), NULL, 'ORDER BY c_catalogue_name,c_days,c_price');
$prices = array();
foreach ($_prices as $_price) {
    $prices[] = array('PRICE_CATALOGUE' => $_price['c_catalogue_name'], 'PRICE_DAYS' => strval($_price['c_days']), 'PRICE_LABEL' => get_translated_text($_price['c_label']), 'PRICE_PRICE' => float_to_raw_string($_price['c_price']), 'ID' => 'existing_' . strval($_price['id']));
}
// 10 more
for ($i = 0; $i < 10; $i++) {
    $prices[] = array('PRICE_CATALOGUE' => '', 'PRICE_DAYS' => '', 'PRICE_LABEL' => '', 'PRICE_PRICE' => '', 'ID' => 'new_' . strval($i));
}
$_catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('c_name', 'c_title'), NULL, 'ORDER BY c_name');
$catalogues = array();
foreach ($_catalogues as $_catalogue) {
    $catalogues[$_catalogue['c_name']] = get_translated_text($_catalogue['c_title']);
}
$ret = do_template('CLASSIFIEDS_PRICING_SCREEN', array('TITLE' => $title, 'SUBMIT_NAME' => do_lang_tempcode('SAVE'), 'CATALOGUES' => $catalogues, 'PRICES' => $prices, 'POST_URL' => get_self_url()));
$ret->evaluate_echo();
コード例 #19
0
function _create_catalogue_subtree($fields, $first_cat, $catalogue_name, $root_cat, $full_tree, $node, $tree_pos)
{
    if (!array_key_exists('children', $node)) {
        $node['children'] = array();
    }
    // Bottom level
    $id = _create_catalogue_position($catalogue_name, $tree_pos, $root_cat, $node['details'], $full_tree);
    $node['details']['l_min_latitude'] = $node['details']['l_latitude'];
    $node['details']['l_max_latitude'] = $node['details']['l_latitude'];
    $node['details']['l_min_longitude'] = $node['details']['l_longitude'];
    $node['details']['l_max_longitude'] = $node['details']['l_longitude'];
    foreach ($node['children'] as $name => $child) {
        if (!array_key_exists('details', $child)) {
            $child['details'] = array('l_latitude' => NULL, 'l_longitude' => NULL);
        }
        $child = _create_catalogue_subtree($fields, $first_cat, $catalogue_name, $root_cat, $full_tree, $child, array_merge($tree_pos, array($name)));
        $node['children'][$name] = $child;
        // If updated
        // Work out latitude/longitude bounding boxes
        if (!is_null($child['details']['l_min_latitude']) && (is_null($node['details']['l_min_latitude']) || $child['details']['l_min_latitude'] < $node['details']['l_min_latitude'])) {
            $node['details']['l_min_latitude'] = $child['details']['l_min_latitude'];
        }
        if (!is_null($child['details']['l_max_latitude']) && (is_null($node['details']['l_max_latitude']) || $child['details']['l_max_latitude'] > $node['details']['l_max_latitude'])) {
            $node['details']['l_max_latitude'] = $child['details']['l_max_latitude'];
        }
        if (!is_null($child['details']['l_min_longitude']) && (is_null($node['details']['l_min_longitude']) || $child['details']['l_min_longitude'] < $node['details']['l_min_longitude'])) {
            $node['details']['l_min_longitude'] = $child['details']['l_min_longitude'];
        }
        if (!is_null($child['details']['l_max_longitude']) && (is_null($node['details']['l_max_longitude']) || $child['details']['l_max_longitude'] > $node['details']['l_max_longitude'])) {
            $node['details']['l_max_longitude'] = $child['details']['l_max_longitude'];
        }
    }
    if (is_null($node['details']['l_latitude'])) {
        $node['details']['l_latitude'] = ($node['details']['l_min_latitude'] + $node['details']['l_max_latitude']) / 2;
    }
    if (is_null($node['details']['l_longitude'])) {
        $node['details']['l_longitude'] = ($node['details']['l_min_longitude'] + $node['details']['l_max_longitude']) / 2;
    }
    // Save into category: bounding box, and own latitude/longitude if specified
    $map = array($fields[0]['id'] => float_to_raw_string($node['details']['l_latitude']), $fields[1]['id'] => float_to_raw_string($node['details']['l_longitude']), $fields[2]['id'] => float_to_raw_string($node['details']['l_min_latitude']), $fields[3]['id'] => float_to_raw_string($node['details']['l_max_latitude']), $fields[4]['id'] => float_to_raw_string($node['details']['l_min_longitude']), $fields[5]['id'] => float_to_raw_string($node['details']['l_max_longitude']));
    $existing = get_bound_content_entry('catalogue_category', strval($id));
    if (!is_null($existing)) {
        actual_edit_catalogue_entry($existing, $first_cat, 1, '', 0, 0, 0, $map);
    } else {
        $catalogue_entry_id = actual_add_catalogue_entry($first_cat, 1, '', 0, 0, 0, $map);
        $GLOBALS['SITE_DB']->query_insert('catalogue_entry_linkage', array('catalogue_entry_id' => $catalogue_entry_id, 'content_type' => 'catalogue_category', 'content_id' => strval($id)));
    }
    return $node;
}
コード例 #20
0
ファイル: search.php プロジェクト: erico-deh/ocPortal
 /**
  * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
  * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declaritive.
  * Assumptions: You can assume all Lang/CSS/Javascript files in this addon have been pre-required.
  *
  * @return array			Array of previews, each is Tempcode. Normally we have just one preview, but occasionally it is good to test templates are flexible (e.g. if they use IF_EMPTY, we can test with and without blank data).
  */
 function tpl_preview__block_side_tag_cloud()
 {
     $tpl_tags = array();
     $tags = array(lorem_word() => 3, lorem_word_2() => 5);
     foreach ($tags as $tag => $count) {
         $em = 1.0;
         $tpl_tags[] = array('TAG' => $tag, 'COUNT' => "{$count}", 'EM' => float_to_raw_string($em), 'LINK' => placeholder_url());
     }
     return array(lorem_globalise(do_lorem_template('BLOCK_SIDE_TAG_CLOUD', array('TITLE' => lorem_phrase(), 'TAGS' => $tpl_tags)), NULL, '', true));
 }
コード例 #21
0
ファイル: catalogues.php プロジェクト: erico-deh/ocPortal
/**
 * Get the value for the specified field, for the stated catalogue entry.
 *
 * @param  AUTO_LINK		The ID of the field we are getting
 * @param  mixed			The ID of the entry we are getting for OR the row
 * @param  ID_TEXT		The type of field
 * @set    short long
 * @param  ?array			A list of field IDs that we are limiting ourselves to (NULL: get ALL fields)
 * @return string			The value
 */
function _get_catalogue_entry_field($field_id, $entry_id, $type = 'short', $only_field_ids = NULL)
{
    if (is_array($entry_id)) {
        $entry_id = $entry_id['id'];
    }
    global $SITE_INFO;
    if (!running_script('ajax_tree') && (!isset($SITE_INFO['mysql_old']) || $SITE_INFO['mysql_old'] == '0') && (!isset($SITE_INFO['mysql_old']) || !is_file(get_file_base() . '/mysql_old'))) {
        // Pre-caching of whole entry
        static $catalogue_entry_cache = array();
        if (!isset($catalogue_entry_cache[$entry_id][$field_id])) {
            if (!isset($catalogue_entry_cache[$entry_id])) {
                $catalogue_entry_cache[$entry_id] = array();
            }
            $query = '';
            foreach (array('catalogue_efv_float', 'catalogue_efv_integer', 'catalogue_efv_long', 'catalogue_efv_long_trans', 'catalogue_efv_short', 'catalogue_efv_short_trans') as $table) {
                if ($query != '') {
                    $query .= ' UNION ';
                }
                $query .= 'SELECT f.id,v.cv_value,';
                if (strpos($table, '_trans') !== false) {
                    $query .= 't.text_original,t.text_parsed';
                } else {
                    $query .= 'NULL AS text_original,NULL AS text_parsed';
                }
                $query .= ' FROM ' . get_table_prefix() . 'catalogue_fields f JOIN ' . get_table_prefix() . $table . ' v ON v.cf_id=f.id';
                if (strpos($table, '_trans') !== false) {
                    $query .= ' JOIN ' . get_table_prefix() . 'translate t ON t.id=v.cv_value';
                }
                $query .= ' WHERE v.ce_id=' . strval($entry_id);
                if (!is_null($only_field_ids)) {
                    $query .= ' AND (';
                    if ($only_field_ids != array()) {
                        foreach ($only_field_ids as $i => $_field_id) {
                            if ($i != 0) {
                                $query .= ' OR ';
                            }
                            $query .= 'f.id=' . strval($_field_id);
                        }
                    } else {
                        $query .= '1=0';
                    }
                    $query .= ')';
                }
            }
            foreach ($GLOBALS['SITE_DB']->query($query, NULL, NULL, false, true) as $line) {
                $catalogue_entry_cache[$entry_id][$line['id']] = $line['cv_value'];
                if (isset($line['text_original'])) {
                    $GLOBALS['SITE_DB']->text_lookup_original_cache[$line['cv_value']] = $line['text_original'];
                    $GLOBALS['SITE_DB']->text_lookup_cache[$line['cv_value']] = $line['text_parsed'];
                }
            }
        }
        $value = isset($catalogue_entry_cache[$entry_id][$field_id]) ? $catalogue_entry_cache[$entry_id][$field_id] : NULL;
    } else {
        $value = $GLOBALS['SITE_DB']->query_value_null_ok('catalogue_efv_' . $type, 'cv_value', array('cf_id' => $field_id, 'ce_id' => $entry_id));
    }
    if (is_integer($value)) {
        $value = strval($value);
    }
    if (is_float($value)) {
        $value = float_to_raw_string($value);
    }
    return $value;
}
コード例 #22
0
ファイル: worldpay.php プロジェクト: erico-deh/ocPortal
 /**
  * Make a subscription (payment) button.
  *
  * @param  ID_TEXT		The product codename.
  * @param  SHORT_TEXT	The human-readable product title.
  * @param  AUTO_LINK		The purchase ID.
  * @param  float			A transaction amount.
  * @param  integer		The subscription length in the units.
  * @param  ID_TEXT		The length units.
  * @set    d w m y
  * @param  ID_TEXT		The currency to use.
  * @return tempcode		The button
  */
 function make_subscription_button($product, $item_name, $purchase_id, $amount, $length, $length_units, $currency)
 {
     $username = $this->_get_username();
     $ipn_url = $this->get_ipn_url();
     $trans_id = $this->generate_trans_id();
     $length_units_2 = '1';
     $first_repeat = time();
     switch ($length_units) {
         case 'd':
             $length_units_2 = '1';
             $first_repeat = 60 * 60 * 24 * $length;
             break;
         case 'w':
             $length_units_2 = '2';
             $first_repeat = 60 * 60 * 24 * 7 * $length;
             break;
         case 'm':
             $length_units_2 = '3';
             $first_repeat = 60 * 60 * 24 * 31 * $length;
             break;
         case 'y':
             $length_units_2 = '4';
             $first_repeat = 60 * 60 * 24 * 365 * $length;
             break;
     }
     $digest = md5(get_option('ipn_digest') . ':' . $trans_id . ':' . float_to_raw_string($amount) . ':' . $currency . $length_units_2 . strval($length));
     $GLOBALS['SITE_DB']->query_insert('trans_expecting', array('id' => $trans_id, 'e_purchase_id' => $purchase_id, 'e_item_name' => $item_name, 'e_member_id' => get_member(), 'e_amount' => float_to_raw_string($amount), 'e_ip_address' => get_ip_address(), 'e_session_id' => get_session_id(), 'e_time' => time(), 'e_length' => NULL, 'e_length_units' => ''));
     return do_template('ECOM_SUBSCRIPTION_BUTTON_VIA_WORLDPAY', array('_GUID' => '1f88716137762a467edbf5fbb980c6fe', 'PRODUCT' => $product, 'DIGEST' => $digest, 'TEST' => ecommerce_test_mode(), 'LENGTH' => strval($length), 'LENGTH_UNITS_2' => $length_units_2, 'ITEM_NAME' => $item_name, 'PURCHASE_ID' => strval($trans_id), 'AMOUNT' => float_to_raw_string($amount), 'FIRST_REPEAT' => date('Y-m-d', $first_repeat), 'CURRENCY' => $currency, 'USERNAME' => $username, 'IPN_URL' => $ipn_url));
 }
コード例 #23
0
ファイル: float.php プロジェクト: erico-deh/ocPortal
 /**
  * Get form inputter.
  *
  * @param  string			The field name
  * @param  string			The field description
  * @param  array			The field details
  * @param  ?string		The actual current value of the field (NULL: none)
  * @param  boolean		Whether this is for a new entry
  * @return ?tempcode		The Tempcode for the input field (NULL: skip the field - it's not input)
  */
 function get_field_inputter($_cf_name, $_cf_description, $field, $actual_value, $new)
 {
     if ($_cf_name == 'Longitude') {
         $pretty_name = $_cf_name;
         $description = $_cf_description;
         $name = 'field_' . strval($field['id']);
         $required = $field['cf_required'] == 1;
         if (isset($actual_value) && $actual_value != '' && $actual_value != do_lang('NA')) {
             $longitude = float_to_raw_string(floatval($actual_value), 10);
         }
         global $LATITUDE;
         if (isset($LATITUDE) && $LATITUDE != '' && $LATITUDE != do_lang('NA')) {
             $latitude = float_to_raw_string(floatval($LATITUDE), 10);
         }
         if ($latitude == '0.0000000000') {
             $latitude = '0';
         }
         if ($longitude == '0.0000000000') {
             $longitude = '0';
         }
         $input = do_template('FORM_SCREEN_INPUT_MAP_POSITION', array('REQUIRED' => $required, 'NAME' => $name, 'LATITUDE' => $latitude, 'LONGITUDE' => $longitude));
         return _form_input($name, 'Position', '', $input, $required, false);
     }
     if ($_cf_name == 'Latitude') {
         global $LATITUDE;
         $LATITUDE = $actual_value;
         // Store for when Longitude field is rendered - critical, else won't be entered
         return new ocp_tempcode();
     }
     return form_input_float($_cf_name, $_cf_description, 'field_' . strval($field['id']), is_null($actual_value) || $actual_value === '' ? NULL : floatval($actual_value), $field['cf_required'] == 1);
 }
コード例 #24
0
ファイル: xml_storage.php プロジェクト: erico-deh/ocPortal
/**
 * Take a PHP map array, and make it look nice.
 *
 * @param  array			Map array
 * @return string			Pretty version
 */
function make_map_nice($map)
{
    $out = '';
    foreach ($map as $key => $val) {
        if (!is_string($val)) {
            if (is_float($val)) {
                $val = float_to_raw_string($val);
            } else {
                $val = strval($val);
            }
        }
        if ($out != '') {
            $out .= chr(10);
        }
        $out .= $key . ' = ' . $val;
    }
    return $out;
}
コード例 #25
0
ファイル: shopping.php プロジェクト: erico-deh/ocPortal
/**
 * Payment step.
 *
 * @return tempcode	The result of execution.
 */
function payment_form()
{
    require_code('ecommerce');
    $title = get_page_title('PAYMENT_HEADING');
    $cart_items = find_products_in_cart();
    $purchase_id = NULL;
    $tax_opt_out = get_order_tax_opt_out_status();
    if (count($cart_items) > 0) {
        $insert = array('c_member' => get_member(), 'session_id' => get_session_id(), 'add_date' => time(), 'tot_price' => 0, 'order_status' => 'ORDER_STATUS_awaiting_payment', 'notes' => '', 'purchase_through' => 'cart', 'transaction_id' => '', 'tax_opted_out' => $tax_opt_out);
        if (is_null($GLOBALS['SITE_DB']->query_value_null_ok('shopping_order', 'id'))) {
            $insert['id'] = hexdec('1701D');
            // Start offset
        }
        $order_id = $GLOBALS['SITE_DB']->query_insert('shopping_order', $insert, true);
    } else {
        $order_id = NULL;
    }
    $total_price = 0;
    foreach ($cart_items as $item) {
        $product = $item['product_id'];
        $hook = $item['product_type'];
        require_code('hooks/systems/ecommerce/' . filter_naughty_harsh($hook), true);
        $object = object_factory('Hook_' . filter_naughty_harsh($hook), true);
        if (is_null($object)) {
            continue;
        }
        $temp = $object->get_products(false, $product);
        if ($temp[$product][0] == PRODUCT_SUBSCRIPTION) {
            continue;
        }
        //Subscription type skipped.
        $price = $temp[$product][1];
        $item_name = $temp[$product][4];
        if (method_exists($object, 'set_needed_fields')) {
            $purchase_id = $object->set_needed_fields($product);
        } else {
            $purchase_id = strval(get_member());
        }
        $length = NULL;
        $length_units = '';
        if (method_exists($object, 'calculate_product_price')) {
            $price = $object->calculate_product_price($item['price'], $item['price_pre_tax'], $item['product_weight']);
        } else {
            $price = $item['price'];
        }
        if (method_exists($object, 'calculate_tax') && $tax_opt_out == 0) {
            $tax = round($object->calculate_tax($item['price'], $item['price_pre_tax']), 2);
        } else {
            $tax = 0.0;
        }
        $GLOBALS['SITE_DB']->query_insert('shopping_order_details', array('p_id' => $item['product_id'], 'p_name' => $item['product_name'], 'p_code' => $item['product_code'], 'p_type' => $item['product_type'], 'p_quantity' => $item['quantity'], 'p_price' => $price, 'included_tax' => $tax, 'order_id' => $order_id, 'dispatch_status' => ''), true);
        $total_price += $price * $item['quantity'];
    }
    $GLOBALS['SITE_DB']->query_update('shopping_order', array('tot_price' => $total_price), array('id' => $order_id), '', 1);
    if (!perform_local_payment()) {
        $result = make_cart_payment_button($order_id, get_option('currency'));
    } else {
        if (!tacit_https() && !ecommerce_test_mode()) {
            warn_exit(do_lang_tempcode('NO_SSL_SETUP'));
        }
        if (is_null($order_id)) {
            $fields = new ocp_tempcode();
            $hidden = new ocp_tempcode();
        } else {
            list($fields, $hidden) = get_transaction_form_fields(NULL, strval($order_id), $item_name, float_to_raw_string($price), NULL, '');
        }
        /*$via	=get_option('payment_gateway');
        		require_code('hooks/systems/ecommerce_via/'.filter_naughty_harsh($via));
        		$object=object_factory('Hook_'.$via);
        		$ipn_url=$object->get_ipn_url();*/
        $finish_url = build_url(array('page' => 'purchase', 'type' => 'finish'), get_module_zone('purchase'));
        $result = do_template('PURCHASE_WIZARD_STAGE_TRANSACT', array('FIELDS' => $fields, 'HIDDEN' => $hidden));
        require_javascript('javascript_validation');
        return do_template('PURCHASE_WIZARD_SCREEN', array('TITLE' => $title, 'CONTENT' => $result, 'URL' => $finish_url));
    }
    return $result;
}
コード例 #26
0
ファイル: invoices.php プロジェクト: erico-deh/ocPortal
 /**
  * Show my invoices.
  *
  * @return tempcode	The interface.
  */
 function pay()
 {
     $id = get_param_integer('id');
     if (!tacit_https() && !ecommerce_test_mode()) {
         warn_exit(do_lang_tempcode('NO_SSL_SETUP'));
     }
     $title = get_page_title('MAKE_PAYMENT');
     $post_url = build_url(array('page' => 'purchase', 'type' => 'finish'), get_module_zone('purchase'));
     $rows = $GLOBALS['SITE_DB']->query_select('invoices', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $row = $rows[0];
     $product = $row['i_type_code'];
     $object = find_product($product);
     $products = $object->get_products(false, $product);
     $invoice_title = $products[$product][4];
     list($fields, $hidden) = get_transaction_form_fields(NULL, strval($id), $invoice_title, float_to_raw_string($row['i_amount']), NULL, '');
     $text = do_lang_tempcode('TRANSACT_INFO');
     return do_template('FORM_SCREEN', array('_GUID' => 'e90a4019b37c8bf5bcb64086416bcfb3', 'TITLE' => $title, 'SKIP_VALIDATION' => '1', 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'HIDDEN' => $hidden, 'SUBMIT_NAME' => do_lang_tempcode('MAKE_PAYMENT')));
 }
コード例 #27
0
ファイル: topics.php プロジェクト: erico-deh/ocPortal
 /**
  * Render posts.
  *
  * @param  integer		Maximum to load if non-threaded
  * @param  array			Tree structure of posts
  * @param  boolean		Whether the current user may reply to the topic (influences what buttons show)
  * @param  ?AUTO_LINK	Only show posts under here (NULL: show posts from root)
  * @param  array			Review ratings rows
  * @param  AUTO_LINK		ID of forum this topic in in
  * @return tempcode		Rendered tree structure
  */
 function _render_post_tree($num_to_show_limit, $tree, $may_reply, $highlight_by_user, $all_individual_review_ratings, $forum_id)
 {
     list($rendered, ) = $tree;
     $sequence = new ocp_tempcode();
     foreach ($rendered as $post) {
         if (get_forum_type() == 'ocf') {
             require_code('ocf_topicview');
             require_code('ocf_posts');
             $post += ocf_get_details_to_show_post($post);
         }
         // Misc details
         $datetime_raw = $post['date'];
         $datetime = get_timezoned_date($post['date']);
         $poster_url = is_guest($post['user']) ? new ocp_tempcode() : $GLOBALS['FORUM_DRIVER']->member_profile_url($post['user'], false, true);
         $poster_name = array_key_exists('username', $post) ? $post['username'] : $GLOBALS['FORUM_DRIVER']->get_username($post['user']);
         if (is_null($poster_name)) {
             $poster_name = do_lang('UNKNOWN');
         }
         $highlight = $highlight_by_user === $post['user'];
         // Find review, if there is one
         $individual_review_ratings = array();
         foreach ($all_individual_review_ratings as $potential_individual_review_rating) {
             if ($potential_individual_review_rating['r_post_id'] == $post['id']) {
                 $individual_review_ratings[$potential_individual_review_rating['r_rating_type']] = array('REVIEW_TITLE' => $potential_individual_review_rating['r_rating_type'], 'REVIEW_RATING' => float_to_raw_string($potential_individual_review_rating['r_rating']));
             }
         }
         // Edit URL
         $emphasis = new ocp_tempcode();
         $buttons = new ocp_tempcode();
         $last_edited = new ocp_tempcode();
         $last_edited_raw = '';
         $unvalidated = new ocp_tempcode();
         $poster = mixed();
         $poster_details = new ocp_tempcode();
         $is_spacer_post = false;
         if (get_forum_type() == 'ocf') {
             // Spacer post fiddling
             if (!is_null($this->first_post_id) && !is_null($this->topic_title) && !is_null($this->topic_description) && !is_null($this->topic_description_link)) {
                 $is_spacer_post = $post['id'] == $this->first_post_id && substr($post['message_comcode'], 0, strlen('[semihtml]' . do_lang('SPACER_POST_MATCHER'))) == '[semihtml]' . do_lang('SPACER_POST_MATCHER');
                 if ($is_spacer_post) {
                     $c_prefix = do_lang('COMMENT') . ': #';
                     if (substr($this->topic_description, 0, strlen($c_prefix)) == $c_prefix && $this->topic_description_link != '') {
                         list($linked_type, $linked_id) = explode('_', substr($this->topic_description, strlen($c_prefix)), 2);
                         $linked_url = $this->topic_description_link;
                         require_code('ocf_posts');
                         list($new_description, $new_post) = ocf_display_spacer_post($linked_type, $linked_id);
                         //if (!is_null($new_description)) $this->topic_description=$new_description;	Actually, it's a bit redundant
                         if (!is_null($new_post)) {
                             $post['message'] = $new_post;
                         }
                         $highlight = false;
                         $this->topic_title = do_lang('SPACER_TOPIC_TITLE_WRAP', $this->topic_title);
                         $post['title'] = do_lang('SPACER_TOPIC_TITLE_WRAP', $post['title']);
                         $this->topic_description = '';
                     }
                 }
             }
             // Misc meta details for post
             $emphasis = ocf_get_post_emphasis($post);
             $unvalidated = $post['validated'] == 0 ? do_lang_tempcode('UNVALIDATED') : new ocp_tempcode();
             if (array_key_exists('last_edit_time', $post)) {
                 $last_edited = do_template('OCF_TOPIC_POST_LAST_EDITED', array('LAST_EDIT_DATE_RAW' => is_null($post['last_edit_time']) ? '' : strval($post['last_edit_time']), 'LAST_EDIT_DATE' => $post['last_edit_time_string'], 'LAST_EDIT_PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($post['last_edit_by'], false, true), 'LAST_EDIT_USERNAME' => $post['last_edit_by_username']));
                 $last_edited_raw = is_null($post['last_edit_time']) ? '' : strval($post['last_edit_time']);
             }
             // Post buttons
             if (!$is_spacer_post) {
                 if (!is_null($this->topic_id)) {
                     if (is_null($this->topic_info)) {
                         $this->topic_info = ocf_read_in_topic($this->topic_id, 0, 0, false, false);
                     }
                     require_lang('ocf');
                     $buttons = ocf_render_post_buttons($this->topic_info, $post, $may_reply);
                 }
             }
             // OCF renderings of poster
             static $hooks = NULL;
             if (is_null($hooks)) {
                 $hooks = find_all_hooks('modules', 'topicview');
             }
             static $hook_objects = NULL;
             if (is_null($hook_objects)) {
                 $hook_objects = array();
                 foreach (array_keys($hooks) as $hook) {
                     require_code('hooks/modules/topicview/' . filter_naughty_harsh($hook));
                     $object = object_factory('Hook_' . filter_naughty_harsh($hook), true);
                     if (is_null($object)) {
                         continue;
                     }
                     $hook_objects[$hook] = $object;
                 }
             }
             if (!$is_spacer_post) {
                 if (!is_guest($post['poster'])) {
                     require_code('ocf_members2');
                     $poster_details = ocf_show_member_box($post, false, $hooks, $hook_objects, false);
                 } else {
                     $custom_fields = new ocp_tempcode();
                     if (array_key_exists('ip_address', $post) && addon_installed('ocf_forum')) {
                         $custom_fields->attach(do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('NAME' => do_lang_tempcode('IP_ADDRESS'), 'VALUE' => $post['ip_address'])));
                         $poster_details = do_template('OCF_GUEST_DETAILS', array('CUSTOM_FIELDS' => $custom_fields));
                     } else {
                         $poster_details = new ocp_tempcode();
                     }
                 }
             }
             if (addon_installed('ocf_forum')) {
                 if (!is_guest($post['poster'])) {
                     $poster = do_template('OCF_POSTER_MEMBER', array('ONLINE' => member_is_online($post['poster']), 'ID' => strval($post['poster']), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($post['poster'], false, true), 'POSTER_USERNAME' => $post['poster_username']));
                 } else {
                     $ip_link = array_key_exists('ip_address', $post) && has_actual_page_access(get_member(), 'admin_lookup') ? build_url(array('page' => 'admin_lookup', 'param' => $post['ip_address']), get_module_zone('admin_lookup')) : new ocp_tempcode();
                     $poster = do_template('OCF_POSTER_GUEST', array('IP_LINK' => $ip_link, 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $post['poster_username']));
                 }
             } else {
                 $poster = make_string_tempcode(escape_html($post['poster_username']));
             }
         }
         // Child posts
         $children = mixed();
         // NULL
         $other_ids = array();
         if (array_key_exists('children', $post)) {
             foreach ($post['children'][1] as $u) {
                 $other_ids[] = strval($u['id']);
             }
             if ($this->is_threaded) {
                 $children = $this->_render_post_tree($num_to_show_limit, $post['children'], $may_reply, $highlight_by_user, $all_individual_review_ratings, $forum_id);
             }
         }
         if (get_forum_type() == 'ocf') {
             require_code('feedback');
             actualise_rating(true, 'post', strval($post['id']), get_self_url(), $post['title']);
             $rating = display_rating(get_self_url(), $post['title'], 'post', strval($post['id']), 'RATING_INLINE_DYNAMIC', $post['user']);
         } else {
             $rating = new ocp_tempcode();
         }
         if (array_key_exists('intended_solely_for', $post)) {
             decache('side_ocf_personal_topics', array(get_member()));
             decache('_new_pp', array(get_member()));
         }
         // Render
         $sequence->attach(static_evaluate_tempcode(do_template('POST', array('_GUID' => 'eb7df038959885414e32f58e9f0f9f39', 'INDIVIDUAL_REVIEW_RATINGS' => $individual_review_ratings, 'HIGHLIGHT' => $highlight, 'TITLE' => $post['title'], 'TIME_RAW' => strval($datetime_raw), 'TIME' => $datetime, 'POSTER_ID' => strval($post['user']), 'POSTER_URL' => $poster_url, 'POSTER_NAME' => $poster_name, 'POSTER' => $poster, 'POSTER_DETAILS' => $poster_details, 'ID' => strval($post['id']), 'POST' => $post['message'], 'POST_COMCODE' => isset($post['message_comcode']) ? $post['message_comcode'] : NULL, 'CHILDREN' => $children, 'OTHER_IDS' => count($other_ids) == 0 ? NULL : $other_ids, 'RATING' => $rating, 'EMPHASIS' => $emphasis, 'BUTTONS' => $buttons, 'LAST_EDITED_RAW' => $last_edited_raw, 'LAST_EDITED' => $last_edited, 'TOPIC_ID' => is_null($this->topic_id) ? '' : strval($this->topic_id), 'UNVALIDATED' => $unvalidated, 'IS_SPACER_POST' => $is_spacer_post, 'NUM_TO_SHOW_LIMIT' => strval($num_to_show_limit)))));
     }
     return $sequence;
 }
コード例 #28
0
function find_nearest_location($latitude, $longitude, $latitude_field_id = NULL, $longitude_field_id = NULL, $error_tolerance = 0.0005)
{
    $where = '';
    $where .= '(';
    $where .= '(l_latitude>' . float_to_raw_string($latitude - $error_tolerance);
    $where .= ' AND ';
    $where .= 'l_latitude<' . float_to_raw_string($latitude + $error_tolerance) . ')';
    if ($latitude - $error_tolerance < -45.0) {
        $where .= ' OR ';
        $where .= '(l_latitude>' . float_to_raw_string($latitude - $error_tolerance + 90.0);
        $where .= ' AND ';
        $where .= 'l_latitude<' . float_to_raw_string($latitude + $error_tolerance + 90.0) . ')';
    }
    if ($latitude + $error_tolerance > 45.0) {
        $where .= ' OR ';
        $where .= '(l_latitude>' . float_to_raw_string($latitude - $error_tolerance - 90.0);
        $where .= ' AND ';
        $where .= 'l_latitude<' . float_to_raw_string($latitude + $error_tolerance - 90.0) . ')';
    }
    $where .= ')';
    $where .= ' AND ';
    $where .= '(';
    $where .= '(l_longitude>' . float_to_raw_string($longitude - $error_tolerance);
    $where .= ' AND ';
    $where .= 'l_longitude<' . float_to_raw_string($longitude + $error_tolerance) . ')';
    if ($longitude - $error_tolerance < -45.0) {
        $where .= ' OR ';
        $where .= '(l_longitude>' . float_to_raw_string($longitude - $error_tolerance + 90.0);
        $where .= ' AND ';
        $where .= 'l_longitude<' . float_to_raw_string($longitude + $error_tolerance + 90.0) . ')';
    }
    if ($longitude + $error_tolerance > 45.0) {
        $where .= ' OR ';
        $where .= '(l_longitude>' . float_to_raw_string($longitude - $error_tolerance - 90.0);
        $where .= ' AND ';
        $where .= 'l_longitude<' . float_to_raw_string($longitude + $error_tolerance - 90.0) . ')';
    }
    $where .= ')';
    if (is_null($latitude_field_id) || is_null($longitude_field_id)) {
        $query = 'SELECT * FROM ' . get_table_prefix() . 'locations WHERE ' . $where;
        $locations = $GLOBALS['SITE_DB']->query($query);
    } else {
        $where = str_replace(array('l_latitude', 'l_longitude'), array('a.cv_value', 'b.cv_value'), $where);
        $query = 'SELECT a.ce_id,c.id,cc_title,a.cv_value AS l_latitude,b.cv_value AS l_longitude FROM ' . get_table_prefix() . 'catalogue_efv_float a JOIN ' . get_table_prefix() . 'catalogue_efv_float b ON a.ce_id=b.ce_id AND a.cf_id=' . strval($latitude_field_id) . ' AND b.cf_id=' . strval($longitude_field_id) . ' LEFT JOIN ' . get_table_prefix() . 'catalogue_entry_linkage x ON a.ce_id=x.catalogue_entry_id AND ' . db_string_equal_to('x.content_type', 'catalogue_category') . ' LEFT JOIN ' . get_table_prefix() . 'catalogue_categories c ON c.id=x.content_id WHERE ' . $where;
        $locations = $GLOBALS['SITE_DB']->query($query, NULL, NULL, false, false, array('cc_title'));
    }
    if (count($locations) == 0) {
        if ($latitude - $error_tolerance < -90.0 && $latitude + $error_tolerance > 90.0 && $longitude - $error_tolerance < -90.0 && $longitude + $error_tolerance > 90.0) {
            return NULL;
            // Nothing, in whole world
        }
        return find_nearest_location($latitude, $longitude, $latitude_field_id, $longitude_field_id, $error_tolerance * 1.3);
    }
    $best = mixed();
    $best_at = mixed();
    foreach ($locations as $l) {
        $dist = sqrt($l['l_latitude'] * $l['l_latitude'] + $l['l_longitude'] * $l['l_longitude']);
        if (is_null($best) || $dist < $best) {
            $best = $dist;
            $best_at = $l;
        }
    }
    $locations = array($best_at);
    return $locations[0];
}
コード例 #29
0
ファイル: about.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard modular render function for profile tab hooks.
  *
  * @param  MEMBER			The ID of the member who is being viewed
  * @param  MEMBER			The ID of the member who is doing the viewing
  * @param  boolean		Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later
  * @return array			A triple: The tab title, the tab contents, the suggested tab order
  */
 function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false)
 {
     $title = do_lang_tempcode('PROFILE');
     $order = 10;
     $photo_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_url');
     if ($photo_url != '' && addon_installed('ocf_member_photos') && has_specific_permission($member_id_viewing, 'view_member_photos')) {
         require_code('images');
         $photo_thumb_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_thumb_url');
         $photo_thumb_url = ensure_thumbnail($photo_url, $photo_thumb_url, strpos($photo_url, 'uploads/photos') !== false ? 'photos' : 'ocf_photos', 'f_members', $member_id_of, 'm_photo_thumb_url');
         if (url_is_local($photo_url)) {
             $photo_url = get_complex_base_url($photo_url) . '/' . $photo_url;
         }
         if (url_is_local($photo_thumb_url)) {
             $photo_thumb_url = get_complex_base_url($photo_thumb_url) . '/' . $photo_thumb_url;
         }
     } else {
         $photo_url = '';
         $photo_thumb_url = '';
     }
     $avatar_url = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id_of);
     $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
     // Things staff can do with this user
     $modules = array();
     if (has_specific_permission($member_id_viewing, 'warn_members') && has_actual_page_access($member_id_viewing, 'warnings') && addon_installed('ocf_warnings')) {
         $redir_url = get_self_url(true);
         $modules[] = array('usage', do_lang_tempcode('WARN_MEMBER'), build_url(array('page' => 'warnings', 'type' => 'ad', 'id' => $member_id_of, 'redirect' => $redir_url), get_module_zone('warnings')));
         $modules[] = array('usage', do_lang_tempcode('PUNITIVE_HISTORY'), build_url(array('page' => 'warnings', 'type' => 'history', 'id' => $member_id_of), get_module_zone('warnings')));
     }
     if (has_specific_permission($member_id_viewing, 'view_content_history') && has_actual_page_access($member_id_viewing, 'admin_ocf_history')) {
         $modules[] = !addon_installed('ocf_forum') ? NULL : array('usage', do_lang_tempcode('POST_HISTORY'), build_url(array('page' => 'admin_ocf_history', 'member_id' => $member_id_of), 'adminzone'));
     }
     if (has_actual_page_access($member_id_viewing, 'admin_lookup')) {
         require_lang('submitban');
         $modules[] = array('usage', do_lang_tempcode('INVESTIGATE_USER'), build_url(array('page' => 'admin_lookup', 'param' => $member_id_of), 'adminzone'));
     }
     if (has_actual_page_access($member_id_viewing, 'admin_security')) {
         require_lang('security');
         $modules[] = array('usage', do_lang_tempcode('SECURITY_LOGGING'), build_url(array('page' => 'admin_security', 'member_id' => $member_id_of), 'adminzone'));
     }
     if (addon_installed('actionlog')) {
         if (has_actual_page_access($member_id_viewing, 'admin_actionlog')) {
             require_lang('submitban');
             $modules[] = array('usage', do_lang_tempcode('VIEW_ACTION_LOGS'), build_url(array('page' => 'admin_actionlog', 'type' => 'list', 'id' => $member_id_of), 'adminzone'));
         }
     }
     if (has_actual_page_access($member_id_viewing, 'search') && addon_installed('ocf_forum') && addon_installed('search')) {
         $modules[] = array('content', do_lang_tempcode('SEARCH_POSTS'), build_url(array('page' => 'search', 'type' => 'results', 'id' => 'ocf_posts', 'author' => $username, 'sort' => 'add_date', 'direction' => 'DESC', 'content' => ''), get_module_zone('search')), 'search');
     }
     if (has_actual_page_access($member_id_viewing, 'search') && addon_installed('search')) {
         $modules[] = array('content', do_lang_tempcode('SEARCH'), build_url(array('page' => 'search', 'type' => 'misc', 'author' => $username), get_module_zone('search')), 'search');
     }
     if (addon_installed('authors')) {
         $author = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT author FROM ' . get_table_prefix() . 'authors WHERE (forum_handle=' . strval($member_id_viewing) . ') OR (forum_handle IS NULL AND ' . db_string_equal_to('author', $username) . ')');
         if (has_actual_page_access($member_id_viewing, 'authors') && !is_null($author)) {
             $modules[] = array('content', do_lang_tempcode('AUTHOR'), build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $author), get_module_zone('authors')), 'me');
         }
     }
     require_code('ocf_members2');
     if (!is_guest() && ocf_may_whisper($member_id_of) && has_actual_page_access($member_id_viewing, 'topics') && ocf_may_make_personal_topic() && $member_id_viewing != $member_id_of) {
         $modules[] = !addon_installed('ocf_forum') ? NULL : array('contact', do_lang_tempcode('ADD_PERSONAL_TOPIC'), build_url(array('page' => 'topics', 'type' => 'new_pt', 'id' => $member_id_of), get_module_zone('topics')), 'reply');
     }
     $extra_sections = array();
     $info_details = array();
     $hooks = find_all_hooks('modules', 'members');
     foreach (array_keys($hooks) as $hook) {
         require_code('hooks/modules/members/' . filter_naughty_harsh($hook));
         $object = object_factory('Hook_members_' . filter_naughty_harsh($hook), true);
         if (is_null($object)) {
             continue;
         }
         if (method_exists($object, 'run')) {
             $hook_result = $object->run($member_id_of);
             $modules = array_merge($modules, $hook_result);
         }
         if (method_exists($object, 'get_info_details')) {
             $hook_result = $object->get_info_details($member_id_of);
             $info_details = array_merge($info_details, $hook_result);
         }
         if (method_exists($object, 'get_sections')) {
             $hook_result = $object->get_sections($member_id_of);
             $extra_sections = array_merge($extra_sections, $hook_result);
         }
     }
     if (addon_installed('ocf_contactmember')) {
         if (($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_allow_emails') == 1 || get_option('allow_email_disable') == '0') && $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_email_address') != '' && !is_guest($member_id_of) && has_actual_page_access($member_id_viewing, 'contactmember') && $member_id_viewing != $member_id_of) {
             $redirect = get_self_url(true);
             $modules[] = array('contact', do_lang_tempcode('_EMAIL_MEMBER'), build_url(array('page' => 'contactmember', 'redirect' => $redirect, 'id' => $member_id_of), get_module_zone('contactmember')), 'reply');
         }
     }
     require_lang('menus');
     $sections = array('contact' => do_lang_tempcode('CONTACT'), 'profile' => do_lang_tempcode('EDIT_PROFILE'), 'views' => do_lang_tempcode('ACCOUNT'), 'usage' => do_lang_tempcode('USAGE'), 'content' => do_lang_tempcode('CONTENT'));
     $actions = array();
     global $M_SORT_KEY;
     $M_SORT_KEY = mixed();
     $M_SORT_KEY = 1;
     @uasort($modules, 'multi_sort');
     /* @ is to stop PHP bug warning about altered array contents when Tempcode copies are evaluated internally */
     foreach ($sections as $section_code => $section_title) {
         $links = new ocp_tempcode();
         foreach ($modules as $module) {
             if (count($module) == 3) {
                 list($_section_code, $lang, $url) = $module;
                 $rel = NULL;
             } else {
                 list($_section_code, $lang, $url, $rel) = $module;
             }
             if ($section_code == $_section_code) {
                 $links->attach(do_template('OCF_MEMBER_ACTION', array('_GUID' => '67b2a640a368c6f53f1b1fa10f922fd0', 'ID' => strval($member_id_of), 'URL' => $url, 'LANG' => $lang, 'REL' => $rel)));
             }
         }
         $actions[$section_code] = $links;
     }
     // Custom fields
     $_custom_fields = ocf_get_all_custom_fields_match_member($member_id_of, $member_id_viewing != $member_id_of && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL, $member_id_viewing == $member_id_of && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL);
     $custom_fields = array();
     require_code('encryption');
     $value = mixed();
     foreach ($_custom_fields as $name => $_value) {
         $value = $_value['RAW'];
         $rendered_value = $_value['RENDERED'];
         $encrypted_value = '';
         if (is_data_encrypted($value)) {
             $encrypted_value = remove_magic_encryption_marker($value);
         } elseif (is_integer($value)) {
             $value = strval($value);
         } elseif (is_float($value)) {
             $value = float_to_raw_string($value);
         }
         if (!is_object($value) && $value != '' || is_object($value) && !$value->is_empty()) {
             $custom_fields[] = array('NAME' => $name, 'RAW_VALUE' => $value, 'VALUE' => $rendered_value, 'ENCRYPTED_VALUE' => $encrypted_value);
             if ($name == do_lang('KEYWORDS')) {
                 $GLOBALS['SEO_KEYWORDS'] = is_object($value) ? $value->evaluate() : $value;
             }
             if ($name == do_lang('DESCRIPTION')) {
                 $GLOBALS['SEO_DESCRIPTION'] = is_object($value) ? $value->evaluate() : $value;
             }
         }
     }
     // Birthday
     $dob = '';
     if ($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_reveal_age') == 1) {
         $day = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_day');
         $month = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_month');
         $year = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_year');
         if (!is_null($day)) {
             if (@strftime('%Y', @mktime(0, 0, 0, 1, 1, 1963)) != '1963') {
                 $dob = strval($year) . '-' . str_pad(strval($month), 2, '0', STR_PAD_LEFT) . '-' . str_pad(strval($day), 2, '0', STR_PAD_LEFT);
             } else {
                 $dob = get_timezoned_date(mktime(12, 0, 0, $month, $day, $year), false, true, true);
             }
         }
     }
     // Find forum with most posts
     $forums = $GLOBALS['FORUM_DB']->query('SELECT id,f_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE f_cache_num_posts>0');
     $best_yet_forum = 0;
     // Initialise to integer type
     $best_yet_forum = NULL;
     $most_active_forum = NULL;
     $_best_yet_forum = $GLOBALS['FORUM_DB']->query_select('f_posts', array('COUNT(*) as cnt', 'p_cache_forum_id'), array('p_poster' => $member_id_of), 'GROUP BY p_cache_forum_id');
     $_best_yet_forum = collapse_2d_complexity('p_cache_forum_id', 'cnt', $_best_yet_forum);
     foreach ($forums as $forum) {
         if (array_key_exists($forum['id'], $_best_yet_forum) && (is_null($best_yet_forum) || $_best_yet_forum[$forum['id']] > $best_yet_forum)) {
             $most_active_forum = has_category_access($member_id_viewing, 'forums', strval($forum['id'])) ? protect_from_escaping(escape_html($forum['f_name'])) : do_lang_tempcode('PROTECTED_FORUM');
             $best_yet_forum = $_best_yet_forum[$forum['id']];
         }
     }
     $post_count = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_cache_num_posts');
     $best_post_fraction = $post_count == 0 ? do_lang_tempcode('NA_EM') : make_string_tempcode(integer_format(100 * $best_yet_forum / $post_count));
     $most_active_forum = is_null($best_yet_forum) ? new ocp_tempcode() : do_lang_tempcode('_MOST_ACTIVE_FORUM', $most_active_forum, make_string_tempcode(integer_format($best_yet_forum)), array($best_post_fraction));
     $time_for_them_raw = tz_time(time(), get_users_timezone($member_id_of));
     $time_for_them = get_timezoned_time(time(), true, $member_id_of);
     $banned = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_is_perm_banned') == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO');
     $last_submit_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_last_submit_time');
     $submit_days_ago = intval(floor(floatval(time() - $last_submit_time) / 60.0 / 60.0 / 24.0));
     require_code('ocf_groups');
     $primary_group_id = ocf_get_member_primary_group($member_id_of);
     $primary_group = ocf_get_group_link($primary_group_id);
     $signature = get_translated_tempcode($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_signature'), $GLOBALS['FORUM_DB']);
     $last_visit_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_last_visit_time');
     if (member_is_online($member_id_of)) {
         $online_now = do_lang_tempcode('YES');
         $_online_now = true;
     } else {
         $_online_now = false;
         $minutes_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0));
         $hours_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0));
         $days_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0 / 24.0));
         $months_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0 / 24.0 / 31.0));
         if ($minutes_ago < 180) {
             $online_now = do_lang_tempcode('_ONLINE_NOW_NO_MINUTES', integer_format($minutes_ago));
         } elseif ($hours_ago < 72) {
             $online_now = do_lang_tempcode('_ONLINE_NOW_NO_HOURS', integer_format($hours_ago));
         } elseif ($days_ago < 93) {
             $online_now = do_lang_tempcode('_ONLINE_NOW_NO_DAYS', integer_format($days_ago));
         } else {
             $online_now = do_lang_tempcode('_ONLINE_NOW_NO_MONTHS', integer_format($months_ago));
         }
     }
     $join_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_join_time');
     $days_joined = intval(round((time() - $join_time) / 60 / 60 / 24));
     $total_posts = $GLOBALS['FORUM_DB']->query_value('f_posts', 'COUNT(*)');
     $join_date = $join_time == 0 ? '' : get_timezoned_date($join_time, false);
     $count_posts = do_lang_tempcode('_COUNT_POSTS', integer_format($post_count), float_format(floatval($post_count) / floatval($days_joined == 0 ? 1 : $days_joined)), array(float_format(floatval(100 * $post_count) / floatval($total_posts == 0 ? 1 : $total_posts))));
     $a = $avatar_url == '' ? 0 : ocf_get_member_best_group_property($member_id_of, 'max_avatar_width');
     $b = $photo_thumb_url == '' ? 0 : intval(get_option('thumb_width'));
     $right_margin = max($a, $b) == 0 ? 'auto' : strval(max($a, $b) + 6) . 'px';
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MEMBERS'))));
     if (has_specific_permission($member_id_viewing, 'see_ip')) {
         $ip_address = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_ip_address');
     } else {
         $ip_address = '';
     }
     $secondary_groups = ocf_get_members_groups($member_id_of, true);
     unset($secondary_groups[$primary_group_id]);
     if (count($secondary_groups) > 0) {
         $_secondary_groups = array();
         $all_groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true, false, false, array_keys($secondary_groups), $member_id_of);
         foreach (array_keys($secondary_groups) as $key) {
             $_secondary_groups[$key] = $all_groups[$key];
         }
         $secondary_groups = $_secondary_groups;
     }
     if (addon_installed('points')) {
         require_code('points');
         $count_points = integer_format(total_points($member_id_of));
     } else {
         $count_points = '';
     }
     $user_agent = NULL;
     $operating_system = NULL;
     if (has_specific_permission($member_id_viewing, 'show_user_browsing') && addon_installed('stats')) {
         $last_stats = $GLOBALS['SITE_DB']->query_select('stats', array('browser', 'operating_system'), array('the_user' => $member_id_of), 'ORDER BY date_and_time DESC', 1);
         if (array_key_exists(0, $last_stats)) {
             $user_agent = $last_stats[0]['browser'];
             $operating_system = $last_stats[0]['operating_system'];
         }
     }
     /*if ((get_option('allow_member_integration')!='off') && (get_option('allow_member_integration')!='hidden'))
     		{
     			$remote=$GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of,'m_password_compat_scheme')=='remote';
     		} else */
     $remote = NULL;
     $_on_probation = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_on_probation_until');
     if (is_null($_on_probation) || $_on_probation <= time()) {
         $on_probation = NULL;
     } else {
         $on_probation = strval($_on_probation);
     }
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $join_time), 'creator' => $username, 'publisher' => '', 'modified' => '', 'type' => 'Member', 'title' => '', 'identifier' => '_SEARCH:members:view:' . strval($member_id_of), 'description' => '', 'image' => $avatar_url == '' && has_specific_permission($member_id_viewing, 'view_member_photos') ? $photo_url : $avatar_url);
     // Look up member's clubs
     $clubs = array();
     if (addon_installed('ocf_clubs')) {
         $club_ids = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id_of, true);
         $club_rows = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), array('g_is_private_club' => 1), '', 200));
         if (count($club_rows) == 200) {
             $club_rows = NULL;
         }
         foreach ($club_ids as $club_id) {
             if (is_null($club_rows)) {
                 $club_rows = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), array('g_is_private_club' => 1, 'id' => $club_id), '', 200));
                 if (!array_key_exists($club_id, $club_rows)) {
                     continue;
                 }
                 $club_row = $club_rows[$club_id];
                 $club_rows = NULL;
             } else {
                 if (!array_key_exists($club_id, $club_rows)) {
                     continue;
                 }
                 $club_row = $club_rows[$club_id];
             }
             $club_name = get_translated_text($club_row['g_name'], $GLOBALS['FORUM_DB']);
             $club_forum = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=f.f_description', 'f.id', array('text_original' => do_lang('FORUM_FOR_CLUB', $club_name)));
             $clubs[] = array('CLUB_NAME' => $club_name, 'CLUB_ID' => strval($club_row['id']), 'CLUB_FORUM' => is_null($club_forum) ? '' : strval($club_forum));
         }
     }
     $content = do_template('OCF_MEMBER_PROFILE_ABOUT', array('_GUID' => 'fodfjdsfjsdljfdls', 'CLUBS' => $clubs, 'REMOTE' => $remote, 'RIGHT_MARGIN' => $right_margin, 'AVATAR_WIDTH' => strval($a) . 'px', 'PHOTO_WIDTH' => strval($b) . 'px', 'MOST_ACTIVE_FORUM' => $most_active_forum, 'TIME_FOR_THEM' => $time_for_them, 'TIME_FOR_THEM_RAW' => strval($time_for_them_raw), 'SUBMIT_DAYS_AGO' => integer_format($submit_days_ago), 'SUBMIT_TIME_RAW' => strval($last_submit_time), 'LAST_VISIT_TIME_RAW' => strval($last_visit_time), 'ONLINE_NOW' => $online_now, '_ONLINE_NOW' => $_online_now, 'BANNED' => $banned, 'USER_AGENT' => $user_agent, 'OPERATING_SYSTEM' => $operating_system, 'DOB' => $dob, 'IP_ADDRESS' => $ip_address, 'COUNT_POSTS' => $count_posts, 'COUNT_POINTS' => $count_points, 'PRIMARY_GROUP' => $primary_group, 'PRIMARY_GROUP_ID' => strval($primary_group_id), 'PHOTO_URL' => $photo_url, 'PHOTO_THUMB_URL' => $photo_thumb_url, 'EMAIL_ADDRESS' => $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_email_address'), 'AVATAR_URL' => $avatar_url, 'SIGNATURE' => $signature, 'JOIN_DATE' => $join_date, 'JOIN_DATE_RAW' => strval($join_time), 'CUSTOM_FIELDS' => $custom_fields, 'ACTIONS_contact' => $actions['contact'], 'ACTIONS_profile' => $actions['profile'], 'ACTIONS_views' => $actions['views'], 'ACTIONS_usage' => $actions['usage'], 'ACTIONS_content' => $actions['content'], 'USERNAME' => $username, 'MEMBER_ID' => strval($member_id_of), 'SECONDARY_GROUPS' => $secondary_groups, 'VIEW_PROFILES' => $member_id_viewing == $member_id_of || has_specific_permission($member_id_viewing, 'view_profiles'), 'ON_PROBATION' => $on_probation, 'EXTRA_INFO_DETAILS' => $info_details, 'EXTRA_SECTIONS' => $extra_sections));
     return array($title, $content, $order);
 }
コード例 #30
0
    $RELATIVE_PATH = substr($FILE_BASE, ($a > $b ? $a : $b) + 1);
    $FILE_BASE = substr($FILE_BASE, 0, $a > $b ? $a : $b);
} else {
    $RELATIVE_PATH = '';
}
@chdir($FILE_BASE);
if (!is_file($FILE_BASE . '/sources/global.php')) {
    exit('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . chr(10) . '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN"><head><title>Critical startup error</title></head><body><h1>ocPortal startup error</h1><p>The second most basic ocPortal startup file, sources/global.php, could not be located. This is almost always due to an incomplete upload of the ocPortal system, so please check all files are uploaded correctly.</p><p>Once all ocPortal files are in place, ocPortal must actually be installed by running the installer. You must be seeing this message either because your system has become corrupt since installation, or because you have uploaded some but not all files from our manual installer package: the quick installer is easier, so you might consider using that instead.</p><p>ocProducts maintains full documentation for all procedures and tools, especially those for installation. These may be found on the <a href="http://ocportal.com">ocPortal website</a>. If you are unable to easily solve this problem, we may be contacted from our website and can help resolve it for you.</p><hr /><p style="font-size: 0.8em">ocPortal is a website engine created by ocProducts.</p></body></html>');
}
require $FILE_BASE . '/sources/global.php';
require_code('addons');
require_code('dump_addons');
require_code('version');
require_code('downloads2');
$version = ocp_version_number();
$version_for_name = preg_replace('/\\./', '', float_to_raw_string($version));
$get_cat = get_param('cat', NULL);
if ($get_cat === NULL) {
    exit("Please pass the category name in the URL (?cat=name).");
}
// $file_list = get_file_list_of_addons();
$addon_list = get_details_of_addons();
$parent_id = $GLOBALS['SITE_DB']->query_value_null_ok('download_categories c JOIN ' . get_table_prefix() . 'translate t ON t.id=c.category', 'c.id AS id', array('parent_id' => 1, 't.text_original' => 'Addons'));
$c_main_id = check_and_add_category($get_cat, $parent_id);
/*$cat_id=add_download_category('Themes',$c_main_id,'','','');
$all_groups=$GLOBALS['FORUM_DRIVER']->get_usergroup_list(true);
foreach (array_keys($all_groups) as $_group_id)
{
	$GLOBALS['SITE_DB']->query_insert('group_category_access',array('module_the_name'=>'downloads','category_name'=>strval($cat_id),'group_id'=>$_group_id));
}*/
header('Content-type: text/plain');