-
Posts
902 -
Joined
-
Last visited
-
Days Won
9
Everything posted by doddsey_65
-
I have an array with a list of timezones and their offsets but the names of the timezones(which i got off my OS's clock) dont match the timezone names in php. Heres my array: $tz = array( "0" => "Select A Timezone", "-12" => "(GMT - 12:00) International Date Line West", "-11" => "(GMT - 11:00) Midway Island, Samoa", "-10" => "(GMT - 10:00) Hawaii", "-9" => "(GMT - 09:00) Alaska", "-8" => "(GMT - 08:00) Pacific Time US, Canada, Baja", "-7" => "(GMT - 07:00) Mountain Time US", "-6" => "(GMT - 06:00) Central America, Mexico City", "-5" => "(GMT - 05:00) Eastern Time US, Bogota, Lima, Quito", "-4:30" => "(GMT - 04:30) Caracas", "-4" => "(GMT - 04:00) Atlantic Time Canada, La Paz, Santiago", "-3:30" => "(GMT - 03:30) Newfoundland", "-3" => "(GMT - 03:00) Brazil, Buenos Aires, Fortaleza, Greenland", "-2" => "(GMT - 02:00) Mid-Atlantic", "-1" => "(GMT - 01:00) Azores, Cape Verde Island", "0" => "(GMT) Western Europe Time, Casablanca, Lisbon, London", "+1" => "(GMT + 01:00) Brussles, Copenhagen, Madrid, Paris, Vienna", "+2" => "(GMT + 02:00) Kaliningrad, South Africa, Cairo", "+3" => "(GMT + 03:00) Baghdad, Riyadh, Moscow, St. Petersberg", "+3:30" => "(GMT + 03:30) Tehran", "+4" => "(GMT + 04:00) Abu Dhabi, Muscat, Yerevan, Baku, Tbilisi", "+4:30" => "(GMT + 04:30) Kabul", "+5" => "(GMT + 05:00) Ekateringberg, Islamabad, Karachi, Tashkent", "+5:30" => "(GMT + 05:30) Mumbai, Kolkata, Chennai, New Delhi", "+5:45" => "(GMT + 05:45) Kathmandu", "+6" => "(GMT + 06:00) Almaty, Dhaka, Colombo", "+6:30" => "(GMT + 06:30) Yangon, Cocos Islands", "+8" => "(GMT + 08:00) Beijing, Perth, Singapore, hong Kong", "+9" => "(GMT + 09:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk", "+9:30" => "(GMT + 09:30) Adelaide, Darwin", "+10" => "(GMT + 10:00) Eastern Australia, Guam, Vladivostok", "+11" => "(GMT + 11:00) Magadan, Solomon Islands, New Caledonia", "+12" => "(GMT + 12:00) Auckland, Wellington, Fiji, Kamchatka", );
-
im setting up timezones so every user will be able to have the times displayed in their timezone. however when they register their timezone is sent to the database as an integer value: eg/ -3. meaning -3 hours from GMT. but to set the timezone in php i am using: date_default_timezone_set(); i have the list of available timezones but they just display the names and not the hour difference. Is there any where to get such a list or should i be doing things differently?
-
im using urlencode() to replace special characters in the url. It works on spacs, replacing them with '+' but it isnt working on a special character i have tried, the exclamation mark. Is this the right function to use for this? and if so why isnt it working for me? function create_url($str) { $str = urlencode($str); return $str; } function decode_url($str) { $str = urldecode($str); return $str; } i use the function create_url() for the link and use decode_url() when the link is clicked so i can display the proper name. eg: $forum_url_name = create_url($row['f_name']); and when viewing the forum: $forum_name = decode_url($_GET['f_name']);
-
i came across this problem with my site so i made a table for friend requests and a table for friends. once the request is confirmed delete it from the requests table and add their details to the friends table. more queries and it can probably be done better but it saved me confusion and complexity.
-
not sure about mobile devices and ipods. Some of these have JS turned off by default. Do you have a fallback option for this case? I would personally use onBlur to check the value and then use a php script to check when the form is being submitted. That way people with JS turned off will still recieve an error when entering the wrong values.
-
Im assuming there would be an alert when pressing the back button saying the data would be resent. This is normal. Its why sites redirect to a confirmation page when a form is submitted. If it stayed on the same page and the user hit refresh then it would also resend the data.
-
$menuData isnt set when you are using it in the statements.
-
can you show how your table is set up? what is the name of the database table?
-
im using the floowing code to pull all alerts from the database. as you can see i have 3 types of alertsd. Profile alerts, forum alerts and topic alerts. They are sorted and placed on the screen under their respective header. However i want to limit it so it only displays 4 of each type of alert. I cant use LIMIT in the query because that would limit all alerts meaning only 4 alerts in total would show up and i just need to limit each alert type. any ideas? $alert_query = $link->query("SELECT a.a_aid, a.a_alert_type, a.a_time_alerted, a.a_fid, a.a_poster, a_alert_read, a.a_tid, c.f_name as cat_name, f.f_fid, f.f_name, t.t_name, u.u_avatar, u.u_avatar_cropped FROM ".TBL_PREFIX."alerts as a LEFT JOIN ".TBL_PREFIX."forums as f ON (f.f_fid = a.a_fid) LEFT JOIN ".TBL_PREFIX."topics as t ON (t.t_tid = a.a_tid) LEFT JOIN ".TBL_PREFIX."forums as c ON (c.f_fid = f.p_id) LEFT JOIN ".TBL_PREFIX."users as u ON (u.u_username = a.a_poster) WHERE a.a_user_name = '$user_name' ORDER BY a_time_alerted ") or die(print_link_error()); $alert_info = $alert_query->fetchAll(); $pm_alert_list = ''; $num_pm_alerts = 0; $num_forum_alerts = 0; $num_topic_alerts = 0; foreach($alert_info as $key => $val) { $alert_info[$key]['a_alert_read'] == 0 ? $color = '#f5dfaf' : $color = '#f4f4f4'; // if alert is a profile message alert if($alert_info[$key]['a_alert_type'] == 1) { $pm_alert_list .= '<dd style="background:'.$color.';" class="alert" id="alert-'.$alert_info[$key]['a_aid'].'"><p class="alert_intro">'; $pm_alert_list .= '<input type="checkbox" class="pm_checkbox" id="pm_checkbox-'.$alert_info[$key]['a_aid'].'" />'.profile_link($alert_info[$key]['a_poster']).' posted on your wall</p>'; $pm_alert_list .= '<p class="alert_time"> on '.asf_date($alert_info[$key]['a_time_alerted'],'full').'</p>'; $pm_alert_list .= '</dd>'; $num_pm_alerts++; } if($alert_info[$key]['a_alert_type'] == 2) { $forum_alert_list .= '<dd style="background:'.$color.';" class="alert" id="alert-'.$alert_info[$key]['a_aid'].'"><p class="alert_intro">'; $forum_alert_list .= '<input type="checkbox" class="pm_checkbox" id="pm_checkbox-'.$alert_info[$key]['a_aid'].'" /><strong><a href="'.$config['asf_root'].'category/'.create_url($alert_info[$key]['cat_name']).'/forum/'.create_url($alert_info[$key]['f_name']).'">'.$alert_info[$key]['f_name'].'</a></strong> has a new topic</p>'; $forum_alert_list .= '<p class="alert_time"> '.asf_date($alert_info[$key]['a_time_alerted'],'full').'</p>'; $forum_alert_list .= '</dd>'; $num_forum_alerts++; } if($alert_info[$key]['a_alert_type'] == 3) { $topic_alert_list .= '<dd style="background:'.$color.';" class="alert" id="alert-'.$alert_info[$key]['a_aid'].'"><p class="alert_intro">'; $topic_alert_list .= '<input type="checkbox" class="pm_checkbox" id="pm_checkbox-'.$alert_info[$key]['a_aid'].'" /><strong><a href="'.$config['asf_root'].'category/'.create_url($alert_info[$key]['cat_name']).'/forum/'.create_url($alert_info[$key]['f_name']).'/topic/'.create_url($alert_info[$key]['t_name']).'">'.$alert_info[$key]['t_name'].'</a></strong> has a new post</p>'; $topic_alert_list .= '<p class="alert_time"> '.asf_date($alert_info[$key]['a_time_alerted'],'full').'</p>'; $topic_alert_list .= '</dd>'; $num_topic_alerts++; } }
-
$query should be your actual query where you get the information from the database. <?php $query = mysql_query("SELECT * FROM table") or die(mysql_error()); \\ use your table names echo '<ul>'; while($result = mysql_fetch_array($query)) { echo '<li>'.$result['Property_Facilities_General'].'</li>'; } echo '</ul>'; ?>
-
you would use a while loop: echo '<ul>'; while($result = mysql_fetch_array($query)) { echo '<li>'.$result['column_name'].'</li>'; } echo '</ul>';
-
its in its infancy still because i havent recieved enough feedback about the current design/layout to make it final. if i dont get crits on how it looks then how do i know if its good or not? I think it looks good but its not just up to me, its upto the end user aswell, which is why i need as much critique as possible on the current design and layout. Im just trying to get asf off the ground.
-
Since the last topic was locked(rightly so btw) i have decided to make a new one but stick to the forum rules this time. The other topic was locked because it was turning into a diary of my work. Hopefully i will recieve some constructive crits through this topic though. If you want to know what ASF is then look at this topic: http://www.phpfreaks.com/forums/index.php?topic=309878.msg1463762#msg1463762 its basically an open source forum package that i have been working on for some months now. I would love to hear what people think. http://www.asimpleforum.co.uk thanks for reading and i hope to hear some constructive crits soon. Carl
-
im trying to link a profile if it is prefixed with an @ symbol. I have tried this but it doesnt work as i thought it wouldnt. $content = preg_replace('|@(.*?)|', profile_link('$1'), $content);
-
Ive just implemented a function which shows how many queries have been run on the specific page. Since the result returned 38 queries on the index page alone i need a way of listing all of these queries. I could just go through the code and find them all but there are several pages to go through. so does anyone know of a function which will list all the queries that have been run?
-
Im using the following query to pull all topics that have a new reply since the users last visit and where the user has posted within them. $topic_query = $link->query("SELECT t.*, u.*, p.* FROM ".TBL_PREFIX."topics as t LEFT JOIN ".TBL_PREFIX."users as u ON (u.u_username = t.t_poster) LEFT JOIN ".TBL_PREFIX."posts as p ON (t.t_tid = p.p_tid) WHERE t.t_last_post_time > u.u_activity_time AND p.p_poster = '".$user->user_name."' GROUP BY t.t_tid ORDER BY t.t_sticky DESC, t.t_time_posted DESC LIMIT $start_page, $topics_to_show") or die(print_link_error()); for some reason though it still shows two topics that have a last post time which is less than that of the users activity time. The last_post_time for the topic is 1300309160 compare that with the users last activity time 1300784679 as you can see the last activity time is more than the last post time. there are no records in the database that are more than the last activity time so i shouldnt be getting any results. Anyone have any ideas?
-
if $start was 1 then it would show the records from the table begining with the second. in order to show the first record you must set start to 0. so if start is 0 and end is 5 it would show records 0,1,2,3,4
-
echo out your query and see what it prints: echo "SELECT * FROM stories ORDER BY id DESC LIMIT $start, $end";
-
$end=$start+5; $stories = mysql_query("SELECT * FROM stories ORDER BY id DESC LIMIT $start, $end") or die(mysql_error()); $num = mysql_num_rows($stories); print $num; hint* Use or die mysql_error() to print any errors that are within your query. Give that a go and let me know if it works
-
in login.php i use this to logout the user $link->query("UPDATE ".TBL_PREFIX."users SET u_last_login = '".$config['time_now']."', u_online = '0' WHERE u_username = '$username'") or die(print_link_error()); but that only runs if the get value do is present and it = logout and when they are logging in that value isnt set. if(isset($_GET['do']) && $_GET['do'] == 'logout')
-
I am using a query to update the db when a user logs in. It sets every value correctly but it doesnt set the colum u_online which is INT(1). $link->query("UPDATE ".TBL_PREFIX."users SET u_last_login = '".$config['time_now']."', u_online = 1, u_ip = '".$_SERVER['REMOTE_ADDR']."', u_activity_time = '".$config['time_now']."', u_points = u_points + '$login_points' WHERE u_username = '$username'") or die(print_link_error()); when i echo the query: UPDATE asf_users SET u_last_login = '1300310822', u_online = 1, u_ip = '127.0.0.1', u_activity_time = '1300310822', u_points = u_points + '1' WHERE u_username = 'doddsey65' which works because i tried it in phpmyadmin and it changed the column. But it doesnt work in the actual script. It changes every other value that its supposed to but the u_online. Anyone have any ideas why?
-
Since it appears my login system is broken i have been trying to fix it. The problem is that it isnt loggin people in. This is what im doing: The user visits login.php they enter their details and click login the posted data gets sent to login_process.php via jQuery login_process.php checks to see if the details are correct if they are it sets a cookie called uid with their user id if they clicked the remember me box then this cookie is set for a year if not then it is set as a session cookie login_process echos a success back to the jQuery in login.php when jQuery gets this success status it redirects to login_success.php the user should now be logged in. to show a logged in user i echo their username by running a query on the cookie uid but somewhere along the lines cookie uid isnt being set so the user is never logged in. here is the code:(shortened) $username = $_POST['user_name']; $password = asf_hash($_POST['password']); $remember_me = $_POST['remember_me']; //check the values with a query then: if($remember_me == 'yes' && !isset($_COOKIE['uid'])) { setcookie('uid', $_SESSION['uid'], time()+(((60*60)*24)*365)); } elseif($remember_me == 'no' && !isset($_COOKIE['uid'])) { setcookie('uid', $_SESSION['uid'], 0); } else { setcookie('uid', '', time()-3600); } login_success just contains a like to go back to the page they were originally viewing. and in my init script which is run when a page loads: $user = new user; $user->setup($_COOKIE['uid']); // this basically sets info like the username and such from a query run on the cookie. so why isnt the cookie being set? any ideas? also any ideas on making this more secure if it isnt? Thanks
-
I have spent the best part of 2 hours completely revamping the code for the topic display page. I have gotten rid of the jQuery pagination and have dramatically cleaned up the code. I havent added the files to the server yet because i want to make sure the changes i have made work fully and dont mess up anything else. I have also done some small graphical changes as i wasnt completely happy with the layout. I will start next on the post display pages and once that is done i will upload the new files to the server.
-
good question, i forgot to mention that the header has the name of the forum within it, which is grabbed from the query
-
The current system I am using has worked so far but it has its problems. Basically I have 2 files to display forum topics. view_topics.php and topic_list_tpl.php view_topics.php defines some variables like so $template->topic_name = $row[$key]['topic_name'] then it renders the page like so $template->render('topic_list_tpl.php'); then in topic_list_tpl.php i use this to print the name of the topic <?php echo $this->topic_name; ?> which works fine. But as you know a topic list needs a header. But the render function is within a foreach loop so it displays all of the topics from the query. This poses the problem of the header being looped, which it shouldnt be. So in view_topics.php i use: $template->topic_id = $row[$key]['topic_id']; $template->first_topic_id = $row[0]['topic_id']; then in topic_list_tpl.php i can use: <?php if($this->topic_id == $this->first_topic_id) { echo the header } else { echo the topics } but the problem comes when adding a footer bar at the bottom(for the new reply link and other topic options). i can use something like $amount_of_topics = count($row); $template->last_topic_id = $row[$amount_of_topics-1]['topic_id'] and then check it like that but that wont work when using pagination as the last topic displayed isnt always going to be the last topic in the query. So another option i have is to have the header and footer bars in seperate files and call them outside of the loop. But these files would only be 2 or 3 lines each. So is this the best option? or is there an easier way of doing things?