PHP - R Code Execution From Php Fails Only In Browser And Not In Terminal
I am trying call an R batch file inside php script from browser. The R script basically generate an imgae and save in a folder. Unfortunately, I could call the R within php (means that no image is saved in the folder) using BROWSER. But when I run the php script from the commadline, it works and image is saved in the folder.
<?php exec("Rscript /var/www/html/phil/figs/map.R"); ?>Execuition of following R batch code and php codes work and save image in the specified folder from the terminal. 58A-UD3R:~$ php /var/www/html/phil/x.php 58A-UD3R:~$ Rscript /var/www/html/phil/figs/map.RI totally in confusion why browser cannot successfully save image. Or is there anythinng need to be change in server for generating image? Anyone please help me for solving this probelm. Thank You.. Similar TutorialsI have a very weird problem on my PHP5.3/Apache/MySQL based system on WinXp Pro. I have written php script which basically scans every directory in my local hard disc, checks which files are images, sets a counter of the number of images found per folder and saves this count in a MySQL table. To put you in the picture, we are talking about 1000 folders with about 8-10pics each on average 9000 files. On the previous PHP 5.1 / IIS system, (same PC) this used to work moderately well (took a nice 6 mins) and I had to include the command set_time_limit of about 3seconds in the looping to avoid execution timeout failures. (also worked by setting a high value of 10mins before the loopping) ANyway, now I run the exact same script on the new Php5.3 and have the problem that the code starts operating quite fast and gradually it slows and slows until eventually it is dead slow and have to quit internet explorer. For exampe, the first 3000 files are scanned in just 60seconds, then the next 1000 in the next 4 mins, and eventually drops to about 100files or less files per minute. I also noticed that the CPU consumption of iexplorer.exe is 90-99%, and the window of Internet explorer is very slugish with a temp '(not responding)' messages on the top window bar. WHat can I do and test? Is it the code itself, the PHP5.3 or something in php.ini or apache conf. file? Buffers? memory? WHat? gonna crazy! basically, the code scans a dir (location of dir taken from Mysql) puts file contents in an array, analyse the array for .jpg/.gif (and other parameters specific to pics, counts the valid pic files in a variable, puts this in a MySql databse, loops for next folder. The code is a kind of tool to have a count of my pics in my folders and never used remote server/online but only local. Thanks for your time Dear Friends I want to execute a php code when my session has been destroy or demoinshed, I need a help regarding this kindly help me. Best Regards Habib Hello, I have a contact form that is not working. It just keeps providing the failed delivery message specified in the contact. php file. Any help would be much appreciated. Thanks, Code: [Select] <?php $field_department = $_POST['cf_department']; $field_message = $_POST['cf_message']; $mail_to = 'blah@blah.com'; $subject = 'Website Feedback'; $body_message .= 'Addressed to: '.$field_department."\n"; $body_message .= 'Message: '.$field_message; $mail_status = mail($mail_to, $subject, $body_message); if ($mail_status) { ?> <script language="javascript" type="text/javascript"> alert('Thank you for your feedback.'); window.location = 'contact.html'; </script> <?php } else { ?> <script language="javascript" type="text/javascript"> alert('Message failed. Please, send an email to blah@blah.com'); window.location = 'contact.html'; </script> <?php } ?> ------------------------------------------------ Code: [Select] <form action="contact.php" method="post"> <ol><li> </li><li> <label for="department">Addressed to:</label> <input type="text" name="cf_department" class="text" /> </li><li> <label for="message">Your Message:</label> <textarea name="cf_message"rows="10" cols="50"></textarea> </li><li> <input type="submit" value="send" /><input type="reset" value="Clear"/> <div class="clr"></div> </li></ol> </form> "BACK" or REFRESH: Preventing database interaction / code execution how to prevent database interaction / code execution when user presses back or refresh button? can i detect? can i disable back/refresh? Hello house, I am new to coding, I have a project about generating school terminal results and using pin to check results in codeigniter framework. Any help will be appreciated. Thanks
Hi everyone, i'm trying to get it so when i visit my webpage called start.php it executes the command (/bigbrotherbot start) in the terminal which then should start the process on my linux machine. I'm currently using this code Code: [Select] <?php shell_exec('sudo /bigbrotherbot start'); ?> This script doesn't appear to do anything though. I'm very new to php and would really appreciate the help. P.S the file bigbrotherbot is the bash script which works if i actually go to the terminal myself and type /bigbrotherbot start yet when i try to make the php do it it doesnt do anything. any ideas? The fancy-looking quotes won't insert into my DB, so I'm trying to convert them to %93 & %94 or normal quotes.
Nothing I've tried works.
Code:
$fancy=" “test” "; $fixed=htmlentities($old, ENT_QUOTES); echo "fancy: $fancy<br>"; echo "fixed: $fixed"; Results: fancy: “test” fixed: I want $fixed to be %93test%94, or even "test" would work. Edited by rwmaho, 18 October 2014 - 01:28 PM. Code: [Select] <?php if (eregi("MSIE",getenv("HTTP_USER_AGENT")) || eregi("Internet Explorer",getenv("HTTP_USER_AGENT"))) { Header("Location: http://mysite.com/ie_reject.html"); exit; } ?> How would i make users who are using Safari get redirected like in this example would i use this Code: [Select] <?php if (eregi("SAFARI",getenv("HTTP_USER_AGENT")) || eregi("Safari",getenv("HTTP_USER_AGENT"))) { Header("Location: http://mysite.com/safari_reject.html"); exit; } ?>If so how would i add these together in one statement to stop both accessing my site and get redirected so I am a beginner and have this very beginner-level PHP doubt. I have some basic code which is supposed to fetch the contents of a table and then display them in a table. What it's actually showing is the PHP code itself, instead of the table contents, in the browser. I'm using WAMP When I searched the net reasons given were 1. using short tags, and 2. some configuration problem. I haven't used short tags, and my wamp installation was done a long time back. Moreover this problem is not occuring all the time, even when I run the same code. Many thanks if anyone can suggest anything helpful. Sorry if I posted in the wrong place (new here). Hi, I came across this code that detects a user's browser and I don't understand parts of it. Here is the code below. Code: [Select] $agent = $_SERVER['HTTP_USER_AGENT']; if ( strpos(strtoupper($agent), 'MSIE')) { print "Internet Explorer"; } else if (strpos(strtoupper($agent), 'FIREFOX')) { print "Firefox"; } else if (strpos(strtoupper($agent), 'KONQUEROR')) { print "Konqueror"; } else if (strpos(strtoupper($agent), "LYNX")) { print "Lynx"; } else { print $agent; } and here is the part I don't understand. Code: [Select] if ( strpos(strtoupper($agent), 'MSIE')) I know that strtoupper makes all letters uppercase, and that strpos returns the position of the string within the larger string, but I don't know why they are in an if statement. Any help or explanation is greatly appreciated. Thanks. Derek Hello, I had updated from PHP 5.x to PHP 7.2. The issue is that my cron files are not running now. The sites based on php 5 code runs without any issues. The cron files when run from cmd are producing errors like to change to mysqli. Any solutions? Thanks. Hi there, I've looked into the PHP superglobal array $_SERVER, but could not find a variable that stores the plugins a client has on his/her browser such as firefox and google chrome. The point here is to detect if a user has hacking addons such as firebug and inspect element installed, and displays an error message telling the user to disable such plugins in order to access site content. Is it possible to accomplish such tasks? Please help. Is there a way in php to not execute the whole script if there is error on the script? For example: Code: [Select] <?php execute script here; .......... ........... [b] error encounter here[/b]. -> error is not logical execute script ............. ............. ?> I don't want to execute the above script... tnx everyone. Hi,
I have this code:
<div id="pics"> <?php if (count($itemRow['pics']) == 0) { ?> <img src="<?php h("{$www_base}/none.jpg"); ?>" class="pic active" /> <?php } else { ?> <?php for ($i = 0; $i < count($itemRow['pics']); $i++) { ?> <img src="<?php h(getThumbnail($itemRow['site'], $itemRow['pics'][$i])); ?>" class="thumbnail<?php if ($i == 0) e(" active"); ?>" picnum="<?php h($i); ?>" /> <?php } ?> <div style="clear:both;"></div> <br /> <?php for ($i = 0; $i < count($itemRow['pics']); $i++) { ?> <a target="_blank" href="<?php h(getPicture($itemRow['site'], $itemRow['pics'][$i])); ?>"> <img src="<?php h(getPicture($itemRow['site'], $itemRow['pics'][$i])); ?>" class="pic<?php if ($i == 0) e(" active"); ?>" /> </a> <?php } ?> <?php } ?> </div>This code practically take a picture and post it on my website, but the problem is that is also take the superfish advertisement, that I can see only in the html source. <div id="similarproducts_inimg" class="__similarproducts similarproducts_inimg generic generic" style="left:15px; top:465px;"><div class="container"><div class="explore_button _open_full_ui" style="height:100px; background-image: url('http://www.superfish.com/ws/images/inimg2/explore_en.png');" data-report-action="explore click"><div class="label"></div></div><a class="item free_shipping _merchant_click" target="_blank" href="http://www.........................</div></div>How I can block a specific DIV to be created. I try some java-script and no success until now. Some other solutions? hey guys... below is my code... when i hit the "submit" button the browser displays the php file rather than writing to the db... can anyone see what im doing wrong .. thanks Code: [Select] <table width="300" border="0" align="center" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="post" action="insert_ac.php"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td colspan="3"><strong>Insert Data Into mySQL Database </strong></td> </tr> <tr> <td width="71">Name</td> <td width="6">:</td> <td width="301"><input name="name" type="text" id="name"></td> </tr> <tr> <td>Lastname</td> <td>:</td> <td><input name="lastname" type="text" id="lastname"></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form> </td> </tr> </table> Code: [Select] <?php $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="test_mysql"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Get values from form $name=$_POST['name']; $lastname=$_POST['lastname']; $email=$_POST['email']; // Insert data into mysql $sql="INSERT INTO $tbl_name(name, lastname, email)VALUES('$name', '$lastname', '$email')"; $result=mysql_query($sql); // if successfully insert data into database, displays message "Successful". if($result){ echo "Successful"; echo "<BR>"; echo "<a href='insert.php'>Back to main page</a>"; } else { echo "ERROR"; } // close connection mysql_close(); ?> Hello, I am developing an account manager for our local network and I want people to be able to login to my website and change their UNIX & Mailbox password. These people have SSH access so that is why the UNIX passwd should also be changed. So what I want to do is get the values $username, $currentpwd , $newpwd and $newpwdcnfrm from the HTML form and execute the following shell commands : Quote su -l $username passwd Enter current UNIX Passwd : $currentpwd Enter new UNIX Passwd : $newpwd Confirm UNIX Passwd : $newpwdcnfrm The problem here is, passwd takes old and new passwords as input, not as command parameters. So I cant just do shell_exec("passwd $currentpwd $newpwd $newpwdcnfrm") ; Do you guys know how to give input to the command? thanks. Btw : Please do not argue about the security issues. I am aware of everything and I am perfectly sure that the script will run securely. i wanna put condition that if ($signupbonus > 0.00) then following should not be executed <font size="3" color="red"><b>Referral bonus: <font color="green" size="4">$<? echo $signupbonus; ?></font></b></font><br><br> please help Hello, i've been coding a CLI php mailer which i'm using with a webshell. My problem shows up when i execute my mailer, the hole server crash or in the best case scenario it slows down a lot. In the same folder that my script was executing a huge error log appears with this error repeated: Quote PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-zts-20060613/sqlite.so' - /usr/local/lib/php/extensions/no-debug-zts-20060613/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-zts-20060613/pdo_mysql.so' - /usr/local/lib/php/extensions/no-debug-zts-20060613/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-zts-20060613/ixed.5.2ts.lin' - /usr/local/lib/php/extensions/no-debug-zts-20060613/ixed.5.2ts.lin: cannot open shared object file: No such file or directory in Unknown on line 0 I'm not getting why this happens since i just use normal functions like mail(), fread(), etc. I'm not using any sql function or anything like that. Any clues? Another non related thing i wanted to ask was: Is it possible to make an "interactive" cli script? I mean using a similar function like getc() in C or something. Hi All,
I'm hoping somebody would be able to help me with a performance issue I'm having with a bit of code I've written.
The setup:
Client request arrives on Apache2 reverse proxy over HTTPS. SSL is offloaded and proxy initiates connection to backend development web server over standard HTTP. The website is being developed using HTML5 syled with CSS, Javascript (to dynamically show counters on message text area, perform client side validation for browsers that do not support the build in HTML5 input validation) and PHP for server side validation and form submission (sends email to webadmin).
The development web server is located in a LXC container on the production web server. The host server presents the "public" IP address to the physical network and uses UFW to NAT all traffic inbound and outbound from the development website to trick the network into thinking that the server is on the physical network (Only way to get it routeable across the rest of the network).
The problem:
On form submission, if I intentionally leave the fields blank and turn off client side validation, the script echos "An error occured in your form, please check to make sure that all relevent fields are filled in!!!". This response returns in 16.50ms with a latency of 34.92ms. The POST appears instantly in the Apache2 logs less than a second after I submit the form.
If I submit the form with all fields (Name, Email, Phone, Website, Subject and Message), it takes 60 - 65 seconds before Apache logs the POST has arrived. I'm not entirely sure why its taking this long for the server to receive the content. GET Requests are pretty much instant as I would expect. Could this be an issue with inefficient scripting that maye be causing this type of delay? This issue occurs regardless of whether I use firefox or Safari.
Could this be a result of inefficient scripting? Using timelines in Safari and on form submission with content, I get 1.0min latency with an actual duration/script run time of 5.336ms. Where would this latency be coming from? Standard GET requests for HTML and CSS content is instant, next to no latency but once the Payload increases in size, it seems like I run into the issue.
Any views, thoughts or possible things to try would be hugely appreciated. I'm learning the ropes with scriping at the moment but this high latency, as a hunch, appears to be server related. Happy to upload the submit.php script and web form if it will help.
Many Thanks,
A
|