-1

我正在尝试使用来自http://www.bqscripts.com/item/postcards/的脚本。我已经联系他们提出问题,但他们没有回应。我认为代码有点过时了,但我找不到其他更好的免费的东西。

我对 PHP 并不陌生,但肯定在学习。我需要做的是添加更多输入框并向我添加 CC 电子邮件,以便我可以查看从该站点发送的明信片。

我不确定要复制和粘贴哪个文件/代码,因为有几个文件。该脚本使用 PHP 和数据库。它发送一个电子邮件链接,将接收者引导至preview.php。

我找不到 sendmail 功能,很困惑。

有人知道这个脚本以及如何做到这一点吗?

这是我认为我需要编辑的地方。

函数.PHP

 <?php

 function sqlimport() {

global $_c;

$file='priv/config/sqlimport.sql';
if ($fr=@fopen($file,"r")) {

    $data=fread($fr,filesize($file));
    fclose($fr);

    $ex=explode(';',$data);
    if (is_array($ex))
    foreach ($ex as $h) {

        $h=mb_ereg_replace("\[dbprefix\]",$_c['dbprefix'],$h);
        mysql_query($h);
        }
    }
}

function bqmq($q) {

return @mysql_query($q);
}

function bqma(&$r) {

$o=@mysql_fetch_array($r);

if (is_array($o))
foreach ($o as $k => $h)
    if (!is_int($k)) $out[$k]=stripslashes($h);

return $out;
}

function bqmr(&$r) {

$o=@mysql_fetch_row($r);

if (is_array($o))
foreach ($o as $k => $h)
    if (is_int($k)) $out[$k]=stripslashes($h);

return $out;
}

function bqmnr($r) {

return @mysql_num_rows($r);
}

function bqmi() {

return @mysql_insert_id();
}


function getlist($url,$actual,$count,$step,$max) {

if (!($count>0)) return "";
if ($count<=$step) return "";

$out.="<div class=\"list-div\">";
$out.="<span class=\"stranka\">page:</span>";

$c=ceil($count/$step);

$start=0;
if ($c>$max) {

    $stt=$actual-floor($max/2);
    if ($stt>0) $start=$stt;

    if ($start>($c-$max)) $start=$c-$max;

    if ($start>0) $out.="<span>. . .</span>";
    for ($i=0;$i<$max;$i++) {

        $st=$i+$start;
        $tex=$st+1;

        if ($actual==$st) $more=' class="selected"';
        else $more="";

        $out.="<span{$more}>";
        if ($st!=$actual) $out.="<a href=\"{$url}p={$st}\"       {$more}>$tex</a>";
        else $out.="$tex";
        $out.="</span>";
        }
    if ($start+$max<$c) $out.="<span>. . .</span>";
    }
else {

    for ($i=0;$i<$c;$i++) {

        $st=$i;
        $tex=$st+1;

        if ($actual==$st) $more=' class="selected"';
        else $more="";

        $out.="<span{$more}>";
        if ($st!=$actual) $out.="<a href=\"{$url}p={$st}\"{$more}>$tex</a>";
        else $out.="$tex";
        $out.="</span>";
        }
    }

$out.="</div>";

return $out;
}

函数 bqgencode($len=8) {

return mb_substr(md5(uniqid(rand(),true)),0,$len);
}

功能项目($项目){

global $_c;

$ok=true;

foreach ($_c['req'] as $k => $h) {

    if ($h==1) {

        if (mb_strlen($item[$k])==0) $ok=false;
        }
    }

return $ok;
}

function bqsendemail($to,$from,$subject,$body,$plain) {

define("EmailNewLine", "\n");
define("EmailTextCharset", "utf-8");

$charset="utf-8";

$theboundary=md5(uniqid("EMAIL"));
$headers="From: ".$from." ".EmailNewLine."Reply-To: ".$from." ".EmailNewLine."Date:  ".date("r", time()).EmailNewLine;

$headers.="MIME-Version: 1.0".EmailNewLine."Content-Type: multipart/mixed; ";
$headers.="boundary=$theboundary".EmailNewLine.EmailNewLine;
$headers.="This is a multi-part message in MIME format.".EmailNewLine.EmailNewLine;

$thebody.="--$theboundary".EmailNewLine;
$thebody.="Content-Type: text/html; charset=$charset".EmailNewLine;
$thebody.="Content-Transfer-Encoding: 7bit".EmailNewLine ."Content-Disposition: inline";
$thebody.=EmailNewLine.EmailNewLine.$body.EmailNewLine.EmailNewLine;

$thebody.="--$theboundary".EmailNewLine;
$thebody.="Content-Type: text/plain; charset=$charset".EmailNewLine;
$thebody.="Content-Transfer-Encoding: 7bit".EmailNewLine ."Content-Disposition: inline";
$thebody.=EmailNewLine.EmailNewLine.$plain.EmailNewLine.EmailNewLine;

$thebody.="--$theboundary--";

return mail($to,$subject,$thebody,$headers);
}

function bqemailact($id) {

global $_c;

$r=bqmq("select * from {$_c['dbprefix']}item where id='{$id}' and ccode=''");
if ($row=bqma($r)) {

    $code=bqgencode();
    bqmq("update {$_c['dbprefix']}item set ccode='{$code}' where id='{$id}' and  ccode=''");

    $body="<style>
<!--
body { font-family:Arial, Helvetica, sans-serif;font-size:10pt;background- color:#015709;color:#fff; }
h1 { color:#fff;font-size:11pt; }
p { font-weight:normal;font-size:9pt; }
a { color:#fff; }
--> 
</style>";
    $body.='<h1>Postcard from '.$_l['name'].'</h1>'."\n\n";
    $body.='<p>Confirmation URL: '.$_c['auri'].'?s=confirm&code='.$code.''."\n\n";
    $body.='<p>Postcard will be send after your confirmation.'."\n\n";
    $body.='<p>Request send from '.$row['ip'].' v '.date('H:i:s d.m.Y',$row['c_time']).'</p>'."\n\n";
    $body.=$b;

    $plain='Non HTML:'."\n\n".strip_tags(str_replace('&nbsp;','',$body));

    bqsendemail($row['from_email'],$_c['emailfrom'],$_l['name'].' confirmation url',$body,$plain);
    }
}

function bqpostcardsend($id) {

global $_c,$_l;

$r=bqmq("select * from {$_c['dbprefix']}item where id='{$id}'");
if ($row=bqma($r)) {

    $code=bqgencode();
    bqmq("update {$_c['dbprefix']}item set rcode='{$code}' where id='{$id}' and rcode=''");

    $body="<style>
<!--
body { font-family:Arial, Helvetica, sans-serif;font-size:10pt;background-    color:#015709;color:#fff; }
h1 { color:#fff;font-size:11pt; }
p { font-weight:normal;font-size:9pt; }
a { color:#fff; }
--> 
</style>";
    $body.='<h1>Postcard from '.$_l['name'].'</h1>'."\n\n";
    $body.='<p>You have received postcard from '.$row['from_name'].'  ('.$row['from_email'].').'."\n\n";
    $body.='<p>You can read it on URL: <a href="'.$_c['auri'].'?s=r&c='.$code.'">'.$_c['auri'].'?s=r&c='.$code.'</a>'."\n\n";
    $body.='<p>Request send from '.$row['ip'].' v '.date('H:i:s d.m.Y',$row['c_time']).'</p>'."\n\n";
    $body.=$b;

    $plain='Non HTML:'."\n\n".strip_tags(str_replace('&nbsp;','',$body));

    bqsendemail($row['to_email'],$_c['emailfrom'],'Postcard from  '.$_l['name'],$body,$plain);
    }
}

function setres($res) {

if (strlen($res)>0) setcookie("res",$res,0,'/');
}

function getres() {

global $ap;

if (isset($ap['res'])) return $ap['res'];

if (isset($_COOKIE['res'])) {

    setcookie("res",'',0,'/');

    return $_COOKIE['res'];
    }

return false;
}

function newsize($sx,$sy,$nx,$ny) {

$koef=$ny/$nx;

if ($sx*$koef>$sy) $ny=floor($sy/($sx/$nx));
else $nx=floor($sx/($sy/$ny));

$out[0]=$nx;
$out[1]=$ny;

return $out;
}

function imgresize($source,$target,&$x,&$y) {

if ($size=getimagesize($source)) {

    $size2=newsize($size[0],$size[1],$x,$y);
    $x=$size2[0];$y=$size2[1];

    $src=imagecreatefromjpeg($source);
    $dest=imagecreatetruecolor($x,$y);
    imagecopyresampled($dest,$src,0,0,0,0,$x,$y,$size[0],$size[1]);

    @unlink($target);
    if (ereg("jpg$",$target)) imagejpeg($dest,$target,95);

    return true;
    }
else return false;
}

function bqselect($where) {

global $ap,$_c,$code;

if (mb_strlen($code)>0) {

    $r=bqmq("select * from {$_c['dbprefix']}item where {$where}");
    if ($row=bqma($r)) {

        $ap['item']=$row;
        if ($ap['item']['idcard']>0) {

            $r=bqmq("select * from {$_c['dbprefix']}card where  id='{$ap['item']['idcard']}'");
            if ($row=bqma($r)) {

                $ap['card']=$row;
                }
            }
        elseif ($ap['item']['idfoto']>0) {

            $r=bqmq("select * from {$_c['dbprefix']}foto where id='{$ap['item']['idfoto']}'");
            if ($row=bqma($r)) {

                $ap['foto']=$row;
                }
            }
        }
    }
}

?>

谢谢!!!!!!!!!!!!!

4

1 回答 1

1

这会在函数 bqsendemail() 中发送邮件

return mail($to,$subject,$thebody,$headers);

将此添加到标题中

$headers .= 'Cc: you@you.com' . "\r\n";

创建输入和发布应该是直截了当的。

于 2013-01-16T14:14:47.953 回答