PDA

View Full Version : static URL e-mail to user


roma
11-30-2005, 10:50 PM
Hi.
I need to do one thing.
when link is approved - script email to user information about his link.
directory where it's placed.

how to do that in this e-mail together with URL of directory user see URL from " Link Details " (static URL with his link)

:?:

Simon Gooffin
12-01-2005, 05:02 AM
hmm, please try to make the following changes:

*** open DirMailer.php ***

*** find the following code ***
$body = str_replace('{own_dir_url}', $this->mConfig['base'].$this->mConfig['dir'], $body);
$body = str_replace('{dir_link}', "{$this->mConfig['base']}{$this->mConfig['dir']}{$aCategory['path']}/", $body);

*** add the following after it ***
$link_url = $this->mConfig['base'].$this->mConfig['dir'].$aCategory['path'].'/'.convert_str($aLink['title'])."-l{$aLink['id']}.html";
$body = str_replace('{dir_link_url}', $link_url, $body);

*** save changes ***
and add {dir_link_url} in your approval message body...

It should work

roma
12-01-2005, 06:49 AM
hmm. tested right now - don't work.

Fatal error: Call to undefined function: convert_str() in /home/rubcbiz/domains/auto-service.su/public_html/classes/DirMailer.php on line 70

"line 70" - place , where I put this code. I was change it's position, but don't work..

Simon Gooffin
12-01-2005, 07:43 AM
ok.. then try to add the following changes:

add the following function to your DirMailer.php file:
/**
* Converts string to url valid string
*
* @param arr $aParams text string
*
* @return str
*/
function convert_str($aParams)
{
$aParams['string'] = strtolower($aParams['string']);
$aParams['string'] = preg_replace('/[^a-z0-9]+/i', '-', $aParams['string']);
$aParams['string'] = preg_replace('/\-+/', '-', $aParams['string']);
$aParams['string'] = trim($aParams['string'], '-');

return $aParams['string'];
}

and in the code I gave you before use it as $this->convert_str($aLink['title'])

roma
12-01-2005, 07:58 AM
Simon, please, tell me where I'll need to put this code?

or, please, if it's not hard to you - post there all code of DirMailer.php with this modification.
because, wherever I was place this code - popup a error :roll:

thx!

Simon Gooffin
12-01-2005, 08:21 AM
try to add it after the following code:
class Mailer
{
var $mConfig;

/**
* Initialize class constructor
*/
function Mailer()
{
}

roma
12-14-2005, 02:35 AM
Hi, Simon. I'am have not time to this topic, but I remember 8)
At my work site I can't test this, and I create one more project and now remember about this finction what we are talk with you. and try it again...

but it's don't work. now without errors, but simply don't work.

Simon, maybe I have change some wrong in code?
Please, look at my DirMailer.php with this changes and say me, where I do error

<?php
/************************************************** *************************
*
* IMPORTANT: This program is a commercial software and any kind of using
* it must agree to eSyndiCat license agreement. It can be found here:
* http://www.esyndicat.com/license.html
*
* This notice may not be removed from the source code.
*
* Copyright 2005 eSyndiCat Software Development Ltd.
* http://www.esyndicat.com/
*
************************************************** *************************
*
* Implements main class for email sending
*
************************************************** *************************/
class Mailer
{
var $mConfig;

/**
* Initialize class constructor
*/
function Mailer()
{
}
/**
* Converts string to url valid string
*
* @param arr $aParams text string
*
* @return str
*/
function convert_str($aParams)
{
$aParams['string'] = strtolower($aParams['string']);
$aParams['string'] = preg_replace('/[^a-z0-9]+/i', '-', $aParams['string']);
$aParams['string'] = preg_replace('/\-+/', '-', $aParams['string']);
$aParams['string'] = trim($aParams['string'], '-');

return $aParams['string'];
}
/**
* Send email to recepient
*
* @param str $aEmail recepient email
* @param str $aSubject email subject
* @param str $aBody email body
* @param str $aFrom email FROM
* @param str $aReplyto email for REPLY
*/
function sendEmail($aEmail, $aSubject, $aBody, $aFrom, $aReplyto)
{
return mail($aEmail, $aSubject, $aBody, "From: {$aFrom}\r\n"."Reply-To: {$aReplyto}\r\n");
}

/**
* Sends email by the given action
*
* @param str $aAction action that happened
* @param arr $aLink link info array
* @param arr $aCategory category info
*
* @return bool
*/
function sendMail($aAction, $aLink, $aCategory)
{
$subject = $this->mConfig["{$aAction}_subject"];
$body = $this->mConfig["{$aAction}_body"];

$subject = str_replace('{own_site}', $this->mConfig['site'], $subject);

$body = str_replace('{your_site_url}', $aLink['url'], $body);
$body = str_replace('{your_site_title}', $aLink['title'], $body);
$body = str_replace('{your_site_desc}', $aLink['description'], $body);
$body = str_replace('{your_site_rank}', $aLink['rank'], $body);
$body = str_replace('{your_site_status}', $aLink['status'], $body);
$body = str_replace('{your_site_email}', $aLink['email'], $body);
$body = str_replace('{own_site}', $this->mConfig['site'], $body);
$body = str_replace('{own_url}', $this->mConfig['base'], $body);
$body = str_replace('{own_email}', $this->mConfig['site_email'], $body);
$body = str_replace('{own_dir_url}', $this->mConfig['base'].$this->mConfig['dir'], $body);
$body = str_replace('{dir_link}', "{$this->mConfig['base']}{$this->mConfig['dir']}{$aCategory['path']}/", $body);
$link_url = $this->convert_str($aLink['title']);
$body = str_replace('{dir_link_url}', $link_url, $body);

$body = stripslashes($body);

return $this->sendEmail($aLink['email'], $subject, $body, $this->mConfig['site_email'], $this->mConfig['site_email']);
}

/**
* Sends email when editor action happens
*
* @param $aAction action that happens
* @param $aEditor editor information
*
* @return bool
*/
function sendEditorMail($aAction, $aEditor)
{
$subject = $this->mConfig["{$aAction}_subject"];
$body = $this->mConfig["{$aAction}_body"];

$subject = str_replace('{own_site}', $this->mConfig['site'], $subject);

$body = str_replace('{editor_username}', $aEditor['username'], $body);
$body = str_replace('{editor_pwd}', $aEditor['password2'], $body);
$body = str_replace('{own_site}', $this->mConfig['site'], $body);
$body = str_replace('{own_url}', $this->mConfig['base'], $body);
$body = str_replace('{own_email}', $this->mConfig['site_email'], $body);

$body = stripslashes($body);

return $this->sendEmail($aEditor['email'], $subject, $body, $this->mConfig['site_email'], $this->mConfig['site_email']);
}
}
?>


at Email Temes I'am add {dir_link_url} ...

wayting for your reply :- ) thx!

Simon Gooffin
12-14-2005, 03:56 AM
try to change the following code
$link_url = $this->convert_str($aLink['title']);
$body = str_replace('{dir_link_url}', $link_url, $body);

to the following:

$params['string'] = $aLink['title'];
$link_url = $this->convert_str($params);
$body = str_replace('{dir_link_url}', $link_url, $body);

I hope it can help

roma
12-14-2005, 06:26 AM
Hi, Simon )
I do this , e-mails sents without problems, but feature don't work = )
and strange thing, this - {dir_link_url} don't write in the e-mail.
I thing script work up at this, but something is wrong, but what? =)

for clearness look at this example:

at my Email Temes:


You can view it at {dir_link}.

bla bla bla...
{dir_link_url}


result as email:


You can view it at http://mydomain.ru/something - It's OK!

bla bla bla...

(nothing is here :) )


I really can't understand what is wrong )
Please, Simon, maybe you can puzzle out at this )
Because it's really needed feature for good optimized working process.

Simon Gooffin
12-14-2005, 10:11 AM
please look through this thread very carefully. You did not make changes I told you before:
$link_url = $this->mConfig['base'].$this->mConfig['dir'].$aCategory['path'].'/'.convert_str($aLink['title'])."-l{$aLink['id']}.html";
$body = str_replace('{dir_link_url}', $link_url, $body);
I do not see this line in your DirMailer.php..
Anyway now here is the advise again:

*** open DirMailer.php and find there the following code ***
$body = str_replace('{own_dir_url}', $this->mConfig['base'].$this->mConfig['dir'], $body);
$body = str_replace('{dir_link}', "{$this->mConfig['base']}{$this->mConfig['dir']}{$aCategory['path']}/", $body);

*** add the following after ***

$params['string'] = $aLink['title'];
$link_title = $this->convert_str($params);
$link_url = $this->mConfig['base'].$this->mConfig['dir'].$aCategory['path']."/{$link_title}-l{$aLink['id']}.html";
$body = str_replace('{dir_link_url}', $link_url, $body);

*** and leave convert_str function where it is now ***
*** save changes ***
let me know if it helps

roma
12-15-2005, 06:41 AM
Hi, Simon!
Ok, I was do it again, all changes , nut I see only the erorr

Parse error: syntax error, unexpected '{' in /home/rubcbiz/domains/bcat.ru/public_html/classes/DirMailer.php on line 90

what is wrong?
:roll:

my code like this:

<?php
/************************************************** *************************
*
* IMPORTANT: This program is a commercial software and any kind of using
* it must agree to eSyndiCat license agreement. It can be found here:
* http://www.esyndicat.com/license.html
*
* This notice may not be removed from the source code.
*
* Copyright 2005 eSyndiCat Software Development Ltd.
* http://www.esyndicat.com/
*
************************************************** *************************
*
* Implements main class for email sending
*
************************************************** *************************/
class Mailer
{
var $mConfig;

/**
* Initialize class constructor
*/
function Mailer()
{
}

/**
* Converts string to url valid string
*
* @param arr $aParams text string
*
* @return str
*/
function convert_str($aParams)
{
$aParams['string'] = strtolower($aParams['string']);
$aParams['string'] = preg_replace('/[^a-z0-9]+/i', '-', $aParams['string']);
$aParams['string'] = preg_replace('/\-+/', '-', $aParams['string']);
$aParams['string'] = trim($aParams['string'], '-');

return $aParams['string'];
}

/**
* Send email to recepient
*
* @param str $aEmail recepient email
* @param str $aSubject email subject
* @param str $aBody email body
* @param str $aFrom email FROM
* @param str $aReplyto email for REPLY
*/
function sendEmail($aEmail, $aSubject, $aBody, $aFrom, $aReplyto)
{
return mail($aEmail, $aSubject, $aBody, "From: {$aFrom}\r\n"."Reply-To: {$aReplyto}\r\n");
}

/**
* Sends email by the given action
*
* @param str $aAction action that happened
* @param arr $aLink link info array
* @param arr $aCategory category info
*
* @return bool
*/
function sendMail($aAction, $aLink, $aCategory)
{
$subject = $this->mConfig["{$aAction}_subject"];
$body = $this->mConfig["{$aAction}_body"];

$subject = str_replace('{own_site}', $this->mConfig['site'], $subject);

$body = str_replace('{your_site_url}', $aLink['url'], $body);
$body = str_replace('{your_site_title}', $aLink['title'], $body);
$body = str_replace('{your_site_desc}', $aLink['description'], $body);
$body = str_replace('{your_site_rank}', $aLink['rank'], $body);
$body = str_replace('{your_site_status}', $aLink['status'], $body);
$body = str_replace('{your_site_email}', $aLink['email'], $body);
$body = str_replace('{own_site}', $this->mConfig['site'], $body);
$body = str_replace('{own_url}', $this->mConfig['base'], $body);
$body = str_replace('{own_email}', $this->mConfig['site_email'], $body);
$body = str_replace('{own_dir_url}', $this->mConfig['base'].$this->mConfig['dir'], $body);
$body = str_replace('{dir_link}', "{$this->mConfig['base']}{$this->mConfig['dir']}{$aCategory['path']}/", $body);

$params['string'] = $aLink['title'];
$link_title = $this->convert_str($params);
$link_url = $this->mConfig['base'].$this->mConfig['dir'].$aCategory['path']."/{$link_title}"-l{$aLink['id']}.html";
$body = str_replace('{dir_link_url}', $link_url, $body);

$body = stripslashes($body);

return $this->sendEmail($aLink['email'], $subject, $body, $this->mConfig['site_email'], $this->mConfig['site_email']);
}

/**
* Sends email when editor action happens
*
* @param $aAction action that happens
* @param $aEditor editor information
*
* @return bool
*/
function sendEditorMail($aAction, $aEditor)
{
$subject = $this->mConfig["{$aAction}_subject"];
$body = $this->mConfig["{$aAction}_body"];

$subject = str_replace('{own_site}', $this->mConfig['site'], $subject);

$body = str_replace('{editor_username}', $aEditor['username'], $body);
$body = str_replace('{editor_pwd}', $aEditor['password2'], $body);
$body = str_replace('{own_site}', $this->mConfig['site'], $body);
$body = str_replace('{own_url}', $this->mConfig['base'], $body);
$body = str_replace('{own_email}', $this->mConfig['site_email'], $body);

$body = stripslashes($body);

return $this->sendEmail($aEditor['email'], $subject, $body, $this->mConfig['site_email'], $this->mConfig['site_email']);
}
}
?>

Simon Gooffin
12-15-2005, 06:55 AM
can you please provide me your ftp credentials and I will make necessary changes myself? Be sure I'm not going to damage your server :)
my email is sgooffin@esyndicat.com

roma
12-15-2005, 07:11 AM
Simon, check up e-mail
I create root ftp acc for you and sent this )

Simon Gooffin
12-15-2005, 07:38 AM
sure, I got your email. Read the answer ;)