主页 个人PHP笔记 PMB的制作代码记录,仅供作者个人记忆参考
admin
发表于2013-04-02 10:09:44    只看楼主 楼主
头衔:  精益求精
注册时间: 2012-10-07
用户组: 日常管理组
发帖数:  502
金币数:  187
短消息
PMB,publish message board

message.php
<?php

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('','../','../../','../../../','../../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load field values
$tableName = 'accounts';
$recordNum = null; // you must set either $recordNum or $preSaveTempId to null
$preSaveTempId = @$_REQUEST['preSaveTempId'] ? $_REQUEST['preSaveTempId'] : uniqid('x');
$errorsAndAlerts = '';

// get field options for Country Billing
$fieldname = 'country_billing';
$selectedValue = $CURRENT_USER['country_billing'];
$valuesAndLabels = getListOptions($tableName, $fieldname);
$optionsCountryBilling = getSelectOptions($selectedValue, array_keys($valuesAndLabels), array_values($valuesAndLabels));

// error checking
if (!@$GLOBALS['WEBSITE_MEMBERSHIP_PLUGIN']) { die("You must activate the Website Membership plugin before you can access this page."); }

//
if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); }

// prepopulate form with current user values
foreach ($CURRENT_USER as $name => $value) {
if (array_key_exists($name, $_REQUEST)) { continue; }
$_REQUEST[$name] = $value;
}
?>
<?php include ("include_header.php"); ?>
<!-- main content -->
<div id="main">
<div class="title">
<!-- button-list -->
<ul class="button-list">
<li><a href="cart.php"><span><em>VIEW CART (<?php if(!empty($_SESSION['cart_num'])){echo sizeof($_SESSION['cart_num']);}else{echo '0';} ?>)</em></span></a></li>
<!--<li><a href="checkout.php"><span>CHECKOUT</span></a></li> -->
</ul>
<h1>MESSAGES</h1>
</div>
<!-- container -->
<div class="container">
<!-- breadcrumbs -->
<ul class="breadcrumbs">
<li><a href="./dashboard.php">DASHBOARD</a> &gt;</li>
<li>MESSAGE BOARD</li>
</ul>
<!-- heading -->
<div class="heading">
<h2>MESSAGE BOARD</h2>
</div>
<?php if(!empty($_SESSION['Tip'])){ ?>
<div class="confirmation-box" id="message">
<a href="javascript:void(0)" class="close" onclick="$('#message').fadeTo('slow',0).slideUp('slow');">close</a>
<p><?php echo $_SESSION['Tip']; $_SESSION['Tip']='';?></p>
</div>
<?php } ?>
<div class="error-box" id="message_notice" style="display:none">
<a href="javascript:void(0)" class="close" onclick="$('#message_notice').fadeTo('slow',0).slideUp('slow');">close</a>
<p></p>
</div>
<!-- form-block -->
<h3>Messages</h3>
<div class="form-block">
<form action="#">
<fieldset>
<table class="table-details" id="messages">
<tr>
<th class="col-8">
<span class="holder">
<label><input type="checkbox" id="mess_ck"/></label> FROM
</span>
</th>
<th class="col-9">TO</th>
<th class="col-10">SUBJECT</th>
<th class="col-11"><span class="holder">LAST UPDATED</span></th>
</tr>
<?php
$sql = "select num,createdDate,createdByUserNum,updatedDate,updatedByUserNum,message_read,r_num,status,first_name,last_name,organisation,phone,email,message,product,t_num from `{$TABLE_PREFIX}" . "advertiser_pmb` where createdByUserNum=".@$_REQUEST['num']." and r_num is null and (status='Open' or status='Closed' or status='Sold' or status is null)
union all
select num,createdDate,createdByUserNum,updatedDate,updatedByUserNum,message_read,r_num,status,first_name,last_name,organisation,phone,email,message,product,t_num from `{$TABLE_PREFIX}" . "user_pmb` where createdByUserNum=".@$_REQUEST['num']." and r_num is null and (status='Open' or status='Closed' or status='Sold' or status is null) order by num desc";
$query=@mysql_query($sql);
$num=mysql_num_rows($query);
if($num>0){
while($arr=@mysql_fetch_array($query)){
?>
<tr id="<?php echo 'tr'.$arr['t_num']; ?>">
<td class="col-8">
<?php
if($arr['message_read']=='0'){ ?>
<label class="new"><?php
}else{ ?>
<label><?php
} ?>
<input type="checkbox" class="message_ck" value="<?php echo $arr['t_num']; ?>"/> <span class="text">
<?php
$lasttime='';
$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "advertiser_pmb` where (t_num=".$arr['t_num']." or r_num=".$arr['t_num'].") order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$arr_tmp_1_1=mysql_fetch_array($query_tmp_1_1);
$lasttime=$arr_tmp_1_1['createdDate']; //get time

$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "advertiser_pmb` where createdByUserNum=".@$_REQUEST['num']." and (t_num=".$arr['t_num']." or r_num=".$arr['t_num'].") order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$num_tmp_1_1=mysql_num_rows($query_tmp_1_1);
if($num_tmp_1_1>=1){
$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "advertiser_pmb` where (t_num=".$arr['t_num']." or r_num=".$arr['t_num'].") order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$arr_tmp_1_1=mysql_fetch_array($query_tmp_1_1);
if($arr_tmp_1_1['email']==$CURRENT_USER['email']){
echo 'Me';
}else{
echo $arr['first_name']." ".$arr['last_name'];
}
}else{
$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "user_pmb` where t_num=".$arr['t_num']." order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$num_tmp_1_1=mysql_num_rows($query_tmp_1_1);
if($num_tmp_1_1>0){
$arr_tmp_1_1=mysql_fetch_array($query_tmp_1_1);
if($arr_tmp_1_1['updatedByUserNum']==0){
echo 'Me';
}else{
echo $arr['first_name']." ".$arr['last_name'];
}
}
}
?>
</span></label>
<ul class="list-buttons">
<li><a href="javascript:void(0)" class="m_no_archive" list="<?php echo $arr['t_num']; ?>">ARCHIVE</a></li>
<li><a href="./message_view.php?pnum=<?php echo $arr['t_num']; ?>">VIEW / REPLY &gt;</a></li>
</ul>
</td>
<td class="col-9">
<?php
$lasttime='';
$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "advertiser_pmb` where (t_num=".$arr['t_num']." or r_num=".$arr['t_num'].") order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$arr_tmp_1_1=mysql_fetch_array($query_tmp_1_1);
$lasttime=$arr_tmp_1_1['createdDate']; //get time

$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "advertiser_pmb` where createdByUserNum=".@$_REQUEST['num']." and (t_num=".$arr['t_num']." or r_num=".$arr['t_num'].") order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$num_tmp_1_1=mysql_num_rows($query_tmp_1_1);
if($num_tmp_1_1>=1){
$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "advertiser_pmb` where (t_num=".$arr['t_num']." or r_num=".$arr['t_num'].") order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$arr_tmp_1_1=mysql_fetch_array($query_tmp_1_1);
if($arr_tmp_1_1['email']==$CURRENT_USER['email']){
echo $arr['first_name']." ".$arr['last_name'];
}else{
echo 'Me';
}
}else{
$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "user_pmb` where t_num=".$arr['t_num']." order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$num_tmp_1_1=mysql_num_rows($query_tmp_1_1);
if($num_tmp_1_1>0){
$arr_tmp_1_1=mysql_fetch_array($query_tmp_1_1);
if($arr_tmp_1_1['updatedByUserNum']!=0){
echo 'Me';
}else{
echo $arr['first_name']." ".$arr['last_name'];
}
}
}
?>
</td>
<td class="col-10"><?php echo $arr['product']." (ID:".$arr['t_num'].")"; ?></td>
<td class="col-11"><?php
echo date("d M Y",strtotime($arr['createdDate']))."<br>".date("h:i a",strtotime($lasttime));
?></td>
</tr>
<?php
}
}else{
?>
<tr><td colspan="4" style="text-align:center;background:#F5F5F5; height: 85px; vertical-align:middle;">You currently have no messages in your inbox</td></tr>
<?php
}
?>
</table>
<div class="btn-holder">
<a href="javascript:void(0)" class="button button-gray"><span class="m_archive">ARCHIVE</span></a>
</div>
</fieldset>
</form>
</div>


<!-- form-block -->
<div class="form-block">
<h3>Archived Messages</h3>
<form action="#">
<fieldset>
<table class="table-details" id="messages2">
<tr>
<th class="col-8">
<span class="holder"><label><input type="checkbox" id="mess_ck_archive"/></label> FROM</span>
</th>
<th class="col-9">TO</th>
<th class="col-10">SUBJECT</th>
<th class="col-11"><span class="holder">LAST UPDATED</span></th>
</tr>
<?php
$sql = "select num,createdDate,createdByUserNum,updatedDate,updatedByUserNum,message_read,r_num,status,first_name,last_name,organisation,phone,email,message,product,t_num from `{$TABLE_PREFIX}" . "advertiser_pmb` where createdByUserNum=".@$_REQUEST['num']." and r_num is null and status='Archived' union all select num,createdDate,createdByUserNum,updatedDate,updatedByUserNum,message_read,r_num,status,first_name,last_name,organisation,phone,email,message,product,t_num from `{$TABLE_PREFIX}" . "user_pmb` where createdByUserNum=".@$_REQUEST['num']." and r_num is null and status='Archived' order by num desc";
$query=@mysql_query($sql);
$num=mysql_num_rows($query);
if($num>0){
while($arr=@mysql_fetch_array($query)){
?>
<tr id="<?php echo 'tr'.$arr['t_num']; ?>">
<td class="col-8">
<?php
if($arr['message_read']=='0'){ ?>
<label class="new"><?php
}else{ ?>
<label><?php
} ?>
<input type="checkbox" class="message_ck2" value="<?php echo $arr['t_num']; ?>"/> <span class="text">
<?php
$lasttime='';
$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "advertiser_pmb` where (t_num=".$arr['t_num']." or r_num=".$arr['t_num'].") order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$arr_tmp_1_1=mysql_fetch_array($query_tmp_1_1);
$lasttime=$arr_tmp_1_1['createdDate']; //get time

$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "advertiser_pmb` where createdByUserNum=".@$_REQUEST['num']." and (t_num=".$arr['t_num']." or r_num=".$arr['t_num'].") order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$num_tmp_1_1=mysql_num_rows($query_tmp_1_1);
if($num_tmp_1_1>=1){
$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "advertiser_pmb` where (t_num=".$arr['t_num']." or r_num=".$arr['t_num'].") order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$arr_tmp_1_1=mysql_fetch_array($query_tmp_1_1);
if($arr_tmp_1_1['email']==$CURRENT_USER['email']){
echo 'Me';
}else{
echo $arr['first_name']." ".$arr['last_name'];
}
}else{
$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "user_pmb` where t_num=".$arr['t_num']." order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$num_tmp_1_1=mysql_num_rows($query_tmp_1_1);
if($num_tmp_1_1>0){
$arr_tmp_1_1=mysql_fetch_array($query_tmp_1_1);
if($arr_tmp_1_1['updatedByUserNum']==0){
echo 'Me';
}else{
echo $arr['first_name']." ".$arr['last_name'];
}
}
}
?></span></label>
<ul class="list-buttons">
<li><a href="javascript:void(0)" class="m_no_delete" list="<?php echo $arr['t_num']; ?>">DELETE</a></li>
<li><a href="./message_view.php?pnum=<?php echo $arr['t_num']; ?>">VIEW / REPLY &gt;</a></li>
</ul>
</td>
<td class="col-9"><?php
$lasttime='';
$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "advertiser_pmb` where (t_num=".$arr['t_num']." or r_num=".$arr['t_num'].") order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$arr_tmp_1_1=mysql_fetch_array($query_tmp_1_1);
$lasttime=$arr_tmp_1_1['createdDate']; //get time

$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "advertiser_pmb` where createdByUserNum=".@$_REQUEST['num']." and (t_num=".$arr['t_num']." or r_num=".$arr['t_num'].") order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$num_tmp_1_1=mysql_num_rows($query_tmp_1_1);
if($num_tmp_1_1>=1){
$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "advertiser_pmb` where (t_num=".$arr['t_num']." or r_num=".$arr['t_num'].") order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$arr_tmp_1_1=mysql_fetch_array($query_tmp_1_1);
if($arr_tmp_1_1['email']==$CURRENT_USER['email']){
echo $arr['first_name']." ".$arr['last_name'];
}else{
echo 'Me';
}
}else{
$sql_tmp_1_1="select * from `{$TABLE_PREFIX}" . "user_pmb` where t_num=".$arr['t_num']." order by num desc";
$query_tmp_1_1=mysql_query($sql_tmp_1_1);
$num_tmp_1_1=mysql_num_rows($query_tmp_1_1);
if($num_tmp_1_1>0){
$arr_tmp_1_1=mysql_fetch_array($query_tmp_1_1);
if($arr_tmp_1_1['updatedByUserNum']!=0){
echo 'Me';
}else{
echo $arr['first_name']." ".$arr['last_name'];
}
}
}
?></td>
<td class="col-10"><?php echo $arr['product']." (ID:".$arr['t_num'].")"; ?></td>
<td class="col-11"><?php
echo date("d M Y",strtotime($arr['createdDate']))."<br>".date("h:i a",strtotime($lasttime));
?></td>
</tr>
<?php
}
}else{
?>
<tr><td colspan="4" style="text-align:center;background:#F5F5F5; height: 85px; vertical-align:middle;">You currently have no archived messages</td></tr>
<?php
}
?>
</table>
<div class="btn-holder">
<a href="javascript:void(0)" class="button button-gray"><span class="m_delete">DELETE</span></a>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
<script>
var trs=document.getElementById("messages").getElementsByTagName("tr");
for(var i=0;i<trs.length;i++){
if(i!=0&&i%2==0){
trs[i].className="even";
}
}
var trs=document.getElementById("messages2").getElementsByTagName("tr");
for(var i=0;i<trs.length;i++){
if(i!=0&&i%2==0){
trs[i].className="even";
}
}
</script>
<script type="text/javascript" src="./js/message.js"></script>
<?php include ("include_footer.php"); ?>

引用回复  把握生命里的每一分钟,没有人能随随便便成功~^_^
 
admin
发表于2013-04-02 10:10:56 1楼
头衔:  精益求精
注册时间: 2012-10-07
用户组: 日常管理组
发帖数:  502
金币数:  187
短消息
message_view.php
<?php
error_reporting(0);
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('','../','../../','../../../','../../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
// load field values
$tableName = 'accounts';
$recordNum = null; // you must set either $recordNum or $preSaveTempId to null
$preSaveTempId = @$_REQUEST['preSaveTempId'] ? $_REQUEST['preSaveTempId'] : uniqid('x');
$errorsAndAlerts = '';

// get field options for Country Billing
$fieldname = 'country_billing';
$selectedValue = $CURRENT_USER['country_billing'];
$valuesAndLabels = getListOptions($tableName, $fieldname);
$optionsCountryBilling = getSelectOptions($selectedValue, array_keys($valuesAndLabels), array_values($valuesAndLabels));

// error checking
if (!@$GLOBALS['WEBSITE_MEMBERSHIP_PLUGIN']) { die("You must activate the Website Membership plugin before you can access this page."); }
//
if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); }

// prepopulate form with current user values
foreach ($CURRENT_USER as $name => $value) {
if (array_key_exists($name, $_REQUEST)) { continue; }
$_REQUEST[$name] = $value;
}

// mysql_query("update cms_attaches set sizes=0 where createdByUserNum=".$CURRENT_USER['num']);
if(empty($_GET['pnum'])){
echo '<script>window.location.href="./messages.php";</script>';
}
$msql="select * from cms_advertiser_pmb t where t.t_num='".$_GET['pnum']."'";
$mquery=mysql_query($msql);
$mnum=mysql_num_rows($mquery);
if($mnum>0){
$result=mysql_fetch_array($mquery);
$result_2='';
if($CURRENT_USER['num']!=$result['createdByUserNum']){
$msql_2="select * from cms_user_pmb t where t.t_num='".$_GET['pnum']."'";
$mquery_2=mysql_query($msql_2);
$mnum_2=mysql_num_rows($mquery_2);
if($mnum_2>0){
$result_2=mysql_fetch_array($mquery_2);
if($CURRENT_USER['num']!=$result_2['createdByUserNum']){
echo file_get_contents("./no_permission.html");
exit;
}
if($result_2['message_read']=='0'){
mysql_query("update cms_user_pmb set message_read=1 where t_num='".$_GET['pnum']."'");
}
}else{
echo file_get_contents("./no_permission.html");
exit;
}
}
if(empty($result_2)){
if($result['message_read']=='0'){
mysql_query("update cms_advertiser_pmb set message_read=1 where t_num='".$_GET['pnum']."'");
}
}else{
if($result['message_read']=='0'){
mysql_query("update cms_user_pmb set message_read=1 where t_num='".$_GET['pnum']."'");
}
}
}else{
echo file_get_contents("./no_record.html");
exit;
}
$marr=array();
$msql2="select * from cms_advertiser_pmb r where r.r_num='".$_GET['pnum']."' order by num desc";
$mquery2=mysql_query($msql2);
$mnum2=mysql_num_rows($mquery2);
if($mnum2>0){
while($result2=mysql_fetch_array($mquery2)){
$marr[]=$result2;
}
}
if(isset($_POST['sub'])){
$msql2="select * from cms_advertiser_pmb r where r.r_num='".$_POST['hid']."' order by num desc";
$mquery2=mysql_query($msql2);
$mnum2=mysql_num_rows($mquery2);
if($mnum2>0){
$result2=mysql_fetch_array($mquery2);
$uid=$result2['createdByUserNum'];
$tmp="select first_name,last_name,email from cms_accounts where num='".$uid."' order by num desc";
$query_tmp=mysql_query($tmp);
$num_tmp=mysql_num_rows($query_tmp);
if($num_tmp>0){
$arr_tmp=mysql_fetch_array($query_tmp);
}
}

//$to=$result['name'].' '.$result['lname'].' <'.$result['email'].'>';
//$headers = 'MIME-Version: 1.0' . "\r\n";
//$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
//$headers .= 'From: '.$arr_tmp['first_name'].' '.$arr_tmp['last_name'].' <'.$arr_tmp['email'].'>' . "\r\n";
//if(mail($to,$result['product_name'], $_POST['ta'], $headers)){

require_once("./phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$subject = $result['product'];
$body = nl2br($_POST['ta']);
$mail->ClearAllRecipients();
$mail->CharSet = "UTF-8";
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Port = 587; //587,465
$mail->SMTPSecure = 'tls'; //ssl tls
$mail->Host = 'smtp.gmail.com';
$mail->Username = 'mail@labmerchant.com';
$mail->Password = 'pmbpassword';
$mail->SetFrom('mail@labmerchant.com','Lab Merchant');
if(!empty($result_2))
$mail->AddAddress($result_2['email'], $result_2['first_name'].' '.$result_2['last_name']);
else
$mail->AddAddress($result['email'], $result['first_name'].' '.$result['last_name']);
$attaches_pmb=$_POST['attaches_pmb'];
$attaches_pmb=explode("attach::attach",$attaches_pmb);
array_pop($attaches_pmb);

foreach($attaches_pmb as $v){
$mail->AddAttachment("/home/demolabm/public_html/login/imap/example/attachments/".$_POST['hid']."/".trim($v));
}
$mail->Subject = $subject." <ID:".$_POST['hid'].">";
$mail->MsgHTML(":: Reply above this line to post a reply ::<br><hr>" .$body. "<br><hr><p>We recommend you simply reply to this email to send your message.<strong>
</strong></p>
<p>Regards,</p>
<p><strong>Lab Merchant</strong></p>
<p><strong><img src='http://demo.labmerchant.com/images/logo_signature.png' />
</strong>Oxford Labs<br>
2 Royal College Street<br>
London, NW1 0NH<br>
United Kingdom</p>
<p>Tel: +44 (0) 20 7691 2159<br>
Email: admin@labmerchant.com<br>
Web: <a href='http://www.labmerchant.com'>http://www.labmerchant.com</a></p>;
<p></p>
<p><strong>For Your Information:</strong> To help arbitrate disputes and preserve trust and safety, we retain all messages buyers and sellers send through labmerchant.com. For your protection we recommend that you only communicate with buyers and sellers by replying to mail@labmerchant.com or by sending a message through your Lab Merchant control panel.</p>
");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
if(!empty($_POST['attaches_pmb'])){
$atta='<hr><ul class="file-icons">';
foreach($attaches_pmb as $m){
$m_tmp=substr($m,strrpos($m,".")+1);
if(in_array($m_tmp,array('jpg','JPG','gif','GIF','png','PNG','bmp','BMP'))){
$m_tmp="img";
}
if(!is_dir("/home/demolabm/public_html/login/imap/example/attachments/".$_POST['hid'])){
mkdir("/home/demolabm/public_html/login/imap/example/attachments/".$_POST['hid'], 0777);
}
$atta.="<li class='".$m_tmp."'><a target='_blank' href='./imap/example/attachments/".$_POST['hid']."/".$m."'>".$m."</a></li>";
}
$atta.='</ul>';
}else{
$atta='';
}
$tmp_sql="select * from `{$TABLE_PREFIX}user_pmb` where t_num='".$_POST['hid']."'";
$tmp_num=mysql_num_rows(mysql_query($tmp_sql));
if($tmp_num<=0){
$sql="insert into `{$TABLE_PREFIX}" . "advertiser_pmb`(createdDate,createdByUserNum,email,message,r_num,status) values(now(),'".@$_REQUEST['num']."','".addslashes($CURRENT_USER['email'])."','".addslashes(nl2br($_POST['ta']).$atta)."','".addslashes($_POST['hid'])."','".$result['status']."')";
mysqlStrictMode(false);
mysql_query($sql);

$cnum_sql="select * from `{$TABLE_PREFIX}accounts` where email='".$result['email']."'";
$cnum_arr=mysql_fetch_array(mysql_query($cnum_sql));
$createdByUserNum_copy=$cnum_arr['num'];
$updatedByUserNum_copy=$cnum_arr['num'];
$email_copy=$CURRENT_USER['email'];
$phone_copy=$CURRENT_USER['telephone_number'];
$message_copy=nl2br(addslashes($_POST['ta']));
$first_name_copy=$CURRENT_USER['first_name'];
$last_name_copy=$CURRENT_USER['last_name'];
$organisation_copy=$CURRENT_USER['organisation_name'];
$product_copy=$subject;

mysql_query("INSERT INTO `{$TABLE_PREFIX}user_pmb` SET
createdDate = '".mysql_datetime()."',
updatedDate = '".mysql_datetime()."',
createdByUserNum = '".$createdByUserNum_copy."',
updatedByUserNum = '".$updatedByUserNum_copy."',
message_read ='0',
email ='".$email_copy."',
phone ='".$phone_copy."',
message ='".$message_copy."',
first_name ='".$first_name_copy."',
last_name ='".$last_name_copy."',
organisation ='".$organisation_copy."',
product ='".$product_copy."',
t_num ='".$_POST['hid']."'"
)
or die("MySQL Error Creating Record:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
}
else{
$arr_sql=mysql_fetch_array(mysql_query($tmp_sql));
mysqlStrictMode(false);
if(empty($result_2)){
$sql="update cms_user_pmb set message_read=0 where t_num='".$_POST['hid']."'";
mysql_query($sql);
}else{
$sql="update cms_advertiser_pmb set message_read=0 where t_num='".$_POST['hid']."'";
mysql_query($sql);
}
if($arr_sql['email']==$CURRENT_USER['email']){
$sql="update cms_user_pmb set updatedByUserNum=".$CURRENT_USER['num']." where t_num='".$_POST['hid']."'";
mysql_query($sql);
}else{
$sql="update cms_user_pmb set updatedByUserNum=0 where t_num='".$_POST['hid']."'";
mysql_query($sql);
}
$sql="insert into `{$TABLE_PREFIX}" . "advertiser_pmb`(createdDate,createdByUserNum,email,message,r_num,status) values(now(),'".@$_REQUEST['num']."','".addslashes($CURRENT_USER['email'])."','".addslashes(nl2br($_POST['ta']).$atta)."','".addslashes($_POST['hid'])."','".$result['status']."')";
mysql_query($sql);
}
}
redirectBrowserToURL("message_view.php?pnum=".addslashes($_POST['hid']));
}

?>
<?php include ("include_header.php"); ?>
<script src="uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="uploadify/uploadify.css">
<link media="all" rel="stylesheet" type="text/css" href="./css/custom.css"/>
<!-- main content -->
<div id="main">
<div class="title">
<!-- button-list -->
<ul class="button-list">
<li><a href="./cart.php"><span><em>VIEW CART (<?php if(!empty($_SESSION['cart_num'])){echo sizeof($_SESSION['cart_num']);}else{echo '0';} ?>)</em></span></a></li>
<!--<li><a href="checkout.php"><span>CHECKOUT</span></a></li> -->
</ul>
<h1>MESSAGES</h1>
</div>
<!-- container -->
<div class="container">
<!-- breadcrumbs -->
<ul class="breadcrumbs">
<li><a href="./dashboard.php">DASHBOARD</a> &gt;</li>
<li><a href="./messages.php">MESSAGES</a> &gt;</li>
<li><?php echo $result['product']; ?></li>
</ul>
<!-- heading -->
<div class="heading">
<h2><?php echo $result['product']; ?></h2>
</div>
<!-- columns -->
<div class="columns">
<!-- message-col -->
<div class="message-col">
<div class="textarea-box">
<div class="holder">
<div class="frame" style="overflow:auto">
<form action="" method="post" onsubmit="return check();">
<fieldset>
<div class="textarea-holder">
<textarea class="textarea" name="ta" cols="30" rows="10" id="tarea">Type your reply here...</textarea>
</div>
<input type="hidden" name="hid" value="<?php echo $_GET['pnum']; ?>">
<input type="hidden" name="attaches_pmb" id="attaches_pmb" value="">
<input type="hidden" name="attachessizes" id="attachessizes" value="0">
<div class="btn-block" style="height:auto;">
<a href="javascript:void(0)" class="button button-green"><input name="sub" type="submit" value="POST MESSAGE" /></a>
<form>
<div id="queue"></div><div style="position: relative;left: -100px;float: right;top: 10px;">(20 MB available | 5 MB limit per file)</div>
<input id="file_upload" name="file_upload" type="file" multiple="true">
</form>
<div id="lists"></div>
<script type="text/javascript">
$(function() {
$('#file_upload').uploadify({
'formData' : {
'timestamp' : '<?php echo $timestamp;?>',
'token' : '<?php echo md5('unique_salt' . $timestamp);?>',
'pnum':'<?php echo $_GET['pnum']; ?>'
},
'fileSizeLimit' : '5MB',
'multi' : false,
'swf' : './uploadify/uploadify.swf',
'uploader' : './uploadify/uploadify_pmb.php',
'onUploadSuccess' : function(file, data, response) {
var fname=file.name;
var c=parseInt($("#attachessizes").val())+parseInt(file.size);
fname_pos=fname.lastIndexOf(".");
fname_2=fname.substring(fname_pos);
fname=fname.substring(0,fname_pos);
fname_1=fname.replace(/\s+/,'-');
fname=fname_1+fname_2;
$("#lists").html($("#lists").html()+"<div>"+fname+"<img style='cursor:pointer;position: relative;top: 4px;margin-left:14px;' class='imgatta' title='"+fname+"' src='./uploadify/img/uploadify-cancel.png'></div>");
$("#attaches_pmb").val($("#attaches_pmb").val()+fname+"attach::attach");
$("#attachessizes").val(c);
},
'onUploadError' : function(file, errorCode, errorMsg, errorString) {
alert(errorString);
}
});
$(".imgatta").live("click",function(){
$(this).parent().remove();
$.post("./uploadify/uploadify_pmb_del.php",{pnum:"<?php echo $_GET['pnum']; ?>",name:$(this).attr('title')},function(dat){
var dat = eval("(" + dat + ")");
document.getElementById("attaches_pmb").value=document.getElementById("attaches_pmb").value.replace(dat.name+"attach::attach",'');
var c=parseInt($("#attachessizes").val())-parseInt(dat.size);
$("#attachessizes").val(c);
})
})
})
</script>
</div>
</fieldset>
</form>
</div>
</div>
</div>
<table class="table-details-2" id="dialog">
<tr>
<th class="col-1">
<span class="holder">SENDER</span>
</th>
<th class="col-2">MESSAGE</th>
<th class="col-3"><span class="holder">SENT</span></th>
</tr>
<?php
if(!empty($marr)){
foreach($marr as $v){
?>
<tr>
<td class="col-1"><a href="javascript:void(0)"><?php
$uemail=$v['email'];
$uid=$v['createdByUserNum'];
// if($uemail==$CURRENT_USER['email'] || $uemail==$CURRENT_USER['username']){
if($uid!=0){
$tmp="select first_name,last_name from cms_accounts where num='".$uid."'";
}else{
$tmp="select first_name,last_name from cms_accounts where email='".$uemail."'";
}

$query_tmp=mysql_query($tmp);
$num_tmp=mysql_num_rows($query_tmp);
if($num_tmp>0){
$arr_tmp=mysql_fetch_array($query_tmp);
echo $arr_tmp['first_name']."&nbsp;".$arr_tmp['last_name'];
}

/* else{
if($uemail==$result['email']){
$tmp="select * from cms_advertiser_pmb where r_num='".$v['r_num']."'";
$query_tmp=mysql_query($tmp);
$num_tmp=mysql_num_rows($query_tmp);
if($num_tmp>0){
$arr_tmp=mysql_fetch_array($query_tmp);
echo $arr_tmp['first_name']."&nbsp;".$arr_tmp['last_name'];
}
}
} */
?></a></td>
<td class="col-2"><div style="width:320px;"><?php
$v['message']=preg_replace('/<([^@<>\s]*@[^\.\s]*\.[^<>\s]*)>/','&lt;$1&gt;',$v['message']);
echo $v['message']; ?></div></td>
<td class="col-3" style="font-size: 12px;margin: 0;padding: 15px;"><?php
echo date("d M Y",strtotime($v['createdDate']))."<br>".date("h:i a",strtotime($v['createdDate']));
?></td>
</tr>
<?php } } ?>
<?php
if(!empty($result)){
?>
<tr>
<td class="col-1"><a href="javascript:void(0)"><?php echo $result['first_name']."&nbsp;".$result['last_name']; ?></a></td>
<td class="col-2"><?php
$result['message']=preg_replace('/<([^@<>\s]*@[^\.\s]*\.[^<>\s]*)>/','&lt;$1&gt;',$result['message']);
echo $result['message']; ?></td>
<td class="col-3" style="font-size: 12px;margin: 0;padding: 15px;"><?php
echo date("d M Y",strtotime($result['createdDate']))."<br>".date("h:i a",strtotime($result['createdDate']));
?></td>
</tr>
<?php
}
?>
</table>
<script>
var trs=document.getElementById("dialog").getElementsByTagName("tr");
for(var i=0;i<trs.length;i++){
if(i!=0&&i%2==0){
trs[i].className="even";
}
}
</script>
</div>
<!-- contact-col -->
<div class="contact-col">
<h3>CONTACT DETAILS</h3>
<div class="box">
<dl>
<dt>FIRST NAME</dt>
<dd><?php if(!empty($result_2)){echo $result_2['first_name'];}else{echo $result['first_name'];} ?></dd>
<dt>LAST NAME</dt>
<dd><?php if(!empty($result_2)){echo $result_2['last_name'];}else{echo $result['last_name'];} ?></dd>
<dt>ORGANISATION</dt>
<dd><?php if(!empty($result_2)){echo $result_2['organisation'];}else{echo $result['organisation'];} ?></dd>
<dt>TELEPHONE</dt>
<dd><?php if(!empty($result_2)){echo $result_2['phone'];}else{echo $result['phone'];} ?></dd>
<dt>EMAIL</dt>
<dd><a href="mailto:<?php if(!empty($result_2)){echo $result_2['email'];}else{echo $result['email'];} ?>"><?php if(!empty($result_2)){echo $result_2['email'];}else{echo $result['email'];} ?></a></dd>
</dl>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="./js/pmb.js"></script>
<?php include ("include_footer.php"); ?>
引用回复  把握生命里的每一分钟,没有人能随随便便成功~^_^
 
admin
发表于2013-04-02 10:11:57 2楼
头衔:  精益求精
注册时间: 2012-10-07
用户组: 日常管理组
发帖数:  502
金币数:  187
短消息
cron job的定时处理文件
index.php
<?php
error_reporting(E_ALL);
date_default_timezone_set('UTC');
$con=mysql_connect("localhost","demolabm_demo","2dD6j5JT");
mysql_select_db("demolabm_demo",$con);
require_once('/home/demolabm/public_html/login/imap/ImapMailbox.php');

// IMAP must be enabled in Google Mail Settings
define('GMAIL_EMAIL', 'mail@labmerchant.com');
define('GMAIL_PASSWORD', 'pmbpassword');
define('ATTACHMENTS_DIR', dirname(__FILE__) . '/attachments');

$mailbox = new ImapMailbox('{imap.gmail.com:993/imap/ssl}INBOX', GMAIL_EMAIL, GMAIL_PASSWORD, ATTACHMENTS_DIR, 'utf-8');
$mails = array();
require_once("/home/demolabm/public_html/login/phpmailer/class.phpmailer.php");
$mail_php = new PHPMailer();
$marray=array();
$marray=$mailbox->searchMails('ALL');
foreach($marray as $mailId) {
$mail = $mailbox->getMail($mailId);
$mails[] = $mail;
$mailbox->setMailAsSeen($mail->mId);
$mailbox->deleteMail($mail->mId);
}
if(!empty($mails)){
foreach($mails as $v){
$email=$v->fromAddress;
$message=$v->textPlain;
$message=explode(":: Reply above this line to post a reply ::",$message);
$message=trim($message[0]);
$message=preg_replace("/>\s*\*\*/",'',$message);
$message=htmlentities($message,ENT_QUOTES,'UTF-8');
$message=nl2br(trim($message));
$tmp=$v->subject;
$tmp2=explode("<ID:",$tmp);
$r_num=substr($tmp2[1],0,-1);
$attaches=$v->attachments;
if(!empty($attaches)){
$atta='<hr><ul class="file-icons">';
foreach($attaches as $m=>$n){
$m_tmp=substr($m,strrpos($m,".")+1);
if(in_array($m_tmp,array('jpg','JPG','gif','GIF','png','PNG','bmp','BMP'))){
$m_tmp="img";
}
if(!is_dir("/home/demolabm/public_html/login/imap/example/attachments/".$r_num)){
mkdir("/home/demolabm/public_html/login/imap/example/attachments/".$r_num, 0777);
}
rename("/home/demolabm/public_html/login/imap/example/attachments/".$m,"/home/demolabm/public_html/login/imap/example/attachments/".$r_num."/".$m);
$atta.="<li class='".$m_tmp."'><a target='_blank' href='./imap/example/attachments/".$r_num."/".$m."'>".$m."</a></li>";
}
$atta.='</ul>';
}else{
$atta='';
}
$tmp_sql="select * from `cms_advertiser_pmb` where t_num='".$r_num."'";
$tmp_query=mysql_query($tmp_sql);
$tmp_num=mysql_num_rows($tmp_query);
if($tmp_num>0){
$tmp_arr_arr=mysql_fetch_array($tmp_query);
}

$tmp_sql="select * from `cms_user_pmb` where t_num='".$r_num."'";
$tmp_num=mysql_num_rows(mysql_query($tmp_sql));
if($tmp_num<=0 && ($email!=$tmp_arr_arr['email']) ){
$sql_tmp_2="select * from cms_advertiser_pmb where t_num='".$r_num."'";
$arr_tmp_2=mysql_fetch_array(mysql_query($sql_tmp_2));
$cnum_sql_2="select * from `cms_accounts` where email='".$arr_tmp_2['email']."'";
$cnum_arr_2=mysql_fetch_array(mysql_query($cnum_sql_2));

$sql="insert into cms_advertiser_pmb(createdDate,message_read,email,message,r_num) values(now(),0,'".$email."','".addslashes($message.$atta)."','".$r_num."')";
mysql_query($sql);
$sql_tmp_1="select * from cms_advertiser_pmb where r_num='".$r_num."'";
$arr_tmp_1=mysql_fetch_array(mysql_query($sql_tmp_1));
$cnum_sql="select * from `cms_accounts` where email='".$arr_tmp_1['email']."'";
$cnum_arr=mysql_fetch_array(mysql_query($cnum_sql));
$createdByUserNum_copy=$cnum_arr_2['num'];
$updatedByUserNum_copy=$cnum_arr_2['num'];
$email_copy=$cnum_arr['email'];
$phone_copy=$cnum_arr['telephone_number'];
$message_copy=nl2br(addslashes($message.$atta));
$first_name_copy=$cnum_arr['first_name'];
$last_name_copy=$cnum_arr['last_name'];
$organisation_copy=$cnum_arr['organisation_name'];
$product_copy=$arr_tmp_2['product'];

mysql_query("INSERT INTO `cms_user_pmb` SET
createdDate = '".date('Y-m-d H:i:s', time())."',
updatedDate = '".date('Y-m-d H:i:s', time())."',
createdByUserNum = '".$createdByUserNum_copy."',
updatedByUserNum = '".$updatedByUserNum_copy."',
message_read ='0',
email ='".$email_copy."',
phone ='".$phone_copy."',
message ='".$message_copy."',
first_name ='".$first_name_copy."',
last_name ='".$last_name_copy."',
organisation ='".$organisation_copy."',
product ='".$product_copy."',
t_num ='".$r_num."'"
)
or die("MySQL Error Creating Record:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
if($tmp){
$subject = $tmp;
$body = $message;
$mail_php->ClearAllRecipients();
$mail_php->CharSet = "UTF-8";
$mail_php->IsSMTP();
$mail_php->SMTPAuth = true;
$mail_php->Port = 587; //587,465
$mail_php->SMTPSecure = 'tls'; //ssl tls
$mail_php->Host = 'smtp.gmail.com';
$mail_php->Username = 'mail@labmerchant.com';
$mail_php->Password = 'pmbpassword';
$mail_php->SetFrom('mail@labmerchant.com','Lab Merchant');
$mail_php->AddAddress($arr_tmp_2['email']);
$mail_php->Subject = $subject;
if(!empty($attaches)){
foreach($attaches as $m=>$n){
$mail_php->AddAttachment("/home/demolabm/public_html/login/imap/example/attachments/".$r_num."/".$m);
}
}
$mail_php->MsgHTML(":: Reply above this line to post a reply ::<br><hr>" .$body. "<br><hr><p>We recommend you simply reply to this email to send your message.<strong>
</strong></p>
<p>Regards,</p>
<p><strong>Lab Merchant</strong></p>
<p><strong><img src='http://demo.labmerchant.com/images/logo_signature.png' />
</strong>Oxford Labs<br>
2 Royal College Street<br>
London, NW1 0NH<br>
United Kingdom</p>
<p>Tel: +44 (0) 20 7691 2159<br>
Email: admin@labmerchant.com<br>
Web: <a href='http://www.labmerchant.com'>http://www.labmerchant.com</a></p>;
<p></p>
<p><strong>For Your Information:</strong> To help arbitrate disputes and preserve trust and safety, we retain all messages buyers and sellers send through labmerchant.com. For your protection we recommend that you only communicate with buyers and sellers by replying to mail@labmerchant.com or by sending a message through your Lab Merchant control panel.</p>
");
if(!$mail_php->Send()) {
echo "Mailer Error: " . $mail_php->ErrorInfo;
}
}
}
else{
$sql="insert into cms_advertiser_pmb(createdDate,message_read,email,message,r_num) values(now(),0,'".$email."','".addslashes($message.$atta)."','".$r_num."')";
mysql_query($sql);
$sql_tmp="select * from cms_advertiser_pmb where t_num='".$r_num."'";
$arr_tmp=mysql_fetch_array(mysql_query($sql_tmp));
$email_tmp=$arr_tmp['email'];
if($email_tmp==$email){
$sql="update cms_advertiser_pmb set message_read=0 where t_num='".$r_num."'";
mysql_query($sql);
$sql="update cms_user_pmb set updatedByUserNum=0 where t_num='".$r_num."'";
mysql_query($sql);
}else{
$sql="update cms_user_pmb set message_read=0 where t_num='".$r_num."'";
mysql_query($sql);
$sql="update cms_user_pmb set updatedByUserNum=1 where t_num='".$r_num."'";
mysql_query($sql);
}

if($tmp){
$subject = $tmp;
$body = $message;
$mail_php->ClearAllRecipients();
$mail_php->CharSet = "UTF-8";
$mail_php->IsSMTP();
$mail_php->SMTPAuth = true;
$mail_php->Port = 587; //587,465
$mail_php->SMTPSecure = 'tls'; //ssl tls
$mail_php->Host = 'smtp.gmail.com';
$mail_php->Username = 'mail@labmerchant.com';
$mail_php->Password = 'pmbpassword';
$mail_php->SetFrom('mail@labmerchant.com','Lab Merchant');
if($email_tmp==$email){
$sql="select * from cms_advertiser_pmb where t_num=".$r_num;
$arr=mysql_fetch_array(mysql_query($sql));
$sql="select * from cms_accounts where num=".$arr['createdByUserNum'];
$arr=mysql_fetch_array(mysql_query($sql));
$mail_php->AddAddress($arr['email']);
}else{
$mail_php->AddAddress($email_tmp);
}
$mail_php->Subject = $subject;
if(!empty($attaches)){
foreach($attaches as $m=>$n){
$mail_php->AddAttachment("/home/demolabm/public_html/login/imap/example/attachments/".$r_num."/".$m);
}
}
$mail_php->MsgHTML(":: Reply above this line to post a reply ::<br><hr>" .$body. "<br><hr><p>We recommend you simply reply to this email to send your message.<strong>
</strong></p>
<p>Regards,</p>
<p><strong>Lab Merchant</strong></p>
<p><strong><img src='http://demo.labmerchant.com/images/logo_signature.png' />
</strong>Oxford Labs<br>
2 Royal College Street<br>
London, NW1 0NH<br>
United Kingdom</p>
<p>Tel: +44 (0) 20 7691 2159<br>
Email: admin@labmerchant.com<br>
Web: <a href='http://www.labmerchant.com'>http://www.labmerchant.com</a></p>;
<p></p>
<p><strong>For Your Information:</strong> To help arbitrate disputes and preserve trust and safety, we retain all messages buyers and sellers send through labmerchant.com. For your protection we recommend that you only communicate with buyers and sellers by replying to mail@labmerchant.com or by sending a message through your Lab Merchant control panel.</p>
");
if(!$mail_php->Send()) {
echo "Mailer Error: " . $mail_php->ErrorInfo;
}
}

}
}
}
?>
引用回复  把握生命里的每一分钟,没有人能随随便便成功~^_^
 
admin
发表于2013-04-02 10:13:21 3楼
头衔:  精益求精
注册时间: 2012-10-07
用户组: 日常管理组
发帖数:  502
金币数:  187
短消息
设置 cron job

/usr/bin/lynx -source http://demo.xxx.com/login/imap/example/

数据库结构,2张表一样
引用回复  把握生命里的每一分钟,没有人能随随便便成功~^_^

回复人
回复内容

Powered BY YouYaX
个人自主开发论坛,从2010年10月份开发至今!

操作管理