当前位置: 首页>>代码示例>>PHP>>正文


PHP float_to_raw_string函数代码示例

本文整理汇总了PHP中float_to_raw_string函数的典型用法代码示例。如果您正苦于以下问题:PHP float_to_raw_string函数的具体用法?PHP float_to_raw_string怎么用?PHP float_to_raw_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了float_to_raw_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_products

 /**
  * 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;
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:67,代码来源:catalogue_items.php

示例2: get_products

 /**
  * 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;
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:17,代码来源:classifieds.php

示例3: get_file

 /**
  * 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;
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:26,代码来源:choose_ocportalcom_addon.php

示例4: _xml_rpc_type_convert

/**
 * 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;
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:46,代码来源:xmlrpc.php

示例5: _get_simple_gps

/**
 * 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;
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:43,代码来源:exif.php

示例6: import_catalogues


//.........这里部分代码省略.........
                     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');
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:ocp_merge.php

示例7: persistant_cache_set

/**
 * 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);
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:20,代码来源:caches.php

示例8: run


//.........这里部分代码省略.........
     }
     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));
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:main_google_map.php

示例9: install


//.........这里部分代码省略.........
         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');
     }
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:admin_config.php

示例10: make_subscription_button

 /**
  * 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));
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:23,代码来源:secpay.php

示例11: run

 /**
  * 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));
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:98,代码来源:side_tag_cloud.php

示例12: pay

 /**
  * 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);
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:78,代码来源:purchase.php

示例13: handle_transaction

 /**
  * 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);
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:91,代码来源:paypal.php

示例14: currency_convert

/**
 * 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;
//.........这里部分代码省略.........
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:currency.php

示例15: init__global2


//.........这里部分代码省略.........
    	$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();
        }
    }
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:global2.php


注:本文中的float_to_raw_string函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。