|
From: Florin C B. <ory...@us...> - 2013-06-17 18:19:33
|
Update of /cvsroot/mxbb/mx_weather In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv19930 Added Files: citycode_finder.php db_install.php db_uninstall.php db_upgrade.php edit_weather.php index.php install.txt main_weather.php mx_install_readme.htm portal_weather.php weather.pak weather.php Log Message: --- NEW FILE: edit_weather.php --- <?php /*************************************************************************** * edit_weather.php * ------------------- * begin : Septembre, 2002 * copyright : (C) 2002 MX-System * email : su...@mx... * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ // // ERROR HANDLING // //error_reporting( E_ALL ); //ini_set('display_errors', '1'); $phpEx = substr(strrchr(__FILE__, '.'), 1); if (@file_exists( './viewtopic.' . $phpEx )) // -------------------------------------------- phpBB MOD MODE { define('MXBB_MODULE', false); define('IN_PHPBB', true); die('This is a MX-Portal CMS Module, you need to upload all required files in "modules" folder!!!'); } else { if( !defined('IN_PORTAL') || !is_object($mx_block)) { define('IN_PORTAL', true); define('MXBB_MODULE', true); $mx_root_path = '../../'; $module_root_path = $mx_root_path . 'modules/mx_weather/'; // // Let's include some stuff... // $phpEx = substr(strrchr(__FILE__, '.'), 1); include($mx_root_path . 'common.' . $phpEx); // // Page selector // $page_id = $mx_request_vars->request('page', MX_TYPE_INT, 1); // // Start user session // - populate $userdata and $lang // $mx_user->init($user_ip, $page_id, false); // // Load and instatiate CORE (page) and block classes // $mx_page->init($page_id); // // Initiate user style (template + theme) management // - populate $theme, $images and initiate $template. // $mx_user->page_id = $page_id; $mx_user->user_ip = $user_ip; $mx_user->_init_userprefs(); $mx_user->init_style(); $block_id = ( !empty($HTTP_GET_VARS['block_id']) ) ? $HTTP_GET_VARS['block_id'] : $HTTP_POST_VARS['id']; if( empty($block_id) ) { $sql = "SELECT * FROM " . BLOCK_TABLE . " WHERE block_title = 'weather' LIMIT 1"; if(!$result = $db->sql_query($sql)) { mx_message_die(GENERAL_ERROR, "Could not query weather module information", "", __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $block_id = $row['block_id']; } $is_block = FALSE; } else { define('MXBB_MODULE', true); // // Read block Configuration $title = $mx_block->block_info['block_title']; $block_size = ( isset($block_size) && !empty($block_size) ? $block_size : '100%' ); $is_block = true; global $images, $is_block; } } // // Load default header // include($module_root_path . 'include/constants.'.$phpEx); include($module_root_path . 'include/functions.'.$phpEx); $filename = basename(__FILE__); function renumber_order( $user_id ) { global $db; $sql = "SELECT * FROM " . CONFIG_WEATHER_DET_TABLE; $sql .= " WHERE user_id = $user_id ORDER BY weather_order ASC"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Couldn't get list of Weather option", "", __LINE__, __FILE__, $sql); } $i = 10; $inc = 10; while( $row = $db->sql_fetchrow($result) ) { $sql = "UPDATE " . CONFIG_WEATHER_DET_TABLE . " SET weather_order = $i WHERE user_id = $user_id AND weather_id = '" . $row['weather_id'] . "'"; if( !$db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Couldn't update order fields", "", __LINE__, __FILE__, $sql); } $i += 10; } } // // User session management /* if(!$userdata['session_logged_in']) { $user_id = ''; $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: '; @header($header_location . mx_append_sid( $mx_root_path . "login.$phpEx?redirect=./modules/mx_weather/edit_weather.$phpEx", true)); exit; } */ // End session management // // ********************************************************************** // Read language definition // ********************************************************************** /* if ( !file_exists($module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx ) ) { include( $module_root_path . 'language/lang_english/lang_main.'.$phpEx ); } else { include( $module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx ); } */ // // Limit // $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0; // // Region // if( isset($HTTP_GET_VARS['weather_region']) || isset($HTTP_POST_VARS['weather_region']) ) { $weather_region_sel = ( !empty($HTTP_GET_VARS['weather_region'])) ? $HTTP_GET_VARS['weather_region'] : $HTTP_POST_VARS['weather_region']; $weather_region_sel = str_replace("\'","'",$weather_region_sel); } else { $sql = "SELECT DISTINCT weather_region, weather_country, weather_subdiv FROM " . WEATHER_TABLE . " ORDER BY weather_region, weather_country, weather_subdiv"; if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, "Couldn't query weather table", "", __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $weather_region_sel = ( empty( $row['weather_subdiv']) ) ? "weather_region ='" . $row['weather_region'] . "' and weather_country ='" . $row['weather_country'] . "'" : "weather_region ='" . $row['weather_region'] . "' and weather_country ='" . $row['weather_country'] . "' and weather_subdiv ='" . $row['weather_subdiv'] . "'"; } if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) ) { $mode = ($HTTP_GET_VARS['mode']) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; } else { if ( isset($HTTP_POST_VARS['submit'])) { $mode = "update"; } else if ( isset($HTTP_POST_VARS['add_city'])) { $mode = "add_city"; } else if ( isset($HTTP_POST_VARS['save'])) { $mode = "save_city"; } else if ( isset($HTTP_POST_VARS['import_city'])) { $mode = "import_city"; } else { $mode = ""; } } if( $mode != "" ) { switch($mode) { case 'update': $new = array(); $new['weather_unit_default'] = $mx_request_vars->post('weather_unit_default', MX_TYPE_NO_TAGS, ''); $new['weather_city_default'] = $mx_request_vars->post('weather_city_default', MX_TYPE_NO_TAGS, ''); $new['weather_zipcode_default'] = $mx_request_vars->post('weather_zipcode_default', MX_TYPE_NO_TAGS, ''); $new['weather_country_default'] = $mx_request_vars->post('weather_country_default', MX_TYPE_NO_TAGS, ''); $new['partner_id_default'] = $mx_request_vars->post('partner_id_default', MX_TYPE_NO_TAGS, ''); $new['license_key_deault'] = $mx_request_vars->post('license_key_deault', MX_TYPE_NO_TAGS, ''); if (!$result = $db->sql_query("SELECT user_id from ".CONFIG_WEATHER_TABLE)) { switch (PORTAL_BACKEND) { case 'internal': case 'phpbb2': $config_array = array_merge(array('user_id' => (int) '0',), $new); $sql = "INSERT INTO ".CONFIG_WEATHER_TABLE." (". implode(', ', array_keys($config_array)). ") VALUES (". implode(', ', array_values($config_array)). ")"; break; case 'phpbb3': $sql = "INSERT INTO ".CONFIG_WEATHER_TABLE.$db->sql_build_array('INSERT', array_merge(array('user_id' => (int) '0',), $new)); break; } } else { //$weather_unit_default = $HTTP_POST_VARS['weather_unit_default']; $sql = "UPDATE " . CONFIG_WEATHER_TABLE . " SET " . $db->sql_build_array('UPDATE', $new); //$sql = "UPDATE " . CONFIG_WEATHER_TABLE . " SET weather_unit_default = '$weather_unit_default' WHERE user_id = 0" ; } if(!$result = $db->sql_query($sql)) { mx_message_die(GENERAL_ERROR, "Could not update data from weather table", $lang['Error'], __LINE__, __FILE__, $sql); } break; case 'add': $weather_id = ( isset($HTTP_GET_VARS['id']) ) ? $HTTP_GET_VARS['id'] : 0; $user_id = ( isset($HTTP_POST_VARS['uid']) ) ? $HTTP_POST_VARS['uid'] : $HTTP_GET_VARS['uid']; $sql = "SELECT max(weather_order) weather_order FROM " . CONFIG_WEATHER_DET_TABLE . " WHERE user_id = $userdata[user_id]"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Couldn't get list of Weather option", "", __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $weather_order = $row[weather_order] + 10; $sql = "INSERT INTO " . CONFIG_WEATHER_DET_TABLE . " (user_id, weather_id, weather_order ) VALUES ( $user_id , '" . $weather_id . "' , ". $weather_order." ) "; $result = $db->sql_query($sql); // if(!$result = $db->sql_query($sql)) // { // mx_message_die(GENERAL_ERROR, "Could not add data from weather table", $lang['Error'], __LINE__, __FILE__, $sql); // } break; case 'delete': if( isset($HTTP_POST_VARS['id']) || isset($HTTP_GET_VARS['id']) ) { $weather_id = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; $user_id = ( isset($HTTP_POST_VARS['uid']) ) ? $HTTP_POST_VARS['uid'] : $HTTP_GET_VARS['uid']; } else { $weather_id = 0; } if( $weather_id ) { $sql = "DELETE FROM " . CONFIG_WEATHER_DET_TABLE . " WHERE user_id = $user_id AND weather_id = '$weather_id'"; if(!$result = $db->sql_query($sql)) { mx_message_die(GENERAL_ERROR, "Could not remove data from weather table", $lang['Error'], __LINE__, __FILE__, $sql); } renumber_order( $user_id ); } else { mx_message_die(GENERAL_MESSAGE, "No Weather selected"); } break; case 'order': // // Change order of menus in the DB // $move = intval($HTTP_GET_VARS['move']); $weather_id = $HTTP_GET_VARS[POST_URL]; $user_id = $HTTP_GET_VARS['uid']; $sql = "UPDATE " . CONFIG_WEATHER_DET_TABLE . " SET weather_order = weather_order + $move WHERE user_id = $user_id AND weather_id = '$weather_id'"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Couldn't change weather order", "", __LINE__, __FILE__, $sql); } renumber_order( $user_id ); break; default: mx_message_die(GENERAL_ERROR, "Wrong mode for generating select list", "", __LINE__, __FILE__); break; } } $template->set_filenames(array( "weather_edit" => "edit_weather.tpl") ); // ********************************************************************** // Read module config // ********************************************************************** $weather_config = read_weather_config( $userdata[user_id] ); if ($weather_config[user_id] == 0) { $sql = "INSERT INTO " . CONFIG_WEATHER_TABLE . " (user_id, weather_unit_default ) VALUES ( $userdata[user_id] , 'C' ) "; if(!$result = $db->sql_query($sql)) { mx_message_die(GENERAL_ERROR, "Could not add data from weather table", $lang['Error'], __LINE__, __FILE__, $sql); } $weather_config = read_weather_config( $userdata[user_id] ); $sql = "SELECT * FROM " . CONFIG_WEATHER_DET_TABLE . " WHERE user_id = 0"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Couldn't get list of Weather option", "", __LINE__, __FILE__, $sql); } while( $row = $db->sql_fetchrow($result) ) { $sql_insert = "INSERT INTO " . CONFIG_WEATHER_DET_TABLE . " (user_id, weather_id, weather_order ) VALUES ( $weather_config[user_id] , '" . $row[weather_id] . "' , ". $row[weather_order] ." ) "; if(!$result_insert = $db->sql_query($sql_insert)) { mx_message_die(GENERAL_ERROR, "Could not add data from weather table", $lang['Error'], __LINE__, __FILE__, $sql_insert); } } } $template->assign_vars(array( "S_CONFIG_ACTION" => mx_append_sid("edit_weather..$phpEx"), "L_YES" => $lang['Yes'], "L_NO" => $lang['No'], "L_WEATHER_SETTINGS" => $lang['Weather_Settings'], "L_WEATHER_UNIT_DEFAULT" => $lang['Weather_Unit_Default'] , "WEATHER_UNIT_DEFAULT" => $weather_config['weather_unit_default'], "WEATHER_UNIT_SELECT" => weather_unit_select( $weather_config['weather_unit_default'], 'weather_unit_default' ), "WEATHER_REGION_SELECT" => weather_region_select($weather_region_sel, 'weather_region'), "L_WEATHER_CITY_DEFAULT" => $lang['weather_city_default'], "WEATHER_CITY_DEFAULT" => $config['weather_city_default'], "L_WEATHER_ZIPCODE_DEFAULT" => $lang['weather_zipcode_default'], "WEATHER_ZIPCODE_DEFAULT" => $config['weather_zipcode_default'], "L_WEATHER_COUNTRY_DEFAULT" => $lang['weather_country_default'], "WEATHER_COUNTRY_DEFAULT" => $config['weather_country_default'], "L_PARTNER_ID_DEFAULT" => $lang['partner_id_default'], "PARTNER_ID_DEFAULT" => $config['partner_id_default'], "L_LICENSE_KEY_DEAULT" => $lang['license_key_deault'], "LICENSE_KEY_DEAULT" => $config['license_key_deault'], "L_SUBMIT" => $lang['Submit'], "L_RESET" => $lang['Reset'], ) ); $sql = "SELECT t.* FROM " . CONFIG_WEATHER_DET_TABLE . " c , " . WEATHER_TABLE . " t WHERE c.user_id = $userdata[user_id] AND c.weather_id = t.weather_id ORDER BY weather_order"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Could not query weather table", $lang['Error'], __LINE__, __FILE__, $sql); } $weather_rows = $db->sql_fetchrowset($result); $weather_count = count($weather_rows); $template->assign_vars(array( "L_WEATHER_TITLE" => $lang['Weather_Settings'], "L_WEATHER_TEXT" => $lang['Weather_explain'], "L_WEATHER_REGION" => $lang['Region'], "L_WEATHER_COUNTRY" => $lang['Country'], "L_WEATHER_SUBDIV" => $lang['SubDiv'], "L_WEATHER_CITY" => $lang['City'], "L_DELETE" => $lang['Delete'], "L_ADD" => $lang['Add'], "L_MOVE_UP" => $lang['Move_up'], "L_MOVE_DOWN" => $lang['Move_down'], "L_WEATHER_BLOCK" => $lang['Weather_Block'], "L_WEATHER_LIST" => $lang['Weather_List'], "L_CHANGE_NOW" => $lang['Change'], "L_ACTION" => $lang['Action'], "S_WEATHER_ACTION" => mx_append_sid("edit_weather..$phpEx"), "S_HIDDEN_FIELDS" => '') ); for($i = 0; $i < $weather_count; $i++) { $weather_city = $weather_rows[$i]['weather_city']; $weather_country = $weather_rows[$i]['weather_country']; $weather_region = $weather_rows[$i]['weather_region']; $weather_id = $weather_rows[$i]['weather_id']; $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; $template->assign_block_vars("weather", array( "ROW_COLOR" => "#" . $row_color, "ROW_CLASS" => $row_class, "WEATHER_REGION" => $weather_region, "WEATHER_COUNTRY" => $weather_country, "WEATHER_CITY" => $weather_city, "U_DELETE" => mx_append_sid("edit_weather.$phpEx?mode=delete&id=$weather_id&uid=$weather_config[user_id]&weather_region=$weather_region_sel"), "U_MENU_MOVE_UP" => mx_append_sid("edit_weather.$phpEx?mode=order&move=-15&" . POST_URL . "=$weather_id&weather_region=$weather_region_sel&uid=$weather_config[user_id]"), "U_MENU_MOVE_DOWN" => mx_append_sid("edit_weather.$phpEx?mode=order&move=15&" . POST_URL . "=$weather_id&weather_region=$weather_region_sel&uid=$weather_config[user_id]"), ) ); } $sql = "SELECT * FROM " . WEATHER_TABLE . " WHERE " . $weather_region_sel . " ORDER BY weather_region, weather_country, weather_subdiv, weather_city " ; // LIMIT $start, 30 if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Could not query weather table", $lang['Error'], __LINE__, __FILE__, $sql); } $weather_rows = $db->sql_fetchrowset($result); $weather_count = count($weather_rows); for($i = 0; $i < $weather_count; $i++) { $weather_city = $weather_rows[$i]['weather_city']; $weather_country = $weather_rows[$i]['weather_country']; $weather_subdiv = $weather_rows[$i]['weather_subdiv']; $weather_region = $weather_rows[$i]['weather_region']; $weather_id = $weather_rows[$i]['weather_id']; $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; $template->assign_block_vars("weather_list", array( "ROW_COLOR" => "#" . $row_color, "ROW_CLASS" => $row_class, "WEATHER_REGION" => $weather_region, "WEATHER_COUNTRY" => $weather_country, "WEATHER_SUBDIV" => $weather_subdiv, "WEATHER_CITY" => $weather_city, "U_ADD" => mx_append_sid("edit_weather.$phpEx?mode=add&id=$weather_id&uid=$weather_config[user_id]&weather_region=$weather_region_sel"), ) ); } //$page_title = ( !empty( $lang['Weather'] ) ? $lang['Weather'] : 'Weather' ); //include($mx_root_path . 'includes/page_header.'.$phpEx); $template->pparse("weather_edit"); //include($mx_root_path . 'includes/page_tail.'.$phpEx); ?> --- NEW FILE: index.php --- <?php /*************************************************************************** * mx_weather.php * ------------------- * begin : April, 2002 * copyright : (C) 2002 MX-System * email : su...@mx... * ***************************************************************************/ /** * History: * @developer: OryNider (v 2.x - 3.x) */ if( !defined('IN_PORTAL') || !is_object($mx_block)) { @define('IN_PORTAL', true); $mx_root_path = "./../../"; $module_root_path = "./"; @define('MXBB_27x', @file_exists($mx_root_path . 'mx_login.'.$phpEx)); $phpEx = substr(strrchr(__FILE__, '.'), 1); include_once($mx_root_path . 'common.'.$phpEx); // Start session management if (version_compare($portal_config['portal_version'], '2.7.8', '>=')) { $mx_user->init($user_ip, PAGE_WEATHER); } else { $userdata = session_pagestart($user_ip, PAGE_WEATHER); mx_init_userprefs($userdata); } // End session management // Read block Configuration $block_id = (!empty($_GET['block_id']) ) ? $_GET['block_id'] : $_POST['id']; // 0: module, 1: module_id, 2: module_name, 3: module_path, // 4: module_desc, 5: module_include_admin //mx_get_info($table, $idfield = '', $id = 0, $idfield2 = '', $id2 = 0) ... ( $idfield2 != '' && $id2 != '' ) ? " AND $idfield2 = '$id2'" : ''; $block_info = mx_get_info(BLOCK_TABLE, 'block_title', 'PORTAL_WEATHER'); $block_id = ( isset($block_id) && !empty($block_id) ? $block_id : $block_info['block_id'] ); $title = $block_info['block_title']; $block_size = ( isset($block_size) && !empty($block_size) ? $block_size : '100%' ); $description = $block_info['block_desc']; $show_block = $block_info['show_block']; $show_title = ($userdata['user_level'] == ADMIN) ? true : $block_info['show_title']; $show_stats = $block_info['show_stats']; $mx_block->init($block_id); $is_block = FALSE; } else { // Read block Configuration @define('MXBB_27x', @file_exists($mx_root_path . 'mx_login.'.$phpEx)); $title = $mx_block->block_info['block_title']; $block_size = $player_size = ( isset($block_size) && !empty($block_size) ? $block_size : '100%' ); $is_block = TRUE; } @define('STRIP_URL', (@ini_get('allow_url_fopen')) ? false : true); //fopen_url not allowed /* * Include the functions file */ require($module_root_path . 'includes/constants.'.$phpEx); require($module_root_path . 'includes/functions.'.$phpEx); require($module_root_path . 'includes/class_xmlparser.'.$phpEx); require($module_root_path . 'includes/class_weather.'.$phpEx); $weather_config = read_weather_config($userdata['user_id']); /* * Ends all session management */ // ********************************************************************** // Set Parameter // ********************************************************************** if ($mx_request_vars->is_request('accid')) { $weather_region_sel = $mx_request_vars->request('accid', MX_TYPE_NO_TAGS); } if (!$accid) { $accid = $weather_config['weather_city_default'] ; # Your default city location code "YUL"; } $tp = $_GET_VARS['tmp']; if (!$tp) { $tp = $weather_config['weather_unit_default']; # Your Default temperature unit (C for Celsius, F for Fahrenheit) } /* * Begin main code here */ if ($mx_request_vars->is_request('p')) { $zip_code = $mx_request_vars->request('p', MX_TYPE_NO_TAGS); } else { $zip_code = $weather_config['weather_zipcode_default']; } if ($mx_request_vars->is_request('u')) { $weather_unit = $mx_request_vars->request('u', MX_TYPE_NO_TAGS); } else { $weather_unit = $weather_config['weather_unit_default']; } if ($mx_request_vars->is_request('w')) { $weather_citycode = $mx_request_vars->request('w', MX_TYPE_NO_TAGS); } else { $weather_citycode = $zip_code; } $weather_country = $weather_config['weather_country_default']; // Specific country id $weather_citycode = $weather_config['weather_city_default']; // Forecast city id //@ url: http://www.weather.com/outlook/travel/businesstraveler/extended/ROXX0024 //@ url: http://www.weather.com/outlook/recreation/boatandbeach/local/RO0AR0001 //Weather("ROXX0024"); //WeatherIndex($tp, $zip_code, $module_root_path); // Create the new weather object! // RO0AR0001 = ROXX0024 = 866307 - Location Code from weather.yahoo.com // 3600 = seconds of cache lifetime (expires after that) // C = Units in Celsius! (Option: F = Fahrenheit) $weather_loc = new weather($zip_code, 3600, $tp, $module_root_path); // Parse the weather object via cached // This checks if there's an valid cache object allready. if yes // it takes the local object data, what's much FASTER!!! if it // is expired, it refreshes automatically from rss online! $weather_loc->parsecached(); // => RECOMMENDED! // allway refreshes from rss online. NOT SO FAST. //$weather_loc->parse(); // => NOT recommended! //Set some variables again $weather_image_code = isset($weather_loc->imageurl) ? "<div style=\"background-image: url('".$weather_loc->imageurl."'); background-position: 0px 0px; height: 40px; width: 200px; padding-left: 5px; padding-right: 5px; border: 0px;\" alt=\"\"> </div>" : ""; $weather_cityname = isset($weather_loc->city) ? $weather_loc->city : $weather_country; // Arad, Romania $weather_yahoolink = isset($weather_loc->yahoolink) ? $weather_loc->yahoolink : 'http://us.rd.yahoo.com/dailynews/rss/weather/'.$weather_cityname.'__'.$zip_site.'/*http://xml.weather.yahoo.com/forecast/'.$zip_code.'_c.html'; $weather_unit = isset($weather_loc->unit) ? $weather_loc->unit : $weather_unit; //Yahoo is in the process of an upgrade. It is removing the p= part and replacing it with w= to use the more powerful new WOEID codes. $weather_yahooxml = "http://xml.weather.yahoo.com/forecastrss?u=".$weather_unit."&p=".$weather_citycode; $weather_actimage = isset($weather_loc->actcode) ? "http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_loc->actcode.".gif" : ""; //$weather_sunrise = $weather_loc->sunrise; // 6:49 am //$weather_sunset = $weather_loc->sunset; // 08:05 pm /** * generate the XML header * Assings Main Variables to Constants */ $v_Fore[1] = ""; $v_Fore[2] = ""; $v_Fore[3] = ""; $v_Fore[4] = ""; $v_Fore[5] = $weather_loc->fore_day1_date; $v_Fore[6] = $weather_loc->fore_day2_date; $v_Fore[7] = $weather_loc->fore_day3_date; $v_Fore[8] = $weather_loc->fore_day4_date; $v_Fore[9] = $weather_loc->fore_day5_date; $weather_actimage = $fday_imgsrc[0] = isset($weather_loc->actcode) ? "http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_loc->actcode.".gif" : ""; $v_Fore[10] = $fday_imgsrc[1] = isset($weather_loc->fore_day1_imgcode) ? "http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_loc->fore_day1_imgcode.".gif" : $weather_actimage; $v_Fore[11] = $fday_imgsrc[2] = isset($weather_loc->fore_day2_imgcode) ? "http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_loc->fore_day2_imgcode.".gif" : $weather_actimage; $v_Fore[12] = $fday_imgsrc[3] = isset($weather_loc->fore_day3_imgcode) ? "http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_loc->fore_day3_imgcode.".gif" : $weather_actimage; $v_Fore[13] = $fday_imgsrc[4] = isset($weather_loc->fore_day4_imgcode) ? "http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_loc->fore_day4_imgcode.".gif" : $weather_actimage; $v_Fore[14] = $fday_imgsrc[5] = isset($weather_loc->fore_day5_imgcode) ? "http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_loc->fore_day5_imgcode.".gif" : $weather_actimage; $v_Fore[15] = ""; $v_Fore[16] = ""; $v_Fore[17] = ""; $v_Fore[18] = ""; $v_Fore[19] = ""; // MAIN ATTRIBUTES $zip_code = $zip_code; $unit = strtoupper($weather_unit); // CONTENT ATTRIBUTES $title = (!empty($weather_loc->title) ? $weather_loc->title : trim($title)); $link = $weather_yahoolink; $description = $weather_loc->description; $language = $weather_loc->language; $lastbuilddate = $weather_loc->lastdate; $ttl = $weather_loc->ttl; // YAHOO! WEATHER $citycode = $weather_citycode; //YWEATHER:LOCATION $city = $v_City = $weather_cityname; $region = $weather_loc->region; $country = $weather_loc->country; //YWEATHER:UNITS $temperature = $weather_loc->temperature; $distance = $weather_loc->distance; $pressure = $weather_loc->pressure; $speed = $weather_loc->speed; //YWEATHER:ATMOSPHERE $chill = $weather_loc->chill; $direction = $weather_loc->direction; $wind = $weather_loc->wind; $humidity = $weather_loc->humidity; $visibility = $weather_loc->visibility; $pressure = $weather_loc->pressure; $rising = $weather_loc->rising; //YWEATHER:ASTRONOMY $sunrise = $weather_loc->sunrise; $sunset = $weather_loc->sunset; //ACTUAL SITUATION $acttemp = $weather_loc->acttemp; $acttext = $weather_loc->acttext; $acttime = @format_weather_date($weather_loc->acttime); $imagurl = $weather_image_code; $actcode = $weather_loc->actcode; $imageurl = $fday_imgsrc[0]; //FORECAST DAY 1 $fore_day1_day = $weather_loc->fore_day1_day; $fore_day1_date = @format_weather_date($weather_loc->fore_day1_date); $fore_day1_tlow = $weather_loc->fore_day1_tlow; $fore_day1_thigh = $weather_loc->fore_day1_thigh; $fore_day1_text = $weather_loc->fore_day1_text; $fore_day1_imgcode = $fday_imgsrc[1]; //FORECAST DAY 2 $fore_day2_day = $weather_loc->fore_day2_day; $fore_day2_date = @format_weather_date($weather_loc->fore_day2_date); $fore_day2_tlow = $weather_loc->fore_day2_tlow; $fore_day2_thigh = $weather_loc->fore_day2_thigh; $fore_day2_text = $weather_loc->fore_day2_text; $fore_day2_imgcode = $fday_imgsrc[2]; //FORECAST DAY 3 $fore_day3_day = $weather_loc->fore_day3_day; $fore_day3_date = @format_weather_date($weather_loc->fore_day3_date); $fore_day3_tlow = $weather_loc->fore_day3_tlow; $fore_day3_thigh = $weather_loc->fore_day3_thigh; $fore_day3_text = $weather_loc->fore_day3_text; $fore_day3_imgcode = $fday_imgsrc[3]; //$v_Fore = explode("|", $v_Fore); $v_Fore[20] = $weather_loc->fore_day1_thigh; $v_Fore[21] = $weather_loc->fore_day2_thigh; $v_Fore[22] = $weather_loc->fore_day3_thigh; $v_Fore[23] = $weather_loc->fore_day4_thigh; $v_Fore[24] = $weather_loc->fore_day5_thigh; $v_Fore[40] = $weather_loc->fore_day1_tlow; $v_Fore[41] = $weather_loc->fore_day2_tlow; $v_Fore[42] = $weather_loc->fore_day3_tlow; $v_Fore[43] = $weather_loc->fore_day4_tlow; $v_Fore[44] = $weather_loc->fore_day5_tlow; $v_Baro_nice = PreNumber($v_Baro, $tp); $v_WindS_nice = VelNumber($v_WindS, $tp); $v_Real_nice = CelNumber2($v_Real, $tp); $v_Vis_nice = LenNumber($v_Vis, $tp); if ($tp == "C") { $temperature = CelNumber( $v_Temp, $tp); } else { $temperature = $v_Temp; } $image_path = "http://image.weather.com/web/common/wxicons/52/"; //$image_path = $module_root_path . "images/"; $image = $image_path . $v_CIcon . ".gif"; // End session management // Start Page Template Management $page_title = (!empty( $lang['Weather'] ) ? $lang['Weather'] : 'Weather'); include($mx_root_path . 'includes/page_header.'.$phpEx); //Set the Template file name(s) $template->set_filenames(array( "body_weather" => 'mx_weather_view.tpl') ); //Some vars for template $day1 = format_weather_date($v_Fore[5]); $day2 = $v_Fore[6]; $day3 = $v_Fore[7]; $day4 = date('l', ToDate($v_Fore[8])); $day5 = date('l', ToDate($v_Fore[9])); $image_day1 = $fday_imgsrc[1]; $image_day2 = $fday_imgsrc[2]; $image_day3 = $fday_imgsrc[3]; $image_day4 = $fday_imgsrc[4]; $image_day5 = $fday_imgsrc[5]; $v_Baro_nice = PreNumber ($v_Baro , $tp); $v_WindS_nice = VelNumber ($v_WindS, $tp); $v_Real_nice = CelNumber2($v_Real , $tp); $v_Vis_nice = LenNumber ($v_Vis , $tp); $checked_on = 'checked'; $checked_off = ''; // Asign vars to template $template->assign_vars(array( 'L_TITLE' => ( !empty( $lang['Weather'] ) ? $lang['Weather'] : 'Weather' ), 'L_INFO' => $v_City . ", " . $v_Region, 'L_DAY1' => !empty($lang['datetime'][$day1]) ? $lang['datetime'][$day1] : $day1, 'L_DAY2' => !empty($lang['datetime'][$day2]) ? $lang['datetime'][$day2] : $day2, 'L_DAY3' => !empty($lang['datetime'][$day3]) ? $lang['datetime'][$day3] : $day3, 'L_DAY4' => !empty($lang['datetime'][$day4]) ? $lang['datetime'][$day4] : $day4, 'L_DAY5' => !empty($lang['datetime'][$day5]) ? $lang['datetime'][$day5] : $day5, 'L_CHANGE_NOW' => $lang['Change'], 'IMG_DAY1' => $image_day1, 'IMG_DAY2' => $image_day2, 'IMG_DAY3' => $image_day3, 'IMG_DAY4' => $image_day4, 'IMG_DAY5' => $image_day5, 'IMG_CURRENT_COND' => $module_root_path . "images/current_cond.gif", 'IMG_FORECAST' => $module_root_path . "images/forecast.gif", 'TEMP_MAX_DAY1' => CelNumber($v_Fore[20],$tp), 'TEMP_MAX_DAY2' => CelNumber($v_Fore[21],$tp), 'TEMP_MAX_DAY3' => CelNumber($v_Fore[22],$tp), 'TEMP_MAX_DAY4' => CelNumber($v_Fore[23],$tp), 'TEMP_MAX_DAY5' => CelNumber($v_Fore[24],$tp), 'TEMP_MIN_DAY1' => CelNumber($v_Fore[40],$tp), 'TEMP_MIN_DAY2' => CelNumber($v_Fore[41],$tp), 'TEMP_MIN_DAY3' => CelNumber($v_Fore[42],$tp), 'TEMP_MIN_DAY4' => CelNumber($v_Fore[43],$tp), 'TEMP_MIN_DAY5' => CelNumber($v_Fore[44],$tp), 'WINDD' => $v_WindD, 'WINDS' => $v_WindS_nice, 'BARO' => $v_Baro_nice, 'HUMID' => $v_Humid .'%', 'UV' => $v_UV, 'REAL' => $v_Real_nice, 'VIS' => $v_Vis_nice, 'ACCID' => $accid, 'U_URL' => "index.$phpEx", 'TEMPERATURE' => $temperature, 'GRAD' => "°". $tp , 'IMG' => $image, 'L_COPYRIGHT' => "This Weather is provided by MSNBC", 'S_ACTION' => mx_append_sid("index.$phpEx"), 'WEATHER_CITY_SELECT' => weather_city_select($accid, 'accid'), 'CHECKED_TP_C' => ($tp == "C") ? $checked_on : $checked_off, 'CHECKED_TP_F' => ($tp == "F") ? $checked_on : $checked_off, 'ONCLICK_C' => ($tp == "F") ? "onClick=javascript:location.href='" . mx_append_sid("./index.php?ta=y&tmp=C&accid=" . $accid) . "';" : '', 'ONCLICK_F' => ($tp == "C") ? "onClick=javascript:location.href='" . mx_append_sid("./index.php?ta=y&tmp=F&accid=" . $accid) . "';" : '' )); $template->pparse("body_weather"); $template->destroy(); include($mx_root_path . 'includes/page_tail.'.$phpEx); ?> --- NEW FILE: main_weather.php --- <?php /** * * @package Mx-Publisher Module - mx_weather * @version $Id: main_weather.php,v 1.1 2013/06/17 18:19:30 orynider Exp $ * @copyright (c) 2007 [ory...@rd..., OryNider] Mx-Publisher Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ /****************************************************************** * MODIFICATIONS * --------------- * started : April 2002 * copyright : © MX-System * email : ory...@rd... * version : 1.0 * * MODIFICATIONS: * -adapted for MX-Publisher 3.x by OryNider * *******************************************************************/ if( !defined('IN_PORTAL') || !is_object($mx_block)) { die("Hacking attempt"); } // Read Block Settings $title = $mx_block->block_info['block_title']; //PORTAL_METEO_SETTINGS $block_id = (isset($block_id) ? $block_id : $mx_block->block_info['block_id']); $block_size = (isset($column) ? $mx_page->columns[$column]['column_size'] : 176); $b_description = $mx_block->block_info['block_desc']; // ********************************************************************** // Read module config // ********************************************************************** global $v_City, $v_SubDiv, $v_Country, $v_Region, $v_Temp, $v_CIcon, $v_WindS, $v_WindD, $v_Baro; global $v_Humid, $v_Real, $v_UV, $v_Vis, $v_LastUp, $v_Fore, $v_Acid; // =================================================== // Include the functions file // =================================================== require($module_root_path . 'includes/constants.'.$phpEx); require($module_root_path . 'includes/functions.'.$phpEx); $weather_config = read_weather_config($userdata['user_id']); $block_config = read_block_config($block_id); // -------------------------------- // Is admin? // -------------------------------- switch (PORTAL_BACKEND) { case 'internal': case 'phpbb2': $is_admin = ( ( $userdata['user_level'] == ADMIN ) && $userdata['session_logged_in'] ) ? true : 0; break; case 'phpbb3': $is_admin = ( $userdata['user_type'] == USER_FOUNDER ) ? true : 0; break; } // ********************************************************************** // Set Parameter // ********************************************************************** if (!isset($tp)) { $tp = $weather_config['weather_unit_default']; # Your Default temperature unit (C for Celsius, F for Fahrenheit) } //$weather_config[user_id] $sql = "SELECT t.weather_id, t.weather_city FROM " . CONFIG_WEATHER_DET_TABLE . " c , " . WEATHER_TABLE . " t WHERE c.user_id = 0 AND c.weather_id = t.weather_id ORDER BY weather_order"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Could not query weather table", $lang['Error'], __LINE__, __FILE__, $sql); } $weather_rows = $db->sql_fetchrowset($result); $weather_count = count($weather_rows); $image_path = $module_root_path . "images/"; $template->set_filenames(array( "body_weather" => 'mx_weather.tpl') ); // Now, this tries to optimize DB access involved in auth(), // passing AUTH_LIST_ALL will load info for all forums at once. $is_auth_ary = array(); //$is_auth_ary = $this->auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata); if ( $is_auth_ary['auth_edit'] ) if ((($mx_block->auth_view && $mx_block->auth_edit && $mx_block->show_block ) || $mx_block->auth_mod)) { $url_edit = mx_append_sid(PORTAL_URL . $module_root_path . "edit_weather.".$phpEx); $edit_img = '<a href="' . $url_edit . '"><img src="' . PHPBB_URL . $images['icon_edit'] . '" alt="' . $lang['Edit_Weather'] . '" title="' . $lang['Edit_Weather'] . '" border="0" /></a>'; } $template->assign_vars(array( 'BLOCK_SIZE' => ( !empty( $block_size ) ? $block_size : '100%' ), 'L_TITLE' => ( !empty( $lang['Weather'] ) ? $lang['Weather'] : 'Weather' ), 'EDIT_IMG' => $edit_img, 'L_CHANGE_NOW' => $lang['Change'], 'U_URL' => mx_append_sid( PORTAL_URL . 'index.'.$phpEx . '?block_id=' . $block_id), 'L_COPYRIGHT' => "This Weather is provided by weather.com", 'S_ACTION' => mx_append_sid(PORTAL_URL . "index.".$phpEx) )); for($i = 0; $i < $weather_count; $i++) { $city = $weather_rows[$i]['weather_id']; $cityname = $weather_rows[$i]['weather_city']; WeatherIndex($tp, $city, $module_root_path); if ( empty($v_CIcon) ) { $v_CIcon = $v_Fore[10]; } $image = $image_path . $v_CIcon . ".gif"; $template->assign_block_vars("cityrow", array( "U_CITY" => mx_append_sid( PORTAL_URL . $module_root_path . "index.".$phpEx.'?accid=' .$city ), "CITY" => $cityname, "IMAGE" => $image, "GRAD" => CelNumber($v_Fore[40],$tp) . '..' . CelNumber($v_Fore[20],$tp), "CITYID" => $city) ); } $template->pparse("body_weather"); ?> --- NEW FILE: mx_install_readme.htm --- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1250"> <TITLE>Mx Portal installation - readme</TITLE> <META NAME="CREATED" CONTENT="0;0"> <META NAME="CHANGEDBY" CONTENT="Florin Bodin"> <!-- link rel="stylesheet" href="templates/subSilver/subSilver.css" type="text/css" --> <SCRIPT LANGUAGE="Javascript"> <!-- if ( 0 ) { window.open('privmsg.php?mode=newpm', '_phpbbprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');; } //--> </SCRIPT> <STYLE TYPE="text/css"> <!-- P { color: #000000; font-family: "Verdana", "Arial", "Helvetica", sans-serif } TD P { color: #000000; font-family: "Verdana", "Arial", "Helvetica", sans-serif } A:link { color: #006699 } --> </STYLE> </HEAD> <BODY LANG="ro-RO" TEXT="#000000" LINK="#006699" BGCOLOR="#e5e5e5" DIR="LTR"> <TABLE BORDER=1 CELLPADDING=2 CELLSPACING=2 FRAME=VOID STYLE="page-break-before: always"> <TR> <TD COLSPAN=2> <P><A NAME="top"></A><A NAME="install"></A><A NAME="themes"></A><A NAME="languages"></A> <FONT SIZE=2 STYLE="font-size: 9pt"><BR></FONT><FONT SIZE=3><B>Module</B></FONT><FONT SIZE=2 STYLE="font-size: 9pt"> <BR>- for Mx Portal v. 2.7.9, 2.8.3+ or 3.0+ <BR><BR></FONT><FONT SIZE=2 STYLE="font-size: 9pt"><B>Description: Displays weather conditions on your site</B></FONT><FONT SIZE=2 STYLE="font-size: 9pt"> <BR>This module is an addon module for the Mx Portal. More detailed release info is published (and updated) at <A HREF="http://www.mx-system.com/">www.mx-publisher.com</A>.<BR><BR>I. <A HREF="#install">Installation instructions</A> <BR><BR>II. <A HREF="#themes">Additional styles</A> <BR><BR>III. <A HREF="#languages">Additional languages</A> <BR><BR><A HREF="http://www.mx-system.com/" TARGET="_blank">DEMO </A><BR><BR><A HREF="http://www.mx-system.com/index.php?page=4&action=category&cat_id=5" TARGET="_blank">DOWNLOAD </A><BR><BR><BR></FONT><FONT SIZE=2 STYLE="font-size: 9pt"><B>I. Installation Instructions</B></FONT><FONT SIZE=2 STYLE="font-size: 9pt"> <BR>To install this module, follow these instructions. If you encounter any problems during install, visit the <A HREF="http://www.mx-system.com/forum/viewforum.php?f=20" TARGET="_blank">module support forum</A>. <BR><BR>1) Remove possible old installation (older than v. 1.0) <BR>Delete all module files within /modules/modulename<BR><BR>2) Copy and upload new files <BR>Unzip the distributed files into your portal modules directory ([Portal_URL]/modules/) and upload <BR><BR>3) Import definition file <BR>In the Administration Panel -> Module Administration, import Module Pack for this module <BR><BR>4) Now the module is installed, but to use it you need to add the module Block to a Portal Page. <BR><BR>- Portal Administration Panel -> Page Administration -> Add Block -> Select your module Block from the drop-down list <BR><BR><A HREF="#top">Back to Top</A> <BR><BR><BR></FONT><FONT SIZE=2 STYLE="font-size: 9pt"><B>II. Additional Styles</B></FONT><FONT SIZE=2 STYLE="font-size: 9pt"> <BR>This module is compatible with any theme/style. All template files are located within modules/mx_modulename/templates. Note: You dont have to specify 'SubSilver' or any theme name, since all theme settings follow from the general portal/phpbb page header. <BR><BR><A HREF="#top">Back to Top</A> <BR><BR><BR></FONT><FONT SIZE=2 STYLE="font-size: 9pt"><B>III. Additional Languages</B></FONT><FONT SIZE=2 STYLE="font-size: 9pt"> <BR>First check to see if your language is already translated. <BR><BR>Translated languages are downloaded <A HREF="http://www.mx-system.com/index.php?page=4&action=category&cat_id=5" TARGET="_blank">here</A>. <BR><BR>If exists, download and install in the modules/mx_modulename/language folder. If not, duplicate (copy and paste) any included language file, rename to match your language, translate using any texteditor, save and upload. <BR><BR><A HREF="#top">Back to Top</A> <BR><BR>/Mx Team</FONT></P> </TD> </TR> </TABLE> <P><BR><BR> </P> </BODY> </HTML> --- NEW FILE: portal_weather.php --- <?php /** * * @name weather.php * @package MX-Publisher Core * @version $Id: portal_weather.php,v 1.1 2013/06/17 18:19:30 orynider Exp $ * @copyright (c) 2007-2012 MX-Publisher Project Team * @docs: http://docs.rainmeter.net/tips/webparser-weather-location-code * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ // // ERROR HANDLING // //error_reporting( E_ALL ); if(!defined('IN_PORTAL') || !is_object($mx_block)) { die("Hacking attempt"); } /** * Read Block Settings * Default modulename * Set 'PORTAL_WEATHER' in block settings then use lang[] */ $title = $mx_block->block_info['block_title']; $show_title = $mx_block->block_info['show_title']; $block_id = (isset($block_id) ? $block_id : $mx_block->block_info['block_id']); $block_size = (isset($column) ? $mx_page->columns[$column]['column_size'] : 176); $b_description = $mx_block->block_info['block_desc']; /** * Default module-image: * file must be in "{T_THEME_PATH}/images/portal/" * $image_src = 'portal_weather.png'; */ // Read configuration definition $legend1 = $mx_block->get_parameters('GER'); $module_icon_name = $mx_block->get_parameters('module_image'); $module_icon_width = $mx_block->get_parameters('module_img_width'); $module_icon_height = $mx_block->get_parameters('module_img_height'); $weather_cityZipcode = $mx_block->get_parameters('weather_default_zipcode'); // RO0AR0001 = ROXX0024 $weather_citycode = $mx_block->get_parameters('weather_default_citycode'); //866307 $weather_country = $mx_block->get_parameters('weather_default_country'); //RO $weather_unit = $mx_block->get_parameters('weather_default_unit'); //Your Default temperature unit (C for Celsius, F for Fahrenheit) $weather_alternate_url0 = $mx_block->get_parameters('ALTERNATE_URL'); $weather_alternate_url1 = $mx_block->get_parameters('ALTERNATE_URL1'); $weather_alternate_url2 = $mx_block->get_parameters('ALTERNATE_URL2'); $template_use_large = $mx_block->get_parameters('template_use_large'); /** * Get menu icon */ $module_icon_name = (@file_exists($mx_root_path . $images['mx_graphics']['menu_icons'] . '/' . $module_icon_name) ? $module_icon_name : 'icon_blank.gif'); $module_iconhot_name = str_replace('.gif', '_hot.gif', $module_icon_name); if (@file_exists($mx_root_path . $images['mx_graphics']['menu_icons'] . '/' . $module_iconhot_name)) { $module_icon_file = $module_iconhot_name; $module_icon_style = 'mnu-nm-current'; $core_icon_style = 'cattitle'; } else { $module_icon_file = $module_icon_name; $module_icon_style = 'mnu-nm'; $core_icon_style = 'genmed'; } //Align = ALIGN = LEFT | RIGHT | TOP | TEXTTOP | MIDDLE | ABSMIDDLE | BOTTOM | ABSBOTTOM | BASELINE $module_icon_align = 'left'; $module_icon_url = PORTAL_URL . $images['mx_graphics']['menu_icons'] . '/' . $module_icon_file; $module_icon = (!empty($module_icon_name) && $module_icon_name != 'none') ? '<img class="'.$module_icon_style.'" border="0" align="'.$module_icon_align.'" src="' . $module_icon_url . '" alt="' . $b_description . '" /> ' : '<img class="'.$module_icon_style.'" border="0" align="'.$module_icon_align.'" src="' . $images['weather_logo'] . '" width="'. $module_icon_width .'" height="'. $module_icon_height .'" alt="' . $b_description . '" /> '; /* * Include the functions file */ require($module_root_path . 'includes/constants.'.$phpEx); require($module_root_path . 'includes/functions.'.$phpEx); require($module_root_path . 'includes/class_xmlparser.'.$phpEx); require($module_root_path . 'includes/class_weather.'.$phpEx); /* * Start session management */ $weather_config = read_weather_config($userdata['user_id']); /* * Begin block script here */ $weather_zipcode = !empty($weather_cityZipcode) ? $weather_cityZipcode : $weather_config['weather_zipcode_default']; // default postal code $weather_country = !empty($weather_country) ? $weather_country : $weather_config['weather_country_default']; // default country name /* $weather_alternate_url0 = $weather_config['weather_alternate_url']; $weather_alternate_url1 = $weather_config['weather_alternate_url1']; $weather_alternate_url2 = $weather_config['weather_alternate_url2']; */ // Set Local variables $partner_ID = $weather_config['partner_id_default']; $license_key = $weather_config['license_key_default']; $tp = $weather_config['weather_unit_default']; # Your Default temperature unit (C for Celsius, F for Fahrenheit) //Set User variables $zip_code = !empty($userdata['user_zipcode']) ? $userdata['user_zipcode'] : $weather_zipcode; $user_loc = !empty($userdata['user_from']) ? $userdata['user_from'] : $weather_country; /* * Set the filename of the template you want to use for this file. */ // // BEGIN OUTPUT // $template_tmp = (($recent_use_large == 'horizontal') ? array('weather_body' => 'weather_4401.tpl') : array('weather_body' => 'weather_side.tpl')); $template->set_filenames($template_tmp); /* * Some cod */ if (!($length >= 1 && $length <= 10)) { $length = 10; } if(empty($user_loc)) { $user_loc = $zip_code; } if (strlen($zip_code) < 5) { $zip_code = '0' . $zip_code; } //Arad, Romania //$user_loc = $user_loc; //Country Site is first 2 characters from the left of ZIP_CODE or the last 2 characters of COUNTRY_CODE (RO or EURO, etc) $zip_site = !is_numeric(substr($zip_code, 0, 2)) ? strtoupper(substr($zip_code, 0, 2)) : strtoupper(substr($weather_country, 1, 2)); //print_r("$user_loc"); // Create the new weather object! $cachefile = $module_root_path . "cache/".$zip_code.".dat"; // Cache duration in seconds. The cache will be updated with a live feed after the specified time // 3600 = seconds of cache lifetime (expires after that) $cachetimeinseconds = 3600; // RO0AR0001 = ROXX0024 = 866307 - Location Code from weather.yahoo.com // C = Units in Celsius! (Option: F = Fahrenheit) $weather_loc = new weather($zip_code, $cachetimeinseconds, $weather_unit, $module_root_path); // Parse the weather object via cached // This checks if there's an valid cache object allready. if yes // it takes the local object data, what's much FASTER!!! if it // is expired, it refreshes automatically from rss online! $weather_loc->parsecached(); // => RECOMMENDED! // allway refreshes from rss online. NOT SO FAST. //$weather_loc->parse(); // => NOT recommended! //Set some variables again $weather_image_code = isset($weather_loc->imageurl) ? "<div style=\"background-image: url('".$weather_loc->imageurl."'); background-position: 0px 0px; height: 40px; width: 200px; padding-left: 5px; padding-right: 5px; border: 0px;\" alt=\"\"> </div>" : ""; $weather_cityname = isset($weather_loc->city) ? $weather_loc->city : $weather_country; // Arad, Romania $weather_yahoolink = isset($weather_loc->yahoolink) ? $weather_loc->yahoolink : 'http://us.rd.yahoo.com/dailynews/rss/weather/'.$weather_cityname.'__'.$zip_site.'/*http://xml.weather.yahoo.com/forecast/'.$zip_code.'_c.html'; $weather_unit = isset($weather_loc->unit) ? $weather_loc->unit : $weather_unit; //Yahoo is in the process of an upgrade. It is removing the p= part and replacing it with w= to use the more powerful new WOEID codes. $weather_yahooxml = "http://xml.weather.yahoo.com/forecastrss?u=".$weather_unit."&w=".$weather_citycode; $weather_actimage = isset($weather_loc->actcode) ? "http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_loc->actcode.".gif" : ""; //$weather_sunrise = $weather_loc->sunrise; // 6:49 am //$weather_sunset = $weather_loc->sunset; // 08:05 pm $fday_imgsrc = array(); $fday_imgsrc[0] = isset($weather_loc->actcode) ? "http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_loc->actcode.".gif" : ""; $fday_imgsrc[1] = isset($weather_loc->fore_day1_imgcode) ? "http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_loc->fore_day1_imgcode.".gif" : $weather_actimage; $fday_imgsrc[2] = isset($weather_loc->fore_day2_imgcode) ? "http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_loc->fore_day2_imgcode.".gif" : $weather_actimage; $fday_imgsrc[3] = isset($weather_loc->fore_day3_imgcode) ? "http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_loc->fore_day3_imgcode.".gif" : $weather_actimage; /** * Assings Main Template Variables to Constants */ $template->assign_vars(array( 'L_TITLE' => (!empty($lang[$title]) ? $lang[$title] : $title), 'SHOW_TITLE' => $show_title, 'SHOW_ICON' => $legend1, 'BLOCK_SIZE' => (!empty($block_size) ? $block_size : '100%'), 'BLOCK_ID' => $block_id, 'BLOCK_ICON' => $module_icon, 'IMAGE_SRC' => $module_icon_url, 'IMAGE_STYLE' => $module_icon_style, 'IMAGE_CORESTYLE' => $core_icon_style, 'LOCATION_ZIP' => $zip_code, 'L_WEATHER' => (!empty($weather_loc->title) ? $weather_loc->title : $lang['Weather']), 'L_WEATHER_NOW' => $lang['WEATHER_NOW'], 'L_YAHOO_WEATHER' => $lang['Yahoo_Forecast'], 'L_WEATHER_CHANNEL' => $lang['Weather_Channel'], 'L_ACTTEXT' => $lang['acttext'], 'L_ACTTEMP' => $lang['acttemp'], 'L_ACTTIME' => $lang['acttime'], 'L_IMAGURL' => $lang['imageurl'], 'L_ACTCODE' => $lang['actcode'], 'L_TEMP_ICON' => $lang['Temp_icon'], 'L_TEMP_UNIT' => strtoupper($weather_unit), 'WEATHER_YAHOOLINK' => $weather_yahoolink, 'WEATHER_COUNTRY' => $user_loc, 'CITY_CODE' => $weather_citycode, 'CITY_NAME' => $weather_cityname, 'ACTTEMP' => $weather_loc->acttemp, 'ACTTEXT' => (!empty($lang[strtoupper(weather_clean_string($weather_loc->acttext))]) ? $lang[strtoupper(weather_clean_string($weather_loc->acttext))] : $weather_loc->acttext), 'ACTTIME' => @format_weather_date($weather_loc->acttime), 'IMAGURL' => $weather_image_code, 'ACTCODE' => $weather_loc->actcode, 'ACTIMG_SRC' => $weather_actimage, 'L_FORECAST_DAY' => $lang['Forecast_Day'], 'FDAY_DAY' => $weather_loc->fore_day1_day, 'FDAY_DATE' => @format_weather_date($weather_loc->fore_day1_date), 'FDAY_TEMPLOW' => $weather_loc->fore_day1_tlow, 'FDAY_TEMPHIGHT' => $weather_loc->fore_day1_thigh, 'FDAY_FORECAST' => $weather_loc->fore_day1_text, 'FDAY_IMGNUM' => $weather_loc->fore_day1_imgcode, 'FDAY_IMGSRC' => $fday_imgsrc[1], 'WEATHER_ALTERNATE_URL0' => sprintf(htmlspecialchars_decode($weather_alternate_url0)), 'WEATHER_ALTERNATE_URL1' => sprintf(htmlspecialchars_decode($weather_alternate_url1)), 'WEATHER_ALTERNATE_URL2' => sprintf(htmlspecialchars_decode($weather_alternate_url2)) )); /* Parse Template */ $template->pparse('weather_body'); ?> --- NEW FILE: install.txt --- [RELEASE] Weather Module 1.0 - for Mx Portal v. 2.7 (or later) Description The Download module is an addon module for the Mx Portal. Installation Instructions To install the Weather module, follow these instructions. If you encounter any problems during install, visit the module support forum. 1) Copy and upload new files Unzip the distributed files into your portal directory and upload 2) Import definition file In the Administration Panel -> Module Administration, import Module Pack "modules/mx_weather/Weather.pak" 4) Install new db tables In you browser, call: [portal URL]/modules/mx_weather/weather_db_install.php Additional Styles To install/adapt the download module for another theme/style not included in the module distribution, simply duplicate (copy and paste) any included styles folder content (from for example the 'default' or 'SubSilver' folder), to your already installed theme/style folder. For example: You have already installed the theme 'Mytheme' for the Mx Portal. This theme is not included in the module distribution. Then copy all files from [portal URL]/templates/default/* (distributed with the module) to [portal URL]/templates/Mytheme/ Upload new/modified files. Additional Languages First verify that your language hasn't already been translated. If not, duplicate (copy and paste) any included language file, rename to match your language, translate using any texteditor, save and upload. Example: // Set Local variables $partner_ID = "1028415260"; $license_key = "2e4acb02077ea1da"; $location = urlencode($HTTP_POST_VARS['loc']); //search on location (city or zip) $loc_id = $HTTP_POST_VARS['id']; // specific town id $length = $HTTP_POST_VARS['length']; // Forecast length if (!($length >= 1 && $length <= 10)) $length = 10; if(empty($loc_id) && empty($location)) { $loc_id = $userdata['user_zipcode']; } // First URL for searching, second for detail. $search_url = "http://xoap.weather.com/search/search?where=$location"; $forecast_url = "http://xoap.weather.com/weather/local/$loc_id?cc=*&dayf=$length&link=xoap&par=$partner_ID&key=$license_key"; --- NEW FILE: db_install.php --- <?php /** * * @package Mx-Publisher Module - mx_weather * @version $Id: db_install.php,v 1.1 2013/06/17 18:19:30 orynider Exp $ * @copyright (c) 2003 [ory...@rd..., OryNider] Mx-Publisher Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ define( 'IN_PORTAL', true ); if ( !defined( 'IN_ADMIN' ) ) { $mx_root_path = './../../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include( $mx_root_path . 'common.' . $phpEx ); // Start session management $mx_user->init($user_ip, PAGE_INDEX); // End session management if ( !$userdata['session_logged_in'] ) { die( "Hacking attempt(1)" ); } if ( $userdata['user_level'] != ADMIN ) { die( "Hacking attempt(2)" ); } } global $mx_user; /* switch (PORTAL_BACKEND) { case 'internal': case 'phpbb2': $user_id = $userdata['user_id']; $user_ip = $userdata['session_ip']; break; case 'phpbb3': $user_id = $mx_user->data['user_id']; $user_ip = phpBB2::encode_ip($mx_user->data['session_ip']); break; default: $user_id = $userdata['user_id']; $user_ip = $userdata['session_ip']; } */ $mx_module_version = '3.0.0'; $mx_module_copy = 'Mx-Publisher <i> - Weather </i> module by <a href="http://www.mx-publisher.com/" target="_blank">Jon Ohlsson</a> & <a href="http://www.pubory.uv.ro/" target="_blank">Florin C. Bodin</a>'; // For compatibility with core 2.7.+ define('MXBB_27x', file_exists($mx_root_path . 'mx_login.php')); if (MXBB_27x) { include_once($mx_root_path . 'modules/mx_weather/includes/functions_mx.' . $phpEx); } // If fresh install if (!$result = $db->sql_query("SELECT license_key_deault from " . $mx_table_prefix . "weather_config")) { $message = "<b>This is a fresh install!</b><br/><br/>"; $sql = array( "CREATE TABLE ".$mx_table_prefix."weather_config ( user_id mediumint(8) NOT NULL default '0', weather_unit_default char(1) default 'C', weather_city_default varchar(100) default NULL, weather_zipcode_default varchar(100) default NULL, weather_country_default varchar(100) NOT NULL default '', partner_id_default varchar(100) default NULL, license_key_deault varchar(100) default NULL, PRIMARY KEY (user_id) )", "CREATE TABLE ".$mx_table_prefix."weather_det_config ( user_id mediumint(8) NOT NULL default '0', weather_id varchar(30) NOT NULL default '', weather_order smallint(5) unsigned NOT NULL default '0', PRIMARY KEY (user_id,weather_id) )", "CREATE TABLE ".$mx_table_prefix."weather ( weather_id varchar(30) NOT NULL default '', weather_country varchar(100) NOT NULL default '', weather_city varchar(100) default NULL, weather_region varchar(100) default NULL, weather_subdiv varchar(100) default NULL, PRIMARY KEY (weather_id) ) " ); $sql[] = "INSERT INTO " . $mx_table_prefix . "weather_config VALUES (0, 'C', '866307', 'ROXX0024', 'RO', '0', '0')"; if (!MXBB_27x) { $sql[] = "UPDATE " . $mx_table_prefix . "module" . " SET module_version = '" . $mx_module_version . "', module_copy = '" . $mx_module_copy . "' WHERE module_id = '" . $mx_module_id . "'"; } $sql[] = "ALTER TABLE " . $phpbb_table_prefix . "users ADD user_zipcode VARCHAR (10) "; $message .= mx_do_install_upgrade($sql); } else { // If already installed $message = "<b>Module is already installed...consider upgrading ;)</b><br/><br/>"; } echo "<br /><br />"; echo "<table width=\"90%\" align=\"center\" cellpadding=\"4\" cellspacing=\"1\" border=\"0\" class=\"forumline\">"; echo "<tr><th class=\"thHead\" align=\"center\">Module Installation/Upgrading/Uninstalling Information - module specific db tables</th></tr>"; echo "<tr><td class=\"row1\" align=\"left\"><span class=\"gen\">" . $message . "</span></td></tr>"; echo "</table><br />"; ?> --- NEW FILE: weather.php --- <?php /** * * @package Mx-Publisher Module - Weather * @version $Id: weather.php,v 1.1 2013/06/17 18:19:30 orynider Exp $ * @copyright (c) 2007 [ory...@rd..., OryNider] Mx-Publisher Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ /*************************************************************************** * MODIFICATIONS * --------------- * begin : Monday, February 15, 2006 * copyright : (C) 2006 MichaelLewisMusic.com Web Team * email : Fr...@mi... * * $Id: weather.php,v 1.1 2013/06/17 18:19:30 orynider Exp $ * * ***************************************************************************/ if( !defined('IN_PORTAL') || !is_object($mx_block)) { die("Hacking attempt"); } // Read Block Settings $title = $mx_block->block_info['block_title']; //PORTAL_METEO_SETTINGS $block_id = (isset($block_id) ? $block_id : $mx_block->block_info['block_id']); $block_size = (isset($column) ? $mx_page->columns[$column]['column_size'] : 176); $b_description = $mx_block->block_info['block_desc']; // Read configuration definition $legend1 = $mx_block->get_parameters( 'SETTINGS_GER' ); $weather_ger_image = $mx_block->get_parameters('module_image'); $weather_ger_width = $mx_block->get_parameters('module_img_width'); $weather_ger_height = $mx_block->get_parameters('module_img_height'); $weather_zipcode = $mx_block->get_parameters('weather_default_postal'); $weather_country = $mx_block->get_parameters('weather_default_country'); $partner_ID = $mx_block->get_parameters('weather_default_partner_id'); $license_key = $mx_block->get_parameters('weather_default_license_key'); $legend2 = $mx_block->get_parameters('SETTINGS_ALT'); $weather_alternate_url = $mx_block->get_parameters('ALTERNATE_URL'); $weather_alternate_url1 = $mx_block->get_parameters('ALTERNATE_URL1'); $weather_alternate_url2 = $mx_block->get_parameters('ALTERNATE_URL2'); // =================================================== // Include the functions file // =================================================== require($module_root_path . 'includes/constants.'.$phpEx); require($module_root_path . 'includes/functions.'.$phpEx); $weather_config = read_weather_config($userdata['user_id']); $template->set_filenames(array( 'body' => 'mx_weather_local.tpl') ); // Set Local variables $weather_zipcode = !empty($weather_zipcode) ? $weather_zipcode : $weather_config['weather_zipcode_default']; // default postal code $weather_cou... [truncated message content] |