Jump to content

doddsey_65

Members
  • Posts

    902
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by doddsey_65

  1. never mind lol. i was hashing $password before building the if statement, which meant even though the field was empty it was hashing it, therefore it was no longer empty.
  2. im wanting to change the sql in my query based on if a field is empty or not. if the field is empty then i dont want it to post anything, but if its not empty then it can post the content. heres what i have so far but it does post the content even if the field is empty. (!empty($password)) ? $pass_sql = "u_password = '$password'," : $pass_sql = null; $link->query("UPDATE ".TBL_PREFIX."users SET $pass_sql u_allow_user_pm = '".$_POST['allow_user_pm']."' WHERE u_username = '".$_POST['user_name']."'") or die(print_link_error()); how can i stop it from updating if the field is empty?
  3. fixed
  4. ill see whats up with the activation, thanks for letting me know. As for uploading to github is that an SVN thing? because i tried uploading to googlecode that way and couldnt figure it out lol.
  5. Okay, its been a while but im at the alpha release of ASF. The core structure works and the template is the way it is going to stay. You can post topics or reply to topics, register, login, change some profile options, view other peoples profiles, add attachments. I would now like some crits please. These could be regarding features(current and new) or something to do with the look and feel of the site. Im now focusing on the user center more in hopes to have it finished in a few days. let me know what you think.
  6. cannot connect to server is your error?
  7. used: [color=black]$bb[$i] = "#\[attachment=(.*?)\]#si"; $html[$i] = $description;[/color] and it works.
  8. for some reason $description is just showing the first result in the preg_replace function but when i echo it outside the function it shows all 3. if(!empty($post_info[$key]['p_attachments'])) { $attachment_list = explode('|', $post_info[$key]['p_attachments']); $a_list = ''; $p_content = str_replace('<br>', '', $post_info[$key]['p_content']); $amount = count($attachment_list); for($i=0; $i<$amount-1; $i++) { $query = $link->query("SELECT a_name, a_description, a_size FROM ".TBL_PREFIX."post_attachments WHERE a_name = '".$attachment_list[$i]."'") or die(print_link_error()); $result = $query->fetchAll(); foreach($result as $k => $v) { $description = $result[$k]['a_description']; } $bb[] = "#\[attachment=(.*?)\]#si"; $html[] = $description; // this just shows the first result 3 times echo $description; // but this shows all of the 3 results $p_content = preg_replace($bb, $html, $p_content); } } is this something todo with preg_replace?
  9. ok it might work but the script isnt getting that far. if(file_exists($config['asf_root'].'attachments/'.$attach[$i])) { $p_content = preg_replace('#\[attachment=([0-9a-zA-Z\.-_])\]#is', $attach[$i], $p_content); } the file doesnt exist since the $attach array includes the normal text aswell as the attachment names. i thought: $attach = preg_split('|\[attachment=|', $p_content); would have worked to just add the attachments to the array but it adds everything in the post.
  10. im having trouble using this function. im trying to change the strings within a post. eg: This is an example post [attachment=file.png] what im trying to do is change [attachment=file.png] to file.png. Here is the code i have but it doesnt change anything. $p_content = str_replace('<br>', '', $post_info[$key]['p_content']); $attach = preg_split('|\[attachment=|', $p_content); for($i=0; $i<count($attach); $i++) { $attach[$i] = str_replace(']', '', $attach[$i]); if(file_exists($config['asf_root'].'attachments/'.$attach[$i])) { $p_content = preg_replace('|\[attachment=([0-9a-zA-Z\.-_])\]|#i', $attach[$i], $p_content); } } echo $p_content; it first gets all the attachment tags within the post then applies the preg replace to all of them. But the preg replace isnt replacing, so i must have gone wrong somewhere. Any tips/ideas? Thanks
  11. how doesnt it work? are you getting an error message?
  12. i am using the fancy upload script for post attachments on my forum. the problem is that when a user starts a new post and adds an attachment the attachment is uploaded before the post is complete. so how would i associate the attachment with the post that they are going to post when i have no post id to go off? i had tried not uploading the files straight away and instead populate an input box with the filenames but i cant figure it out with this script. Anyone got any other options or ideas?
  13. ok here is the whole file, i hope someone can help. when it is successful it echos 1 back to the javascript file which redirects to the page they were on or redirects back to index.php if there isnt a redirect session. <?php ob_start(); /* ASF A Simple Forum * Version 0.1.0 * Page Created 21/01/2011 */ // can page be accessed directly? define('ACCESS', TRUE); // start sessions session_start(); // get the functions file include(dirname(dirname(__FILE__)).'/functions/functions.php'); include(dirname(dirname(__FILE__)).'/includes/initialize.php'); if(isset($_POST['user_name']) && isset($_POST['password'])) { $username = $_POST['user_name']; $password = $_POST['password']; $session_length = $_POST['session_length']; if(empty($session_length) &&!$error) { $error = 'Invalid Session Length'; } if(empty($username)) { if(!$error) { $error = 'Please Enter A Username'; } } if(empty($password)) { if(!$error) { $error = 'Please Enter A Password'; } } if(empty($error)) { $query = $link->query("SELECT * FROM ".TBL_PREFIX."users WHERE u_username = '$username' AND u_password = '".asf_hash($password)."' LIMIT 1") or die(print_link_error()); $row = $query->fetchAll(); $num_rows = $query->rowCount(); if($num_rows == 1) { if($row[0]['u_confirmed'] == 1 && $row[0]['u_banned'] == 0) { setcookie("uid", "1", time()+3600); if (setcookie('uid', "1", time()+3600) === false) { echo 'Failed To Set Cookie'; } else { echo 1; } } elseif($row[0]['u_banned'] == 1) { $error = 'You Have Been Banned From This Forum'; } else { $error = 'You Need To Activate Your Account'; } } else { if(!$error) { echo $lang->incorrect_login_details; } } } else { echo $error; } } ob_flush(); ?>
  14. when the processing of the login is complete it passes a value to a javascript file which then redirects to the page they were last on, or the index page if no redirect session exists. Im trying to upload the files to the server to see if this is a localhost thing but filezilla always breaks down so its taking a while lol. also does anyone know why i might have phpbb3 cookies on my localhost site? i do have a setup of phpbb in another folder but not this one.
  15. i have tried: if (setcookie('uid', $row[0]['u_uid'], time() + $session_length) == false) { echo 'Setcookie failed'; } else { echo 'success'; } and it echos success, but no cookie is added. Could this be something to do with WAMP server?
  16. when a user logs in the cookie isnt being set. am i doing it wrong? if(empty($error)) { $query = $link->query("SELECT * FROM ".TBL_PREFIX."users WHERE u_username = '$username' AND u_password = '".asf_hash($password)."'") or die(print_link_error()); $row = $query->fetchAll(); $num_rows = $query->rowCount(); if($num_rows == 1) { if($row[0]['u_confirmed'] == 1) { setcookie('uid', $row[0]['u_uid'], time() + $session_length); // this cookie isnt being set echo 1; } else { $error = 'You Need To Activate Your Account'; } } else { if(!$error) { echo $lang->incorrect_login_details; } } } im doing a print_r on all cookies and it doesnt appear in the list. $session_length is set at 99999999
  17. im joining a table onto the query to show how many likes a post has but it is displaying the post x amount of times depending on how many likes there are. I think its something to do with the way im joining onto the pid of the post table: $post_query = $link->query("SELECT p.*, u.*, l.* FROM ".TBL_PREFIX."posts as p JOIN ".TBL_PREFIX."users as u ON (u.u_username = p.p_poster) LEFT JOIN ".TBL_PREFIX."post_likes as l ON (l.l_pid = p.p_pid) WHERE p_tid = '$tid' ORDER BY p.p_time_posted ASC")or die(print_link_error()); $likes = array(); while($post_info = $post_query->fetch()) { // SOF LIKE LIST if (count($post_info['l_pid']) >= 1) { $likes[] = $post_info['l_username']; $amount_likes = count($likes); $slice = array_slice($likes, 0, 4, true); $remain = array_slice($likes, 4, $amount_likes, true); $remain_num = count($remain); $like_list = ''; if($amount_likes > 4) { for($i=0; $i<=3; $i++) { $like_list .= profile_link($likes[$i]).', '; } $like_list .= 'and '.$remain_num.' other like this'; } elseif($amount_likes <= 3) { for($i=0; $i<3; $i++) { $like_list .= profile_link($likes[$i]).' '; } $like_list .= 'like this'; } } the likes are stored in their own database table seperate from the posts any advice?
  18. Thanks for the info. This worked fine: $insert = $link->prepare("INSERT INTO ".TBL_PREFIX."posts (p_fid, p_tid, p_poster, p_name, p_content, p_time_posted) VALUES ('$forum_id', '$topic_id', '$user_name', '$subject', '$message', '".$config['time_now']."') ") or die(print_link_error()); $insert->execute(); $lid = $link->lastInsertId();
  19. im using PDO not mysql
  20. im trying to get the last inserted id from the database so when the user makes a post i can reload the page and center it on their post via the url hash(http://website/posts#221) however everytime i try this i get a result of 0. here is my code: $link->query("INSERT INTO ".TBL_PREFIX."posts (p_fid, p_tid, p_poster, p_name, p_content, p_time_posted) VALUES ('$forum_id', '$topic_id', '$user_name', '$subject', '$message', '".$config['time_now']."') ") or die(print_link_error()); echo $link->lastInsertId(); its just a simple insert query(which works as expected) but the lastInsertId function returns 0. where am i going wrong?
  21. a typo when posting the topic
  22. im trying to display the contents of a file within a div. plain html is fine but i need this file to have php variables within it. eg: the file tos.php <?php $foo = 'bar'; ?> <p></php echo $foo; ?></p> the code to display it: file_get_contents(tos.php); but this func only displays the html and doesnt print the contents of anything between php tags. any ideas?
  23. http://articles.sitepoint.com/article/hierarchical-data-database is a good read. the second method(preorder tree traversal) doesnt use recursion.
  24. still struggling with this. this is the revised code but still it only shows 1 of the subforums: $fids = $pids = $children = $list = array(); $query = $link->query("SELECT * FROM ".TBL_PREFIX."forums ORDER BY f_lid ASC"); $row = $query->fetchAll(); foreach($row as $key => $value) { $forum_id = $row[$key]['f_fid']; if($row[$key]['f_pid'] == 0) { $template->is_cat = true; $template->f_cat_name = $row[$key]['f_name']; $template->c_url_name = create_url($template->f_cat_name); } else { for($i=0; $i<count($row); $i++) { $fids[] = $row[$i]['f_fid']; // gather all of the forum ids $pids[] = $row[$i]['f_pid']; // gather all of the parent ids } if($row[$key]['f_type'] == 'c') { $template->is_child = true; // forum is a child so dont display it on main list } else { $template->is_child = false; // forum can be displayed on main list } // if the forum id is in the list of parent ids if(in_array($forum_id, $pids)) { $template->has_child = true; // this forum has children $children[$forum_id] = $row[$key]['f_name']; $list[] = $children[$forum_id]['name']; // echo the list of children for this forum $template->child_name = implode(' | ', $list); } else { // forum doesnt have children $template->has_child = false; } var_dump($list); can anyone help?
  25. ok ill try to make it clearer. explaining things isnt a strong point of mine. heres the annotated code. $link just refers to the database connection. $template adds the variables to a file with the html code in it. basically just echos the variables assigned to it. $query = $link->query("SELECT * FROM ".TBL_PREFIX."forums ORDER BY f_lid ASC"); // select every forum and order by the left id $row = $query->fetchAll(); // this is a PDO query $fids = $pids = $children = $child_ids = array(); foreach($row as $key => $value) { $forum_id = $row[$key]['f_fid']; for($i=0; $i<count($row); $i++) { $fids[] = $row[$i]['f_fid']; // gather all of the forum ids $pids[] = $row[$i]['f_pid']; // gather all of the parent ids } if($row[$key]['f_type'] == 'c') { $template->is_child = true; // forum is a child so dont display it on main list } else { $template->is_child = false; // forum can be displayed on main list } // if the forum id is in the list of parent ids if(in_array($row[$key]['f_fid'], $pids)) { $template->has_child = true; // this forum has children // populate child ids array with the forum ids of this forums children $child_ids[] = $row[$forum_id]['f_fid']; for($i=0; $i<count($child_ids); $i++) { // get the child forum names from the ids above $children[] = $row[$child_ids[$i]]['f_name']; } // echo the list of children for this forum $template->child_name = implode(' | ', $children); } else { // forum doesnt have children $template->has_child = false; } as you can see i can now display which forum has children and display the name of the child. my only problem now is that the $children array only gets populated with one value when 2 exist.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.