Good Day
I am not sure if this is possible but any advice would be greatly be appreciated.
I have a code in PHP as below and would like to add additional PHP code Not sure how to explain it but maybe if I show code it would make some sence.
<?php
//Clickatell login
$user = "##";
$password = "##";
$api_id = "##";
$baseurl ="http://api.clickatell.com";
$text = urlencode("Recovery Assist Panic Activated (BETA TEST VERSION");
$to = "'0827910119'";
?>
The above is the current code I have with some additional extra's not required here. I want to add the following to this code as part of Sitelok page manager
<?php
//Clickatell login
$user = "##";
$password = "##";
$api_id = "##";
$baseurl ="http://api.clickatell.com";
$text = urlencode("Recovery Assist Panic Activated (BETA TEST VERSION");
<?php if (sl_ismemberof("RecAssist")){ ?>
$to = "'0827911119'";
<?php } ?>
<?php if (sl_ismemberof("Gold")){ ?>
$to = "'0827952558'";
<?php } ?>
?>
The "is a member of" is part of the sitelok code to exclude on HTML where a person does not have access to. I am not sure if I can run another inside the one running already. I know this can be done with IF and ELS most prob but the coding for the amount of groups will just be too much so hoped that somehow I can use the Sitelok section
Why not just use an if statement?
e.g.
<?php
//Clickatell login
$user = "##";
$password = "##";
$api_id = "##";
$baseurl = "http://api.clickatell.com";
$text = urlencode("Recovery Assist Panic Activated (BETA TEST VERSION");
if (sl_ismemberof("RecAssist")){
$to = "'0827911119'";
} elseif (sl_ismemberof("Gold")) {
$to = "'0827952558'";
}
?>
The best an most maintainable way to achieve this would be to define all of your groups or w/e in an associative array and loop through it because it will be the most maintainable.
<?php
//Clickatell login
$user = "##";
$password = "##";
$api_id = "##";
$baseurl = "http://api.clickatell.com";
$text = urlencode("Recovery Assist Panic Activated (BETA TEST VERSION");
$groups = array(
"RecAssist" => "0827911119",
"Gold" => "0827952558",
);
$to = "";
foreach($groups as $k=>$v)
{
if(sl_ismemberof($k)) // $k is the RecAssist or Gold or w/e
{
$to = "'$v'"; // $v is those digits
// if $groups were to have 100 items or even 1,000 then there is no need to run sl_ismemberof() on the remaining items once we found what we are looking for. It would be a waste of time.
break; // break out of our loop
}
}
echo $to;
?>
Related
So i'm trying pull data from my MySQL server here's my php code it want show none of the data i need help
<?php
$action = $_GET['action'];
$id = $_GET['id'];
$myID = $_GET['memberID'];
// Load Servers
$loadServers = $db->fetchAll("SELECT * FROM servers WHERE id = ? AND memberID = ?", array($id, $myID));
if($loadServers) {
foreach($loadServers as $loadServer) {
$id = $loadServer['id'];
$serverName = $loadServer['serverName'];
$serverType = $loadServer['serverType'];
$OS = $loadServer['OS'];
$hostName = $loadServer['hostName'];
$serverNode = $loadServer['serverNode'];
$IP = $loadServer['IP'];
}
}
?>
i don't know what i'm doing wrong can somebody help me.
So when i was grabbing the data from the MySQL server i had add on to the link i had set this how my link look like
Link Before
listserver.php?serverID=<?php echo $serverID;?>
Link Now
listserver.php?serverID=<?php echo $serverID;?>&memberID=<?php echo $memberID;?>
thank guys for the help i had to really look at my code in fix it
Hi there I'm trying to write a .php file using this code, server replying this error : syntax error, unexpected '0' (T_LNUMBER) in
I wanna know how can I write integer in php file as you can see
$status1 = \''0'\';
This code having problem, anybody please tell me what to do.
<?php
if(isset($_POST['user1'])){
$data = urldecode('%3C').'?php
$user1 = \''.$_POST['user1'].'\';
$pass1 = \''.$_POST['pass1'].'\';
$status1 = \''0'\';
$user2 = \''.$_POST['user2'].'\';
$pass2 = \''.$_POST['pass2'].'\';
$status2 = \''0'\';
$user3 = \''.$_POST['user3'].'\';
$pass3 = \''.$_POST['pass3'].'\';
$status3 = \''0'\';
$user4 = \''.$_POST['user4'].'\';
$pass4 = \''.$_POST['pass4'].'\';
$status4 = \''0'\';
$user5 = \''.$_POST['user5'].'\';
$pass5 = \''.$_POST['pass5'].'\';
$status5 = \''0'\';
$user6 = \''.$_POST['user6'].'\';
$pass6 = \''.$_POST['pass6'].'\';
$status6 = \''0'\';
$user7 = \''.$_POST['user7'].'\';
$pass7 = \''.$_POST['pass7'].'\';
$status7 = \''0'\';
$user8 = \''.$_POST['user8'].'\';
$pass8 = \''.$_POST['pass8'].'\';
$status8 = \''0'\';
$user9 = \''.$_POST['user9'].'\';
$pass9 = \''.$_POST['pass9'].'\';
$status9 = \''0'\';
$user10 = \''.$_POST['user10'].'\';
$pass10 = \''.$_POST['pass10'].'\';
$status10 = \''0'\';
?'.urldecode('%3E');
$fx=fopen('datauser.php','w');
fwrite($fx,$data);
fclose($fx);
if($fx === false) {
header("Location: ./tokensettings.php?save=err");
}
else {
header("Location: ./tokensettings.php?save=success");
}
}
?>
Thank you so much.
Here is how my form looks like.
If you still want to do it your way you need to use the \ correctly for each ' to be included in the string even those in [ ] - not saying the final string produced would actually work but it is based on your code and my best guess at your desired result
<?php
$string1=' \'\'.$_POST[\'user1\']\'\';';
$string1=$string1.'\'\'0\'\';';
echo $string1;
?>
The whole urlencoding stuff is not needed at all, your quoting and escaping is messy and incorrect. and why not simply use file_put_contents? Use HEREDOC to avoid messy escaping.
file_put_contents('datauser.php', <<<CONTENT
<?php
\$user = '{$_POST['user']}';
\$pass = '{$_POST['pass']}';
\$status = '0';
CONTENT
);
but if you really want to use files as data storage, I would encourage you to save it in a data format like xml or json instead of writing php.
// save data to file ($_POST used as example...)
file_put_contents('user.json', json_encode($_POST));
// read data
$data = json_decode(file_get_contents('user.json'));
I was amazed I didn't found answer on Google for this answer.
So basically I have a PHP code which have to be stored in a variable as a string. Unfortunately PHP recognize the opening and ending tag not as a string but a PHP code... I want it as a string :)
$settings_string =
'
<?php
//Locker ID
$userToSearch = '.$_POST["usertosearch"].';
//User Folder
$userFolder = '.$folder.';
//User Link
$userLink = '.$_POST["userlink"].';
// Username and pass
$affiliateuser = '.$_POST["affiliateuser"].';
$affiliatepassword = '.$_POST["affiliatepassword"].';
?>
';
you can use like this.
if u tell your purpose. so i can give you better than this.
$settings_string ='
<?php
//Locker ID
$userToSearch = \'.$_POST["usertosearch"].\';
//User Folder
$userFolder = \'.$folder.\';
//User Link
$userLink = \'.$_POST["userlink"].\';
// Username and pass
$affiliateuser = \'.$_POST["affiliateuser"].\';
$affiliatepassword = \'.$_POST["affiliatepassword"].\';
?>
';
Now you have to use like this
$file = fopen('file_name.php', 'w');
fwrite($file, $settings_string);
If you want the value of the $_POST injected in there you still need to quote it properly in the output.
$settings_string =
'
<?php
//Locker ID
$userToSearch = "'.$_POST["usertosearch"].'"; //add them quotes!!!!
//User Folder
$userFolder = "'.$folder.'";
//User Link
$userLink = "'.$_POST["userlink"].'";
// Username and pass
$affiliateuser = "'.$_POST["affiliateuser"].'";
$affiliatepassword = "'.$_POST["affiliatepassword"].'";
?>
';
I'll assume $_POST["usertosearch"] = 'user' currently in your output would be this.
$userToSearch = user;
When instead you want
$userToSearch = "user";
Above you will see the added double quote, to properly quote the strings in the output file. That file still has to have valid syntax.
As a note, if any of the post values contain " your gonna have issues, unless you do addslashes() for them.
For example
$userLink = "'.$_POST["userlink"].'";
Assume this is $_POST["userlink"] = 'link' OR
$userLink = "link";
See the issue with that. When you'll want this
$userLink = "link";
Your looking for eval
<?php
$settings_string ='
//Locker ID
$userToSearch = '.$_POST["usertosearch"].';
//User Folder
$userFolder = '.$folder.';
//User Link
$userLink = '.$_POST["userlink"].';
// Username and pass
$affiliateuser = '.$_POST["affiliateuser"].';
$affiliatepassword = '.$_POST["affiliatepassword"].';
';
eval($settings_string);
I am passing a website and a message through a url to another webpage. The website in its self contains some get variables. The problem comes from the fact that when the site and the message is passed, the site variables are being truncated. I have searched for a way to solve this and did not understand what others were doing. Thanks for the help in advance. The code is below:
<?php
$I_D = 0;
$EI_D = 1;
$site = "orowland/eval.php?eval=$I_D&stats=$EI_D";
header("location:message.php?message=Site has been created&site=$site");
?>
In message.php:
<?php
if (isset($_GET['message']))
{
$message = $_GET['message'];
$site = $_GET['site'];
echo $message;
echo $site;
}
?>
Output on page:
orowland/eval.php?eval=0
But the expected output is:
orowland/eval.php?eval=0&stats=1
It is probably a good idea to urlencode() that string as it contains spaces
So do
<?php
$I_D = 0;
$EI_D = 1;
$site = "orowland/eval.php?eval=$I_D&stats=$EI_D";
$message = urlencode('Site has been created');
$url = "message.php?message=$message&site=$site";
header("location: $url");
?>
I can access this script directly via URL and it works fine but as a cron job ot doesnt work. Is it aweber or am I doing something wrong?
Awebre's documentation is one of the worst ones I have ever come across!
I am not sure why there is no explanation of this in their docs!
Thanks
<?php
include "wp-load.php";
include_once('wp-includes/class-phpass.php');
$sql = "SELECT member_id, email FROM wp_members_tbl WHERE aweber != 1";
$result = $wpdb->get_results($sql);
if(count($result)>0)
{
##Add aweber
require_once('aweber/aweber_api/aweber_api.php');
$consumerKey = '***';
$consumerSecret = '***';
$accessKey = '***'; # put your credentials here
$accessSecret = '***'; # put your credentials here
$account_id = '***'; # put the Account ID here
$list_id = '***'; # put the List ID here 3823593
$aweber = new AWeberAPI($consumerKey, $consumerSecret);
# Get an access token
if(empty($_COOKIE['accessToken']))
{
if (empty($_GET['oauth_token']))
{
$callbackUrl = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
list($requestToken, $requestTokenSecret) = $aweber->getRequestToken($callbackUrl);
setcookie('requestTokenSecret', $requestTokenSecret);
setcookie('callbackUrl', $callbackUrl);
header("Location: {$aweber->getAuthorizeUrl()}");
exit();
}
$aweber->user->tokenSecret = $_COOKIE['requestTokenSecret'];
$aweber->user->requestToken = $_GET['oauth_token'];
$aweber->user->verifier = $_GET['oauth_verifier'];
list($accessToken, $accessTokenSecret) = $aweber->getAccessToken();
setcookie('accessToken', $accessToken);
setcookie('accessTokenSecret', $accessTokenSecret);
header('Location: '.$_COOKIE['callbackUrl']);
exit();
}
##End add aweber
foreach($result as $val=>$row)
{
# Get AWeber Account
try {
$account = $aweber->getAccount($_COOKIE['accessToken'], $_COOKIE['accessTokenSecret']);
$listURL = "https://api.aweber.com/1.0/accounts/***/lists/".$list_id;
$list = $account->loadFromUrl($listURL);
$params = array(
'email' => $row->email
);
$subscribers = $list->subscribers;
$new_subscriber = $subscribers->create($params);
$update_data = array('aweber' => 1);
$where = array('member_id' => $row->member_id);
$wpdb->update( 'wp_members_tbl', $update_data, $where, $format = null, $where_format = null);
# success!
//print "A new subscriber was added to the $list->name list!";
}
catch(AWeberAPIException $exc)
{
print "<h3>AWeberAPIException:</h3>";
print " <li> Type: $exc->type <br>";
print " <li> Msg : $exc->message <br>";
print " <li> Docs: $exc->documentation_url <br>";
print "<hr>";
//exit(1);
}
}
}
Looks like a few places where this could be failing:
1) You have relative paths in your includes. The cron may not be able to find the included files. Try changing these to full paths.
2) Your code requires a browser environment (setting cookies, http header Location etc). None of this will work outside of a browser.
You should always execute the file from the command line as the user the cron runs as to test it. Any errors will be obvious.
To fix your issue you should use this tutorial which uses the browser to setup the credentials. After that it can be run from the command line/cron:
http://engineering.aweber.com/quick-start-api-script-in-php/
Try using this in the cron command:
wget -qO- http://yoururlhere/ &> /dev/null
It's not the best solution since "self calls" aren't recommended, but it'll keep you from dealing with environment settings.