I have a statement ":
$hash = strtoupper(sha1($_POST['orderID'] . $_POST['currency'] .
$_POST['amount'] . $_POST['PM'] . $_POST['ACCEPTANCE'] .
$_POST['STATUS'] . $_POST['CARDNO'] . $_POST['PAYID'] .
$_POST['NCERROR'] . $_POST['BRAND'] . 'Kerkkl01'));
statement is needed to login and sent a payment request
This statement needs to be converted to a SHA-256, as my payment provider wants me to connect with SHA-256.
The sha1() is a normal php function, so my thought was to change the sha1() into sha256() and change the SHA-IN parameter from 'Kerkkl01' to '543GropTeter01?!890' as a stronger/longer encryption phrase is needed.
But...no way this is working. So how do I change from a SHA-1 to a SHA-256 connection in the above given $hash ?
Related
I need a way to log queries that go to wp-admin/admin-ajax.php (extra points if I can log specific queries). This will help to troubleshoot some stuff happening in production with my custom plugin.
Scenario
I’ve been working on a plugin which varies the message a user gets depending on the time on the server. The process also depends on other settings retrieved from the server.
The plugin uses javascript to call admin-ajax.php to do the magic. (due to the nature of the plugin, I don’t think I can or should use straight client-side JS for this).
In development it works reliably but in production there are definitely situations where the result returned is unexpected.
This has led me to think that the results of admin-ajax.php are sometimes cached, I need a way to validate my current guess by doing some logging of responses from the production server.
Put this code in you theme functions.php
A log file ajaxlog.txt will now be created in your template folder
add_action( 'admin_init', 'my_ajax_checker', 10, 2);
function my_ajax_checker() {
$file = dirname(__FILE__) . '/ajaxlog.txt';
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$message = $actual_link . " - " . date('m/d/Y h:i:s a', time()) . " - " .$_SERVER['REMOTE_ADDR'] . "\r\n" ;
file_put_contents($file, $message, FILE_APPEND);
}
}
Send requests with a unique identifier and then count if they are all in the log.
I have customized the default welcome e-mail send out by WordPress when you add a user, but when I change the default "From" information it no longer gets delivered to #gmail.com e-mailaddresses. I have tried it with multiple accounts, but always the same results. I haven't had any problems with #hotmail.com or any custom domain e-mailaddresses.
Below is the function I used to alter the default e-mail:
// Change the default welcome e-mail
add_filter( 'wp_new_user_notification_email', 'welcome__email', 10, 3 );
function welcome__email( $wp_new_user_notification_email, $user, $blogname ) {
$wp_new_user_notification_email['subject'] = sprintf(__( 'Company Name | Complete registration' ), $blogname, $user->user_login );
// Set password link
$key = get_password_reset_key( $user );
// Build the email
$message = sprintf(__('Welcome!')) . "\r\n\r\n";
$message .= 'By clicking the link below you can activate your account:' . "\r\n";
$message .= network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login') . "\r\n\r\n";
$message .= "After setting a password you can login." . "\r\n";
$wp_new_user_notification_email['message'] = $message;
// Change header information
$wp_new_user_notification_email['headers'] = 'From: Company Name <noreply#example.com>';
return $wp_new_user_notification_email;
}
If I comment out the last part about the 'headers' the e-mail with link to set a password does get delivered to #gmail.com e-mailaddresses, but ofcourse the default name and e-mailaddress are show then.
I can't see what I am missing out here to make sure the e-mails get delivered to #gmail.com addresses, so I'm hoping anybody here is able to help me in the right direction.
PS: I do not have any SMPT plug-in set-up.
I just noticed the e-mails are not send to #gmail.com addresses because the sender e-mailaddress does not belong to the same domain as where the website is on. Once these match, there no longer is an issue.
i am currently using gapi-google-analytics to get data from analytics without login credentials
but i am getting nothing in the output of this.getting blank page as a output
my code is given below:
require 'gapi-google-analytics/gapi.class.php';
$ga = new gapi('xxxxxxxxxxxxxx-uq0529xxxxxxxucf1pjlnk45t8nd00gup#developer.gserviceaccount.com','testproject.p12');
$metrics=array('pageviews');
$dimensions=array('browser','browserVersion');
$ga->requestReportData('11111554',$dimensions,$metrics,'-visits');
//echo"123";exit;
foreach($ga->getResults() as $result)
{
echo '<strong>'.$result.'</strong><br />';
echo 'Pageviews: ' . $result->getPageviews() . ' ';
echo 'Visits: ' . $result->getVisits() . '<br />';
}
echo '<p>Total pageviews: ' . $ga->getPageviews() . ' total visits: ' . $ga->getVisits() . '</p>';
Looks like you are trying to use a service account make sure that you go to the Admin page on Google Analytics website and add the service account email address as a user at the Account level. This will give the service account permission to access your data.
Update
Google Analytics data is private data, data that is owned by a user. In order to access someone's private data you must have there permission. You can not access Google Analytics data without some form of authentication.
I have this panel that i'm developing at my company where i will show the user's information from Google Analytics but i don't want the user to authorize or log in with his account every time he comes to the panel.
What i would like to do is: on the first time using my panel he would connect his Google account and i would save some info and on the next time he connects at my panel i would use this saved info to log on his account so i can list the Analytics info without ask for his permission or list that info even if he's not connected on is Google account right now.
Basically i would log in his account automatically and permit the 'app' to show the information.
I already have some code that connects on the API if he is connected on is Google account, but when he's not i get the login screen where he has to provide his email e password.
What i have so far is this:
<?php
require_once 'Google/Client.php';
require_once 'Google/Service/Analytics.php';
session_start();
$client = new Google_Client();
$client->setApplicationName("Google Analytics PHP Starter Application");
$client->setClientId('KEY');
$client->setClientSecret('SECRET');
$client->setRedirectUri('RETURN URI');
$client->setScopes('https://www.googleapis.com/auth/analytics.readonly');
$client->setAccessType('offline');
$service = new Google_Service_Analytics($client);
if(isset($_GET['logout']))
{
unset($_SESSION['token']);
}
if(isset($_GET['code']))
{
$client->authenticate($_GET['code']);
$_SESSION['token'] = $client->getAccessToken();
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}
if(isset($_SESSION['token']))
{
$client->setAccessToken($_SESSION['token']);
}
if($client->getAccessToken())
{
$props = $service->management_webproperties->listManagementWebproperties("12008145");//~all
print "<h1>Web Properties</h1><pre>" . print_r($props, true) . "</pre>";
$accounts = $service->management_accounts->listManagementAccounts();
//print "<h1>Accounts</h1><pre>" . print_r($accounts, true) . "</pre>";
$segments = $service->management_segments->listManagementSegments();
//print "<h1>Segments</h1><pre>" . print_r($segments, true) . "</pre>";
$goals = $service->management_goals->listManagementGoals("~all", "~all", "~all");
//print "<h1>Goals</h1><pre>" . print_r($goals, true) . "</pre>";
$_SESSION['token'] = $client->getAccessToken();
}
else
{
$authUrl = $client->createAuthUrl();
header("Location: " . $authUrl);
}
?>
Is there any way to do that ? I have looked for it around everywhere and couldn't find something near it.
In google Api's, when user authenticate the first time, you receive a CODE (which you are already getting i suppose). Use this code to get refresh token (lifetime is (always), until and unless, user revokes the permissions). Save this refresh token in Database for further use. Refresh token is used to get access token(lifetime is a short time, returned in the expires in argument). Access token is to give you access to your user's data for some time. You can keep using refresh token to get access token whenever you need to access your user's data.
Whenever you want to access user's data, use refresh token to get access token and then use that access token to get user's data.
In your case, you are using google api php client, you can use Methods in Client.php like:
getAccessToken()---to get refresh token the first time. When you call this method, you get back a json in a form: let this json name be $accessToken
$accessToken = {"access_token":"TOKEN", "refresh_token":"TOKEN", "token_type":"Bearer",
"expires_in":3600,"id_token":"TOKEN", "created":1320790426}
parse json to take refresh_token($refreshToken = $accessToken.refresh_token) and save it for later use.
setAccessToken($accessToken)---call this to set the OAuth access token.
refreshToken($refreshToken)---Fetches a fresh OAuth access token with the given refresh token.
For further clearity, look at Client.php and also read:
https://developers.google.com/accounts/docs/OAuth2WebServer
I have a website that has to insert users in a Drupal database. I include the Drupal bootstrap file and call the user_save() function.
The paramenters I pass to user_save are: the first one a stdClass with property 'status'=1, and the second parameter is (what's expected to be sent, because the insert works just fine).
The problem I'm having is that the user receives no confirmation email. I think user_save should send the user an email, but it doesn't. Maybe I'm missing something here, so your help is much appreciated!
The second paramater should be an array:
user_save($account, array('status' => 1));
You can always look at http://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_save/6 to understand the user_save function in detail..
Just to make sure, you have checked the settings for sending email on registration?
admin/config/people/accounts
Sometimes there are problem with email on crappy servers/some hosts are limiting the php mail function. Here is a simple php mail call you could try if you're not sure if the mail-function runs without problem on your server.
<?php
$to = 'youremail#yourhost.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: youremail#yourhost.com' . "\r\n" . 'Reply-To: youremail#yourhost.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>