PHP - Server Crash At Execution.
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. Similar TutorialsHi I am select something from the DB and counting it. On the localhost on my own computer it works but on my server it crashes. Most likely for different versions of mysql / php!? Here is the code, is there some other ways to write this? so the server doesnt crash: $num = mysql_num_rows($result); $i=1; if($i < $num) { echo "<table border='1' width='100%'>"; echo "<tr><th>#</th><th>" . ucf(translate('country')) . "</th><th>" . ucf(translate('navn')) . "</th><th>" . translate('date') . "</th><th>" . ucf(translate('bodyweight')) . "</th><th>". translate('lifted') ."</th></tr>"; // keeps getting the next row until there are no more to get while ($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td align='center'>"; echo $i++; // Krasj?? echo "</td><td align='center'>"; echo "<div><img src='img/flags/16/". strtolower($row['user_country']) .".png' /></div> " . translate(ucf(getCountryName(strtolower($row['user_country'])))) . ""; echo "</td><td align='center'>"; echo "<a href='index.php?action=profile&sub=show&tid=". $row['training_id'] ."'>" . getNameFromId($row['user_id']) . "</a>"; echo "</td><td align='center'>"; echo formatDate($row['date'], $dateformat); echo "</td><td align='center'>"; echo r_nr2(calcFromKg($row['bodyweight'])). $w_metric; echo "</td><td align='center'>"; echo r_nr(calcFromKg($row['kg'])). $w_metric; echo "</td></tr>"; } echo "</table> <div class='fixed'> </div> </div> </div> <div class='fixed'> </div> <div id='footer'> <a id='gotop' href='#' onclick='MGJS.goTop();return false;'>" . translate('top') . "</a> <div align='center' id='copyright'>© " . translate('copyrightyear') . " " . translate('header_text'). " - " . translate('curversion') ." - <a href='index.php?action=contact'>" . translate('contact') ."</a> - <a href='index.php?action=about'>" . translate('about') . "</a> - " . translate('onlineusers'). ": " . getActiveUsers() . "<br /> </div>"; exit; } else { blablabla Versions: Local: php mysql 5.3 mysql 5.1.36 Server: php 5.29 mysql 5.0.87 I hope there is someone who sees something I have not seen he P hehe .. Thanks for the reply Here is one of those purely conceptual questions, which involves no code. I'm trying to create a select query which among other things, allows a user of a website to search other members who fall within a particular age range. I have a column in the table where the members' information are stored which records their ages. Which brings us to the problem. On any given day, a member's age may increase by one year compared to what it was the previous day, hence the need to update this column periodically. I can't think of any way to automatically update this column on a daily basis. So my solution is to run an initial update query every time a member tries to search other members based on age, which updates the age column for all other members, before running the select query which eventually retrieves the desired age range. This leads to the second problem. Imagine there are thousands of users using the website. At any given instance, there could be hundreds of members, trying to search others based on age. This means hundreds of users will be updating a single column (the age column) in one table at the same time. Is this feasible? Can it cause the server to crash? Or is there really a more reasonable way to do all of this? Thank you all for taking your time to read this. Appreciate any responses. I'm running one of those really dense zend-based frameworks with masses of recursion (Magento), and I'm getting a problem with reading/writing the session, before I deal with that I'm trying to find some feedback on where the issue is happening. I've got everything ( i know of ) switched on, error_reporting(E_ALL); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); + I'm using PHPStorm with Xdebug and I've got Php Exception breakpoint set, I'm watching the Phpstorm Output/Console/Terminal (don't quite know the difference) +var/log/Exception.log, but....It just hangs without telling me which line. Is this someting I've got to take on the chin with Php (I'm a relative newbie)? Or is there some way else? Debian/Php 7.3 I think this is the absolute best are to post this question. I hope it's not moved. Can you guys recommend any books that would give a very solid crash course in PHP5 OOP? Anything you've read and feel is worth it. I don't want to just go and pickup any first book i see. Thanks! Hi, I'm Chris, first time here, I usually post on stackoverflow but I think that this is a little bit more complex than usual.
I believe I really need a PHP expert to solve this issue. We have an application which is crawling the web. There's 2 main PHP scripts that are doing the work, using using proc_open, and exec() and running over a circular reference. Both scripts that compose the main structure are saving all and every single error on a custom error log, defined this way:
//error_log @ini_set('error_reporting', -1); @ini_set('log_errors','On'); @ini_set('display_errors','On'); @ini_set('error_log','/var/www/vhosts/xxx/xxx/resonance/such_a_mess'); The problem is simple, after running for some hours or days, the application stops crawling. And there's no error information at all on the error_logs that could explain the problem or the reason why it stopped. I've been trying to get more details using Newrelic and XHProf, no luck.- There's no HTTP server involved on the execution of the scripts as they are being executed like I mentioned, using exec() and proc_open: exec("sh -c \"$cmd | logger\" > /dev/null &"); It has been around 3 months on the same situation... and to be honest the only thing I want at this point is to see a fatal error on the logs, to understand what's going on... 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. 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 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. 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(); ?> I have a PHP web system that store in a windows server. In the system, there is a function for user to upload files to another server (Shared server in Unix). When i try to upload a file, it gives warning: Warning: move_uploaded_file(\\unixserver/sharedfolder/upload/test.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\wamp\www\upload\index.php on line 40 For your information, my username has been assigned in xxx's group that has access to read and write on that folder. Besides, i'm able to open,create and delete files on that folder's server manually (samba). The safe mode setting is off. Does anybody has any idea why this thing happen? I'm trying to make a simple website where people register to my website. When the user doesn't fill anything inside the boxes they get a message "Please fill all required fields" on the register.php page On my local host require_once works good. It shows up.
But when i upload the files to my sever the require_once does not show up on the register.php It just refreshes and i dont get the message "Please fill all required fields"
This is the code that works in local host but not in a live server <?php require_once 'messages.php'; ?>
Here is my full code
Register page: <html> <?php require_once 'messages.php'; ?> <br><br> <form action="register-clicked.php" method="POST"> Username:<br> <input type="text" name="usernamebox" placeholder="Enter Username Here"> <br><br> Email:<br> <input type="text" name="emailbox" placeholder="Enter email here"> <br><br> Password:<br> <input type="password" name="passwordbox" placeholder="Enter password here"> <br><br> Confirm Password:<br> <input type="password" name="passwordconfirmbox" placeholder="Re-enter password here"> <br><br> <input type="submit" name="submitbox" value="Press to submit"> <br><br> </form> </html>
Register clicked <?php session_start(); $data = $_POST; if( empty($data['usernamebox']) || empty($data['emailbox']) || empty($data['passwordbox']) || empty($data['passwordconfirmbox'])) { $_SESSION['messages'][] = 'Please fill all required fields'; header('Location: register.php'); exit; } if ($data['passwordbox'] !== $data['passwordconfirmbox']) { $_SESSION['messages'][] = 'Passwords do not match'; header('Location: register.php'); exit; } $dsn = 'mysql:dbname=mydatabase;host=localhost'; $dbUser='myuser'; $dbPassword= 'password'; try{ $connection = new PDO($dsn, $dbUser, $dbPassword); } catch (PDOException $exception){ $_SESSION['messages'][] = 'Connection failed: ' . $exception->getMessage(); header('Location: register.php'); exit; }
messages.php <?php session_start(); if (empty($_SESSION['messages'])){ return; } $messages = $_SESSION['messages']; unset($_SESSION['messages']); ?> <ul> <?php foreach ($messages as $message): ?> <li><?php echo $message; ?></li> <?php endforeach; ?> </ul> Edited Wednesday at 12:49 AM by bee65 Hi, I am not a PHP programmer. I took on a new client with a simple PHP site, without any databases. The site is up and running on the web. I would like to get it running on my local machine for further development. I have latest version of WAMP installed, running Apache version 2.2.11 and PHP version 5.3.0 I created a directory in the WAMP "www" project directory and it shows up there like it's supposed to when I browse to "localhost" Problem: The home page of website displays text but no, images, styles, footer, header, nav links, etc. Here is the code for the home page: <? define("NAV","home"); require_once('local/local.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>TITLE</title> <meta name="keywords" content=""> <meta name="Description" content=""> <? include("common/dochead.php"); ?> </head> <body onLoad="<? include('common/preloads.php'); ?>"> <!-- ============================ main ============================= --> <div id="main-frame"><div id="main" class="noCollapse"> <? include("common/sign.php"); ?> <div id="right-frame"> <? include("common/navigation.php"); ?> <div id="content-frame"> <div id="content"> <h1>Welcome</h1> <p>This is the content area. This is the content area. This is the content area. </p> </div><!-- end content --> </div><!-- end content-frame --> </div><!-- end right-frame --> <div class="clearFloats"></div> </div><!-- end main --></div><!-- end main-frame --> <? include("common/footer.php"); ?> </body> </html> Any help would be greatly appreciated. I have spent many hours on this. Regards Hi folks, I'm curious if I can for example, save a file from my server and it will save to all other servers - obviously if they accepted the connection first. It's for a software I developed and is almost complete and know there will be frequent updates to it. Instead of users downloading upates, I want the update files from my server to somehow synchronize to their server automatically? Anything called this?? Thanks for info. I've been using php for a while now to create forms, up until now i've always transmitted the form data to a new php document that then processes them. I wanna take this to the next level and start trying to process the data within the same document. I know this has something to do with checking if the submit button is pressed and then processing the submitted data but thats about as far as my knowledge goes. Can anyone help me out on how i can achieve this type of thing. The reason is that i've found a way to execute php code within a joomla 1.6 environment without having to use the iframe option. I know the iframe option may be easier in a way of doing things but its out of the question. The final fase of the php will output code that will trigger a specific joomla plugin to do some specific action. If i pull a php document via an iframe the plugin doesnt trigger as it only gets triggered after the joomla "afterRender" (or something" has executed. If i use the iframe option then that rendering never gets used so the plugin doesnt get triggered. So in a nutshell, i wanna create forms that submit data and that data gets processed in the same document (in this case joomla article). How do i go about doing this. Guys, why the following mysql stored procedure taking much more time comparing with firebird one?
1. MySQL stored procedure
CREATE DEFINER=`lxc`@`::1` PROCEDURE `insertData`(IN it INT) BEGIN declare i int Default 0; declare str char(4); declare p_hash int; myloop: loop set p_hash = round(rand() * 999); set str='book'; insert into test.users (name,password) VALUES (concat(str,'_',i+1),PASSWORD(p_hash)); set i = i+1; if (i = it) then leave myloop; end if; end loop myloop; endObject info: Table: users Columns: id int(10) UN PK AI name varchar(45) password char(41)Time: mysql> call insertData(10000); Query OK, 1 row affected (9 min 38.22 sec)2. Firebird Stored Procedure SET TERM ^ ; CREATE PROCEDURE INSERDATA ( IT integer ) --iteration number AS DECLARE VARIABLE i integer; BEGIN i = 0; while ( i < it ) do begin INSERT INTO PRODUCT( CODE,NAME,PASS) VALUES(:i, 'jazz_' || :i, fb_hash(round(rand() * 999))); i = i + 1; end END^ SET TERM ; ^ COMMIT;Object Info: Table: product columns CODE integer, NAME varchar(45), PASS CHAR(41)Time: ( for 10 000 records it takes less than 1 sec for execution) Executing statement... Statement executed (elapsed time: 0.063s). 31464 fetches, 11084 marks, 0 reads, 0 writes. 10000 inserts, 0 updates, 0 deletes, 5 index, 0 seq. Delta memory: 24264 bytes. PRODUCT: 10000 inserts. 0 rows affected directly. Total execution time: 0.151s Script execution finished.Do you see something wrong in mysql stored procedure code? jazz. Edited by jazzman1, 31 July 2014 - 03:21 PM. Code: [Select] <?php //Start session session_start(); //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect($hostname, $username, $password); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db($dbname); if(!$db) { die("Unable to select database"); } //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $login = clean($_POST['login']); $password = clean($_POST['password']); //Input Validations if($login == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'Password missing'; $errflag = true; } //If there are input validations, redirect back to the login form if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) { echo '<ul class="err">'; foreach($_SESSION['ERRMSG_ARR'] as $msg) { echo '<li>',$msg,'</li>'; } echo '</ul>'; unset($_SESSION['ERRMSG_ARR']); } session_write_close(); header("location: index.php"); exit(); } //Create query $qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'"; $result=mysql_query($qry); //Check whether the query was successful or not if($result) { if(mysql_num_rows($result) == 1) { //Login Successful session_regenerate_id(); $member = mysql_fetch_field($result); $_SESSION['SESS_MEMBER_ID'] = $member['member_id']; $_SESSION['SESS_FIRST_NAME'] = $member['firstname']; $_SESSION['SESS_LAST_NAME'] = $member['lastname']; session_write_close(); header("location: member-index.php"); exit(); }else { //Login failed header("location: login-failed.php"); exit(); } }else { die("Query failed"); } ?> This is my login execution script and when i run it, i get this - Fatal error: Cannot use object of type stdClass as array in /home/a8029060/public_html/login-exec.php on line 75 Please any help :/ 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
I have this one issue. While logging in into our system, we call a routine called getToken(). This calls a routine on another server (used to be able to securely access documents). The issue we have is if that other server goes down, this call fails, and the user isn't able to login. I want to make it so that even if the other server goes down, users can still login and access our system (just not documents). I know that I can't prevent fatal errors or even ignore them, correct (even with set_error_handler)? Any thoughts? It's a simple call, here's all it is: require_once('include/utils.php'); $token=getToken(); Hello, I have the following code: <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" name="loginform" id="loginform" class="niceform" "> The problem is that the code isn't executed after the action="<?php echo $_SERVER['REQUEST_URI']; ?>" so the result doesn't have css. Any ideas? |