Jump to content

climbjm

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Everything posted by climbjm

  1. thorpe, wow! I didnt see this when I was looking. Totally looking in the wrong spot! Thanks!
  2. What I am trying to do is use the PHP SSH2 functions to tunnel into a linux box and login. However SSH2 fails because the system I am logging into asks for two usernames and two passwords so I need to catch both using a regex. Currently I have a PHP script executing a perl script trying to use expect to do this, but I'd prefer to do this all in PHP. :'( Any thoughts or ideas? Thanks!
  3. Is there a way to make this even smaller or run even faster? I have another page that send a text fields input to this page. The name/id of that text field is "Question". <?php if(eregi("bb",$_POST["Question"])) echo("2B"); else echo("!2B"); ?> I'd like to make it as small as possible. I will be turning it into a bumper sticker eventually. Aiming for <4 lines. (feel free to make your own bumper stickers too)
  4. Ok, looking over the code example... that is just to kill a process right? I want it to completely shut down the server.
  5. I'll try that Dark Freaks and will let you know if it works! Thanks!
  6. Another Info: Functions I have tried: shell_exec() exec() system() Commands I have tried: halt shutdown reboot sudo halt sudo shutdown sudo reboot
  7. The Story/Setup: I have an Ubuntu FF Server up and running. However it is very noisy and it sits in my bedroom with the printer and all my other networking stuff. However, if I am not at home... I would like a way for my wife to be able to shut the box off without having to SSH into the box, but instead click a simple link to turn it off. However, nothing has worked so far. Anyone have any ideas? What I have so far: $v = ""; if($_GET['command']=='shutdown') { echo("<h1>SHUTTING DOWN SERVER</h1>"); $loadpage=false; // for something else, ignore this $v .= shell_exec('sync'); $v .= shell_exec('sync'); $v .= shell_exec('shutdown'); echo("".$v.""); } // much later down the road <li><a href="index.php?command=shutdown">Shutdown the Server</a> When I run this... it displays the "<h1>SHUTTING DOWN SERVER</h1>" but does not shut down the server.
  8. Check out this and compare. He also explains a lot of things in his tutorial as well as keeping it simple. http://www.tizag.com/phpT/fileupload.php Also make sure that your file "upload.php" and the folder you are uploading too have the correct permissions or you will start to get all sorts of warnings or fatal errors. for more info on that google "php chmod" and google "linux chmod".
  9. Agreed with thorpe... However if you wanted like a little 'splash' page that says something like, you will be redirected in five seconds... I would recommend using JavaScript. However, if they have JavaScript disabled or a JavaScript non-supported browser... they wont be redirected. this is why you usually provide a link stating "if you have not been re-directed in 5 seconds, please click here". It is usually easier to use a client side script to re-direct with a 5 second splash page opposed to having a server side redirect you. If you want this to be instantaneous... use the method above. For a JavaScript redirect tutorial, check here: http://www.tizag.com/javascriptT/javascriptredirect.php
  10. When I lower the permissions on the folder that I am writing too, I get errors just like you are showing. Do you have access to your servers shell? I really think you have a permissions not set correctly on your pending folder. If you have access to a shell, type... sudo chmod 0777 /FULLPATH/pending/ example... my upload folder for my website is located here: /var/www/upload/ so I would chmod my folder like this... sudo chmod 0777 /var/www/upload Once you get your permissions fixed and ruled out, then you can tighten your permissions to increase security. * sudo means you are basically running as a super user. * the chmod part tells the computer you want to change the permissions of the file in regards to read, write and execute. * the 0777 basically makes it so that everyone can read/write/execute (full permissions). * Last but not least you give the file or the folder you want to apply the permissions to. IF YOU DO NOT HAVE SHELL ACCESS TO YOUR SERVER... You can actually write a PHP script to do this for you. It goes something like this... Example from http://us3.php.net/chmod LAST BUT NOT LEAST... I promise I am almost done... Here is another great tutorial about creating scripts to upload files. http://www.tizag.com/phpT/fileupload.php As said in the tutorial, when a file is uploaded to your server... it is there only temporarily until the script finishes executing. Once the script finishes (which can be just milliseconds to execute) it destroys those temporary files. This is why when you looked in the folder, you did not see the file. This is actually why you are 'copying' the temp file, into a different folder. That way when the script finishes and deletes the temp file, you still have a copy else where .
  11. Thanks thorpe... great information! Man, I am falling in love with the linux/php/apache combination everyday. I found this article (site is down but I found a cached version of the site) http://72.14.253.104/search?q=cache:VLCvyCQMfXYJ:www.freeos.com/articles/2879/+/proc&hl=en&ct=clnk&cd=1&gl=us
  12. Check to make sure that your File that is executing the script has the proper permissions and the folder that you are writing the file to has the correct permissions. When I don't have the permissions set correctly or assigned to the wrong group, I often get that error message (or something almost identical to it).
  13. Here is an example of what I did to show just some of my machines information using PHP. status.php <html> <head> <title>System Status</title> </head> <body> <h1>Machine Information & System Status</h1> <? include("memory.php"); include("machine.php"); ?> </body> </html> memory.php <h2>Memory - KB</h2> <pre> <? echo shell_exec('free -o'); ?> </pre> machine.php <h2>Machine Details</h2> <pre> Hardware Type: <? echo shell_exec('uname -m'); ?> Node Name: <? echo shell_exec('uname -n'); ?> Processor: <? echo shell_exec('uname -p'); ?> Release: <? echo shell_exec('uname -r'); ?> OS System Name: <? echo shell_exec('uname -s'); ?> OS Version: <? echo shell_exec('uname -v'); ?> </pre> Works Great on my Ubuntu PHP/Apache Server. Note: This is for linux and doubt it will work on Windows.
  14. I would probably just create a cron job to run the script every 5 minutes.
  15. You could use "lspci" for the hardware and "free -m" for the memory usage. What you have to do to get that info from bash into a file and then into PHP is beyond me. That is a great idea. I could run a batch script that scrapes my hardware information. Then redirect the output to a file to something like "hardware.info" and then just include (not require) that file in my PHP script and convert new lines to breaks. I cannot believe I didnt think of that myself. Thanks for brain storming guys!
  16. Unlike the tutorial, I actually use: action="<?php echo $_SERVER['PHP_SELF']; ?>"
  17. No, but that is a good question. Say your PHP script is in the file "form.php". You would enter the value "form.php" for the attribute action. example: <form id="form1" name="form1" method="post" action="form.php"> OR... There is a PHP variable that echos the name of the file that it is being executed in. So instead you could use: <form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF;?>"> This way, if you rename the file from form.php to anything else, it will always point back at itself. Here is a great tutorial. Check it out. It also gives explanations. http://www.tizag.com/phpT/examples/formex.php
  18. Thanks, but I am not looking for $_SERVER variables. That just displays User's Agent and Apache server information. I am looking specifically for hardware.
  19. <form id="form1" name="form1" method="post" action=""> Your not sending your form anywhere. Action needs to be set.
  20. Is there a way to echo a machines hardware through PHP or pulling the information from Apache? I am trying to figure out a script to display the machines memory, hd disk space, processor information, memory usage (used by programs and used by cache), etc. Anyone have any good articles, links, other info I might look at? Server: Apache/2.2.3 (Ubuntu) PHP/5.2.1 Server
  21. if I have an array that I have created and I want to push data to it.... anyone have an idea as to how to do that? example: [code]$name = "bob"; $age = 21; // I want to push the info so the first Col is the name and the second Col is the age,  I cant use a db. $personArray = array(); array_push($personArray,<this is where i am lost>);[/code] Any ideas? http://us3.php.net/manual/en/function.array-push.php I've tried looking here, but I didn't see it.
  22. I have installed the PDFlib on my server.  When I run phpinfo() it says PHP 5.1.6, and in the 'configure command' section it states '--with-pdflib'.  When I run my script I get a: [tt] Fatal error: Class 'PDFlib' not found in /home/username/public_html/get_pdf.php on line 9.[/tt] This is the code I am trying out: [code] <?php try { $p = new PDFlib(); // this is line 9 in my script. // open new PDF file; insert a file name to create the PDF on disk if ($p->begin_document("", "") == 0) { die("Error: " . $p->get_errmsg()); } $p->set_info("Creator", "get_pdf.php"); $p->set_info("Author", "Just Me"); $p->set_info("Title", "Hello world (PHP)!"); $p->begin_page_ext(595, 842, ""); $font = $p->load_font("Helvetica-Bold", "winansi", ""); $p->setfont($font, 24.0); $p->set_text_pos(50, 700); $p->show("Hello world!"); $p->continue_text("(says PHP)"); $p->end_page_ext(""); $p->end_document(""); $buf = $p->get_buffer(); $len = strlen($buf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=hello.pdf"); print $buf; } catch (PDFlibException $e) { die("PDFlib exception occurred in hello sample:\n" . "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . $e->get_errmsg() . "\n"); } catch (Exception $e) { die($e); } $p = 0; ?> [/code] Any thoughts or ideas anyone?
  23. Thank you btherl. I found out: [url=http://sg.php.net/manual/en/ref.dbx.php]http://sg.php.net/manual/en/ref.dbx.php[/url] FrontBase (available from PHP 4.1.0), Microsoft SQL Server, MySQL, ODBC, PostgreSQL, Sybase-CT (available from PHP 4.2.0), Oracle (oci8) (available from PHP 4.3.0), SQLite (PHP 5). [url=http://sg.php.net/manual/en/ref.uodbc.php]http://sg.php.net/manual/en/ref.uodbc.php[/url] The following databases are supported by the Unified ODBC functions: Adabas D, IBM DB2, iODBC, Solid, and Sybase SQL Anywhere.
×
×
  • 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.