Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by arbitter

  1. ... just kidding! I'm aware of section 10 of the rules (unfortunately), so I'd like to not remove my account but make it somewhat more anonymous. First off, some bonus points for me for not using a real name as username. Unfortunately however, I did post my user details in a post (5 years ago!): http://forums.phpfreaks.com/topic/197099-all-belgian-unite/?p=1037742 This isn't really that important information, not really anything someone couldn't find out if it wasn't there, but nevertheless it would be nice if this could somehow be changed. Is there a way to edit, or ideally remove my comment in that thread? Kind regards, arbitter
  2. My table 'guess': id (int) | user_id (int) | logo_id (int) | guess (varchar) | guess_count (int) | guessed (int) id is unique, unique relation between user_id & logo_id When a user visits the site, a user is made in a 'users' table (so there's a new user_id). The user can then play with this user_id. When the user logs in, the current scores/guesses/... should be transferred to the user_id of the logged in-account. How do I get this done? To clarify: there are two user_id's in play - the user_id from the registered (logged in) user, and the user_id from the session (not logged in). I will refer to these as user_id_login and user_id_session. So, if a row of user_id_login has a guessed = 1 (this int is 0/1. 1 means guessed, 0 means not guessed) for certain logo_id, a row with that logo_id and the user_id_session should be completely ignored. If a row of user_id_login = 0 for certain logo_id exists, the values 'guess_count', 'guessed' and 'guess' of the row with the same logo_id and with user_id_session should be added (for guess_count) or stored (guessed & guess). If a row with user_id_session for certain logo_id exists and hasn't been checked in one of the previous, the user_id of this should be changed from user_id_session to user_id_login. Now how I currently would think about doing this, is check the table for the user_id_login where guessed = 1. For each result, then do a query to check if there is a user_id_session with that logo_id and remove them. Next, check the table for the user_id_login with guessed = 0. For each result, then check if there is a user_id_session with the same logo_id and add those values, then delete that row. And at last, a query to check all the leftover user_id_session and change the id to user_id_login. As you can see, this is dozens of query's, so there must be a better way
  3. Well both actually... I'd like the uploader to be able to handle 100+ images of regular photo-camera quality. Theres no need for images larger than the 8MB, so the upload_max_filesize/post_max_size doesn't need to be altered.
  4. They are both already floated left, and there is 'clear:both' in the footer already...
  5. This doesn't work... The height of the browser screen, and thus the height that the #content needs to be always differs...
  6. Hi there. I need a multi-file uploader for my site. I have been researching my head off, trying plugns with flash (eg. uploadify) and jquery-html5 uploaders (Blueimp), but I just can't get it all to work. So I thought I'd make my own, simply with PHP, no fancy stuff. So I do it, and it works fine, except it has a maximum of a total of 8MB of pictures and maximum 20 pictures. I know some of these can be changed (or at least I think so), but then again I presume there are possibilities of time-out errors and even not enough memory allocation to the script? So the only solution to my problem would be, I guess, using ajax with jquery or so. Now I don't need anything fancy, and it doesn't need to work in all browsers. All I need is a simple way to upload files and run a script on those files. Since I have never actively used jquery, and certainly not the ajax api, I have no clue on how to get started. Could someone give a simple example?
  7. Hi there. The title might be somewhat confusing, but here's the explanation. My site consists of the following layout: Header Left sidebar Main content Footer This I've got working nicely with the following code: HTML: <html> <body> <div id='total'> <div id='wrap'> <div id='banner'></div> <div id='main'> <div id='sidebar'> <div class='menuoption'></div> <div class='menuoption'></div> <div class='menuoption'></div> <div id='leftFill'></div> </div> <div id='content'>Variable content over here</div> </div> </div> <div id='footer'></div> </div> </body> </html> And the css: html{height:100%;} body{ margin:0 0 0 0; height:100%; } #total{ width:1024px; margin:auto; height:100%; } #wrap{ min-height:100%; } #main{ overflow:auto; padding-bottom:28px; /* Height of footer */ } #header{ height:100px; background-color:purple; } #sidebar{ width:149px; float:left; height:100%; } #content{ width:794px; float:left; min-height:600px; } #footer{ height:28px; margin-top: -28px; clear:both; position:relative; } So what's happening: the footer should always be at the bottom of the page, as long as the content inside #content is not larger than the height of the page. Otherwise, the footer goes to the foot of the document. Now the trouble is; I would like the #leftFill to have a border on the right side. But this bordershoul go from the last 'menuoption' down, up to the footer, wherever the footer is. How is this done?
  8. Well currently I unset the session on logout as well, so that wont be a problem. I'll give it a try, thanks!
  9. That does indeed seem to change! Is it because I have session_start() on the top of all my pages? Or how do I prevent this?
  10. Hi there I am having some issues with my site login. When a user logs in, it loads the page as a logged in user. But often when you click on a link inside the page, for some reason the user is logged out. After logging in again it sometimes does work, it's weird.. Also, even if you keep the page loaded in the browser yet you don't interact with it for a couple of minutes, and you click something, you're logged out again.. Here's my code, this is on the top of the page. When a user logs in, the $_POST['login'] is set. <?php session_start(); setlocale(LC_ALL, 'nl_NL'); require_once('mysql_connect.inc.php'); date_default_timezone_set('Europe/Brussels'); $verbinding = mysql_connect(MYSQL_SERVER, MYSQL_GEBRUIKERSNAAM, MYSQL_WACHTWOORD) or die("Connection failed: " . mysql_error()); function CleanMyDirtyData($dirtydata){ return mysql_real_escape_string(htmlentities($dirtydata, ENT_QUOTES,'UTF-8')); } if(isset($_COOKIE['LoginCookie'])){ $hash = mysql_real_escape_string($_COOKIE['LoginCookie']); mysql_select_db('db'); $sql = "SELECT * FROM leden WHERE cookie_hash = '".$hash."'"; if($result = mysql_query($sql)){ $row = mysql_fetch_array($result); if(empty($row)){ setcookie('LoginCookie','',time()-3600); } if(mysql_num_rows($result) == 1){ $_SESSION['loggedin'] = true;//this is the parameter throughout the site that determines wether to show logged in data or not-logged in data. //extra parameters for identification $_SESSION['loggedinnick'] = $row['nick']; $_SESSION['loggedinvoornaam'] = $row['voornaam']; $_SESSION['loggedinachternaam'] = $row['achternaam']; $_SESSION['loggedinid'] = $row['id']; $_SESSION['loggedintype'] = $row['type']; } } } if(isset($_POST['login'])){ if(empty($_POST['username']) || empty($_POST['wachtwoord'])){ $_SESSION['melding'] = "You need to fill in both fields."; header('Location: index.php'); exit(); } $username = CleanMyDirtyData($_POST['username']); $wachtwoord = sha1(CleanMyDirtyData($_POST['wachtwoord'])); mysql_select_db('db'); $sqlmail = mysql_query("SELECT * FROM leden WHERE email='$username' AND wachtwoord = '$wachtwoord'"); $sqlnaam = mysql_query("SELECT * FROM leden WHERE nick='$username' AND wachtwoord = '$wachtwoord'"); if(mysql_num_rows($sqlmail) == 1 || mysql_num_rows($sqlnaam) == 1){ if(mysql_num_rows($sqlmail) == 1){ $row = mysql_fetch_array($sqlmail); }else{ $row = mysql_fetch_array($sqlnaam); } if(isset($_POST['remember'])){ $hash = sha1($whatev);//combination of 3 parameters; time, salt, and something else. setcookie('LoginCookie',$hash,time()+30000000); mysql_query("UPDATE leden SET cookie_hash='" . $hash . "' WHERE id='" . $row['id'] . "'")or die(mysql_error()); } $_SESSION['loggedin'] = true; $_SESSION['loggedinnick'] = $row['nick']; $_SESSION['loggedinvoornaam'] = $row['voornaam']; $_SESSION['loggedinachternaam'] = $row['achternaam']; $_SESSION['loggedinid'] = $row['id']; $_SESSION['loggedintype'] = $row['type']; $_SESSION['melding'] = "You have successfully logged in."; header('Location: index.php'); exit(); }else{ $_SESSION['melding'] = "Wrong combination."; header('Location: index.php'); exit(); } } ?>
  11. Okay I found the regex: preg_replace("/[^a-zA-Z0-9]+/", "", $string); Then a strtolower() and I think I'll be set Thanks guy!
  12. Well doing this would only prevent the '@' from being formed, but all other special characters could be formed? What is the easiest way to do that? Is there a php function for it or do I have to use regex or..?
  13. Hi there I allow users to make new albums. For each album they give a full display name, eg "New Years Eve 2012 at Persons' place", and a shorter display eg "New Years Eve 2012". The first string should be stored in a db and should be shown exactly as it is, so for that string I have: <?php //$fullname gets stored in the db $fullname = myql_real_escape_string(htmlentities($fullname)); //when pulled from the db, it is only echoed, nothing else: echo $fullname; ?> Now I presume it is safe so far. Now is the 'tricky' part. Currently this is what I do to the short name: <?php //$shortname gets stored in the database $shortname = mysql_real_escape_string(urlncode(str_replace(' ','',strtolower($shortname)))); ?> Now from this shortname, before the mysql_real_escape_string(), it makes a directory with that name. Now what happens is, if there are special charcters like '@', the '@' changes into '%40'. So the directory would be eg 'fun%40myplace'. The directories get made without a problem, but for some reason my uploader won't upload to this directory. It isn't the uploaders fault because in folders without these special characters there is no problem with uploading. Any ideas on how to fix this, or what the best method is to clean a string for url/directory names?
  14. Oh my, removing the heights does indeed make the div stretch along with it's content! I removed both div heights and now the left one is smaller but I like it like that! Only have a minor issue that the right div has a bottom-margin of 10px, but it doesn't show that, it just sticks to the end of the content!
  15. Basically I would like a page consisting of two columns. One with a fixed width on the left, ALWAYS being exact 100% of the page (or more, if the right div extends this height), and a right div, also ALWAYS being at least 100% unless ofcourse the content is longer. Currently the divs are always a little larger than the 100%, due to some padding and margin, is there a way to change this without adding another div? Here's my code: #left{ width: 200px; height:100%; float:left; padding:10px 10px 10px 10px; margin:10px 10px 10px 10px; background-color:white; } #right{ height:100%; min-height:100%; position:absolute; left:240px; margin-top:10px; margin-right:10px; background-color:white; padding: 10px; min-height:600px; }
  16. Darnit My bad, works like a charm now! Any idea on the uploadify-part?
  17. And another problem is: when you insert ' and " in the names ($_POST['naam'] and $_POST['urlnaam']), the values do get inserted into the 'albums' table, but there is no table made... Is there a function that strips things so they can be a table name? So I need something that cleans ANYTHING to something that can safely be used in a link and as a table name...
  18. The script seems to work good, but something rather weird is happening. This does work: Resize_Image($fullname,$fullname,600,600,'fotos/'.$urlnaam.'/large/','fotos/'.$urlnaam.'/large/'); but this does not work: Resize_Image($fullname,$fullname,120,120,'fotos/'.$urlnaam.'/large/','fotos/'.$urlnaam.'/thumbs/'); even though the thumbs folder does exist...
  19. Hi there. I'm making an album-upload-thingy. So far I've written the script that uploads an image, changes it's name, makes some directorys, makes a table, and inserts the image name in the table. Here's the script: <?php if(isset($_POST['addAlbum'])){ if(empty($_POST['naam']) || empty($_POST['urlnaam'])){ $_SESSION['melding'] = 'U hebt niet alle verplichte velden ingevuld!'; header('Location: ward/fotos'); exit(); } $naam = mysql_real_escape_string(htmlentities($_POST['naam'])); $urlnaam = mysql_real_escape_string(urlencode(str_replace(' ','',strtolower($_POST['urlnaam'])))); mysql_select_db('dyfemtaw_fotos'); $result = mysql_query("SELECT * FROM albums WHERE naam='$naam'")or die('result:' .mysql_error()); $result2 = mysql_query("SELECT * FROM albums WHERE urlnaam='$urlnaam'")or die('result2:'.mysql_error()); if(mysql_num_rows($result)==0 && mysql_num_rows($result2)==0){ mysql_select_db('dyfemtaw_fotos'); mysql_query("INSERT INTO albums (naam,urlnaam) VALUES ('$naam','$urlnaam')")or die('insert' .mysql_error()); mysql_query("CREATE TABLE $urlnaam( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `photoid` BIGINT NOT NULL , `type` VARCHAR( 5 ) NOT NULL , `description` VARCHAR( 200 ) NOT NULL)")or die('create: '.mysql_error()); mkdir('fotos/'.$urlnaam); mkdir('fotos/'.$urlnaam.'/large'); mkdir('fotos/'.$urlnaam.'/thumbs'); //getting the extension of the file $filename = strtolower($_FILES['bestand']['name']); $exts = explode(".", $filename); $n = count($exts)-1; $exts = '.' . $exts[$n]; $newname = rand(111111,999999) . time(); $targetpath = 'fotos/' . $urlnaam . '/' . $newname . $exts; mysql_query("INSERT INTO $urlnaam (photoid,type) VALUES ('$newname','$exts')")or die(mysql_error()); if(move_uploaded_file($_FILES['bestand']['tmp_name'], $targetpath)) { $_SESSION['melding'] = 'Het bestand ' . basename( $_FILES['bestand']['name']). " is geüpload."; header('Location: ward/fotos'); exit(); }else{ $_SESSION['melding'] = "Er is een probleem opgetreden."; header('Loaction: ward/fotos'); exit(); } }else{ $_SESSION['melding'] = 'Deze naam is al gekozen.'; header('Location: ward/fotos'); exit(); } } ?> So what it does: Check if the name of the database exists (name of the database is user inputted) if not -> insert in the 'albums' table that album and it's name. From the urlname, make a new table make directorys for the large (600px) files and the thumbnail (120px) files get the extension of the file make name of file with a random number and time() insert the file name and the extension in the newly made table with the urlname of the album move the file So what I still need to do is resize the image twice; the large one (600px) should be stored in the album/large directory, the small one should be stored in the album/thumbs directory. And then, I need to find a way to implement this to Uploadify, so I can allow multi-uploads Also, I'm not quite sure my script is safe; I mean, it can make the database and still fail to upload the image, which ofcourse isn't good is it...
  20. It seems to work! I only did the checkdate() though, no jQuery stuff. And it's a new table, so no problems! The dates are so confusing, in america it's mostly mm/dd/yyyy, where I live it's dd/mm/yyyy, and now yyyy/mm/dd It wasn't that much adjusting from the script I had, luckily! Thanks a bunch!
  21. I only store the date, it's for a general calendar.
  22. Okay just to be sure of what I need to do; I have input fields, one for day, one for month, and one for year. What should I do to the fields so I can store it in the datetime field?
  23. well it's varchar, I presume it should be datetime in order for it to work?
  24. Hi there In my database I have a date in the form 'dd/mm/yyyy'. Now, I would like to sort my queries by date... Is there a way to do that? Or is the only option to separate the day/month/year in the database? Thanks in advance.
  25. So this is an easy way of inserting a php var inside some html text? Good to know!
  • 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.