captcha and sending messages?
« on: June 13, 2014, 09:05:02 AM »
hi, is there a need for you to input the captcha image everytime you send a message? i find this pretty time consuming, am i able to disable this feature on sending messages only? thanks,

*

CBG

  • *****
  • 673
    • osDate Forum
Re: captcha and sending messages?
« Reply #1 on: June 13, 2014, 11:58:20 AM »
Hi,

You need to manually remove the code from the template and PHP file.
Regards,
CBG (Garry)
osDate: 2.6.5, 2.7 & Evo
PHP: 5.5.x/5.6.x (5.3.x to 5.6.x) | MySQL: 5.5.34-cll

Re: captcha and sending messages?
« Reply #2 on: June 13, 2014, 11:59:58 AM »
Hi thanks, is it there to stop spamming? U have to login to enter my site, would it still need to be in place to stop this? Thanks

Re: captcha and sending messages?
« Reply #3 on: June 13, 2014, 06:58:25 PM »
I don't see any reason myself to have captcha for anything once a person has already made it through registration and is logged into the site.

Re: captcha and sending messages?
« Reply #4 on: June 13, 2014, 08:03:27 PM »
hi thanks for the replies, i have removed code from compose.php owever when i send a message it gives the captcha error message, could any you  be more specific about what else i need to remove, thanks ,

*

Pharg

  • *****
  • 2,065
  • osDate Version: osDate Evo v1.0
Re: captcha and sending messages?
« Reply #5 on: June 14, 2014, 12:05:07 AM »
Hi mnarkyp77,

You have to remove it from loading in the compose.tpl file also.
Regards,
Pharg ( Phill )

REMEMBER: ALWAYS BACKUP BEFORE YOU MAKE ANY CHANGES!!

osDateEvo v1.0 | PHP: 5.3.42 & PHP: 5.6.18 | MySQL: 5.5.35

Re: captcha and sending messages?
« Reply #6 on: June 14, 2014, 02:02:41 AM »
 :D

Re: captcha and sending messages?
« Reply #7 on: June 15, 2014, 10:28:47 PM »
:D

hi Pharg, dont suppose you know which lines need removing to do the above at all do you? been trying to remove all sortts with no joy at all, thanks,

*

Pharg

  • *****
  • 2,065
  • osDate Version: osDate Evo v1.0
Re: captcha and sending messages?
« Reply #8 on: June 16, 2014, 07:48:56 AM »
:D

hi Pharg, dont suppose you know which lines need removing to do the above at all do you? been trying to remove all sortts with no joy at all, thanks,

Hi mnarkyp77,

Yes I do.

Go to compose.php and find line 60 change from:
Code: [Select]
if( isset( $_POST['frm'] ) ) {
if ($config['spam_code_length'] > 0 && (!isset($_SESSION['spam_code']) || strtolower($_SESSION['spam_code']) != strtolower($_POST['spam_code']) ) )  {

$t->assign('errormsg', get_lang('errormsgs',121));

} else {
if ( $_POST['frm'] == 'frmTemplate' ) {
// templated message
// fetch the template message
$msgdata = $osDB->getRow('SELECT subject, text FROM ! WHERE id = ?', array(USERTEMPLATE_TABLE, $_POST['templateid']) );
$_POST['txtmessage'] = $msgdata['text'];
$_POST['txtsubject'] = $msgdata['subject'];

// make appropriate substitutions

$row = $osDB->getRow( 'select username, firstname, email, country, state_province, county, city, floor((to_days(curdate())-to_days(birth_date))/365.25)  as age from ! where id = ?', array( USER_TABLE, $_POST['txtrecipient'] ) );

// current template variables:
// [username], [firstname], [city], [state], [country], [age]
// you can add more template variables by simply adding to this array

$row['statename'] = getStateName( $row['country'], $row['state_province'] );

$row['countryname'] = getCountryName($row['country'] ) ;

$row['city'] = getCityName($row['country'], $row['state_province'], $row['city'], $row['county']);

$sub = array(
'[username]' => $row['username'],
'[firstname]' => $row['firstname'],
'[city]' => $row['city'],
'[state]' => $row['statename'],
'[country]' => $row['countryname'],
'[age]' => $row['age'],
);

foreach( $sub as $key => $val ) {
$_POST['txtmessage'] = str_replace( $key, $val, $_POST['txtmessage'] );
$_POST['txtsubject'] = str_replace( $key, $val, $_POST['txtsubject'] );
}
}

$_POST['txtmessage'] = strip_tags($_POST['txtmessage']);

// this is frm = frmCompose
$msgs_for_today = 0;

/* Check the count of messages sent for today... */
$msgs_for_today = $osDB->getOne('select act_cnt from ! where userid = ? and act_type = ? and act_date = ?',array(USER_ACTIONS, $_SESSION['UserId'], 'M'
, date('Ymd')));

if (!$msgs_for_today) $msgs_for_today = 0;

$allowed_count = ($_SESSION['security']['message_keep_cnt'] > 0)? $_SESSION['security']['message_keep_cnt'] : $config['message_count'];

$total_msgs_count = $osDB->getOne('select count(*) from ! where owner = ?', array(MAILBOX_TABLE, $_SESSION['UserId']));

if (!isset($_SESSION['security']['messages_per_day'])) $_SESSION['security']['messages_per_day'] = 0;

if ($msgs_for_today > $_SESSION['security']['messages_per_day'] && !isset($_REQUEST['reply'])) {

$t->assign('errormsg',  get_lang('errormsgs',122));

} elseif ($allowed_count <= $total_msgs_count) {

$t->assign('errormsg', get_lang('errormsgs', 131));

} else {

if ( isset( $_SESSION['UserId'] ) && $_SESSION['UserId'] != '' ) {

// check if profile should be included //

if ($_POST["chkinclude"] == "1") {

// get information //

$dataSections = $osDB->getAll( 'SELECT * FROM ! WHERE enabled = ? ORDER BY displayorder', array( SECTIONS_TABLE, 'Y'  ) );

$found = false;

foreach( $dataSections as $section ){

$prefs = array();

$rsPref = $osDB->getAll( 'SELECT DISTINCT q.id, q.question, q.extsearchhead, q.control_type as type FROM ! pref INNER JOIN ! q ON pref.questionid = q.id WHERE pref.userid = ? AND q.section = ? ORDER BY q.id ', array( USER_PREFERENCE_TABLE, QUESTIONS_TABLE, $_SESSION["UserId"], $section['id'] ) );

foreach( $rsPref as $row ){

if ($row['type'] != 'textarea') {

$rsOptions = $osDB->getAll( 'SELECT pref.answer as answer, opt.answer as anstxt from ! pref left join ! opt on pref.questionid = opt.questionid and opt.id = pref.answer where pref.userid = ? and opt.questionid = ? order by opt.questionid, opt.displayorder', array( USER_PREFERENCE_TABLE, OPTIONS_TABLE, $_SESSION["UserId"], $row['id'] ) );

} else {

$rsOptions = $osDB->getAll( 'select pref.answer as answer, pref.answer as anstxt from ! pref where pref.userid = ? and pref.questionid = ?', array( USER_PREFERENCE_TABLE, $_SESSION["UserId"], $row['id'] ) );
}

$opts = array();

foreach( $rsOptions as $key=>$opt ){
$opts[] = $opt['anstxt'];
}
unset($rsOptions);
if (count($opts)>0) {
$optsPhr = implode( ', ', $opts);
} else {
$optsPhr = "";
}

$row['options'] = $optsPhr;

$prefs[] = $row;

$found = true;
}
unset($rsPref);

if( count($prefs) > 0 ){

$pref[] = array( 'SectionName' => $section['section'], 'preferences' => $prefs );
}
}
unset($dataSections, $prefs);
// add to message //

if ( isset($pref) && is_array( $pref ) ) {
foreach ($pref as $item) {

$_POST['txtmessage'] .= "<br />" . "<br />" . stripslashes( $item['SectionName'] ) . "<br />";
$_POST['txtmessage'] .= "-----------------";

foreach ($item['preferences'] as $item2) {

if (strlen($item2['options']) > 0) {

$_POST['txtmessage'] .= "<br />" . "<br />" . stripslashes( $item2['extsearchhead'] ). "<br />";
$_POST['txtmessage'] .= "- " . stripslashes( $item2['options'] );
}
}
}
}

}

$time001 = time();
$osDB->query( 'INSERT INTO ! (owner, senderid, recipientid, subject, message, sendtime, folder, notifysender) values(?, ?, ?, ?, ?, ?, ?, ?)', array( MAILBOX_TABLE, $_POST['txtrecipient'], $_SESSION['UserId'], $_POST['txtrecipient'], stripEmails(strip_tags($_POST['txtsubject'])), stripEmails($_POST['txtmessage']), $time001, 'inbox', ($_POST["chknotify"] - 0) ) );

/* MOD END */

$osDB->query( 'INSERT INTO ! (owner, senderid, recipientid, subject, message, sendtime, folder) values(?, ?, ?, ?, ?, ?, ?)', array( MAILBOX_TABLE, $_SESSION['UserId'], $_SESSION['UserId'], $_POST['txtrecipient'], stripEmails(strip_tags($_POST['txtsubject'])), stripEmails($_POST['txtmessage']), $time001, 'sent' ) );

$recipient_choice = $osDB->getOne('select choice_value from ! where userid=? and choice_name=?', array(USER_CHOICES_TABLE, $_POST['txtrecipient'], 'email_message_received') );

if ($recipient_choice == '1' or $recipient_choice == '' or !isset($recipient_choice) ) {

if ($config['letter_messagereceived'] == 'Y' && ($config['nomail_for_onlineuser'] == 'Y' or ($config['nomail_for_onlineuser'] == 'Y' && !getOnlineStats($_POST['txtrecipient']) )) ) {

/* Send email about the received message to the receiver */

$row = $osDB->getRow( 'select *, floor((to_days(curdate())-to_days(birth_date))/365.25)  as age from ! where id = ?', array( USER_TABLE, $_POST['txtrecipient'] ) );

$sendername = $osDB->getOne('select username from ! where id = ?', array(USER_TABLE, $_SESSION['UserId']) );

$Subject = get_lang('message_received_sub');

$From= $config['admin_email'];

$To = $row['email'];

$t->assign('item', $osDB->getRow('select *, floor((to_days(curdate())-to_days(birth_date))/365.25)  as age from ! where id = ?', array( USER_TABLE, $_SESSION['UserId']) ) );

$message = get_lang('message_received', MAIL_FORMAT);

$message = str_replace('#From#', get_lang('FROM1'), $message);

$message = str_replace('#TO#', get_lang('To1'), $message);

$message = str_replace('#FirstName#', $row['firstname'] ,$message);

$message = str_replace('#SenderName#', $sendername, $message);

$message = str_replace('#UserName#', $row['username'], $message);

$message = str_replace('#Date#', get_lang('col_head_date'), $message);

$message = str_replace('#MESSAGE_DATE#', date(get_lang('DISPLAY_DATETIME_FORMAT'),time()), $message);

$message = str_replace('#Subject#', get_lang('col_head_subject'), $message);

$message = str_replace('#MSG_SUBJECT#', stripEmails(strip_tags($_POST['txtsubject'])), $message);

if (MAIL_FORMAT == 'html') {

$message = str_replace('#smallProfile#',  $t->fetch('profile_for_html_mail.tpl'), $message);

}

mailSender($From, $To, $row['email'], $Subject, $message);
unset($message, $Subject);
}
}

if ($msgs_for_today > 0) {
$osDB->query('update ! set act_cnt=act_cnt+1 where userid=? and act_type=? and act_date = ?', array(USER_ACTIONS,$_SESSION['UserId'], 'M', date('Ymd')));
} else {
$osDB->query('insert into ! (userid, act_type, act_date, act_cnt) values (?,?,?,?)', array(USER_ACTIONS, $_SESSION['UserId'], 'M', date('Ymd'), 1));
}
if (isset($_REQUEST['reply']) && $_REQUEST['reply'] == '2') {

/* update replied flag */

$osDB->query('update ! set replied=? where id=?', array(MAILBOX_TABLE, 1, $_REQUEST['msgid']) );


header("location:mailmessages.php?folder=".$_REQUEST['folder']."&selflag=".$_REQUEST['selflag']."&sort=".$_REQUEST['sort']."&type=".$_REQUEST['type']."&replied=1");
exit;
}

}

$t->assign( 'msg_sent', true );
}
}
}

Change to this:
Code: [Select]
if( isset( $_POST['frm'] ) ) {



if ( $_POST['frm'] == 'frmTemplate' ) {
// templated message
// fetch the template message
$msgdata = $osDB->getRow('SELECT subject, text FROM ! WHERE id = ?', array(USERTEMPLATE_TABLE, $_POST['templateid']) );
$_POST['txtmessage'] = $msgdata['text'];
$_POST['txtsubject'] = $msgdata['subject'];

// make appropriate substitutions

$row = $osDB->getRow( 'select username, firstname, email, country, state_province, county, city, floor((to_days(curdate())-to_days(birth_date))/365.25)  as age from ! where id = ?', array( USER_TABLE, $_POST['txtrecipient'] ) );

// current template variables:
// [username], [firstname], [city], [state], [country], [age]
// you can add more template variables by simply adding to this array

$row['statename'] = getStateName( $row['country'], $row['state_province'] );

$row['countryname'] = getCountryName($row['country'] ) ;

$row['city'] = getCityName($row['country'], $row['state_province'], $row['city'], $row['county']);

$sub = array(
'[username]' => $row['username'],
'[firstname]' => $row['firstname'],
'[city]' => $row['city'],
'[state]' => $row['statename'],
'[country]' => $row['countryname'],
'[age]' => $row['age'],
);

foreach( $sub as $key => $val ) {
$_POST['txtmessage'] = str_replace( $key, $val, $_POST['txtmessage'] );
$_POST['txtsubject'] = str_replace( $key, $val, $_POST['txtsubject'] );
}
}

$_POST['txtmessage'] = strip_tags($_POST['txtmessage']);

// this is frm = frmCompose
$msgs_for_today = 0;

/* Check the count of messages sent for today... */
$msgs_for_today = $osDB->getOne('select act_cnt from ! where userid = ? and act_type = ? and act_date = ?',array(USER_ACTIONS, $_SESSION['UserId'], 'M'
, date('Ymd')));

if (!$msgs_for_today) $msgs_for_today = 0;

$allowed_count = ($_SESSION['security']['message_keep_cnt'] > 0)? $_SESSION['security']['message_keep_cnt'] : $config['message_count'];

$total_msgs_count = $osDB->getOne('select count(*) from ! where owner = ?', array(MAILBOX_TABLE, $_SESSION['UserId']));

if (!isset($_SESSION['security']['messages_per_day'])) $_SESSION['security']['messages_per_day'] = 0;

if ($msgs_for_today > $_SESSION['security']['messages_per_day'] && !isset($_REQUEST['reply'])) {

$t->assign('errormsg',  get_lang('errormsgs',122));

} elseif ($allowed_count <= $total_msgs_count) {

$t->assign('errormsg', get_lang('errormsgs', 131));

} else {

if ( isset( $_SESSION['UserId'] ) && $_SESSION['UserId'] != '' ) {

// check if profile should be included //

if ($_POST["chkinclude"] == "1") {

// get information //

$dataSections = $osDB->getAll( 'SELECT * FROM ! WHERE enabled = ? ORDER BY displayorder', array( SECTIONS_TABLE, 'Y'  ) );

$found = false;

foreach( $dataSections as $section ){

$prefs = array();

$rsPref = $osDB->getAll( 'SELECT DISTINCT q.id, q.question, q.extsearchhead, q.control_type as type FROM ! pref INNER JOIN ! q ON pref.questionid = q.id WHERE pref.userid = ? AND q.section = ? ORDER BY q.id ', array( USER_PREFERENCE_TABLE, QUESTIONS_TABLE, $_SESSION["UserId"], $section['id'] ) );

foreach( $rsPref as $row ){

if ($row['type'] != 'textarea') {

$rsOptions = $osDB->getAll( 'SELECT pref.answer as answer, opt.answer as anstxt from ! pref left join ! opt on pref.questionid = opt.questionid and opt.id = pref.answer where pref.userid = ? and opt.questionid = ? order by opt.questionid, opt.displayorder', array( USER_PREFERENCE_TABLE, OPTIONS_TABLE, $_SESSION["UserId"], $row['id'] ) );

} else {

$rsOptions = $osDB->getAll( 'select pref.answer as answer, pref.answer as anstxt from ! pref where pref.userid = ? and pref.questionid = ?', array( USER_PREFERENCE_TABLE, $_SESSION["UserId"], $row['id'] ) );
}

$opts = array();

foreach( $rsOptions as $key=>$opt ){
$opts[] = $opt['anstxt'];
}
unset($rsOptions);
if (count($opts)>0) {
$optsPhr = implode( ', ', $opts);
} else {
$optsPhr = "";
}

$row['options'] = $optsPhr;

$prefs[] = $row;

$found = true;
}
unset($rsPref);

if( count($prefs) > 0 ){

$pref[] = array( 'SectionName' => $section['section'], 'preferences' => $prefs );
}
}
unset($dataSections, $prefs);
// add to message //

if ( isset($pref) && is_array( $pref ) ) {
foreach ($pref as $item) {

$_POST['txtmessage'] .= "<br />" . "<br />" . stripslashes( $item['SectionName'] ) . "<br />";
$_POST['txtmessage'] .= "-----------------";

foreach ($item['preferences'] as $item2) {

if (strlen($item2['options']) > 0) {

$_POST['txtmessage'] .= "<br />" . "<br />" . stripslashes( $item2['extsearchhead'] ). "<br />";
$_POST['txtmessage'] .= "- " . stripslashes( $item2['options'] );
}
}
}
}

}

$time001 = time();
$osDB->query( 'INSERT INTO ! (owner, senderid, recipientid, subject, message, sendtime, folder, notifysender) values(?, ?, ?, ?, ?, ?, ?, ?)', array( MAILBOX_TABLE, $_POST['txtrecipient'], $_SESSION['UserId'], $_POST['txtrecipient'], stripEmails(strip_tags($_POST['txtsubject'])), stripEmails($_POST['txtmessage']), $time001, 'inbox', ($_POST["chknotify"] - 0) ) );

/* MOD END */

$osDB->query( 'INSERT INTO ! (owner, senderid, recipientid, subject, message, sendtime, folder) values(?, ?, ?, ?, ?, ?, ?)', array( MAILBOX_TABLE, $_SESSION['UserId'], $_SESSION['UserId'], $_POST['txtrecipient'], stripEmails(strip_tags($_POST['txtsubject'])), stripEmails($_POST['txtmessage']), $time001, 'sent' ) );

$recipient_choice = $osDB->getOne('select choice_value from ! where userid=? and choice_name=?', array(USER_CHOICES_TABLE, $_POST['txtrecipient'], 'email_message_received') );

if ($recipient_choice == '1' or $recipient_choice == '' or !isset($recipient_choice) ) {

if ($config['letter_messagereceived'] == 'Y' && ($config['nomail_for_onlineuser'] == 'Y' or ($config['nomail_for_onlineuser'] == 'Y' && !getOnlineStats($_POST['txtrecipient']) )) ) {

/* Send email about the received message to the receiver */

$row = $osDB->getRow( 'select *, floor((to_days(curdate())-to_days(birth_date))/365.25)  as age from ! where id = ?', array( USER_TABLE, $_POST['txtrecipient'] ) );

$sendername = $osDB->getOne('select username from ! where id = ?', array(USER_TABLE, $_SESSION['UserId']) );

$Subject = get_lang('message_received_sub');

$From= $config['admin_email'];

$To = $row['email'];

$t->assign('item', $osDB->getRow('select *, floor((to_days(curdate())-to_days(birth_date))/365.25)  as age from ! where id = ?', array( USER_TABLE, $_SESSION['UserId']) ) );

$message = get_lang('message_received', MAIL_FORMAT);

$message = str_replace('#From#', get_lang('FROM1'), $message);

$message = str_replace('#TO#', get_lang('To1'), $message);

$message = str_replace('#FirstName#', $row['firstname'] ,$message);

$message = str_replace('#SenderName#', $sendername, $message);

$message = str_replace('#UserName#', $row['username'], $message);

$message = str_replace('#Date#', get_lang('col_head_date'), $message);

$message = str_replace('#MESSAGE_DATE#', date(get_lang('DISPLAY_DATETIME_FORMAT'),time()), $message);

$message = str_replace('#Subject#', get_lang('col_head_subject'), $message);

$message = str_replace('#MSG_SUBJECT#', stripEmails(strip_tags($_POST['txtsubject'])), $message);

if (MAIL_FORMAT == 'html') {

$message = str_replace('#smallProfile#',  $t->fetch('profile_for_html_mail.tpl'), $message);

}

mailSender($From, $To, $row['email'], $Subject, $message);
unset($message, $Subject);
}
}

if ($msgs_for_today > 0) {
$osDB->query('update ! set act_cnt=act_cnt+1 where userid=? and act_type=? and act_date = ?', array(USER_ACTIONS,$_SESSION['UserId'], 'M', date('Ymd')));
} else {
$osDB->query('insert into ! (userid, act_type, act_date, act_cnt) values (?,?,?,?)', array(USER_ACTIONS, $_SESSION['UserId'], 'M', date('Ymd'), 1));
}
if (isset($_REQUEST['reply']) && $_REQUEST['reply'] == '2') {

/* update replied flag */

$osDB->query('update ! set replied=? where id=?', array(MAILBOX_TABLE, 1, $_REQUEST['msgid']) );


header("location:mailmessages.php?folder=".$_REQUEST['folder']."&selflag=".$_REQUEST['selflag']."&sort=".$_REQUEST['sort']."&type=".$_REQUEST['type']."&replied=1");
exit;
}

}

$t->assign( 'msg_sent', true );
}
}


Then in the compose.tpl find on line 194
Code: [Select]
{if $config.spam_code_length > 0}
<tr>
<td colspan="2 "valign="middle">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr><td colspan="3" height="4" ></td></tr>
<tr>
<td colspan="3" style="padding-right: 4px;"><b>{lang mkey="security_code_txt"}</b></td>
</tr>
<tr>
<td >
{lang mkey='enter_spamcode'}:&nbsp;
</td>
<td valign="middle">
<input type="text" class="textinput" name="spam_code" id="spam_code" value="" />
</td>
<td valign="middle" style="padding-left: 5px;" nowrap>
<img src="captcha/SecurityImage.php"  alt="Security Code" id="spam_code_img" name="spam_code_img" />
&nbsp;&nbsp;
<a href="javascript:reloadCaptcha();" ><img src="captcha/images/arrow_refresh.png" alt="Refresh Code" border="0" /></a>
</td>
</tr>
</table>
</td>
</tr>
{/if}

Completely remove the above code and save the compose.tpl
That's all there is to it  ;)

Regards,
Pharg ( Phill )

REMEMBER: ALWAYS BACKUP BEFORE YOU MAKE ANY CHANGES!!

osDateEvo v1.0 | PHP: 5.3.42 & PHP: 5.6.18 | MySQL: 5.5.35

Re: captcha and sending messages?
« Reply #9 on: June 16, 2014, 08:19:07 AM »
The easy way to remove the spam control is just set it to 0 and it turns it off.  :)

*

Pharg

  • *****
  • 2,065
  • osDate Version: osDate Evo v1.0
Re: captcha and sending messages?
« Reply #10 on: June 16, 2014, 08:36:18 AM »
The easy way to remove the spam control is just set it to 0 and it turns it off.  :)

Yes but that would disable ALL the spam code that is needed else where   
« Last Edit: June 16, 2014, 09:36:39 AM by Pharg »
Regards,
Pharg ( Phill )

REMEMBER: ALWAYS BACKUP BEFORE YOU MAKE ANY CHANGES!!

osDateEvo v1.0 | PHP: 5.3.42 & PHP: 5.6.18 | MySQL: 5.5.35

Re: captcha and sending messages?
« Reply #11 on: June 16, 2014, 09:33:07 AM »
Thanks for that mate!! Saved me a lot of time  :D

Re: captcha and sending messages?
« Reply #12 on: June 23, 2014, 12:52:40 AM »
The easy way to remove the spam control is just set it to 0 and it turns it off.  :)

Yes but that would disable ALL the spam code that is needed else where
I was just giving another option. Thanks for the nice coding change and I have saved this one for future use.

Re: captcha and sending messages?
« Reply #13 on: August 22, 2014, 06:53:04 PM »
hi pharg, i have removed the captcha from send birthday messages but i am not sure which part you remove from the php file can you help? thanks,

*

Pharg

  • *****
  • 2,065
  • osDate Version: osDate Evo v1.0
Re: captcha and sending messages?
« Reply #14 on: August 23, 2014, 01:27:36 AM »
Hi mnarkyp77,

It's much the same as before.

In the send_birthday_message.php find
Code: [Select]
if ( $cmd == 'posted' ){

$txtcomments = strip_tags(trim($_POST['txtcomments']));

$t->assign('txtcomments', $txtcomments);
$uid = $_POST['id'];

if ( (strtolower($_SESSION['spam_code']) != strtolower($_POST['spam_code']) || !isset($_SESSION['spam_code']) ) && $config['spam_code_length'] > 0)  {
$t->assign('msg', get_lang('errormsgs','121') );
} else {

$subj = get_lang('birthday_msg_sub');

/* Check the count of messages sent for today... */
$msgs_for_today = $osDB->getOne('select act_cnt from ! where userid = ? and act_type = ? and act_date = ?',array(USER_ACTIONS, $_SESSION['UserId'], 'M'
, date('Ymd')));

if (!$msgs_for_today) $msgs_for_today = 0;

$allowed_count = ($_SESSION['security']['message_keep_cnt'] > 0)? $_SESSION['security']['message_keep_cnt'] : $config['message_count'];

$total_msgs_count = $osDB->getOne('select count(*) from ! where owner = ?', array(MAILBOX_TABLE, $_SESSION['UserId']));

if (!isset($_SESSION['security']['messages_per_day'])) $_SESSION['security']['messages_per_day'] = 0;

if ($msgs_for_today > $_SESSION['security']['messages_per_day'] ) {

$t->assign('msg',  get_lang('errormsgs',122));

} elseif ($allowed_count <= $total_msgs_count) {

$t->assign('msg', get_lang('errormsgs', 131));

} else {
/* Replace #USERNAME# and #FROMNAME# in the message text */
$txtcomments = str_replace('#USERNAME#',$_POST['uname'],$txtcomments);
$txtcomments = str_replace('#FROMNAME#', '<a href="showprofile.php?id='.$_SESSION['UserId'].'">'.$_SESSION['UserName'].'</a>', $txtcomments);

/* Add message to the recipient's inbox and sender's sent box */

$time001 = time();
$osDB->query( 'INSERT INTO ! (owner, senderid, recipientid, subject, message, sendtime, folder, notifysender) values(?, ?, ?, ?, ?, ?, ?, ?)', array( MAILBOX_TABLE, $_POST['id'], $_SESSION['UserId'], $_POST['id'], $subj, stripEmails($txtcomments), $time001, 'inbox', '0' ) );
$osDB->query( 'INSERT INTO ! (owner, senderid, recipientid, subject, message, sendtime, folder) values(?, ?, ?, ?, ?, ?, ?)', array( MAILBOX_TABLE, $_SESSION['UserId'], $_SESSION['UserId'], $_POST['id'], $subj, stripEmails($txtcomments), $time001, 'sent' ) );

if ($msgs_for_today > 0) {
$osDB->query('update ! set act_cnt=act_cnt+1 where userid=? and act_type=? and act_date = ?', array(USER_ACTIONS,$_SESSION['UserId'], 'M', date('Ymd')));
} else {
$osDB->query('insert into ! (userid, act_type, act_date, act_cnt) values (?,?,?,?)', array(USER_ACTIONS, $_SESSION['UserId'], 'M', date('Ymd'), 1));
}

$recipient_choice = $osDB->getOne('select choice_value from ! where userid=? and choice_name=?', array(USER_CHOICES_TABLE, $_POST['id'], 'email_message_received') );

if ($recipient_choice == '1' or $recipient_choice == '' or !isset($recipient_choice) ) {

if ($config['letter_messagereceived'] == 'Y' && ($config['nomail_for_onlineuser'] == 'Y' or ($config['nomail_for_onlineuser'] == 'Y' && !getOnlineStats($_POST['txtrecipient']) )) ) {

/* Send email about the received message to the receiver */

$row = $osDB->getRow( 'select * from ! where id = ?', array( USER_TABLE, $_POST['id'] ) );

$Subject = get_lang('message_received_sub');

$From= $config['admin_email'];

$To = $row['email'];

$t->assign('item', $osDB->getRow('select *, floor((to_days(curdate())-to_days(birth_date))/365.25)  as age from ! where id = ?', array( USER_TABLE, $_SESSION['UserId']) ) );

$message = get_lang('message_received', MAIL_FORMAT);

$message = str_replace('#From#', get_lang('FROM1'), $message);

$message = str_replace('#TO#', get_lang('To1'), $message);

$message = str_replace('#FirstName#', $row['firstname'] ,$message);

$message = str_replace('#SenderName#', $_SESSION['UserName'], $message);

$message = str_replace('#UserName#', $row['username'], $message);

$message = str_replace('#Date#', get_lang('col_head_date'), $message);

$message = str_replace('#MESSAGE_DATE#', date(get_lang('DISPLAY_DATETIME_FORMAT'),time()), $message);

$message = str_replace('#Subject#', get_lang('col_head_subject'), $message);

$message = str_replace('#MSG_SUBJECT#', $subj, $message);

if (MAIL_FORMAT == 'html') {

$message = str_replace('#smallProfile#',  $t->fetch('profile_for_html_mail.tpl'), $message);

}

mailSender($From, $To, $row['email'], $Subject, $message);
unset($message, $Subject);
}
}
$t->assign('success', '1');
}
}
} elseif (isset($_REQUEST['id']) && $_REQUEST['id'] > 0) {
$uid = $_REQUEST['id'];
$t->assign('txtcomments',get_lang('birthday_msg_text') );
}

$t->assign('uname', $osDB->getOne('select username from ! where id=?',array(USER_TABLE,$uid) ) );

$t->assign('uid',$uid);

$t->assign('lang',$lang);

$t->assign('rendered_page', $t->fetch('send_birthday_message.tpl') );

$t->display( 'index.tpl' );
exit;
?>

Change to this on line 40:
Code: [Select]
if ( $cmd == 'posted' ){

$txtcomments = strip_tags(trim($_POST['txtcomments']));

$t->assign('txtcomments', $txtcomments);
$uid = $_POST['id'];



$subj = get_lang('birthday_msg_sub');

/* Check the count of messages sent for today... */
$msgs_for_today = $osDB->getOne('select act_cnt from ! where userid = ? and act_type = ? and act_date = ?',array(USER_ACTIONS, $_SESSION['UserId'], 'M'
, date('Ymd')));

if (!$msgs_for_today) $msgs_for_today = 0;

$allowed_count = ($_SESSION['security']['message_keep_cnt'] > 0)? $_SESSION['security']['message_keep_cnt'] : $config['message_count'];

$total_msgs_count = $osDB->getOne('select count(*) from ! where owner = ?', array(MAILBOX_TABLE, $_SESSION['UserId']));

if (!isset($_SESSION['security']['messages_per_day'])) $_SESSION['security']['messages_per_day'] = 0;

if ($msgs_for_today > $_SESSION['security']['messages_per_day'] ) {

$t->assign('msg',  get_lang('errormsgs',122));

} elseif ($allowed_count <= $total_msgs_count) {

$t->assign('msg', get_lang('errormsgs', 131));

} else {
/* Replace #USERNAME# and #FROMNAME# in the message text */
$txtcomments = str_replace('#USERNAME#',$_POST['uname'],$txtcomments);
$txtcomments = str_replace('#FROMNAME#', '<a href="showprofile.php?id='.$_SESSION['UserId'].'">'.$_SESSION['UserName'].'</a>', $txtcomments);

/* Add message to the recipient's inbox and sender's sent box */

$time001 = time();
$osDB->query( 'INSERT INTO ! (owner, senderid, recipientid, subject, message, sendtime, folder, notifysender) values(?, ?, ?, ?, ?, ?, ?, ?)', array( MAILBOX_TABLE, $_POST['id'], $_SESSION['UserId'], $_POST['id'], $subj, stripEmails($txtcomments), $time001, 'inbox', '0' ) );
$osDB->query( 'INSERT INTO ! (owner, senderid, recipientid, subject, message, sendtime, folder) values(?, ?, ?, ?, ?, ?, ?)', array( MAILBOX_TABLE, $_SESSION['UserId'], $_SESSION['UserId'], $_POST['id'], $subj, stripEmails($txtcomments), $time001, 'sent' ) );

if ($msgs_for_today > 0) {
$osDB->query('update ! set act_cnt=act_cnt+1 where userid=? and act_type=? and act_date = ?', array(USER_ACTIONS,$_SESSION['UserId'], 'M', date('Ymd')));
} else {
$osDB->query('insert into ! (userid, act_type, act_date, act_cnt) values (?,?,?,?)', array(USER_ACTIONS, $_SESSION['UserId'], 'M', date('Ymd'), 1));
}

$recipient_choice = $osDB->getOne('select choice_value from ! where userid=? and choice_name=?', array(USER_CHOICES_TABLE, $_POST['id'], 'email_message_received') );

if ($recipient_choice == '1' or $recipient_choice == '' or !isset($recipient_choice) ) {

if ($config['letter_messagereceived'] == 'Y' && ($config['nomail_for_onlineuser'] == 'Y' or ($config['nomail_for_onlineuser'] == 'Y' && !getOnlineStats($_POST['txtrecipient']) )) ) {

/* Send email about the received message to the receiver */

$row = $osDB->getRow( 'select * from ! where id = ?', array( USER_TABLE, $_POST['id'] ) );

$Subject = get_lang('message_received_sub');

$From= $config['admin_email'];

$To = $row['email'];

$t->assign('item', $osDB->getRow('select *, floor((to_days(curdate())-to_days(birth_date))/365.25)  as age from ! where id = ?', array( USER_TABLE, $_SESSION['UserId']) ) );

$message = get_lang('message_received', MAIL_FORMAT);

$message = str_replace('#From#', get_lang('FROM1'), $message);

$message = str_replace('#TO#', get_lang('To1'), $message);

$message = str_replace('#FirstName#', $row['firstname'] ,$message);

$message = str_replace('#SenderName#', $_SESSION['UserName'], $message);

$message = str_replace('#UserName#', $row['username'], $message);

$message = str_replace('#Date#', get_lang('col_head_date'), $message);

$message = str_replace('#MESSAGE_DATE#', date(get_lang('DISPLAY_DATETIME_FORMAT'),time()), $message);

$message = str_replace('#Subject#', get_lang('col_head_subject'), $message);

$message = str_replace('#MSG_SUBJECT#', $subj, $message);

if (MAIL_FORMAT == 'html') {

$message = str_replace('#smallProfile#',  $t->fetch('profile_for_html_mail.tpl'), $message);

}

mailSender($From, $To, $row['email'], $Subject, $message);
unset($message, $Subject);
}
}
$t->assign('success', '1');
}

} elseif (isset($_REQUEST['id']) && $_REQUEST['id'] > 0) {
$uid = $_REQUEST['id'];
$t->assign('txtcomments',get_lang('birthday_msg_text') );
}

$t->assign('uname', $osDB->getOne('select username from ! where id=?',array(USER_TABLE,$uid) ) );

$t->assign('uid',$uid);

$t->assign('lang',$lang);

$t->assign('rendered_page', $t->fetch('send_birthday_message.tpl') );

$t->display( 'index.tpl' );
exit;
?>



Then in send_birthday_message.tpl change from:
Code: [Select]
{strip}
<script type="text/javascript">
/* <![CDATA[ */
function validate(form)
{ldelim}
ErrorCount=0;
ErrorMsg = new Array();
ErrorMsg[0] = "" + String.fromCharCode(13);

CheckFieldString("noblank",form.txtcomments,"{lang mkey='signup_js_errors' skey='comments_noblank'}");
{if $config.spam_code_length > 0}
CheckFieldString("noblank",form.spam_code,"{lang mkey='errormsgs' skey='120'}");
{/if}

result="";
if( ErrorCount > 0)
{ldelim}
alert(ErrorMsg[1]);
return false;
{rdelim}
return true;
{rdelim}
/* ]]> */
</script>

<div  style="vertical-align:top;" >
{assign var="page_hdr01_text" value="{lang mkey='send_birthday_message_hdr'}"|cat:"{lang mkey='to'}"|cat:$uname}
{assign var="page_title" value=$page_hdr01_text}
{include file="page_hdr01.tpl"}
<div class="module_detail_inside">
{if $success}
{assign var="error_message" value="{lang mkey='send_birthday_message_thanks'}" }
{include file="display_error.tpl"}
{else}
{if $msg != '' }
{assign var="error_message" value=$msg }
{include file="display_error.tpl"}
{/if}
<div class="top_bottom_pad" style="text-align:center; padding:2px;">
<img src="getsnap.php?id={$uid}&amp;typ=tn&amp;height=45" class="smallpic" alt="" />
</div>
<div class="top_bottom_pad" style="padding-left:6px;font-weight:bold;">
#USERNAME# will be replaced with the recipient\'s username and  #FROMNAME# will be replaced with Sender\'s username.
</div>
<form name="frmContact" action="" method="post" onsubmit="javascript: return validate(this);">
<input type="hidden" name="cmd" value="posted" />
<input type="hidden" name="id" value="{$uid}" />
<input type="hidden" name="uname" value="{$uname}" />

<table border="0" cellpadding="{$config.cellpadding}" cellspacing="{$config.cellspacing}">
<tr>
<td valign="top">{lang mkey='im_message'}
<font class="required_info">{$smarty.const.REQUIRED_INFO}</font>
</td>
<td ><textarea rows="10" cols="55" name="txtcomments">{$txtcomments|stripslashes }</textarea></td>
</tr>
<tr><td colspan="2" height="6"></td></tr>
<tr>
<td colspan="2"><b>{lang mkey="security_code_txt"}</b></td>
</tr>
<tr><td colspan="2" height="6"></td></tr>
{if $config.spam_code_length > 0}
<tr>
<td >
{lang mkey='enter_spamcode'}:&nbsp;
</td>
<td valign="middle" style="padding-left: 5px;" nowrap>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle">
<input type="text" class="textinput"  name="spam_code" id="spam_code" value="" />&nbsp;
</td>
<td valign="middle" nowrap>
<img src="captcha/SecurityImage.php"  alt="Security Code" id="spam_code_img" name="spam_code_img" />
&nbsp;&nbsp;
<a href="javascript:reloadCaptcha();" ><img src="captcha/images/arrow_refresh.png" alt="Refresh Code" border="0" /></a>
</td>
</tr>
</table>
</td>
</tr>
<tr><td colspan="2" height="6"></td></tr>
{/if}
<tr>
<td></td>
<td><input name="submit" class="formbutton" type="submit" value="{lang mkey='submit'}"/>&nbsp;
<input name="reset" type="reset" value="{lang mkey='reset'}" class="formbutton"/> </td>
</tr>
</table>
</form>
{/if}
</div>
</div>
{/strip}

Change to
Code: [Select]
{strip}
<script type="text/javascript">
/* <![CDATA[ */
function validate(form)
{ldelim}
ErrorCount=0;
ErrorMsg = new Array();
ErrorMsg[0] = "" + String.fromCharCode(13);

CheckFieldString("noblank",form.txtcomments,"{lang mkey='signup_js_errors' skey='comments_noblank'}");
{if $config.spam_code_length > 0}
CheckFieldString("noblank",form.spam_code,"{lang mkey='errormsgs' skey='120'}");
{/if}

result="";
if( ErrorCount > 0)
{ldelim}
alert(ErrorMsg[1]);
return false;
{rdelim}
return true;
{rdelim}
/* ]]> */
</script>

<div  style="vertical-align:top;" >
{assign var="page_hdr01_text" value="{lang mkey='send_birthday_message_hdr'}"|cat:"{lang mkey='to'}"|cat:$uname}
{assign var="page_title" value=$page_hdr01_text}
{include file="page_hdr01.tpl"}
<div class="module_detail_inside">
{if $success}
{assign var="error_message" value="{lang mkey='send_birthday_message_thanks'}" }
{include file="display_error.tpl"}
{else}
{if $msg != '' }
{assign var="error_message" value=$msg }
{include file="display_error.tpl"}
{/if}
<div class="top_bottom_pad" style="text-align:center; padding:2px;">
<img src="getsnap.php?id={$uid}&amp;typ=tn" class="smallpic" alt="" />
</div>
<div class="top_bottom_pad" style="padding-left:6px;font-weight:bold;">
#USERNAME# will be replaced with the recipient\'s username and  #FROMNAME# will be replaced with Sender\'s username.
</div>
<form name="frmContact" action="" method="post" onsubmit="javascript: return validate(this);">
<input type="hidden" name="cmd" value="posted" />
<input type="hidden" name="id" value="{$uid}" />
<input type="hidden" name="uname" value="{$uname}" />

<table border="0" cellpadding="{$config.cellpadding}" cellspacing="{$config.cellspacing}">
<tr>
<td valign="top">{lang mkey='im_message'}
<font class="required_info">{$smarty.const.REQUIRED_INFO}</font>
</td>
<td ><textarea rows="10" cols="55" name="txtcomments">{$txtcomments|stripslashes }</textarea></td>
</tr>
<tr><td colspan="2" height="6"></td></tr>


<tr>
<td></td>
<td><input name="submit" class="formbutton" type="submit" value="{lang mkey='submit'}"/>&nbsp;
<input name="reset" type="reset" value="{lang mkey='reset'}" class="formbutton"/> </td>
</tr>
</table>
</form>
{/if}
</div>
</div>
{/strip}


All done  ;)
Regards,
Pharg ( Phill )

REMEMBER: ALWAYS BACKUP BEFORE YOU MAKE ANY CHANGES!!

osDateEvo v1.0 | PHP: 5.3.42 & PHP: 5.6.18 | MySQL: 5.5.35