Jump to content

radar

Members
  • Posts

    645
  • Joined

  • Last visited

Everything posted by radar

  1. well first off you'd need to decide if you are using cookies or sessions.. and then alter this code to suite.. $username = $_SESSION['inuser']; if ($username == "") { $username == "Guest" include ('login.php'); } And there you go...
  2. SELECT username FROM users,monkies WHERE test = 1 I think this would be the correct syntax for doing this... 
  3. If i have 2 sites on different servers or with different extensions -- I generally don't set the domain...  This way there is no chance of coding error... Another option you could have is to just add another cookie for the other domain by setting it at login, deleting it at logout, etc.. and basically just doing the same thing twice for every instance of calling the cookie...  Either way -- its your choice.. 
  4. OOP Templating engines...  try using one called FastTemplate -- but if you get that one you want the one that was written for php3.. you have to go in and rename one of the functions as they try to recall it twice.. but ya just rename the second one by putting a 1 at the end...  Another option would be to use Smarty.. http://www.php.net/smarty I think that is the url to smarty.. its a templating engine we use at work.. only problem is youve got to get it on your server..  FastTemplate is easier to impliment as it is only 1 file..  From that you can do just about anything you want...
  5. Seeing as though Geocities is a free hosting company they do not actually offer much technical support if any on their hosting or free services..  Now the fact that you are able to run php on Geocities at all is surprising...  Personally I'd find a new host, preferrably one that's not free and get yourself a .com..  Much less errors except for those in your own coding... The problem with Geocities is that their servers are all co-located.. which basically means a shit ton of people are on their servers instead of having just one.. now yes this is true with Regular Hosts too.. but here is the difference.. Geocities has say 2 servers and each server is on the same ISDN connection (Geocities really isnt on a great connection like a real host should be).. So say each server has 12,000 sites on it because by nature a geocities page generally isnt going to have more than like 4-6 pages on it.. people just dont spend the time to do a nice site when hosting on geocities cause its geocities... So 12,000 people are trying to view their site at the exact same time on a puny ISDN connection..  At least 2000 of those people are going to get a cannot load page error..  and 3000 at least are going to have errors with their scripting if any special scripting was used because of the way Geocities servers are put together..  Final Thought:   Though you may be just learning php and mysql it is in my direct kindness I offer you my next statements.  Geocities is a host for those who are toying around with HTML.  It is definately not a host that a seasons web developer should be using, nor someone who would like to learn or just learn more about a dynamic language such as PHP.  In your quest for knowledge. if you remember only one thing I ever say to you make sure it is this next statement.  Geocities is the devil.  To get a truely flawless execution of your pages you would be better of paying for a domain or at the very least finding someone who has a domain and a lot of space to allocate say 10MB to you.  Peace Love and Haribo Frogs to everybody...  Take care of yourself and each other.
  6. [quote author=AndyB link=topic=105879.msg423132#msg423132 date=1156732203] Simplify your life. If you are the only person able to upload files and you want to restrict them to a particular type, then use FTP or your File Manager to move them to your site.  You'll have that working in a minute - must faster then implementing some password protected file uploader script. [/quote] I wish I could simplify my life..  Though with the project I am working on it's impossible to simplify it any more than I already have without using pre-made code...  My tutorial site I'm coding everything -- forums included..  It's proving to be a pain in the ass but oh well thats okay...  Working on the admin console right now --- plus i'm using a template engine that I ended up re-writing to make work and so yeah..  simplify my life seems impossible at this point.. though for this guy -- seems like a valid idea...
  7. Here is a sample upload script...   [CODE] <table width = "500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form action="multiple_upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td><strong>Multiple Files Upload</strong></td> </tr> <tr> <td>Select File: <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td>Select File: <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td>Select File: <input name="ufile[]" type="file" id="ufile[]" size="50" /></td> </tr> <tr> <td align="center"><input type="submit" name="Submit" value="Upload" /></td> </tr> </table> </td> </form> </tr> </table> [/CODE] This is the form.. and next will be the processing part of it... [CODE] <?php echo $HTTP_POST_FILES['ufile']['name'][0]; echo "<br>"; echo $HTTP_POST_FILES['ufile']['name'][1]; echo "<br>"; echo $HTTP_POST_FILES['ufile']['name'][2]; echo "<br>"; ?> [/CODE] This is a simple way to do it...  I haven't actually tested this code yet as I got it before I actually needed it..  You may have to throw some mysql queries into the second file to make the file location and name etc be entered into a database.. then on the output you would query the database again requesting the url of each download and parsing them out using something like this echo "<a href=\"'$file'\">Download 1</a>"; and it's really that simple.. as far as the login there are tons of login script examples which will also help you get familiar with php and mysql -- in fact in the tutorials section on this site i believe there is a login example.. if you cant find it let me know and i'll post one...
  8. It probably is -- though I rarely use die -- except for when I am doing a necessary exit such as if i cant connect to the database then die("output an error"); in which case this could work in this statement -- just take out the echo and replace the string you are echoing in the die clause... so like die ("a lot of html goes here"); but exit would produce the same outcome either way..  I myself have never had a problem with my exit clause working or something slipping past it...
  9. I suppose you could use that too..  but exit(); does the same thing...
  10. I thought he could just do something like this cause i found 2 differences in the links he provided... #1 $link = ereg_replace('.dbp\\', '\\', $link); $link = ereg_replace('_Site', '', $link); I'd think that using those 2 lines of code would format the links to the way the bottom one looks.. i may be wrong but thats what i'd figure..
  11. Perhaps write another CSS file that overwrites the main css? that'd be the way i'd do it...
  12. PHPBB has two functions built in that helps a lot..  #1 Backup Database #2 Restore Database Run function 1.. move hosts install phpbb  log into your admin control panel and run function 2 and you should be set...
  13. time() - 60 * 5 also you might have to put exit(); after the end of the echo when the session is destroyed to make it so it stops right there....
  14. [code][code][code][/code]See thats where he's having the problem his $_SESSION['username'] is obviously the username and not a timestamp created from time().... so if you switch it back to the $_SESSION['birth'] and declare it by doing session_register('birth'); $_SESSION['birth'] = time(); you would then be able to use the original code of: [/CODE] <?php session_start(); if($_SESSION['birth']+(60*60)<time()){ session_destroy(); die("Please log in again"); }else{ $_SESSION['birth']=time(); } ?> [/CODE] I do it like this.. [CODE] <?php // all of this at the beginning of code after a database connection has been made. $sql = "SELECT * FROM users WHERE alias = '$username'"; $sql = mysql_query($sql); $row = mysql_fetch_assoc($sql); if ($row['last_activity'] <= time()-3600) { $query = mysql_query("UPDATE users SET logged_in = '0' WHERE alias='$ses_user'"); session_unset(); session_destroy(); echo "You have been logged out due to inactivity. <br /><a href='modules.php?name=cpanel'>Log back in</a> - <a href='index.php'>Go to index</a>"; } else { $query = mysql_query("UPDATE users SET last_activity = time() WHERE alias='$ses_user'"); } ?> [/CODE] what that code should do is first set up an array of everything in the users table for the user -- that way you can use it anywhere throughout the page.. or if your using a templating engine anywhere throughout the site... Then it will check to see if the last_activity is equal to or less than current time minus 3600 seconds (1 hour)  If it is -- then delete the session -- if it isnt -- update the last_activity to the current time to refresh the limit..
  15. AdRock -- this tutorial only stresses how to use session which is really easy...  It doesn't go into how if there is way to set the expiry of a session or anything that my post has questioned....
  16. Okay so I will eventually have 2 login systems on my site...  The first one I am writing should expire in 3600 seconds from the time it was written or when the browser is closed -- whichever is first.... this is for the admin console... Then the one for the members to log in..  Will be 1 of 2 choices...  When the browser closes it's gone..  or if they click Remember Me its for as long as I can make it... So what would you say I should make these?  Cookies or Sessions..  and whichever one you think is better -- what would the basic syntax be to set the expiry time...  I thought it was something like $expiry = time() + 3600; setcookie("logged_in_admin", $username, $expiry); or something like that..  and for sessions i have no clue...  Well let me know what yall think would be the best option and possibly what syntax I would use...
  17. Where I am using the classes and the templating engine -- The particular engine that I am using won't allow any php within the html... which is why I had the problem..  Not sure why you would have had the problem. // Radar
  18. I actually did get it fixed..  it has nothing to do with the php_self -- the reason why i had to do that is because the templateing engine requires total seperation of php and html.. so i use the php_self to input the page.. but then i figured why not just change it to index.php since thats what it is always going to be.... I ended up having to almost totally rewrite the class for the templating engine...  so yeah whatever its all good it works now.. thx..
  19. Since you are new I wouldn't even think of starting your own forum set.  Just use a pre-built such as phpbb2.. Work Wonders for you....
  20. I did some testing with this and it's not just this form it's all forms.. it really sucks!  someone please help..
  21. Okay so I did finally get my template system working but now I am having a problem with my login stuff.. and i cant figure it out.. been working on it for like 20 mins.. Here is my Index.php [CODE] <?php include('../includes/template.php'); include('../includes/db.php'); include('../includes/functions.php'); $db = new sql_db(localhost, root, zoindok, cesite, false); $tpl = new FastTemplate('../templates/cesite'); $username = "Guest"; switch($act) { case '' : if (!$submit) { if ($username == "Guest") { $tpl->define(array(login => "admin/login.tpl")); $tpl->assign(error, 'note: you must first login in order to view the admin console'); $tpl->assign(php_self, $PHP_SELF); $tpl->assign(username, ''); $tpl->assign(password, ''); $tpl->parse(MAIN, "login"); $tpl->FastPrint(MAIN); } else { echo "logged in"; } } else { // this is where I'm having trouble... $name = $_POST['login_username']; echo $name; } break; } ?> [/CODE] and here is my login.tpl [CODE] <style type="text/css"> <!-- .style1 { font-family: Arial, Helvetica, sans-serif; font-size: 12px; } .style3 {font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #FF0000; } --> </style> <div align="center">   <p><img src="../templates/cesite/images/judo9.gif" width="150" height="150"><br>     <br>     <span class="style3">{error}</span></p>   <form name="login" method="post" action="php_self">     <table width="236" border="0" cellspacing="0" cellpadding="0">       <tr>         <td width="73"><div align="right"><span class="style1">Username &nbsp;</span></div></td>         <td width="163"><label>           <input name="login_username" type="text" value="username">         </label></td>       </tr>       <tr>         <td class="style1"><div align="right">Password&nbsp;&nbsp;</div></td>         <td><input name="login_password" type="password" value="password"></td>       </tr>       <tr>         <td class="style1">&nbsp;</td>         <td> &nbsp;</td>       </tr>       <tr>         <td class="style1">&nbsp;</td>         <td><label>           <input name="submit" type="submit" id="submit" value="Login">         </label></td>       </tr>     </table>   </form>   <p>&nbsp;</p> </div> [/CODE] As you can tell just a simple login for my admin console..  I need to be able to retrieve my strings from login_username and login_password but i cant get them.. When i use just $login_username it returns blank.  Same with $_REQUEST['login_username']; and $_POST['login_username']; so any help on this would be appreciated.. i cant figure it out..
  22. radar

    Classes

    Okay well I figured this out with the help of PHP Builder...  So I am posting the way I am doing it with my class and all that good stuff for future reference for anyone else [CODE] <?php include('../includes/template.php'); include('../includes/db.php'); include('../includes/functions.php'); $db = new sql_db(host, user, pass, db, false); $tpl = new Template('../templates/cesite'); $username = "Guest"; switch($act) { case '' : if (!$submit) { if ($username == "Guest") { $tpl->define(array(login => "admin/login.tpl"));                                       // assigning error to blank just gets rid of {error} on the site $tpl->assign(error, '');                                       // this is for the form $tpl->assign(php_self, $PHP_SELF); $tpl->parse(MAIN, "login"); $tpl->PPrint(MAIN); } else { echo "logged in"; } } else {                           // this is where we process the submitted form. echo "lets get this workin right"; } break; } ?> [/CODE]
  23. radar

    Classes

    Anyone know anything about this? If you need a visual you can go to http://www.cetutorials.com/cesite/admin/test.php The whole template is main.tpl -- then the boxes on the left side with the links (the navigation) should be in either left_root.tpl, left_site.tpl or left_forum.tpl..  Then the box in the center should be in body.tpl..  and all these files should be brought together by pulling everything and putting it in the right place within the index.php...
  24. ahh see ive never used those -- thought you had written them..  on this one i'll have to step aside and let someone else who's used the functions step in and help.. sorry i was of no use to you..
  25. Though me personally -- since the $logged_in has nothing to do with the database or the session i would totally remove that and just check to see if the session variable is written.. if it is then redirect -- if not show the login form..  that'd be the easiest way to do it..  otherwise it may never work...
×
×
  • 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.