22 พฤษภาคม 2555, 15:57:36
ยินดีต้อนรับผู้เยี่ยมชม
  • noavata
  • ยินดีต้อนรับคุณ, ผู้เยี่ยมชม กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน
    เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น
Page Rank

ทำเว็บไซต์ | แต่งบอร์ด | ออกแบบ | SMF | Joomla | Drupal | WordPress | JQuery | CMS | ECommerce | Tel. +668-08577477

ส่งหัวข้อนี้พิมพ์ หน้า: 1 
icon message ผู้เขียน หัวข้อ: Auto Email ส่งอีเมลถึงสมาชิกอัตโนมัติ  (อ่าน 820 ครั้ง)
0 สมาชิก และ 1 ผู้เยี่ยมชม กำลังดูหัวข้อนี้
*
*


!Personal

Germany   ชาย ผู้เริ่มต้นกระทู้นี้ ออฟไลน์544566157 DexMore DexMore DexMore
เว็บไซต์
icon message
general เมื่อ: 18 มิถุนายน 2553, 22:51:41
  • ชื่อ: Auto Email Inactive Ordinary Users
  • ผู้เขียน: rsw686
  • นำเสนอโดย: DexMoreGroup
  • ประเภท: New Feature
  • รองรับ: SMF 1.1.xx, 2.0.xx
  • ปรับปรุงล่าสุด: 8 พฤษภาคม 2551
  • ต้นฉบับ: Auto Email Inactive Ordinary Users

รายละเอียด
      ส่งอีเมลแจ้งเตือนสมาชิกที่ไม่ได้ออนไลน์เป็นเวลา 21 วันขึ้นไป และสามารถตั้งค่าให้ลบสมาชิกที่ไม่ออนไลน์หลังจากได้ส่งอีเมล ฉบับที่ 2 แต่ mod นี้ทำงานค่อนข้างหนักครับ ใช้ทรัพยากรณ์ของเครื่องแม่ข่ายมากพอสมควร ท่านใดคิดจะใช้ก็ลองๆ ดูก่อนนะครับถ้าหากใช้แล้วคุ้มค่ากับทรัพยกรณ์ที่ใช้ไปก็น่าใช้

ตัวอย่าง


สำหรับ SMF 1.1.xx

แก้ไขไฟล์:

file $boarddir/index.php

ค้นหา -->>
โค๊ด: [Select]
// Load the current user's permissions.
loadPermissions();

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
// Auto Email In active ordinary users
aeiou();

file $sourcedir/Subs.php

ค้นหา -->>
โค๊ด: [Select]
?>

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
// Auto Email Inactive Ordinary Users Function
function aeiou()
{
global $context, $modSettings, $db_prefix, $txt, $scripturl, $sourcedir;

// Max chunk. (max amount of emails to send at a time.)
// Keeps page loading fast, mail server running smoothly
$maxchunk = ($modSettings['aeiou_chunksize'] != 0) ? $modSettings['aeiou_chunksize'] : 4 ;

// Mod disabled?
if(empty($modSettings['aeiou_enable']))
return;

// Time
$time = time();
list($hour, $day) = explode(',', (date('H,d', $time)));
list($lockedhour, $lockedday) = ($modSettings['aeiou_locktimestamp'] == 0) ? array(-1, -1) : explode(',', (date('H,d', $modSettings['aeiou_locktimestamp']))) ;

// 5 min gap between sending each chunk
if($time < ($modSettings['aeiou_locktimestamp'] + 300))
return;

// Different day? Reset?
if($day != $lockedday)
$modSettings['aeiou_day_sent'] = 0;
// Different hour
if($hour != $lockedhour)
$modSettings['aeiou_hour_sent'] = 0;

// Reached limits for this day/hour?
if(($modSettings['aeiou_hour_sent'] >= $modSettings['aeiou_hour_max']) ||
($modSettings['aeiou_day_sent'] >= $modSettings['aeiou_day_max']))
return;

// Update the timestamp - Attempt to Prevent Race Conditions
$request = db_query("
UPDATE {$db_prefix}settings
SET value = $time
WHERE variable = 'aeiou_locktimestamp'
AND value = '". $modSettings['aeiou_locktimestamp'] ."'
LIMIT 1
", __FILE__, __LINE__);

// Race Condition - Timestamp wasn't changed as it was changed already by another.
if(mysql_affected_rows() == 0)
return;

// Update timestamp variable (in case used, such as in the admin)
$modSettings['aeiou_locktimestamp'] = $time;

// Stopped, but its a new day, so re-activate
if(!empty($modSettings['aeiou_stop']) && $day != $lockedday)
{
$modSettings['aeiou_stop'] = 0 ;
aeiou_update(array('stop' => 0, 'day_sent' => $modSettings['aeiou_day_sent'], 'hour_sent' => $modSettings['aeiou_hour_sent']));
}

// Tidy up
unset($day, $lockedday);

// Reset the emails sent for any users who have logged in since we sent the emails
db_query("
UPDATE {$db_prefix}members
SET aeiou_email = 0, aeiou_count = 0
WHERE lastLogin > aeiou_email
AND aeiou_email > 0
", __FILE__, __LINE__);

// Delete users query
if(!empty($modSettings['aeiou_delete']))
aeiou_delete();

// If the mod is still stopped, return. (Since we've completed deleting/updating members)
if(!empty($modSettings['aeiou_stop']))
return;

// How many victims to get?
// Based on the remainder allowed for this hour and max chunk size
$limit = (($modSettings['aeiou_hour_max'] - $modSettings['aeiou_hour_sent']) < $maxchunk) ? $modSettings['aeiou_hour_max'] - $modSettings['aeiou_hour_sent'] : $maxchunk ;
// Based on the remainder allowed for this day
if($limit > ($modSettings['aeiou_day_max'] - $modSettings['aeiou_day_sent']))
$limit = (int) $modSettings['aeiou_day_max'] - $modSettings['aeiou_day_sent'];

// Query to get next victims
// - Must have been registered for 21 days
// - Must not have logged in for 21 days
// - Must not have been sent both initial and final email
// - Must not be an admin
// - Must not been emailed in the last 21 days
// - Must not be banned (is_activated >= 10)
// - Must be an activated username/account (not 0)
$request = db_query("
SELECT ID_MEMBER, emailAddress, memberName, realName, aeiou_count
FROM {$db_prefix}members
WHERE dateRegistered < ". ($time - 1814400) ."
AND lastLogin < ". ($time - 1814400) ."
AND aeiou_email < ". ($time - 1814400) ."
AND ID_GROUP != 1
AND NOT FIND_IN_SET(1, additionalGroups)
AND aeiou_count < 2
AND is_activated < 10
AND is_activated != 0
AND is_activated != 4
ORDER BY aeiou_count ASC, aeiou_email ASC, lastLogin ASC
LIMIT ".$limit."
", __FILE__, __LINE__);

$returned = (int) mysql_num_rows($request);

// No victims, returned
if($returned == 0)
{
mysql_free_result($request);
// No point in calling this script again until tomorrow, So set the stop
aeiou_update(array('stop' => 1));
$modSettings['aeiou_stop'] = 1;
// No point in continuing so return
return;
}

// Store the details of the selected few in an array, the ids to update
$ids = $users = array();
// Now the actual sending
while($row = mysql_fetch_assoc($request))
{
$users[] = $row;
$ids[] = (int) $row['ID_MEMBER'];
}

// Tidy up
unset($row);
mysql_free_result($request);

// Store our updated stats (ready to update the db)
$modSettings['aeiou_day_sent'] = $modSettings['aeiou_day_sent'] + $returned;
$modSettings['aeiou_hour_sent'] = $modSettings['aeiou_hour_sent'] + $returned;

// Update the Stats
if($returned < $limit)
{
// Some returned (must be the last few)
// No point in calling this script again until tomorrow, so stop
$modSettings['aeiou_stop'] = 1;
aeiou_update(array('stop' => 1, 'day_sent' => $modSettings['aeiou_day_sent'], 'hour_sent' => $modSettings['aeiou_hour_sent']));
}
else
{
// Increase our stats for how many have been sent hour/day
// But we won't be stopping as there are clearly more people left to email
aeiou_update(array('day_sent' => $modSettings['aeiou_day_sent'], 'hour_sent' => $modSettings['aeiou_hour_sent']));
}

// Update the users information
db_query("
UPDATE {$db_prefix}members
SET aeiou_email = '". $time ."', aeiou_count = aeiou_count + 1
WHERE ID_MEMBER IN (". implode(', ', $ids) .")
", __FILE__, __LINE__);

// Tidy up
unset($ids);

// Variables to replace with actual strings, with preg patterns.
// PHP4 users don't have str_ireplace, so we're using preg
$search = array(
'~\$username~i'.($context['utf8'] ? 'u' : ''),
'~\$displayname~i'.($context['utf8'] ? 'u' : ''),
'~\$forum~i'.($context['utf8'] ? 'u' : ''),
'~\$link~i'.($context['utf8'] ? 'u' : ''),
'~\$lostpassword~i'.($context['utf8'] ? 'u' : '')
);

// We need the emailing functions
require_once($sourcedir . '/Subs-Post.php');

// Now the important bit - the emailing
foreach($users as $row)
{
// Initial or final email
$which = ($row['aeiou_count'] == 0) ? 'initial' : 'final' ;

// Custom or default message/subject?
$message = empty($modSettings['aeiou_'.$which.'_message']) ? $txt['aeiou_default_message'] : $modSettings['aeiou_'.$which.'_message'] ;
$subject = empty($modSettings['aeiou_'.$which.'_subject']) ? $txt['aeiou_default_subject'] : $modSettings['aeiou_'.$which.'_subject'] ;

// Replace our placeholders in the message eg $username eg
$replace = array($row['memberName'], $row['realName'], $context['forum_name'], $scripturl, $scripturl.'?action=reminder');
// Use preg so matches mixed case
$message = preg_replace($search, $replace, $message);
$subject = preg_replace($search, $replace, $subject);

// Strip_tags - remember no html
$message = strip_tags($message);
$subject = strip_tags($subject);
// Special chars
$message = htmlspecialchars($message, ENT_QUOTES);
$subject = htmlspecialchars($subject, ENT_QUOTES);
// Add Slashes
$message = addslashes($message);
$subject = addslashes($subject);

// Now send the mail
sendmail($row['emailAddress'], $subject, $message);

}
// Tidy up
unset($users, $row, $search, $replace, $subject, $message);

}
// Function to delete users. sends through deleteMembers function in Subs-members.php
function aeiou_delete()
{
global $db_prefix, $modSettings;

$modSettings['aeiou_underposts'] = empty($modSettings['aeiou_underposts']) ? 0 : (int) $modSettings['aeiou_underposts'] ;

// Get a timestamp
$time = time();

// Grab all ordinary (non-admin) users to kill (5 at a time, otherwise it would kill the server)
// - Must not be an admin
// - Must have been registered for 21 days
// - Initially the user must not have logged in for 21 days
// - Then must have been sent initial email
// - Then after 21 days
// - Then must have been sent final email
// - Then it must be 21 days since that second email
// - Now its times to delete a few of them at a time
$request = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE dateRegistered < ". ($time - 1814400) ."
AND lastLogin < ". ($time - 1814400) ."
AND ID_GROUP != 1
AND FIND_IN_SET(1, additionalGroups) = 0
AND aeiou_count > 1
AND aeiou_email < ". ($time - 1814400) ."
". ( ($modSettings['aeiou_underposts'] > 0) ? "AND posts <= ".$modSettings['aeiou_underposts'] : "" ) ."
LIMIT 5
", __FILE__, __LINE__);

// No people to delete
if(mysql_num_rows($request) == 0)
return;

// Store all the users to be deleted in an array
$users = array();
while($row = mysql_fetch_assoc($request))
$users[] = (int) $row['ID_MEMBER'];

// Tidy up
mysql_free_result($request);
unset($row, $condition);

// Delete members (using a bypass of some checks)
require_once('Subs-Members.php');
deleteMembers($users, true);

}
// Function to update a setting of this mod, adds aeiou_ to any variable name
function aeiou_update($array = null)
{
global $db_prefix;

// If not an array, or empty, return
if(!is_array($array) || empty($array))
return;

foreach($array as $a => $b)
{
db_query("
UPDATE {$db_prefix}settings
SET value = ". (int) $b ."
WHERE variable = 'aeiou_".$a."'
", __FILE__, __LINE__);
}
}

file $sourcedir/Subs-Members.php

ค้นหา -->>
โค๊ด: [Select]
function deleteMembers($users)

แก้เป็น -->>
โค๊ด: [Select]
function deleteMembers($users, $bypass = false)

ค้นหา -->>
โค๊ด: [Select]
elseif (count($users) == 1)
{
list ($user) = $users;
$condition = '= ' . $user;

if ($user == $ID_MEMBER)
isAllowedTo('profile_remove_own');
else
isAllowedTo('profile_remove_any');
}
else
{
foreach ($users as $k => $v)
$users[$k] = (int) $v;
$condition = 'IN (' . implode(', ', $users) . ')';

// Deleting more than one?  You can't have more than one account...
isAllowedTo('profile_remove_any');
}

// Make sure they aren't trying to delete administrators if they aren't one.  But don't bother checking if it's just themself.
if (!allowedTo('admin_forum') && (count($users) != 1 || $users[0] != $ID_MEMBER))
{
$request = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE ID_MEMBER IN (" . implode(', ', $users) . ")
AND (ID_GROUP = 1 OR FIND_IN_SET(1, additionalGroups) != 0)
LIMIT " . count($users), __FILE__, __LINE__);
$admins = array();
while ($row = mysql_fetch_assoc($request))
$admins[] = $row['ID_MEMBER'];
mysql_free_result($request);

if (!empty($admins))
$users = array_diff($users, $admins);
}

แก้เป็น -->>
โค๊ด: [Select]
// *Section Modified by Automatically Email Inactive Users mod
if (count($users) == 1)
{
list ($user) = $users;
$condition = '= ' . $user;

// Bypass when called by AEIOU mod
if(!$bypass)
{
if ($user == $ID_MEMBER)
isAllowedTo('profile_remove_own');
else
isAllowedTo('profile_remove_any');
}
else
{
global $boardurl;
// Bypass only valid via SMF, the Board Url and deletion is enabled
if(!defined('SMF') || $boardurl != substr($_SERVER['REQUEST_URL'], 0, strlen($boardurl)) || empty($modSettings['aeiou_delete']))
return;
}
}
else
{
foreach ($users as $k => $v)
$users[$k] = (int) $v;
$condition = 'IN (' . implode(', ', $users) . ')';

// Bypass when called by AEIOU mod
if(!$bypass)
{
// Deleting more than one?  You can't have more than one account...
isAllowedTo('profile_remove_any');
}
else
{
global $boardurl;
// Bypass only valid via SMF && via Board Url
if(!defined('SMF') || $boardurl != substr($_SERVER['REQUEST_URL'], 0, strlen($boardurl)) || empty($modSettings['aeiou_delete']))
return;
}
}

// Make sure they aren't trying to delete administrators if they aren't one.  But don't bother checking if it's just themself.
if (!allowedTo('admin_forum') && (count($users) != 1 || $users[0] != $ID_MEMBER))
{
$request = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE ID_MEMBER IN (" . implode(', ', $users) . ")
AND (ID_GROUP = 1 OR FIND_IN_SET(1, additionalGroups) != 0)
LIMIT " . count($users), __FILE__, __LINE__);
$admins = array();
while ($row = mysql_fetch_assoc($request))
$admins[] = $row['ID_MEMBER'];
mysql_free_result($request);

if (!empty($admins))
$users = array_diff($users, $admins);
}

file $sourcedir/ModSettings.php

ค้นหา -->>
โค๊ด: [Select]
$context['sub_template'] = 'show_settings';

$subActions = array(

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
'aeiou' => 'ModifyAeiouSettings',

ค้นหา -->>
โค๊ด: [Select]
require_once($sourcedir . '/ManageServer.php');

$subActions = array(

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
'aeiou' => 'ModifyAeiouSettings',

ค้นหา -->>
โค๊ด: [Select]
'karma' => array(
'title' => $txt['smf293'],
'href' => $scripturl . '?action=featuresettings;sa=karma;sesc=' . $context['session_id'],

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
),
'aeiou' => array(
'title' => $txt['aeiou'],
'href' => $scripturl . '?action=featuresettings;sa=aeiou;sesc=' . $context['session_id'],

ค้นหา -->>
โค๊ด: [Select]
?>

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
function ModifyAeiouSettings()
{
global $txt, $scripturl, $context, $settings, $sc, $db_prefix, $modSettings;

// If the mod is enabled and we're not saving, query for mod status information
if (!isset($_GET['save']) && $modSettings['aeiou_enable'])
{
// Current time
$time = time();

// Get the delete band
$request = db_query("
SELECT count(*)
FROM {$db_prefix}members
WHERE lastLogin < ". ($time - 1814400) ."
AND aeiou_email < ". ($time - 1814400) ."
AND aeiou_count > 1
AND posts <= ". (int) $modSettings['aeiou_underposts']. "
", __FILE__, __LINE__);
list($deletion) = mysql_fetch_row($request);

// Create an array for the bands, with default values of 0
$temp = array(0 => 0, 1 => 0, 2 => (int) $deletion);

// Tidy up
unset($deletion);
mysql_free_result($request);

// Get the email bands
$request = db_query("
SELECT count(*) as no, aeiou_count
FROM {$db_prefix}members
WHERE dateRegistered < ". ($time - 1814400) ."
AND lastLogin < ". ($time - 1814400) ."
AND aeiou_email < ". ($time - 1814400) ."
AND ID_GROUP != 1
AND NOT FIND_IN_SET(1, additionalGroups)
AND aeiou_count < 2
AND is_activated < 10
AND is_activated != 0
AND is_activated != 4
GROUP BY aeiou_count
ORDER BY aeiou_count ASC
", __FILE__, __LINE__);

// No further emails, if not set already, stop the mod until tomorrow
if(mysql_num_rows($request) == 0)
{
// If not already, tell the mod to stop
if(!empty($modSettings['aeiou_stop']))
aeiou_update(array('stop' => 1));
// Change the variable for the remainder of this page
$modSettings['aeiou_stop'] = 1;
}
else
{
// Store the bands in the array created earlier
while($row = mysql_fetch_assoc($request))
$temp[$row['aeiou_count']] = $row['no'];
// Tidy up
unset($row);

// The mod is set as stopped, but we discovered some emails, so re-activate us
if(!empty($modSettings['aeiou_stop']))
{
aeiou_update(array('stop' => 0));
// Change the variable for the remainder of this page
$modSettings['aeiou_stop'] = 0;
$reactivated = 1;
}
}

// Prepare rows for the stats table
$items = array();

// Last ran
$items['aeiou_last_ran'] = ($modSettings['aeiou_locktimestamp'] == 0) ? $txt['aeiou_never'] : timeformat($modSettings['aeiou_locktimestamp'], true) ;

$again = ($modSettings['aeiou_locktimestamp'] == 0) ? $time : $modSettings['aeiou_locktimestamp'];
// But if reached daily limit or is stopped we will start/check again tomorrow
if($modSettings['aeiou_day_max'] <= $modSettings['aeiou_day_sent'] || !empty($modSettings['aeiou_stop']))
{
$date = explode('-', date('Y-m-d', $again));
$tomorrow = mktime(0, 0, 0, $date[1], $date[2], $date[0]) + (60*60*24);
$items['aeiou_starts_again'] = timeformat($tomorrow, true);
unset($date, $tomorrow);
}
elseif($modSettings['aeiou_hour_max'] <= $modSettings['aeiou_hour_sent'])
{
// Or reached hourly limit we will start/check again next hour
$date = explode('-', date('Y-m-d-h', $again));
$nexthour = mktime($date[3], 0, 0, $date[1], $date[2], $date[0]) + (60*60);
$items['aeiou_starts_again'] = timeformat($nexthour, true);
unset($date, $nexthour);
}
else
// Else Can start again from previous + 5mins
$items['aeiou_starts_again'] = timeformat($again + 300, true) ;

// Emailed today with max in parenthesis
$items['aeiou_sent_day'] = $modSettings['aeiou_day_sent']
.' <span style="font-weight:normal;font-style:italic">('.$txt['aeiou_max'].': '.$modSettings['aeiou_day_max'].')</span>';
// Emailed this hour with max in parenthesis
$items['aeiou_sent_hour'] = $modSettings['aeiou_hour_sent']
.' <span style="font-weight:normal;font-style:italic">('.$txt['aeiou_max'].': '.$modSettings['aeiou_hour_max'].')</span>';

// Now setup the stats about no.s of email etc
$items['aeiou_awaiting_total'] = $temp[0] + $temp[1];
$items['aeiou_awaiting_initial_email'] = $temp[0];
$items['aeiou_awaiting_final_email'] = $temp[1];
$items['aeiou_awaiting_deletion'] = $temp[2] . (empty($modSettings['aeiou_delete']) ? ' <span style="color:red">'.$txt['aeiou_disabled'].'</span>' : '' ) ;

// Reasons for inactive
if(!empty($modSettings['aeiou_stop']))
$status = $txt['aeiou_nofurtheremails'];
elseif($modSettings['aeiou_day_max'] <= $modSettings['aeiou_day_sent'])
$status = $txt['aeiou_reacheddailylimit'];
elseif($modSettings['aeiou_hour_max'] <= $modSettings['aeiou_hour_sent'])
$status = $txt['aeiou_reachedhourlylimit'];

// Is the mod Active? (even if enabled, it might not be active)
// If the mod was stopped, but on loading this page, we discovered more emails, show as re-activated
if(!empty($reactivated))
$status = '<span style="color:darkgreen">'.$txt['aeiou_reactivated'].'</span>';
elseif(empty($status))
$status = '<span style="color:darkgreen">'.$txt['aeiou_active'].'</span>';
else
// Inactive
$status = '<span style="color:maroon">'.$txt['aeiou_stopped'].'</span> - '. $status;

// Header of the stats chunk and status
$chunk = '<table cellpadding="1" cellspacing="0" border="0" width="100%" class="tborder">
<tr class="titlebg"><td colspan="2">'.$txt['aeiou_status'].': '.$status.'</td></tr>';

// Now build the chunk of html of our stats
foreach($items as $string => $value)
{
// Less emphasis on the sub-totals
$italic = ($string == 'aeiou_awaiting_initial_email' || $string == 'aeiou_awaiting_final_email') ? 1 : 0 ;
// Add more rows to the existing chunk
$chunk .= '<tr class="windowbg"><td'.($italic ? ' style="font-weight:normal;font-style:italic"' : '').' >'.$txt[$string].':</td><td'.($italic ? ' style="font-weight:normal;font-style:italic"' : '').'>'.$value.'</td></tr>';
}
$chunk .= '</table><br />';

// Now for the last 10 people emailed
$request = db_query("
SELECT ID_MEMBER, memberName, aeiou_email, aeiou_count
FROM {$db_prefix}members
WHERE aeiou_email != 0
ORDER BY aeiou_email DESC
LIMIT 10
", __FILE__, __LINE__);

$chunk2 = '<table cellpadding="1" cellspacing="0" border="0" width="100%" class="tborder">
<tr class="titlebg"><td colspan="3">'.$txt['aeiou_last10emailed'].'</td></tr>';
if(mysql_num_rows($request) == 0)
$chunk2 .= '<tr class="windowbg"><td colspan="3">'.$txt['aeiou_never'].'</td></tr>';
else
{
// Add each user as a row in the table
while($row = mysql_fetch_assoc($request))
$chunk2 .= '<tr class="windowbg"><td><a href="'.$scripturl.'?action=profile;u='.$row['ID_MEMBER'].'">'.$row['memberName'].'</a></td><td style="font-weight:normal;">'.timeformat($row['aeiou_email'], true).'</td><td style="font-weight:normal;">'. $txt['aeiou_'.( ($row['aeiou_count'] == 1) ? 'initial' : 'final' )].'</td></tr>';
}
$chunk2 .= '</table><br />';

}
else
// If the mod is not enabled, don't show either as chunks.  use a space to prevent it being shown as a delimiter
$chunk = $chunk2 = ' ';

// Compile/Build some language strings/add to
// Avoids using html in the language files
$temp = array('initial_subject' => 'subject', 'initial_message' => 'message', 'final_subject' => 'subject', 'final_message' => 'message');
$add = '<div class="smalltext">'.$txt['aeiou_email_desc1'].'<br />'.$txt['aeiou_email_desc2'].'<br />'.$txt['aeiou_email_desc3'].'</div>';
foreach($temp as $a => $b)
{
// Add the descriptions to the txt string
$txt['aeiou_'.$a] .= $add;
// Use the default message if we don't have a custom one saved
if(empty($modSettings['aeiou_'.$a]))
$modSettings['aeiou_'.$a] = !empty($txt['aeiou_default_'.$b]) ? $txt['aeiou_default_'.$b] : '' ;
}
// Tidy up
unset($temp, $add, $a);

// More descriptions to add with html
$temp = array('delete', 'underposts', 'hour_max', 'day_max', 'chunksize');
foreach($temp as $a)
$txt['aeiou_'.$a] .= '<div class="smalltext">'.$txt['aeiou_'.$a.'_desc'] .'</div>';

// Now the warning chunk.  Comprises of 4 parts.
$txt['aeiou_warning'] .= '<div class="smalltext">'. $txt['aeiou_warning2'] .'<br />'.$txt['aeiou_warning3'].'<br />'.$txt['aeiou_warning4'].'</div>';

// The important array
$config_vars = array(
$chunk,
array('check', 'aeiou_enable'),
array('text', 'aeiou_initial_subject', '30" style="width:95%'),
array('large_text', 'aeiou_initial_message', '5" style="width:95%'),
array('text', 'aeiou_final_subject', '30" style="width:95%'),
array('large_text', 'aeiou_final_message', '5" style="width:95%'),
'',
array('check', 'aeiou_delete'),
array('int', 'aeiou_underposts'),
'',
$txt['aeiou_warning'],
array('int', 'aeiou_hour_max'),
array('int', 'aeiou_day_max'),
array('int', 'aeiou_chunksize'),
$chunk2,
);

// Saving?
if (isset($_GET['save']))
{
saveDBSettings($config_vars);
redirectexit('action=featuresettings;sa=aeiou');
}

$context['post_url'] = $scripturl . '?action=featuresettings2;save;sa=aeiou';
$context['settings_title'] = $txt['aeiou_title'];

prepareDBSettingContext($config_vars);
}

file $languagedir/Modifications.thai-utf8.php

เพิ่ม -->>
โค๊ด: [Select]
$txt['aeiou'] = 'AEIOU';
$txt['aeiou_title'] = 'Auto Email Inactive Ordinary Users';
$txt['aeiou_enable'] = 'Enable Automatic Emailing Of Inactive Users';
$txt['aeiou_email_desc1'] = 'Text-Only (No html, no bbcode)';
$txt['aeiou_email_desc2'] = 'Allowed Variables';
$txt['aeiou_email_desc3'] = '$username, $displayname, $forum, $link, $lostpassword';
$txt['aeiou_initial_subject'] = 'Initial Email Subject';
$txt['aeiou_initial_message'] = 'Initial Email Message';
$txt['aeiou_final_subject'] = 'Final Email Subject';
$txt['aeiou_final_message'] = 'Final Email Message';
$txt['aeiou_delete'] = 'Auto Delete Members (Except Admins)';
$txt['aeiou_delete_desc'] = 'After being sent an initial and final email AND has not returned within a further 21 days (Minimum 63 days total)';
$txt['aeiou_underposts'] = 'Delete Member Post Threshold';
$txt['aeiou_underposts_desc'] = 'With a postcount less than or equal to.';
$txt['aeiou_warning'] = 'It is NOT Recommended To Change Settings Below';
$txt['aeiou_warning2'] = 'Mail is sent in small chunks with hourly/daily limits to ensure your IMPORTANT mail all gets through.';
$txt['aeiou_warning3'] = '(such as Activation Emails, Notifications, Emails, Announcements, Newsletters)';
$txt['aeiou_warning4'] = 'Try reducing the amounts if your emails are not being received.';
$txt['aeiou_hour_max'] = 'Max Emails Per Hour';
$txt['aeiou_hour_max_desc'] = 'Based on a hosts limit of 100 per hour';
$txt['aeiou_day_max'] = 'Max Emails Per Day';
$txt['aeiou_day_max_desc'] = 'Based on a hosts limit of 1000 per day';
$txt['aeiou_chunksize'] = 'Send x emails at a time';
$txt['aeiou_chunksize_desc'] = 'With a min 5 minute interval';
$txt['aeiou_active'] = 'Active';
$txt['aeiou_reactivated'] = 'Re-Activated';
$txt['aeiou_reachedhourlylimit'] = 'Reached Hourly Limit';
$txt['aeiou_reacheddailylimit'] = 'Reached Daily Limit';
$txt['aeiou_nofurtheremails'] = 'No Further Emails To Send';
$txt['aeiou_stopped'] = 'Stopped';
$txt['aeiou_last_ran'] = 'Last Ran';
$txt['aeiou_starts_again'] = 'Will Start Again';
$txt['aeiou_sent_day'] = 'Emails Sent Today';
$txt['aeiou_sent_hour'] = 'Emails Sent This Hour';
$txt['aeiou_awaiting_total'] = 'Total Emails Awaiting To Be Sent';
$txt['aeiou_awaiting_initial_email'] = 'No. of Initial Emails';
$txt['aeiou_awaiting_final_email'] = 'No. of Final Emails';
$txt['aeiou_awaiting_deletion'] = 'Users Awaiting Deletion';
$txt['aeiou_disabled'] = '(Disabled)';
$txt['aeiou_none'] = 'None';
$txt['aeiou_never'] = 'Never';
$txt['aeiou_status'] = 'Status';
$txt['aeiou_max'] = 'Max';
$txt['aeiou_initial'] = 'Initial Email';
$txt['aeiou_final'] = 'Final Email';
$txt['aeiou_last10emailed'] = 'Last 10 Inactive Users Emailed';
$txt['aeiou_default_subject'] = 'Hey $displayname';
$txt['aeiou_default_message'] = 'Hey $displayname, we have missed you at $forum.
Since its been a while, we thought we would send you a personal invitation to return.

$link

Your login username is $username.
If you have forgotten your password you can request it at $lostpassword

Regards
$forum staff';

สร้างไฟล์: 11x-dbmodify.php เพื่อสร้างฐานข้อมูล ไว้ใน $boarddir (ที่เดียวกับไฟล์ SSI.php) รัน http://www.your_url.xxx/$boarddir/11x-dbmodify.php -->> Enter เสร็จแล้วลบทิ้ง
โค๊ด: [Select]
<?php
// If SSI.php is in the same place as this file, and SMF isn't defined, this is being run standalone.
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
        include_once(
dirname(__FILE__) . '/SSI.php');
// Hmm... no SSI.php and no SMF?
elseif (!defined('SMF'))
        die(
'<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');

// Upgrade the database if necessary
$request db_query("SHOW COLUMNS FROM {$db_prefix}members"__FILE____LINE__);
while (
$row mysql_fetch_row($request))
$cols[] = $row[0];
mysql_free_result($request);

if (!
in_array("aeiou_email"$cols))
db_query("
ALTER IGNORE TABLE {$db_prefix}members
ADD aeiou_email int(10) NOT NULL default '0'
AFTER location
"
__FILE____LINE__);

if (!
in_array("aeiou_count"$cols))
db_query("
ALTER IGNORE TABLE {$db_prefix}members
ADD aeiou_count int(10) NOT NULL default '0'
AFTER location
"
__FILE____LINE__);

// Define each setting to be added
$newSetting['aeiou_enable'] = ; // Enable mod (disabled by default so you can customize)
$newSetting['aeiou_locktimestamp'] = ; // Timestamp lock

$newSetting['aeiou_hour_max'] = 50 ; // Max emails per hour (to keep registrations, notifications, emails going through)
// based on a server limit of 100 per hour.
$newSetting['aeiou_day_max'] = 500 ; // Max emails sent in an day at which to disable this mod (to keep registrations, 
// notifications, emails going through), based on a server limit of 1000 per day
$newSetting['aeiou_hour_sent'] = ; // Sent this hour (all emails)
$newSetting['aeiou_day_sent'] = ; // Sent this day (all emails)

$newSetting['aeiou_chunksize'] = ; // The no. of emails to send at a time (reduce to increase performance)
$newSetting['aeiou_stop'] = ; // Set to 1 to stop it sending emails until tomorrow (but it still checks for users 
// to delete, and returning users)

$newSetting['aeiou_delete'] = ; // (Optional, delete inactive users after 30 days after the 3rd email was sent)
$newSetting['aeiou_underposts'] = ; // (Optional, choose to delete only those under a post count threshold)

$newSetting['aeiou_initial_subject'] = ''; // To store a custom initial subject message for the email, if blank revert to use 
// default txt string
$newSetting['aeiou_initial_message'] = ''; // To store a custom initial message, if blank revert to use default txt string
$newSetting['aeiou_final_subject'] = ''; // To store a custom final subject message for the email, if blank revert to use
// default txt string
$newSetting['aeiou_final_message'] = ''; // To store a custom final message, if blank revert to use default txt string

// Cycle through array adding each new setting - if already exists, ignore
foreach ($newSetting as $key => $value)
db_query("
INSERT IGNORE INTO {$db_prefix}settings (`variable`, `value`)
VALUES ('$key', '$value')"
__FILE____LINE__);

// Delete settings used by pre 1.4 versions
$delSetting[] = 'aeiou_message';
$delSetting[] = 'aeiou_subject';
$delSetting[] = 'aeiou_lockkey';

// Cycle through array deleting each setting
db_query("
DELETE FROM {$db_prefix}settings
WHERE variable = '"
.implode("' OR variable = '"$delSetting)."'
"
__FILE____LINE__);

// If we're using SSI, tell them we're done
if(SMF == 'SSI')
echo 'Database changes for the AEIOU mod are complete!';

?>


การตั้งค่า: ผู้ดูแล -->> ส่วนปรับแต่งค่าการใช้งาน -->> AEIOU

ลิงค์หัวข้อ: http://dexmore.com/topic/2020
Windows XP    Firefox 3.6.3   see ip บันทึกการเข้า
ดูรายการสิ่งของสำหรับบอกรักใครสักคน ก็ส่งไปให้เขาเลย!  สำหรับติดหมุดกระทู้ของคุณ!  เพิ่มเวลาที่อยู่ในระบบอีก 12 ชั่วโมง  น้องหมี..เอาไว้กอดนอนแทนกิ๊ก  สำหรับบอกรักใครสักคน ก็ส่งไปให้เขาเลย!  
*
*


!Personal

Germany   ชาย ผู้เริ่มต้นกระทู้นี้ ออฟไลน์544566157 DexMore DexMore DexMore
เว็บไซต์
icon message
general ความคิดเห็นที่ 1 เมื่อ: 19 มิถุนายน 2553, 00:02:26
สำหรับ SMF 2.0.xx

แก้ไขไฟล์:

file $sourcedir/ScheduledTasks.php

ค้นหา -->>
โค๊ด: [Select]
?>

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
function scheduled_email_inactive()
{
global $smcFunc, $context, $modSettings, $scripturl, $sourcedir, $mbname, $txt;

// Going to need this to send the emails.
require_once($sourcedir . '/Subs-Post.php');

$time = time();

// Reset the emails sent for any users who have logged in since we sent the emails
$smcFunc['db_query']('', '
UPDATE {db_prefix}members
SET aeiou_email = {int:aeiou_email},
aeiou_count = {int:aeiou_count}
WHERE last_login > aeiou_email
AND aeiou_email > {int:aeiou_greater}',
array(
'aeiou_email' => 0,
'aeiou_count' => 0,
'aeiou_greater' => 0
)
);

// Query to get next victims
// - Must have been registered for 21 days
// - Must not have logged in for 21 days
// - Must not been emailed in the last 21 days
// - Must not have been sent both initial and final emails
// - Must not be an admin
// - Must have standard activation (is_activated = 1)
// - Must have an email address (NOT NULL)
$request = $smcFunc['db_query']('', '
SELECT id_member, email_address, member_name, real_name, aeiou_count
FROM {db_prefix}members
WHERE date_registered < {int:date_registered}
AND last_login < {int:last_login}
AND aeiou_email < {int:aeiou_email}
AND aeiou_count < {int:aeiou_count}
AND id_group != {int:id_group}
AND NOT FIND_IN_SET({int:additional_groups}, additional_groups)
AND is_activated = {int:is_activated}
AND email_address is NOT NULL
ORDER BY aeiou_count ASC, aeiou_email ASC, last_login ASC',
array(
'date_registered' => $time - 1814400,
'last_login' => $time - 1814400,
'aeiou_email' => $time - 1814400,
'aeiou_count' => 2,
'id_group' => 1,
'additional_groups' => 1,
'is_activated' => 1
)
);

$returned = $smcFunc['db_num_rows']($request);

// Variables to replace with actual strings, with preg patterns.
// PHP4 users don't have str_ireplace, so we're using preg
$search = array(
'~\$username~i'.($context['utf8'] ? 'u' : ''),
'~\$displayname~i'.($context['utf8'] ? 'u' : ''),
'~\$forum~i'.($context['utf8'] ? 'u' : ''),
'~\$link~i'.($context['utf8'] ? 'u' : ''),
'~\$lostpassword~i'.($context['utf8'] ? 'u' : '')
);

// Now the actual sending
$emailed = array();
while($row = $smcFunc['db_fetch_assoc']($request))
{
// Initial or final email
$which = ($row['aeiou_count'] == 0) ? 'initial' : 'final';

// Custom or default message/subject?
$message = empty($modSettings['aeiou_'.$which.'_message']) ? $txt['aeiou_default_message'] : $modSettings['aeiou_'.$which.'_message'];
$subject = empty($modSettings['aeiou_'.$which.'_subject']) ? $txt['aeiou_default_subject'] : $modSettings['aeiou_'.$which.'_subject'];

// Replace our placeholders in the message eg $username eg
$replace = array($row['member_name'], $row['real_name'], $mbname, $scripturl, $scripturl.'?action=reminder');

// Use preg so matches mixed case
$message = preg_replace($search, $replace, $message);
$subject = preg_replace($search, $replace, $subject);

// Strip tags, special chars, and add slashes
$message = addslashes(htmlspecialchars(strip_tags($message), ENT_QUOTES));
$subject = addslashes(htmlspecialchars(strip_tags($subject), ENT_QUOTES));

// Now send the mail
sendmail($row['email_address'], $subject, $message);
$emailed[] = $row['id_member'];
}

// Update each users information
if(!empty($emailed))
$smcFunc['db_query']('', '
UPDATE {db_prefix}members
SET aeiou_email = {int:aeiou_email},
aeiou_count = aeiou_count+1
WHERE id_member IN ({array_int:id_member})',
array(
'aeiou_email' => $time,
'id_member' => $emailed
)
);

// Tidy up
$smcFunc['db_free_result']($request);

return true;
}

file $sourcedir/Admin.php

ค้นหา -->>
โค๊ด: [Select]
// Mod authors if you want to be "real freaking good" then add any setting pages for your mod BELOW this line!

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
array('ModifyAeiouModSettings', 'area=modsettings;sa=aeiou'),

ค้นหา -->>
โค๊ด: [Select]
// Mod Authors for a "ADD AFTER" on this line. Ensure you end your change with a comma. For example:

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
'aeiou' => array($txt['aeiou']),

file $sourcedir/ManageSettings.php

ค้นหา -->>
โค๊ด: [Select]
// Mod authors, once again, if you have a whole section to add do it AFTER this line, and keep a comma at the end.

เพิ่มไว้หลัง -->>
โค๊ด: [Select]
'aeiou' => 'ModifyAeiouModSettings',

ค้นหา -->>
โค๊ด: [Select]
?>

เพิ่มไว้ก่อน -->>
โค๊ด: [Select]
function ModifyAeiouModSettings($return_config = false)
{
global $txt, $scripturl, $context, $settings, $sc, $modSettings, $smcFunc;

$request = $smcFunc['db_query']('', '
SELECT disabled
FROM {db_prefix}scheduled_tasks
WHERE task = {string:task}',
array(
'task' => 'email_inactive'
)
);
list($disabled) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);

$top = str_replace(array('{STATUS}', '{PAGE}'), array(
'<span style="color: ' . ($disabled ? 'red' : 'green') . ';">' . $txt['aeiou_' . ($disabled ? 'disabled' : 'enabled')] . '</span>',
'<a href="' . $scripturl . '?action=admin;area=maintain;sa=tasks">' . $txt['maintain_tasks'] . '</a>'),
$txt['aeiou_status']) . '<br /><br />';

if (empty($modSettings['mail_queue']))
$top .= str_replace(array('{STATUS}', '{PAGE}'), array(
'<span style="color: red;">' . $txt['aeiou_disabled'] . '</span>',
'<a href="' . $scripturl . '?action=admin;area=mailqueue;sa=settings">' . $txt['mailqueue_settings'] . '</a>')
, $txt['aeiou_mail_status']) . '<br />';

// Now for the last 10 people emailed
$request = $smcFunc['db_query']('', '
SELECT id_member, member_name, aeiou_email, aeiou_count
FROM {db_prefix}members
WHERE aeiou_email > {int:aeiou_email}
ORDER BY aeiou_email DESC
LIMIT 10',
array(
'aeiou_email' => 0
)
);

$bottom = '
<table cellpadding="1" cellspacing="0" border="0" width="100%">';

if($smcFunc['db_num_rows']($request) == 0)
$bottom .= '
<tr><td colspan="3">'.$txt['aeiou_never'].'</td></tr>';
else
while($row = $smcFunc['db_fetch_assoc']($request))
$bottom .= '
<tr>
<td width="40%"><a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'">'.$row['member_name'].'</a></td>
<td width="40%" style="font-weight:normal;">'.timeformat($row['aeiou_email'], true).'</td>
<td width="20%" style="font-weight:normal;">'. $txt['aeiou_'.( ($row['aeiou_count'] == 1) ? 'initial' : 'final' )].'</td>
</tr>';

$bottom .= '
</table><br />';

$smcFunc['db_free_result']($request);

// Compile/Build some language strings/add to
$replace = array('initial_subject' => 'subject', 'initial_message' => 'message', 'final_subject' => 'subject', 'final_message' => 'message');
$add = '<div class="smalltext">'.$txt['aeiou_email_desc1'].'<br />'.$txt['aeiou_email_desc2'].'<br />'.$txt['aeiou_email_desc3'].'</div>';
foreach($replace as $custom => $default)
{
// Add the descriptions to the txt string
$txt['aeiou_'.$custom] = '<b>' . $txt['aeiou_'.$custom] . '</b>' . $add;
// Use the default message if we don't have a custom one saved
if(empty($modSettings['aeiou_'.$custom]))
$modSettings['aeiou_'.$custom] = $txt['aeiou_default_'.$default];
}

$config_vars = array(
$top,
array('title', 'aeiou_settings'),
array('text', 'aeiou_initial_subject', '30" style="width:95%'),
array('large_text', 'aeiou_initial_message', '5" style="width:95%'),
array('text', 'aeiou_final_subject', '30" style="width:95%'),
array('large_text', 'aeiou_final_message', '5" style="width:95%'),
'<br />',
array('title', 'aeiou_last_emailed'),
$bottom
);

if ($return_config)
return $config_vars;

$context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=aeiou';
$context['settings_title'] = $txt['aeiou_title'];

// Saving?
if (isset($_GET['save']))
{
checkSession();
saveDBSettings($config_vars);
redirectexit('action=admin;area=modsettings;sa=aeiou');
}

prepareDBSettingContext($config_vars);
}

file $languagedir/Modifications.thai-utf8.php

เพิ่ม -->>
โค๊ด: [Select]
$txt['scheduled_task_email_inactive'] = 'Auto Email Inactive Users';
$txt['scheduled_task_desc_email_inactive'] = 'Sends out a reminder to members inactive for 21 days. <a href="' . $scripturl. '?action=admin;area=modsettings;sa=aeiou">Settings.</a>';
$txt['aeiou'] = 'Email Inactive';
$txt['aeiou_title'] = 'Auto Email Inactive Ordinary Users';
$txt['aeiou_status'] = 'AEIOU is {STATUS}. Configure it on the {PAGE} page.';
$txt['aeiou_mail_status'] = 'Mail queue is {STATUS}. This can cause performance problems.<br />Enable it on the {PAGE} page.';
$txt['aeiou_enabled'] = 'enabled';
$txt['aeiou_disabled'] = 'DISABLED';
$txt['aeiou_settings'] = 'Settings';
$txt['aeiou_initial_subject'] = 'Initial Email Subject';
$txt['aeiou_initial_message'] = 'Initial Email Message';
$txt['aeiou_final_subject'] = 'Final Email Subject';
$txt['aeiou_final_message'] = 'Final Email Message';
$txt['aeiou_email_desc1'] = 'Text-Only (No html, no bbcode)';
$txt['aeiou_email_desc2'] = 'Allowed Variables';
$txt['aeiou_email_desc3'] = '$username, $displayname, $forum, $link, $lostpassword';
$txt['aeiou_last_emailed'] = 'Last 10 Inactive Users Emailed';
$txt['aeiou_never'] = 'Never';
$txt['aeiou_initial'] = 'Initial Email';
$txt['aeiou_final'] = 'Final Email';
$txt['aeiou_default_subject'] = 'Hey $displayname';
$txt['aeiou_default_message'] = 'Hey $displayname, we have missed you at $forum.
Since its been a while, we thought we would send you a personal invitation to return.

$link

Your login username is $username.
If you have forgotten your password you can request it at $lostpassword

Regards
$forum Staff';

ลิงค์หัวข้อ: http://dexmore.com/topic/2020
Windows XP    Firefox 3.6.3   see ip บันทึกการเข้า
ดูรายการสิ่งของสำหรับบอกรักใครสักคน ก็ส่งไปให้เขาเลย!  สำหรับติดหมุดกระทู้ของคุณ!  เพิ่มเวลาที่อยู่ในระบบอีก 12 ชั่วโมง  น้องหมี..เอาไว้กอดนอนแทนกิ๊ก  สำหรับบอกรักใครสักคน ก็ส่งไปให้เขาเลย!  
ส่งหัวข้อนี้พิมพ์ หน้า: 1 
กระโดดไป:  

Creative Commons License

SMF Thai Translation Powered by SMF © 2006–2012, Simple Machines LLC

WordPress Google เข้าเยี่ยมชมหน้านี้ล่าสุดเมื่อ : 19 พฤษภาคม 2555, 16:56:43

jQuery Plugin Copyright © 2551-2555 Themes Design & Hosting by DexMoreGroup

Sitemap | Thai Simple Machines Forum support SMF Thai

Web Begining | SMF Modifications | SMF Thai Translation Web Begining

Drupal | WordPress | CMS Joomla | jQuery Plugin | Web Graphics CMS Joomla