I have a PHP script that I don't want anyone to be able to run through their browser.
It sends emails and is called via curl by my server's cron, yet needs to be in the public www directory. What permissions or owner do I need to set the file to to allow only my server's curl to execute (or do I mean read) the file?
I'm on centos.
Thanks!
I would like to write a script that I can e-mail or that it can receive and e-mail and then do something depending on instructions in that e-mail, but I have no idea where to start with this. Is this possible with PHP?
Currently I have
‘customer_id’ . ‘+’ . ‘operator_domain’ pattern,
e.g., '123456789'.'+'.'987654321'
Desired Pattern:
‘customer_id.operator_domain’ pattern, e.g., '123456789987654321'
How can I achieve this using in php ?
I have a PHP script that uses standard POST variables like $_POST['email']. When a form on a remote server sends a POST request to my script, it doesn't receive the POST data at all. It's not in $_REQUEST either.
Thanks for any help!
I was wondering how can I limit a users input like HTML maxlength attribute but with PHP, example would be nice? Is MySQL varchar(255) one way to limit a users character input? What are the cons of just counting on MySQL to do this?
Are there any working packages to change a linux user passwords using PHP?
I've tried using PECL:PAM but theres an error when it tries to change the password.
Hey guys,
I have this script working fine with OAuth, but I accidentally nuked my 350 API hits with a stupid while statement :( I'm trying to get data from the Twitter API without OAuth, I can't figure it out (still pretty new), heres what I have
<html>
<body>
<center>
<hr />
<br />
<table border="1">
<tr><td>ScreenName</td><td>Followed back?</td></tr>
<?php
//twitter oauth deets
$consumerKey = 'x';
$consumerSecret = 'x';
$oAuthToken = 'x';
$oAuthSecret = 'x';
// Create Twitter API objsect
require_once("twitteroauth.php");
$oauth = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);
//get home timeline tweets and it is stored as an array
$youfollow = $oauth->get('http://api.twitter.com/1/friends/ids.json?screen_name=lccountdown');
$i = 0;
//start loop to print our results cutely in a table
while ($i <= 20){
$youfollowid = $youfollow[$i];
$resolve = "http://api.twitter.com/1/friendships/exists.json?user_a=".$youfollow[$i]."&user_b=jwhelton";
$followbacktest = $oauth->get($resolve);
//$homedate= $hometimeline[$i]->created_at;
//$homescreenname = $hometimeline[$i]->user->screen_name;
echo "<tr><td>".$youfollowid."</td><td>".$followbacktest."</td></tr>";
$i++;
}
?>
</table>
</center>
</body>
</html>
Neither of the two Twitter functions require authentication, so how can I get the same results?
Thanks guys,
Dex
I cant seem to send an email using PHP's mail(). I have also tried PHPMailer and Swiftmail with no success. However, the following command on the server delivers mail successfully.
cat test.txt | mail -s "test mail" [email protected]
Is there a way to trace where the problem is coming from? mail() just seems to return true or false.
I have a PHP application that sends email using the pear Mail function. Unfortunately all my emails end up in the junk folder.
Can i get a checklist for things i should do to make sure my emails are recieved correctly.
Thank you
I am building a PHP and MySQL search as so
SELECT * FROM Properties WHERE Locaion = 'Liverpool'
I want to count how many of each property type there are and display them at the side of the page to use as filters (like Rightmove.co.uk).
This is what I am have come up with but can't get it to work
SELECT *,
count(PropertyType = 'house') AS HouesTotal,
count(PropertyType = 'Apartment') AS ApartmentTotal
FROM Properties WHERE Location = 'Liverpool'
Can anyone help?
So,
I can run the following statements from within mysql itself successfully.
SET @fname = 'point1';
SELECT * FROM country WHERE name=@fname;`
But when I try to pass the query through php like this and run it, I get an error on the second line
$query = "SET @fname = 'point1';";
$query .= "SELECT * FROM country WHERE name=@fname;";
I want to be able to redirect all requests to navigate to an image to a php script which will then show the image but with a nav bar at the top. However using rewrite (im using IIS btw) means that I can't embed those images.
Any help will be greatly appreciated.
hi all,
i found this to check if file exist. is there a way how to check if record exist first?
php.net
i want to check if record exist first, if exist then do update, else do insert. i do understand how to make a queries for select and insert and i dont have problem with it.
if(record exist) {
update query}
else
{ insert query}
Hi, I am looking for ideas for how I can stop external scripts connecting with my site. I'm looking for the same kind of idea behind Google. As in if a certain amount of requests are made per a certain amount of time then block the IP address or something. I thought there maybe a htaccess solution if not, I will write a PHP one.
Any ideas or links to existing methods or scripts is much appreciated.
Regards
Phil
Hi people,
I am trying to figure out how to submit a form in a page being accessed by Ajax?
here are some code snippets to help demonstrate what i am trying to say.
HTML BODY - THIS IS WHAT THE USER WILL SEE.
<html>
<head>
<script language="javascript" src="linktoajaxfile.js">
</head>
<body onLoad="gotoPage(0)">
<div id="fillThis">
</div>
</body>
</html>
AJAX FILE
var xmlhttp
function gotoPage(phase)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="pageofstuffce.php";
url=url+"?stg="+phase;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("fillThis").innerHTML=xmlhttp.responseText;
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
PAGE OF DATA
<?php
$stage = $_GET['stg'];
if($stage == 0)
{
echo '<a onClick="gotoPage(1)">click me</a>';
}
elseif($stage == 1)
{
<form>
<input type="text" name="name">
<input type="submit" name="submit">
</form>
}
elseif(somehow can reach here)
{
show data from form.
}
?>
Can anyone perhaps help me get past the form and display the data in the same page?
Also, i have looked around, and i don't think anything around has what i need... correct me if i'm wrong though :)
Thanks in advance, and i hope i didn't put in too much detail :)
Dronnoc
EDIT
Forgot to mention what I've tried; I have tried submitting the form to itself (same file) and that destroyed the ajax link, and opened the page. i have also tried just having the button move the page onto another step, but the $_POST variable is empty... i am at a loss, so does anyone else have any ideas?
I have searched but could not get solution on this issue.
I am working on an application which will generate unknown number of items and have users select the quantity from a drop down against each item. Eg.
Item(s) | price | Select qty
Rice 23 3
Beans 22 4
Eggs 52 5
...
...
...
unknown
Please, how can I capture the above in an array and also calculate the total value for all selected items and corresponding fees?
I have the following HTML code:
<form id='form1' name='form1' method='post' action='item_calc.php'>
<?php
.....
while($t_row = mysql_fetch_assoc($get_items)) {
echo "<p><label>$t_row['$item_name']
<input type='text' READONLY name='item_price[]' value='$t_row['$item_price']' /></label>
<input type='text' READONLY name='item_fees[]' value='$t_row['$item_fee']' />
<select name="item_qty">
<option value="1">
<option value="2">
<option value="3">
<option value="4">
<option value="5">
</select>
</p><p>";
}
echo "<label><input type='submit' name='submit' value='Submit' /></label></p>
</form>";
Please, how can I get item_price[] + item_fees[] * item_qty for all selected items?
This is what I have tried:
for ($i = 0; $i < count($_POST['item_price']); $i++) {
// Do something here with $_POST['checkbx'][$i]
foreach ($_POST['item_fees'] as $tkey => $tvalue) {
//echo "Key: $tkey; Value: $tvalue<br>";
}
foreach ($_POST['item_price'] as $pkey => $pvalue) {
//echo "Key: $pkey; Value: $pvalue<br>";
}
$total = $tvalue + $pvalue;
}
echo $total;
Is it possible to assign php array in MySQL IN() function? for example,
$numbers = array('8001254656','8886953265','88864357445','80021536245');
$sql = mysql_query("SELECT * FROM `number_table` WHERE `number` IN ($numbers)");
Any Ideas?
Thanks,
I would like to do the following in php :
setcookie('name', $value, $Cookie_Expiration,'/');
then some action
header("location:http://www.example.com")
the problem is that I get :
warning: Cannot modify header information - headers already sent by (...etc )
could you please let me know what i am doing wrong and if there is a way to do this?
by the way , this code is before any output is made ...the cookie setting part works fine on its own and so does the redirection code....the combination fails
thank you
I followed the following article
http://blog.sptechnolab.com/2011/02/10/android/android-connecting-to-mysql-using-php/
I am able to execute my php file. I executed it individually and its working fine. The problem is in the android execution part. Am posting the Log Cat for the error am facing. Tried putting in a List View with id "list" but the error stil
10-28 16:08:27.201: E/AndroidRuntime(664): **FATAL EXCEPTION: main**
10-28 16:08:27.201: E/AndroidRuntime(664): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.city/com.example.city.City}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
10-28 16:08:27.201: E/AndroidRuntime(664): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
10-28 16:08:27.201: E/AndroidRuntime(664): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
10-28 16:08:27.201: E/AndroidRuntime(664): at android.app.ActivityThread.access$600(ActivityThread.java:123)
10-28 16:08:27.201: E/AndroidRuntime(664): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
10-28 16:08:27.201: E/AndroidRuntime(664): at android.os.Handler.dispatchMessage(Handler.java:99)
10-28 16:08:27.201: E/AndroidRuntime(664): at android.os.Looper.loop(Looper.java:137)
10-28 16:08:27.201: E/AndroidRuntime(664): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-28 16:08:27.201: E/AndroidRuntime(664): at java.lang.reflect.Method.invokeNative(Native Method)
10-28 16:08:27.201: E/AndroidRuntime(664): at java.lang.reflect.Method.invoke(Method.java:511)
10-28 16:08:27.201: E/AndroidRuntime(664): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-28 16:08:27.201: E/AndroidRuntime(664): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-28 16:08:27.201: E/AndroidRuntime(664): at dalvik.system.NativeStart.main(Native Method)
10-28 16:08:27.201: E/AndroidRuntime(664): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
10-28 16:08:27.201: E/AndroidRuntime(664): at android.app.ListActivity.onContentChanged(ListActivity.java:243)
10-28 16:08:27.201: E/AndroidRuntime(664): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:254)
10-28 16:08:27.201: E/AndroidRuntime(664): at android.app.Activity.setContentView(Activity.java:1835)
10-28 16:08:27.201: E/AndroidRuntime(664): at com.example.city.City.onCreate(City.java:35)
10-28 16:08:27.201: E/AndroidRuntime(664): at android.app.Activity.performCreate(Activity.java:4465)
10-28 16:08:27.201: E/AndroidRuntime(664): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-28 16:08:27.201: E/AndroidRuntime(664): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
10-28 16:08:27.201: E/AndroidRuntime(664): ... 11 more
Hi everyone,
Will there be any measurable performance difference when passing data as values instead of as reference in PHP?
It seems like few people are aware of that variables can be passed as values instead of references. Is this common sense or not?
I have an array like
Array
(
[0] => A
[2] => B
[4] => C
[6] => D
)
I want to remove the first element and then re-index array to get the output
(
[0] => B
[1] => C
[2] => D
)
Which PHP function i need to use?
Hi everyone,
I am in the middle of building a cache layer for the Redis DB to my application and I have come to the point where's it's about to take care of arrays.
I wonder if there's any good (high performance!) way of controlling an string to be serialized or not with PHP?
Thanks a lot!