Jump to content

teamatomic

Members
  • Posts

    1,202
  • Joined

  • Last visited

Everything posted by teamatomic

  1. What you would do is put a field in the user table with 1-10. Where 1 is a registered user and 10 is an admin, or something like that. SQL: access_level TINYINT(2) NOT NULL DEFAULT '1' HTH Teamatomic
  2. You should escape those before you insert them $escaped_string = "You\'re The Designers, We\'re The Deciders for the band Not Advised"; HTH Teamatomic
  3. start your session above the include. HTH Teamatomic
  4. $path = $_SERVER['SCRIPT_FILENAME']; $f1 = basename($path); //$f1 = "somephrasehere_01.php"; // to test with uncomment list($f2,$ext)=explode(".",$f1); list($name,$num)=explode("_",$f2); $nn = $num+1; $nb = $num-1; $nb = str_pad($nb, 2, "0", STR_PAD_LEFT); $nn = str_pad($nn, 2, "0", STR_PAD_LEFT); $next = "$name" . "_" . "$nn"; $back = "$name" . "_" . "$nb"; $back_link="<a style=\"text-decoration:none\"; href=\"$back.$ext\"><<Last </a>"; $next_link="<a style=\"text-decoration:none\"; href=\"$next.$ext\"> Next>></a>"; if(file_exists("$back.$ext")) {echo "$back_link";} if(file_exists("$next.$ext")) {echo "$next_link";} HTH Teamatomic
  5. Those are ini_sets, conditions that will apply to a session, they must be set before the session starts or they will not be applied. Right. When a user logs in you set what you want to keep, username, level, email, prefs, etc. Then you only have to check say the level if you want to know if they can have access to a certain page. One thing I forgot to say is if you do use garbage collection store your sessions outside of user space. If your base path is /home/joe123/public_html then sessions go into /home/joe123/sessions HTH Teamatomic
  6. Those dont look like "back ticks" in the $res. The shell wont execute it if its not back ticked. You should not even need the exec, in PHP it will use the ticks and do it itself. The back tick is right below the "tilde", upper left of the keyboard. I dont know what your shell script looks like but you have to sudo everything. Is it your box? If not do you have root perms or been made a super-user. If not you wont be able to do anything. Is "safe mode" turned on. If so you have to set the folder you have executables in with safe_mode_exec_dir. If this confuses you you should spend some time with: Linux "Little Black Book" Linux in a nutshell HTH Teamatomic
  7. Yup, use a _GET. HTH Teamatomic
  8. Just stick this where ever you want the links. $path = $_SERVER['SCRIPT_FILENAME']; $f1 = basename($path); //$f1 = "somephrasehere_09.php"; // to test with uncomment list($f2,$ext)=explode(".",$f1); list($name,$num)=explode("_",$f2); $nn = $num+1; $nb = $num-1; $next = "$name" . "_" . "$nn"; $back = "$name" . "_" . "$nb"; $back_link="<a style=\"text-decoration:none\"; href=\"$back.$ext\"><< Last</a>"; $next_link="<a style=\"text-decoration:none\"; href=\"$next.$ext\">Next >> </a>"; echo "$back_link - - $next_link"; HTH Teamatomic
  9. document.macaddressapplet.setSep( ":" ); document.macaddressapplet.setFormat( "%02x" ); var macs = eval( String( document.macaddressapplet.getMacAddressesJSON() ) ); var mac_string = ""; for( var idx = 0; idx < macs.length; idx ++ ) mac_string += "\t" + macs[ idx ] + "\n "; document.write(mac_string); location.href="some_page.php?macaddy=" + mac_string; Now the somepage you use could even be the same page you have the js on if you block it out like a form using the same page for the action. Thats the only way I know that does not involve using a form. But eother way you need to send the data back to the server.
  10. At the very top of your page if($_SESSION['admin_level'] != '10') {header('Location: http://www.domain.com');} or you could send them to an error page header('Location: http://www.domain.com/error.php?error=admin_access')
  11. Curly brackets and round brackets are not compatible! if ($_SESSION['i'] != "yes"}
  12. I use $_SESSION['breadcrumb'] = "$_SERVER['SCRIPT_FILENAME']";
  13. Best way is to put this at the start of each page. It is portable and you dont have to play with php.ini or setup mod_gzip: ob_start("ob_gzhandler");
  14. Easy one! $str = "{one}{two}"; $nstr=trim( $str ,"{}" ); list($domain,$referer)=explode("}{","$nstr"); echo "$domain--$referer";
  15. Yes and no. If you use mod_gzip you have two options. Apache can zip it on the fly and send it to the browser or you can have index.php and index.gz and if the browser supports gziped files then it will send the gz file else it sends the php file. But this is a PITA as mod_gzip is no fun and lots of hosts dont have it implimented. It is much simpler to add to the top(must be the first thing) of each page: <? ob_start("ob_gzhandler"); ?> Simple as that. Really saves bandwidth on free or limited sites. HTH Teamatomic
  16. Just curious. What does make2 do? You unlink it then you recreate it with an empty fopen(you open and close but dont write to them). But you never write to it. To empty and remake a file: unlink($file); touch($file); chmod("$file", 0644);// if you get a permission problem then 755 So as far as I can see you put your $logdetails to the database.html file. file_put_contents does not append unless you tell it to: file_put_contents('Database.html', implode('', array_unique(array_merge($data1,$data2))), FILE_APPEND | LOCK_EX); So why not this? <?php $IP = $_SERVER['REMOTE_ADDR']; // make logdetails line with a break and a new line ending // so it is readable in a browser and as a plain file $logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://dnsstuff.com/tools/city.ch?ip='.$_SERVER['REMOTE_ADDR'].'>'.$_SERVER['REMOTE_ADDR'].'</a><br>\n'; // get the contents of database.html into an array $data1 = file("database.html"); //push logdetails to the end of the array arrary_push($data1,"$logdetails"); //unique the array and APPEND it to database.hrml and LOCK it while we write to it so if //another user accesses the page with the log tickler we dont have an oops file_put_contents('Database.html', implode('', array_unique), FILE_APPEND | LOCK_EX); ?> HTH Teamatomic
  17. Keep it as simple as possible. At login set some session vars. One of them I use is email, I keep it accessible for every page. On the index page: if (!isset($_SESSION['email'])) { $page_name = "login";// put your redirect header here } On the login page. Once checked and verified: $_SESSION['email'] = $email1; Its as simple as that! This redirects them to the login page if they have not logged in. It has not failed yet. You can use anything you set at login. Most common is the username, which is what I use the email for. If you keep it at the top of your pages and dont output anything first you can just use a header(location) to redirect to your login page. You dont have to unset and destroy sessions all the time. If you want to clean up after yourself use the built in garbage collection: ini_set('session.gc_maxlifetime', '10800');// this is three hours ini_set('session.gc_divisor', '1'); //#2 ini_set('session.gc_probability', '1');// this and #2 give a 100% probability of clean-up ini_set('session.cookie_lifetime', '0'); ini_set('session.save_path', /path/to/sessions/app_name); session_name('app_name'); session_start(); HTH Teamatomic
  18. page1.php <form action="page2.php method="post"> <input name="id" type="text" value=""> <form> page2.php $id = $_POST['id']; echo "$id"; HTH Teamatomic
  19. Is it possible that whatever is building your links is keeping the $_GET in the url? HTH Teamatomic
  20. You ask if there is a better way. I dont know what your $map renders, does it use GD to alter a map image? I have made weather maps to display temps and use CSS to position over a map HTH Teamatomic
  21. Do this $name=$_POST['name']; echo "$name"; Does the submitted value get printed?
×
×
  • 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.