Jump to content

jj20051

Members
  • Posts

    201
  • Joined

  • Last visited

    Never

Everything posted by jj20051

  1. Could you comment your code any better? I had a hard time figuring out what your trying to get it to do... It looks like your trying to get it to pull a random image out of the database and display it along with a next button? If thats the case let me know.
  2. $current_path_array = explode('/', $current_path); $current_path_array = array_filter($current_path_array); echo '/'; foreach($current_path_array as $variable){ $cp = $cp.'/'.$variable; $variable = stripslashes($variable); echo '<a href="filemanager.php?open='.$cp.'">'.$variable.'</a>/'; } Figured it out using an array, a for each and a static variable. Thanks for the help
  3. Here is some example code: <?php $img = $_GET['img']; if($img != NULL){ // Mysql query } ?>
  4. You would add the first part ($_SESSION['username'] = $_POST['username'] after // if login is ok then we add a cookie and the second part goes on the pages you want to protect.
  5. What is your database structure? Try this: $set = mysql_query("UPDATE comments SET matserviewed='yes' WHERE threadid='$t' AND matserviewed='no' AND originalpostby='$username'") or die(mysql_error());
  6. There are 2 pieces: 1 ~ create a session variable and 2 ~ check for a session variable. So as an example when you've checked the user's username/password to see if they are correct set the username into a session: $_SESSION['username'] = $username; Then on the pages you want to prevent users who aren't logged in you'd use the code: $username = $_SESSION['username']; if($username != NULL){ // This is where your protected page's code belongs } else { // If the user isn't logged in take them to the login page instead header("Location: login.php"); }
  7. Well that sort of solves 1/2 my problem, but I need two things: The name of the folder and the path to the folder. So with that I can separate the name of the folder... any ideas for the path?
  8. Ok so I'm coding up a file tree for a script and I've got the system setup so that when a user clicks on a folder it adds that folder to the path. The path is stored in a variable, but I'd like to allow the user to be able to go down multiple directories at once. To do this I'm going to seperate each folder name in the path and link to it so as an example: $path = './home/public_html/folder1/folder2'; how can I separate each of those so I can make a link to that folder so that: /home goes to $path = './home/'; /public_html goes to $path = './home/public_html'; etc... --- Basically just seperate the slashes into an array and seperate each of them off based on how far along it is but I don't know how to do that...
  9. Thank you Adam... that did exactly what I was looking for it to do It appears that linux sends back the \n even though it looks like a space...
  10. Its outputting the following in html: <br>t1.sh t2.sh t3.sh test.sh Which means it thinks there is only one row in the array or something?
  11. I have a script that connects to another server to pull data... When it pulls the data it comes back in the following format: t1.sh t2.sh t3.sh test.sh However using the code bellow does not separate it like it should, it should put one file per line but I think I did something wrong... // Pulls the output from the server: $var_test = $ssh->exec('./test.sh'); // Explodes it... $var_test2 = explode(" ", $var_test); // Echos it one per line... foreach ($var_test2 as $variable) { echo '<br>'.$variable; }
  12. Thank you, I misunderstood exactly how it worked... That fixed it thanks
  13. Alright so I have some code for pagination... the problem is on the middle pages it will display double the number of results... (IE if its supposed to display 5, it displays 10) // Number of messages per page: $user_message_number = 5; $page = $_GET['page']; if($page <= 1){ $low = 0; $high = $user_message_number; } else { $low = ($page - 1) * $user_message_number; $high = $page * $user_message_number; } $messages = mysql_query("SELECT * FROM messages WHERE recipient='$user_id' ORDER BY id DESC LIMIT $low, $high") or die(mysql_error()); while($pull_messages = mysql_fetch_array($messages)) { // Displays content } That's all of the code that would directly effect the outcome... Any thoughts/comments/suggestions are greatly appreciated.
  14. I was wondering how you would go about separating words with commas between them into an array. In this case I want users to be able to message multiple other users by entering their names in the following format: user1, user2, user3, user4 and then have php separate those into an array so I can then run them through a foreach(); so they can be sent to the correct users... Any help or functions I should look into would be great... code not necessary, just point me in the right direction thanks!
  15. I'm attempting to create a file manager in php for a "free webhosting company," however before I begin I was wondering what you guys would recommend as far as security and permissions settings. I would like to make sure that no one user can edit another user's files (even with their own scripts) and I'd like to know exactly what I'll need to do to make sure only my script can access all of the files in the user directories. As an example: I want to make sure my script can edit files on user accounts only if they are logged in... I'm not exactly sure how to prevent users from accessing files that aren't theirs with their own php scripts. I was looking at: http://forums.mydigitallife.info/threads/23790-Apache-Restrict-Folder-Access but I'm not sure if that will work, if it would then I'll just place that in the directory between the user's folders
  16. On a side note is it possible to make a list of variables (IE an array full of variable names) globals? and once again if so how would I do it?
  17. Is there a way to use extract to make session variables? If so how would you go about doing it?
  18. Alright, I apologize... I assumed that because it drifted down past 20 that no one had really looked at it... I will wait until after its on the second page from now on. Maybe I'll flip some code around to see if it helps. Update: Apparently if I run it through the function parseTemplate twice (once before and after loading the pages that fixes the problem.
  19. I've been trying to create a basic template system that will replace the data in {} correctly. The template system is supposed to auto load any pages called into the file by things like {load header} and replace the variables in there, but it doesn't... Here is my code and an example page: <?php $site_title = "This Title Works Just Fine"; $template_index = 'index.php'; $template_header = 'header.php'; $template = './templates/default'; class templateParser { var $output; function templateParser($templateFile='default_template.htm'){ (file_exists($templateFile))?$this->output=file_get_contents($templateFile):die('Error:Template file '.$templateFile.' not found'); } function parseTemplate($tags=array()){ if(count($tags)>0){ foreach($tags as $tag=>$data){ $data=(file_exists($data))?$this->parseFile($data):$data; $this->output=str_replace ('{'.$tag.'}',$data,$this->output); } } else { die('[Error: 023 - Template Variables Invalid or Missing]'); } } function parseFile($file){ ob_start(); include($file); $content=ob_get_contents(); ob_end_clean(); return $content; } function display(){ return $this->output; } } // Tags $tags = array( 'site_title'=>$site_title, 'load_header'=>$template.$template_header ); // instantiate a new template Parser object $tp=&new templateParser($template.$template_index); // parse template file $tp->parseTemplate($tags); // display generated page echo $tp->display(); ?> Example Page Code: // index.php {load_header} <div id="container"> <div id="left"> <div id="lefttitle">{site_title}</div><br><p> </p> </div> // header.php <title>{site_title}</title> </head> <body> <div id="headertitle">{site_title}</div> So the page loads fine... The problem is that the site title remains {site_title} and so does the "headertitle". The problem with this is that both are defined in the tags array and should be replaced by the variable $site_title. The "replacement" works just fine in index.php (replacing {site_title} like it should), but will not replace it in header.php which is why there is a problem. Can anyone help me fix this?
  20. I'd like some help debuging my code, I can't seem to figure out why it isn't creating the variables... Here it is: <?php $template_settings = array( "index"=>"index.php", "announcements"=>"announcements.php" ); extract($template_settings, EXTR_PREFIX_ALL, "template_"); echo $template_index; ?> No matter what I do $template_index still equals null and I'm wondering what I'm doing wrong. There are no errors of anykind.
  21. It'd be the admin editing the structure so that they could have custom fields, so that they don't have to edit the script to add custom fields.
  22. Way off... Here is what I'm talking about: I'd like to allow users of the script to add columns to the accounts table (where the user data is stored) and have my script load those columns into variables when the user logs on. So as an example here is my table structure and an example: email_address password first_name last_name admin@test.com d65dh3 Nicholas Someone It needs to create a variable for each ($email_address = "admin@test.com", $password = "d65dh3", etc) ... but lets say that someone adds another column called "address" to the table, well now I want it to create a variable $address automatically along with the other ones it was creating before. They could add 10 or 20 columns to the table, but it will still create a variable for each. Hopefully you see where I want this to go... So that I can allow the creation of custom user fields.
×
×
  • 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.