PHP - Command
I have a shoutbox my friend made, and I'm just adding onto it.
I have command that are like @prune, @prunelogs, @logout, etc.. I am tying to make it so you can type @ban username, @unban username, etc.. Here is my command that my friend came up with. if($_POST['text'] == '@ban'.$username.'') { $unn=$idk['username']; mysql_query("UPDATE users SET banned = '1' WHERE usernane='$unn'") or die(mysql_error()); mysql_query("INSERT INTO chat (`log`, `date` ,`username` ,`text`) VALUES (1, NOW( ) , '".stripslashes($_SESSION['user'])."', 'has banned '$unn'.');") or die(mysql_error()); Similar TutorialsI have created a tar file with my site backup and I assume it is the full backup. Not sure becasue I can't "un"-tar the file. I have tried several ways to "unzip" or untar the file but can not come up with anything. here is how I had created the tar file: Code: [Select] $date = date("m-d-Y"); // repeat this command for multiple backups, changing the path - e.g. you can have a backup for email, another for files, etc. shell_exec("tar cvfz file_backup_$date.tar.gz mydir/ "); now how do extract it? I've created a login page in Dreamweaver and there is a redirect page for login success and login fail. What I want to have is a selection of screens based on a data field held in the user security table. Each security record will have up to 5 different security codes e.g. code1, code2 etc. If a code e.g. TA40, appears in any of the 5 code fields then I want the user directed to one page, if code TA41 appears in any of the 5 code fields then I want them directed to another page. The user code will only appear in one of the fields, but can appear in any of the 5 code fields.. How can I incorporate this in to the login screen logic, as currently it will just show the follwoing if (isset($_POST['opno'])) { $loginUsername=$_POST['opno']; $password=$_POST['pass_word']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "/menu.php"; $MM_redirectLoginFailed = "/loginform.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_Hanson, $Hanson); Hi, I'm having a weird issue when I try to run PHP scripts from the command line on my server. I'm trying to just run a very simple script to test it out: #!/usr/bin/php-cgi -q echo "Hello terminal\n"; And I get the following error in the terminal.. Code: [Select] Error in argument 1, char 3: option not found Usage: php-cgi [-q] [-h] [-s] [-v] [-i] [-f <file>] php-cgi <file> [args...] When I try taking out the quiet (-q) parameter, I get the following error.. Code: [Select] -bash: ./socket_server.php: /usr/bin/php-cgi^M: bad interpreterNo such file or directory As you can see, in the second example, a rogue "^M" was appended to the end of the first line of my socket_server.php file. What does ^M correlate to? I realize it is a character code for something that can't be represented with an actual character, but I don't know what it is, and I'm not sure why it is being appended to the end of my first line. My assumption is that this is happening in the first example too, which is why I get the "error in argument 1" message, since undoubtedly -q^M is an invalid argument... Any help is greatly appreciated! nethnet hello, i was wondering if there is a way to have a link do a command, but not to goto a page. my reason being is that the music player software i use has a built in web server and if you goto a certain page, it will process that command. so right now, i have an iframe that i do a target to. its pretty mickey mouse, but its what i knew how to do. thanks I know that php has a function that can execute ping command but i'm not sure how it works. I am trying to get the result of the ping command to determine: IP address has a reply (PC/device is turned on) IP address has no reply (ip address is vacant and not assigned to any pc/device IP address has a response (PC/device is turned off) is this "do-able" in php?? this is my script: Code: [Select] function ping($ip){ // #5882FA blue color indicates Fiber Module // #FACC2E orange color indicates cascade/uplink cable // #81F781 Green color indicates connected/turned on // #FE2E2E Red color indicates disconnected/turned off // #585858 dark gray color indicates connected patch panel port is vacant at user side if($ip=="Cascade" OR $ip=="Uplink"){ return $status="style=\"background-color:#FACC2E;cursor:pointer;\""; /* orange */ }elseif ($ip=="Fibre Module"){ return $status="style=\"background-color:#5882FA;cursor:pointer;\""; /* blue */ }elseif ($ip==null or $ip==""){ return $status="style=\"cursor:pointer;background-image:url(images/x.gif);\""; /* dark gray */ }else{ $str = exec("ping -n 1 -w 1 $ip", $input, $result); if ($result == 0){ return $status="style=\"background-color:#81F781;cursor:pointer;\""; /* green */ //return "on"; }else{ return $status="style=\"background-color:#FE2E2E;cursor:pointer;\""; /* red */ //return "off"; } } } i can get it display on or off and i've tested it working. but i just can't figure out if i could use this command to determine if the IP address is vacant or unassigned. I'm using this for a IP list inventory system built in PHP. I have careted a page where the the 3com switch is drawn in tabulated format with each port assigned (via PHP) to the corresponding IP address of the device/PC and indicates the port color as described in the above function. Surprisingly it works well for this switch inventory. I just want to create another page for IP address inventory using the same function. To put is simple i want to have the same function as the sofware "Advance IP-Scanner" which does the same thing as well only thing is my resources are limited to PHP (WAMP). any help guys? Is there anything in php that let's me SWAP 2 arrays? like let's say I have 3,2,1 in a array, is there a way I can swap the 2 and 1 if a statement is true? I am having difficulty working out how to grab from a URL within a URL a link to an image and display this image on a webpage. example: http://domainA.com/page1.php?file_image=http://domainB.com/image.jpg I know little of this the code below but this is not working: <?php echo $_GET['file_image']; ?> this just copies the url, whereas I want to display this image.jpg from domainB using image source by grabing it. <img src=" "> I hope you understand me. Hi.. I have a php file where i have only one line which says header('Location: index.php'); How do i run this php file in the terminal on fedora 14? Thanks, Rohit This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=326238.0 It was suggested that I add a ‘report’ parameter to the code, after revising with the ‘scale2ref’ code which appears to prevent the video from uploading/proceeding: $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "[0]scale=426:-2[vid];[1][vid]scale2ref='oh*mdar':'ih/10'[wm][vid];[vid][wm]overlay=5:5:format=rgb,format=yuv420p" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 -report'.$video_output_full_path_240.' 2>&1'; $shell = shell_exec($ffmpegCommand); I couldn’t see where the -report parameter was supposed to output (error.log has a filesize of 0). So I was asked to “run command from the shell and check”? But, I’m not sure what command and where/how to do that. I tried adding this to the php code, and attempted to upload again, same result echo shell_exec("/usr/local/bin/ffmpeg -report log.txt 2>&1");
any additional help is appreciated
Hello people, At the moment I am really desperate. I've done this script over 20 times now, always with the same script but all of a suddon, it doesn't work anymore. heres the problem: I made a very simple "patient database" for a doctor. Where he can upload patients, alter and delete them. The script to add the patients works fine. now im trying to make a script where he can alter the variables agian, using the UPDATE command. but instead of updating the variables it cleares all the date in the row. can someone help me? here s the entire code: Code: [Select] <?PHP include'connect.php'; ?> <?PHP $SQL = mysql_query("SELECT * FROM leys_patienten WHERE patientid='".$_REQUEST['patientid']."'"); while ($row = mysql_fetch_array($SQL)) { ?> <?PHP if ($_POST[submit]) { if (!$_POST[volgnummer]) { echo "<font size=\"2\" color=\"#990000\"><b>--> Vul een volgnummer in a.u.b. <--</b></font>"; } elseif (!$_POST[naam]) { echo "<font size=\"2\" color=\"#990000\"><b>--> Vul een naam in a.u.b. <--</b></font>"; } elseif (!$_POST[voornaam]) { echo "<font size=\"2\" color=\"#990000\"><b>--> Vul een voornaam in a.u.b.! <--</b></font>"; } else { mysql_query("UPDATE leys_patienten SET volgnummer='$volgnummer',naam='$naam',voornaam='$voornaam',adres='$adres',postcode='$postcode',plaats='$plaats',telefoon='$telefoon',email='$email',geboortedatum='$geboortedatum',geboorteplaats='$geboorteplaats',opmerkingen='$opmerkingen' WHERE patientid='".$_REQUEST['patientid']."'") or die(mysql_error()); echo "Het patientendossier is succesvol gewijzigd, let op doorschakeling.";?> <meta http-equiv="Refresh" content="1; url=patient.php?patientid=<?PHP echo $row['patientid']?>" /> <? } } ?></p> <form action="<?$PHP_SELF?>" method="post" name="post" id="post"> <table width="805" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td class="table_forms">Volgnummer*</td> <td class="table_forms"><label><input name="volgnummer" type="text" id="volgnummer" value="<?PHP echo $row['volgnummer']?>" size="40" /></label></td> </tr> <tr> <td width="146" class="table_forms">Naam*</td> <td width="659" class="table_forms"><label><input name="naam" type="text" id="naam" value="<?PHP echo $row['naam']?>" size="40" /></label></td> </tr> <tr> <td class="table_forms">Voornaam*</td> <td class="table_forms"><font color="#FFFFFF" size="2"> <label><input name="voornaam" type="text" id="voornaam" value="<?PHP echo $row['voornaam']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Adres </td> <td><font color="#FFFFFF" size="2"> <label><input name="adres" type="text" id="adres" value="<?PHP echo $row['adres']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Postcode</td> <td><font color="#FFFFFF" size="2"> <label><input name="postcode" type="text" id="postcode" value="<?PHP echo $row['postcode']?>" size="6" /></label> </font></td> </tr> <tr> <td class="table_forms">Plaats</td> <td><font color="#FFFFFF" size="2"> <label><input name="plaats" type="text" id="plaats" value="<?PHP echo $row['plaats']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Telefoon</td> <td><font color="#FFFFFF" size="2"> <label><input name="telefoon" type="text" id="telefoon" value="<?PHP echo $row['telefoon']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">E-mail</td> <td><font color="#FFFFFF" size="2"> <label><input name="email" type="text" id="email" value="<?PHP echo $row['email']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Geboortedatum</td> <td><font color="#FFFFFF" size="2"> <label><input name="geboortedatum" type="text" id="geboortedatum" value="<?PHP echo $row['geboortedatum']?>" size="40" /></label> </font></td> </tr> <tr> <td class="table_forms">Geboorteplaats</td> <td><font color="#FFFFFF" size="2"> <label><input name="geboorteplaats" type="text" id="geboorteplaats" value="<?PHP echo $row['geboorteplaats']?>" size="40" /></label> </font></td> </tr> <tr> <td valign="top" class="table_forms">Opmerkingen</td> <td><font color="#FFFFFF" size="2"> <label><textarea name="opmerkingen" cols="40" rows="4" id="opmerkingen"><?PHP echo $row['opmerkingen']?></textarea></label> </font></td> </tr> <tr> <td valign="top" class="table_forms"> </td> <td><span class="body_tekst"> <input type="submit" id="submit" name="submit" value="verstuur" /> </span></td> </tr> </table> <p class="body_tekst"> </p> </form> <? } ?> is there a way to excute the system() command here but not wait for it and just let it go in the background? And something that wont boggle down the system too much? Thanks! Code: [Select] $this->db->insert('jukebox', $data); echo '1'; system('ffmpeg -i ' . $id . '.mp3 -acodec libvorbis -aq 60 ' . $id . '.ogg'); hello, I have this problem in running a specific command after using shell_exec or exec to execute a certain process. The process I am running is unimrcpclient, after initialization, it expects some command to be entered in order to communicate with the mrcp server. however, passing the command as an attribute is not an option. Is there a way in PHP to execute a process, wait for initialization and then pass the command automatically? thank you. hey guys m using STDIN as input stream in php command line my problem is that some time i get this error Warning: fgets(): supplied argument is not a valid stream resource in D:\myquery \test.php on line 16 $number=fgets(STDIN); anyone knows solution Sorry to be a newbie. I am writing some code that is supposed to query a row in my database. If that row returns the value "yes" I want to display a text or image. It is currently being written within a pop up box, hence within the <span> parameters. Problem is it just doesnt work and was hoping someone could tell me why. Have I got too many brackets? Should the values in the PHP admin table be set differently? The bit I am having trouble is the 'IF commands". Although the row 'moisture' has a yes value in the database it does not perform the echo. The code is below:[/b][/b] <a href="<?php echo $row_Recordset1['fabricpicture']; ?>" class="MagicZoomPlus" rel="caption-source:span;caption-position:right" title="<?php echo $row_Recordset1['fabricgroup']; ?> <?php echo $row_Recordset1['E']; ?>"> <img src="<?php echo $row_Recordset1['fabricpicture']; ?>" name="Grey" width="100" height="100" border="0" class="MagicZoomPlus" id="Grey"/> <span><strong><?php echo $row_Recordset1['fabricgroup']; ?> <?php echo $row_Recordset1['E']; ?></strong> </p> <?php echo $row_Recordset1['fabricmaterial']?> </P> Max Width = <?php echo $row_Recordset1['width']?> </p> Max Drop = <?php echo $row_Recordset1['drop']?> </p> <?php if ($rowRecordset1['moisture']=="yes") {echo "moisture resistant";} ?> </p> <?php if ($rowRecordset1['flame'] == "yes") {echo "flame retardant";} ?></span>. </a> I want to do something like the following: exec('open /Applications/Safari.app'); I can run exec on other commands like: $output = exec('ls -ll); echo $output; And I can run the open command via Terminal, but I can't seem to run the open command via a PHP page using exec(). I've tried the permissions of the .app file at 777 and the open binary at 777. Any suggestions? I am trying to execute a command line tool, but am having a problem adding a variable to the line. Here is the code Code: [Select] $filename = "devices.txt"; $handle = fopen($filename, 'r'); while (!feof($handle)) { $devices = fgets($handle, 4096); $query = 'ipmitool -I lanplus -H 192.168.1.1 -U admin -P adminpass sdr list'; passthru($query); } flcose($handle); On this line I don't want to have the IP manually added like so. Code: [Select] $query = 'ipmitool -I lanplus -H 192.168.1.1 -U admin -P adminpass sdr list'; Instead I want to be able to insert the $devices variable which contains the values from the text file so it would look something like this: Code: [Select] $query = 'ipmitool -I lanplus -H $devices -U admin -P adminpass sdr list'; Problem is the command line tool does not run this way. How do I properly add the $devices variable so the command line tool ipmitool will run with its value? Thanks, Hello, I am mounting google drive to my raspberry pi with this command from command line; sudo gdfs -o allow_other /var/www/html/gdfs.creds /media/pi/gdrives İt is working from command line, but it is not work when i execute it from web browser. Here php content; shell_exec("sudo gdfs -o allow_other /var/www/html/gdfs.creds /media/pi/gdrives"); and i changed my sudoers file giving permission www-data. here is my sudoers file content # This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults env_reset Defaults mail_badpass Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL:ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL www-data ALL=NOPASSWD: ALL # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d Can anyone tell me what i am doing wrong ? Hi all, I need to create a button my page that when clicked will update my mysql table. I also need a command that will find 3 'x' values and update them accordingly, It needs to update the theme column in my model pictures table, Would something similiar like this work? Code: [Select] UPDATE theme SET name = '5' WHERE name = '1 or 2 or 4';[code] Does this make sense? Hi, I have a strange problem using the exec command. I have the following php code : <?php error_reporting(E_ALL); ini_set('display_errors','On'); $accountBase = "HORAIREMOBILE"; $primaryUser = "DUM"; $secondaryUser = "DUM"; $result = exec(escapeshellcmd("/home/evidian/utils/getAccount ".escapeshellarg($accountBase)." ".escapeshellarg($primaryUser)." ".escapeshellarg($secondaryUser)),$output,$return_val); echo $result; ?> When I execute the command from the CLI, with any user, it just works fine, and shows my the result (basically a JSON formated output). However, when I call the code frome the apache server, it simply returns nothing. Could anybody help me with this issue ? |