I have a blank page when using Slim3 + Twig2 + PHP 7.2 when I run the application on production (OVH server).
I'have been looking for any answer to my problem, but none of what I have found corrected it...
Thanks for your answer.
Here is my code in one of my controller :
function getAccueil($request, $response, $args = array(NULL))
{
if (empty($args))
{
$args['lang'] = 'fr';
}
$lang = $args['lang'];
$fr_url = '/fr.html';
$en_url = '/en.html';
return $this->view->render($response, 'accueil.twig', array(
'lang' => $args['lang'],
'fr_url' => $fr_url,
'en_url' => $en_url,
));
}
I'm using php 7.2 (and already tried with previous versions)
and get a 200 return http code (using Chrome/Devlopment tools/Network)
Try doing killing the script with die(); before returning the twig renderer. If it still gives a blank page maybe check if something is wrong in the php file where you define your $app and $container. Hope that you can do something with this answer.
it's been a while since i've purchased freelancer office on codecanyon. i'm using it since 2015. I've never had an issue till last week. If I type in a wrong password it gives me an error (which is normal :D) however when i type the correct one it just reloads the page :/ i've set the ENVIRONMENT to production but no error messages.. except for deprecated each() call in mx/modules.php file.
Codeigniter version: v3.1.0
php version : 7.1
app url:
http://app.wolftech.eu
i've the same error with another 'app' that ive bought on codecanyon for a friend of mine. after 1 year of succesfull usage it just reloads the page when attempting to login.
Based on the error output that you've provided, I assume that the error comes from codeigniter modular extension hmvc, that show up because it uses each() function that is deprecated.
If you look at one of the official repository pull request, and from this codeigniter forum thread, you could change the third_party/MX/Modules.php files line 83 :
(is_array($module)) ? list($module, $params) = each($module) : $params = NULL;
and replace it to :
if(!is_array($module))
{
$params = NULL;
}
else
{
$keys = array_keys($module);
$params = $module[$keys[0]];
$module = $keys[0];
}
In Prestashop 1.6, from a FrontController, I have to send a mail to the administrator of the Shop.
This part works well but I got problems to include a link to the administration page of a specific customer.
The only thing I miss is the name of the administration directory. I would be able to parse and concatenate the PS_ADMIN_DIR constant but it is not available from the FrontController.
I'm kinda stuck here.
Here is the code :
$admin_customer_link =
_PS_BASE_URL_
.__PS_BASE_URI__
/* Missing the Administration directory name here */
.$this->context->link->getAdminLink('AdminCustomers', false)
."&id_customer=".(int)$customer->id."&viewcustomer";
The output I got :
http://127.0.0.1:8080/prestashop/index.php?controller=AdminCustomers&id_customer=2&viewcustomer
The output I need :
http://127.0.0.1:8080/prestashop/administration/index.php?controller=AdminCustomers&id_customer=2&viewcustomer
Any help will be appreciated.
There is no (standard) way to know the administration folder from a front controller, otherwise all the security will flushed down the toilet :).
What you can do is to retrieve the administration folder from the module 'configuration' or when you install it, and save it somewhere, at the moment I suggest into the database but maybe there is a more safely mode.
Something like:
public function install()
{
// your stuff
$current_dir = $_SERVER['PHP_SELF']; // this give you the current dir (administration folder included)
$administration_folder = /* Clean your string with a string replace or preg */
Configuration::updateValue('PS_MYMOD_ADMIN_DIR', $administration_folder);
return true;
}
Then in your front controller retrieve it by:
$adminfolder = Configuration::get('PS_MYMOD_ADMIN_DIR');
However I hope you know that you're creating a security breach through e-mail...
Hope it helps
Since the use of the administration directory name from the Front End and sending a link to the administration in e-mail is not a good idea for security purpose, I choose to implement this another way.
Instead of send the administration customer's page link to the webmaster by e-mail, I create a new customer Thread and message. After that, I send an e-mail to the customer service. So, when they log in the Back Office, they see a new notification who leads them to the specific user.
Here is the code :
ModuleFrontController
// Create a new Customer Thread
$ct = new CustomerThread();
if (isset($customer->id)) {
$ct->id_customer = (int)$customer->id;
}
$ct->id_shop = (int)$this->context->shop->id;
$ct->id_contact = $contact->id;
$ct->id_lang = (int)$this->context->language->id;
$ct->email = $customer->email;
$ct->status = 'open';
$ct->token = Tools::passwdGen(12);
$ct->add();
// Add a new message to the Customer Thread
if ($ct->id) {
$cm = new CustomerMessage();
$cm->id_customer_thread = $ct->id;
$cm->message = $message;
$cm->ip_address = (int)ip2long(Tools::getRemoteAddr());
$cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
$cm->add();
}
Hope it helps someone in the same situation.
I'm using the notify_entity module for Drupal 8 and want to change the mail address used for the from value.
I'm trying to do it using hook_mail_alt r but it doesn't work, Drupal still send mail with the default administrator mail address... Am I doing something wrong? Or there is another way to do this?
Thanks.
/**
* Implements hook_mail_alter()
*/
function notify_entity_mail_alter(&$message){
$from = "foo#bar.com";
$message['from'] = $from;
}
They should be changed like this
$message['headers']['Return-Path'] = 'user#email.com';
$message['headers']['Sender'] = 'user#email.com';
$message['headers']['From'] = 'Site name';
$message['headers']['Reply-to'] = 'user#email.com';
Also note it seems you are modifying (hacking) the notify_entity module right ? You should not do that! If you update it or someone else updates this drupal installation in the future you might end up losing the changes and not realize it ...
You should create your own module and implement the hook_mail_alter and name your function MYMODULE_mail_alter()
Just today I had to do this and stumbled upon your question here it is a very simple module that does exactly what you want https://github.com/GiorgosK/mail_alter_headers.
NOTE: you have to modify the .module file with your own details or comment out // the ones you don't want to modify.
How to log our own error messages(for ex: error due to invalid user date entry) which is generated in php program to drupal error log.
You can use the watchdog function :
watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL)
Quoting the manual, the parameters are :
$type The category to which this message belongs.
$message The message to store in the log.
$variables Array of variables to replace in the message on display or NULL if message is already translated or not possible to translate.
$severity The severity of the message, as per RFC 3164
$link A link to associate with the message.
And the error levels can be found on the page of watchdog_severity_levels. For an error, you'll most probably use WATCHDOG_ERROR, or maybe even something more "critical", depending on the kind of error.
Drupal 8+
// Logs a notice
\Drupal::logger('my_module')->notice($message);
// Logs an error
\Drupal::logger('my_module')->error($message);
See more examples at How to Log Messages in Drupal 8.
1) Indeed, watchdog is a standard way to record own PHP errors.
2) Alternatively, if you need to immediately see error messages while debugging your Drupal pages, you may want to see them logged/printed right at the related page - in FireBug console.
Sometimes is this very convenient when you can see page-related just-in-time logs.
This requires - Devel module, Firebug extension to FireFox and possibly Firephp.
You can use the dfb() function to write log messages directly to the general Firebug console.
dfb($input, $label = NULL)
If you want to keep your Drupal-related log messages out of the normal Firebug console, you can write messages to the Drupal for Firebug log with the firep() function:
firep($item, $optional_title)
Watchdog is the way to go for a production system no doubt but during debugging I find the drupal_set_message function useful.
It outputs the message to the screen where the 'Operation Successful'-type messages are normally displayed (so make sure you remove them before making the site Live).
http://api.drupal.org/api/function/drupal_set_message/6
In drupal 7 we can log message by following method:
drupal watchdog function we can use to log message in database , make sure we have enabled optional core module for Database Logging at /admin/build/modules.
watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL)
$type:
The category to which this message belongs , Example: PHP,cron.., we can filter message by type.
$message :
The message to store in the log,Example: 'The following module is missing from the file system: security_review'
$variables :
Array of variables to replace in the message on display or NULL if message is already translated or not possible to translate.
to make message translated , do not pass dynamic value pass variables in the message should be added by using placeholder strings.
Example:
watchdog('cg_volunteer', 'cg in form_alter %formly', array('%formly' => $form['#id']), WATCHDOG_NOTICE, $link = NULL);
$severity
The severity of the message,logs can be filter by severity as per RFC 3164. Possible values are WATCHDOG_ERROR, WATCHDOG_WARNING, etc.
For more example see https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/watchdog/7.x
$link:
A link to associate with the message.
Example
// for logs notices
watchdog('my_module', $message, array());
// for Loging Error
watchdog('my_module', $message, array(), WATCHDOG_ERROR);
In drupal 8 we used following method:
// For Logs a notice.
\Drupal::logger('my_module')->notice($message);
// For Logs an error.
\Drupal::logger('my_module')->error($message);
// For Alert, action must be taken immediately.
\Drupal::logger('my_module')->alert($message);
// For Critical message.
\Drupal::logger('my_module')->critical($message);
// For Debug-level messages.
\Drupal::logger('my_module')->debug($message);
//For Emergency, system is unusable.
\Drupal::logger('my_module')->emergency($message);
//For Warning
\Drupal::logger('my_module')->warning($message);
//For Informational messages.
\Drupal::logger('my_module')->info($message);
Also for translate we should not use t() function.
\Drupal::logger('my_module')->alert('Message from #module: #message.', [
'#module' => $module,
'#message' => $message,
]);
this will be translated on run time.
Example :
\Drupal::logger('content_entity_example')->notice('#type: deleted %title.',
array(
'#type' => $this->entity->bundle(),
'%title' => $this->entity->label(),
));
Both watchdog for D7 & \Drupal::logger for D8 will write log in watchdog table (in your database), and with HUGE data logged, you can imagine performance impact.
You can use error_log php function to do it (see PHP manual).
error_log("Your message", 3, "/path/to/your/log/file.log");
You need to have permission to write in your log file (/path/to/your/log/file.log)
drupal-8drupalphplog
// Get logger factory.
$logger = \Drupal::service('logger.factory');
// Log a message with dynamic variables.
$nodeType = 'Article';
$userName = 'Admin';
$logger->get($moduleName)->notice('A new "#nodeType" created by %userName.', [
'#nodeType' => $nodeType,
'%userName' => $userName,
]);
Source