I'm attempting to use SagePay's Server Intergration PHP Kit, but on installation I'm getting the error Warning: Invalid Website URL value, email format expected this is in /lib/classes/settings.php on line 1127, all I've done to edit the kit is enter the database details that I have set up
any ideas?
For quick fix this issue you can add url of your test site into sagedemo/lib/classes/settings.php in public function setWebsite($website) like this:
public function setWebsite($website)
{
$website = 'http://sagepayintegrationkit.dev/';
if (!empty($website) && SagepayValid::url($website))
{
$this->_website = $website;
}
else
{
trigger_error("Invalid Website URL value, email format expected, '" . $website . "' given", E_USER_WARNING);
}
}
It works form but it looks like banal crutch :)
Related
I am building a laravel web application which involves the usage of Moodle Service (version 3.6). I have done autologin with a plugin.
The problem is that clicking the Take Course button on my external application will autologin to Moodle (via the plugin), but does not redirect the user to the course described in the button.
Is there a mechanism to do this?
The plugin you are using already has an option to do this:
See the user_login_userkey() method here
/**
* Logs a user in using userkey and redirects after.
*
*/
public function user_login_userkey() {
$keyvalue = required_param('key', PARAM_ALPHANUM);
$wantsurl = optional_param('wantsurl', '', PARAM_URL);
if (!empty($wantsurl)) {
$redirecturl = $wantsurl;
} else {
$redirecturl = $CFG->wwwroot;
}
if (isloggedin()) {
$this->redirect($redirecturl);
}
So you only need to pass the wantsurl parameter having the course URL and it should automatically redirect you to the course after login.
From the plugin github page you linked, I noticed the section:
if (isset($courseid)) {
$path = '&wantsurl=' . urlencode("$domainname/course/view.php?id=$courseid");
}
if (isset($modname) && isset($activityid)) {
$path = '&wantsurl=' . urlencode("$domainname/mod/$modname/view.php?id=$activityid");
}
I believe you can define a redirect url after the login by adding the wantsurl query parameter to your login url.
I am using TYPO 3 version 6.2.14. In this version I am using Formhandler Plugin to generate a contact form. I have implemented custom code of Google
reCAPTCHA V2 Explicitly render. Now reCAPTCHA code is generated. But it is not performing server side validation. I have also created php file for serverside validation inside fileadmin/templates/fromhandler/serversidevalidation.php
if(isset($_POST['g-recaptcha-response']))
{
$captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
echo '<h2>Please check the the captcha form.</h2>';
exit;
}
$secretKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$ip = $_SERVER['REMOTE_ADDR'];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
$responseKeys = json_decode($response,true);
echo $responseKeys;
if(intval($responseKeys["success"]) !== 1) {
echo '<h2>You are spammer ! Get the bot out</h2>';
} else {
echo '<h2>Thanks for posting </h2>';
}
But this simple php file is not including in TypoScript. How can I implement server side validation with formhandler extension. I do not want to use extension because of compatibility issue. Can someone guide me?
I'd like to allow only https:// links to be used as remote avatar images in phpbb to avoid mixed content. This seems to be the code that is used to check whether the entered url is correct (to be found in /phpbb/avatar/driver/remote.php):
if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.('. implode('|', $this->allowed_extensions) . ')$#i', $url))
{
$error[] = 'AVATAR_URL_INVALID';
return false;
}
I'd like to add a if{}-condition before this code block to give an informative error message if the user selected an image from a non-secure server. Can anyone help me defining the correct preg_match() string please?
Based on the suggestion by #casimir, I used the following code and it works:
$urlchk = parse_url($url);
$urlscheme = isset($urlchk['scheme']) ? $urlchk['scheme'].'://' : 'http://';
if ($urlscheme=='http://'){
// error message
}
Not working SMTP_validateEmail on live site using php
https://code.google.com/p/php-smtp-email-validation/
<?php
/**
* Example 1
* Validate a single Email via SMTP
*/
// include SMTP Email Validation Class
require_once('smtp_validateEmail.class.php');
// the email to validate
$email = $_POST['name'];
// an optional sender
$sender = $_POST['name'];
// instantiate the class
$SMTP_Validator = new SMTP_validateEmail();
// turn on debugging if you want to view the SMTP transaction
//$SMTP_Validator->debug = true;
// do the validation
$results = $SMTP_Validator->validate(array($email), $sender);
// send email?
if ($results[$email]) {
echo 1;
} else {
echo 0;
}
enter code here
?>
i am having problem on live site but it works fine in localhost.it shows the print_r($results) in the localhost but shows array(0) result in live.i also find $this->sock value in the class smtp_validateEmail.class function validate(email) value empty in live. how to solve this issue any help will be very thankful.
That "Add your web server ip address to var $nameservers = array(‘192.168.0.1’); and if your web server has Port number then update it here var $port = (Port number); Hope you will get the output by making this changes." Only work if you are sending mail with that script but cant tell if that mail checked is good one or not... I have been testing the code, try all changes, but still cant check other mails outside my domain. I can only make it work on my local and webserver host. Still cant call other servers to check if other mails from outside my domain are valid. Working on it.
Complete downloads are here for others to test : https://code.google.com/p/php-smtp-email-validation/downloads/list
Add your web server ip address to var $nameservers = array(‘192.168.0.1’);
and if your web server has Port number then update it here var $port = (Port number);
Hope you will get the output by making this changes.
For example in my logs I have many lines that repeat, such as:
ERROR - 2011-07-06 09:19:01 --> 404 Page Not Found --> favicon.ico
Is there any way for me to find out who is calling these errant URLs? The favicon is just an example, there are some URLs that for example show an intent to hack, and others it's just the same error repeated over and over and over again. Basically I'd love to know which IP's to potentially block as well as what sites to contact if they have bad links (or if I should just redirect them on my server with .htaccess).
If you feel the need to do this, just extend the Exceptions class and override the show_404() function:
// v2.x: core/MY_Exceptions.php
// v1.x: libraries/MY_Exceptions.php
class MY_Exceptions extends CI_Exceptions {
/**
* 404 Page Not Found Handler
*
* #access private
* #param string
* #return string
*/
function show_404($page = '', $log_error = TRUE)
{
$heading = "404 Page Not Found";
$message = "The page you requested was not found.";
// By default we log this, but allow a dev to skip it
if ($log_error)
{
// Custom code here, maybe logging some $_SERVER variables
// $_SERVER['HTTP_REFERER'] or $_SERVER['REMOTE_ADDR'] perhaps
// Just add whatever you want to the log message
log_message('error', '404 Page Not Found --> '.$page);
}
echo $this->show_error($heading, $message, 'error_404', 404);
exit;
}
}
If you keep getting stuff like favicon.ico, there's a good chance this is your fault, so you might want to look into that.
Just to clarify:
$_SERVER['HTTP_REFERER'] will give you the URL the page was requested from, so you can see where the request originated, whether it be on your site or elsewhere.
$_SERVER['REMOTE_ADDR'] should give you the IP address the request was made by
http://php.net/manual/en/reserved.variables.server.php
Brief Example:
if ($log_error)
{
$msg = '';
if (isset($_SERVER['HTTP_REFERER']))
{
$msg .= 'Referer was '.$_SERVER['HTTP_REFERER'];
}
else
{
$msg .= 'Referer was not set or empty';
}
if (isset($_SERVER['REMOTE_ADDR']))
{
$msg .= 'IP address was '.$_SERVER['REMOTE_ADDR'];
}
else
{
$msg .= 'Unable to track IP';
}
log_message('error', '404 Page Not Found --> '.$page.' - '.$msg);
}
I believe if you want this, you'd have to log it yourself by creating a custom 404 page and manually logging to the log file. You can access the IP address in PHP via $_SERVER['REMOTE_ADDR'].