Jump to content


  • Posts

  • Joined

  • Last visited

About dmallia

  • Birthday 09/06/1992

Previous Fields

  • Languages
    HTML, CSS, PHP, MySQL, Javascript

Contact Methods

  • MSN

Profile Information

  • Location
    Zurrieq, Malta

dmallia's Achievements


Newbie (1/7)



  1. $output = null;exec('top -n 1', $output);print_r($output); i modified the script but the array is empty.
  2. $data = shell_exec('top -d 1');echo $data; i tried this code but nothing is loading. than just to test if the code is good i tried this $data = shell_exec('free -m');echo $data; and it worked correctly
  3. So i am building an admin page as part of a project for the course I am doing. I want to execute the remote command "top" (it doesn't matter if i execute it by php ssh connection) on linux and than I want to store the output of the command in a variable called $data. Is that possible? I tried doing it with shell_exec() and exec() but couldn't get it to work. Thanks before hand.
  4. dmallia

    content script

    what's the best solution to secure it? should i only run the script if the page is a page that exists in the directory of the web? file_exists() or i store all the page names in an array and check if it exists in the array?
  5. dmallia

    content script

    so i made this script and it seems to be working fine. index.php <?phpecho '<a href="/index.php?page=news">News</a>';echo '<a href="/index.php?page=about">About Us</a>';if (empty($_GET['page'])) { $inc = 'news.php'; }else { $page = $_GET['page']; $inc = $page.'.php'; if (file_exists($inc)) { include $inc; } else { $inc="news.php"; include $inc; } }?> about.php <?phpecho '<p>About US</p>';?> news.php <?phpecho '<p>News</p>';?> do you think it's secure? what do you think i can add to be more secure?
  6. dmallia

    content script

    I don't want to do seperate pages using the include. I want to have an index.php than inside of it I include the content according what the user chose from the menu. I want a script that will be in the index.php file, that gets the information of the page the user chose from the menu and than includes it in the index.php file.
  7. dmallia

    content script

    I would like to do a script that includes content from pages according what the user chooses. Example If the users chooses Contact us from the menu I would like to have the index page displayed with the contact us content( www.website.com/index.php?page=contact-us ). I know it is done by GET requests but don't know how to do it or what is it called. Does anyone have a script or a tutorial on how to do it? Or at lest what is it called so I find a tutorial. Thanks before hand.
  8. thanks for the link I was searching only under javascript not ajax >.< made a simple script and seems to work. I will test it with my script and see what happens. Thanks again.
  9. can you give me an example on how to call the script using ajax. I'm new to ajax. about reloading the script itself reloads the page.
  10. I have this php script stop.php <?phpinclude('ssh_con.php');$stop = 'screen -S testapplication -X quit';ssh2_exec($con, $stop);mysql_query("UPDATE servers SET Online=0 WHERE Owner='".$_SESSION['Username']."'");echo "<meta http-equiv='refresh' content='0;index.php'>";?> now i want to execute/call/get this page/script using javascript onclick to execute the code and the page refreshes itself. Can anyone guide me to do this? Thanks before hand.
  11. when putting action the first form displays ok. than when i press start the page refreshes and only loads the stop button.
  12. So i have these 2 forms. <form method="post" enctype="multipart/form-data"><input type="submit" name="start" value="Start" /></form> and <form method="post" enctype="multipart/form-data"><input type="submit" name="stop" value="Stop" /></form> now i need a script that when the start button in form no.1 is pressed the page refreshes and includes form no.2 with the stop button and than if the stop button is pressed it includes the start button. I tried to made this script. if ($server['Online'] == 0) { echo "<meta http-equiv='refresh' content='0;url=start.php'>"; }else { echo "<meta http-equiv='refresh' content='0;url=stop.php'>"; } but it is only including the forms, I would like to stay on the index.php and change the content in the div. The scripts needs to fit in the script below <?php if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username'])) { include('db/get_data.php'); //**SCRIPT HERE**// } elseif(!empty($_POST['username']) && !empty($_POST['password'])) { $username = mysql_real_escape_string($_POST['username']); $password = md5(mysql_real_escape_string($_POST['password'])); $checklogin = mysql_query("SELECT * FROM users WHERE Username = '".$username."' AND Password = '".$password."'"); if(mysql_num_rows($checklogin) == 1) { $row = mysql_fetch_array($checklogin); $email = $row['Emailaddress']; $_SESSION['Username'] = $username; $_SESSION['Emailaddress'] = $email; $_SESSION['LoggedIn'] = 1; echo "<meta http-equiv='refresh' content='0;index.php'>"; } else { echo "<h1>Error</h1>"; echo "<p>Sorry, your account could not be found. Please <a href=\"index.php\">click here to try again</a>.</p>"; } } else {?> <h1>Member Login</h1> <p>Please login below.</p> <form method="post" action="index.php" name="loginform" id="loginform"> <fieldset> <label for="username">Username:</label><input type="text" name="username" id="username" /><br /> <label for="password">Password:</label><input type="password" name="password" id="password" /><br /> <input type="submit" name="login" id="login" value="Login" /> </fieldset> </form> <?php } any ideas on how i can do it? Thanks before hand
  13. Can you explain in little bit more detail and if possible with code because i didn't understand.
  14. I made this script. <form method="post" enctype="multipart/form-data"> <select name="file" style="width: 150px"> <option value="text1.txt">text1.txt</option> <option value="text2.txt">text2.txt</option> </select> <input type="submit" name="load" value="Load"></form><?phpif (isset($_POST['load'])) { $fn = ($_POST['file']); include('box.php'); } if (isset($_POST['save'])) { $fn = ($_POST['file']); $content = stripslashes($_POST['content']); $fp = fopen($fn,"w"); //or die ("Error opening file in write mode!"); fputs($fp,$content); fclose($fp); //or die ("Error closing file!"); }?> and this box.php <form method="post" enctype="multipart/form-data"> <textarea name="content" style="width: 600px; height: 300px;"><?php readfile($fn) ?></textarea><br /> <input type="submit" name ="save" value="Save"></form> the script works fine until when comes to saving the data. It gives me this errors. Notice: Undefined index: file in /var/www/html/daniel/phptextedit/index.php on line 19 Warning: fopen(): Filename cannot be empty in /var/www/html/daniel/phptextedit/index.php on line 21 Warning: fputs() expects parameter 1 to be resource, boolean given in /var/www/html/daniel/phptextedit/index.php on line 22 Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/html/daniel/phptextedit/index.php on line 23 Anyone can help me to solve these problems?
  • Create New...