function ajaxstoreimageAction()
 {
     $currentTime = date("Y-m-d H:i:s");
     $uploaddir = 'images/';
     $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
     $campaign_id = (int) $this->_request->getParam('campaign_id');
     $imgfile = $_FILES['userfile'];
     if (is_array($imgfile)) {
         $name = $imgfile['name'];
         $type = $imgfile['type'];
         $size = $imgfile['size'];
         if (!preg_match('/^image\\//i', $type) ? true : false) {
             $this->view->error = "璇蜂笂浼犳纭殑鍥剧墖";
         } else {
             if ($size > 2000000) {
                 $this->view->error = "鍥剧墖涓嶅緱瓒呰�?M";
             } else {
                 $tmpfile = $imgfile['tmp_name'];
                 if ($tmpfile && is_uploaded_file($tmpfile)) {
                     $file = fopen($tmpfile, "rb");
                     //$imgdata = bin2hex(fread($file,$size)); //bin2hex()灏嗕簩杩涘埗鏁版嵁杞崲鎴愬崄鍏繘鍒惰〃绀�?
                     $imgdata = fread($file, $size);
                     fclose($file);
                     // save to db
                     $imageReportModel = new ImageReport();
                     $imageReport = $imageReportModel->createRow();
                     $imageReport->campaign_id = $campaign_id;
                     $imageReport->consumer_id = $this->_currentUser->id;
                     $imageReport->state = 'NEW';
                     $imageReport->create_date = $currentTime;
                     $imageReport->file_name = $name;
                     $imageReport->type = $type;
                     $imageReport->image = $imgdata;
                     $maxwidth = 80;
                     $maxheight = 80;
                     $im = imagecreatefromstring($imgdata);
                     $width = imagesx($im);
                     $height = imagesy($im);
                     $newwidth = $width;
                     $newheight = $height;
                     if ($maxwidth && $width > $maxwidth || $maxheight && $height > $maxheight) {
                         if ($maxwidth && $width > $maxwidth) {
                             $widthratio = $maxwidth / $width;
                             $RESIZEWIDTH = true;
                         }
                         if ($maxheight && $height > $maxheight) {
                             $heightratio = $maxheight / $height;
                             $RESIZEHEIGHT = true;
                         }
                         if ($RESIZEWIDTH && $RESIZEHEIGHT) {
                             if ($widthratio < $heightratio) {
                                 $ratio = $widthratio;
                             } else {
                                 $ratio = $heightratio;
                             }
                         } elseif ($RESIZEWIDTH) {
                             $ratio = $widthratio;
                         } elseif ($RESIZEHEIGHT) {
                             $ratio = $heightratio;
                         }
                         $newwidth = $width * $ratio;
                         $newheight = $height * $ratio;
                     }
                     $imageReport->thumb_width = round($newwidth);
                     $imageReport->thumb_height = round($newheight);
                     $imageReport->save();
                     $this->view->imageReport = $imageReport;
                 }
             }
         }
     }
     $this->view->campaign_id = $campaign_id;
     $this->_helper->layout->disableLayout();
 }
    function printAll()
    {
        ImagePNG($this->IMAGE);
        ImageDestroy($this->IMAGE);
    }
    //————–调试
    function debug()
    {
        echo "X:" . $this->X . "\r\nY:" . $this->Y;
        echo "\r\nBORDER:" . $this->BORDER;
        $item_array = split($this->ARRAYSPLIT, $this->ITEMARRAY);
        $num = Count($item_array);
        echo "\r\n数值个数:" . $num . "\r\n数值:";
        for ($i = 0; $i < $num; $i++) {
            echo "\r\n" . $item_array[$i];
        }
    }
}
//$report->debug();//调式之用
Header("Content-type:image/png");
$report = new ImageReport();
$report->setImage(330, 140, 255, 255, 255, 1);
//参数(长,高,背影色R,G,B,是否透明1或0)
$temparray = "0,260,400,124,48,720,122,440,475";
//数值,用指定符号隔开
$report->setItem(',', $temparray, 1, 23);
//参数(分隔数值的指定符号,数值变量,样式1为竖柱图2为横柱图3为折线图4为饼图,距离)
$report->setFont(1);
//字体大小1-10
//$report->setX(1,1);//设置X轴刻度值(起始刻度值=1,刻度间隔值=1)
$report->PrintReport();
Example #3
0
 function adminsaveimagereportpointAction()
 {
     $type = $this->_request->getParam('type');
     $db = Zend_Registry::get('db');
     if ($type == 'reportPoint') {
         $idStr = $this->_request->getParam('reportids');
         $idStrArray = explode(',', $idStr);
         $reportIdArray = array();
         $i = 0;
         $config = Zend_Registry::get('config');
         $smtpSender = new Zend_Mail_Transport_Smtp($config->smtp->report->mail->server, array('username' => $config->smtp->report->mail->username, 'password' => $config->smtp->report->mail->password, 'auth' => $config->smtp->report->mail->auth, 'ssl' => $config->smtp->report->mail->ssl, 'port' => $config->smtp->report->mail->port));
         //			$smtpSender = new Zend_Mail_Transport_Smtp(
         //						'smtp.163.com',array(
         //						'username'=>'*****@*****.**',
         //						'password'=>'19990402',
         //						'auth'=>'login'));
         Zend_Mail::setDefaultTransport($smtpSender);
         foreach ($idStrArray as $idAndState) {
             if ($idAndState == '') {
                 continue;
             }
             $idAndStateArray = explode('@', $idAndState);
             if ($idAndStateArray[4] == '' || $idAndStateArray[4] == '0') {
                 $imagereportModel = new ImageReport();
                 $row = $imagereportModel->fetchRow('id = ' . $idAndStateArray[0]);
                 if ($row == null) {
                     continue;
                 }
                 if ($row->reward_point_transaction_record_id != null && $row->reward_point_transaction_record_id != '') {
                     $rewardModel = new RewardPointTransactionRecord();
                     $reward = $rewardModel->fetchRow('id = ' . $row->reward_point_transaction_record_id);
                     if ($reward != null) {
                         $reward->point_amount = $idAndStateArray[4];
                         $reward->save();
                     }
                 }
                 $row->state = $idAndStateArray[1];
                 $row->save();
             } else {
                 $imagereportModel = new ImageReport();
                 $row = $imagereportModel->fetchRow('id = ' . $idAndStateArray[0]);
                 $row->state = $idAndStateArray[1];
                 if ($row->reward_point_transaction_record_id == null || $row->reward_point_transaction_record_id == '') {
                     $rewardModel = new RewardPointTransactionRecord();
                     $reward = $rewardModel->createRow();
                     $reward->consumer_id = $idAndStateArray[2];
                     $reward->date = date("Y-m-d H:i:s");
                     $reward->transaction_id = 9;
                     $reward->point_amount = $idAndStateArray[4];
                     $row->reward_point_transaction_record_id = $reward->save();
                 } else {
                     $rewardModel = new RewardPointTransactionRecord();
                     $reward = $rewardModel->fetchRow('id = ' . $row->reward_point_transaction_record_id);
                     if ($reward != null) {
                         $reward->date = date("Y-m-d H:i:s");
                         $reward->point_amount = $idAndStateArray[4];
                         $reward->save();
                     }
                 }
                 $row->save();
                 //2011-05-13 change the rank of consumer
                 $rankModel = new Rank();
                 $rankModel->changeConsumerRank($idAndStateArray[2]);
             }
             $consumerModel = new Consumer();
             $consumer = $consumerModel->fetchRow('id = ' . $idAndStateArray[2]);
             //send mail...
             $mail = new Zend_Mail('utf-8');
             if ($consumer->language_pref != null && $consumer->language_pref == 'en') {
                 $emailSubject = $this->view->translate('Admin_Reply_WOM_IMAGEReport_Subject_en');
                 $emailBody = $this->view->translate('Admin_Reply_WOM_IMAGEReport_Body_en');
             } else {
                 $emailSubject = $this->view->translate('Admin_Reply_WOM_IMAGEReport_Subject_zh');
                 $emailBody = $this->view->translate('Admin_Reply_WOM_IMAGEReport_Body_zh');
             }
             $campaignModel = new Campaign();
             $campaign = $campaignModel->fetchRow('id = ' . $row->campaign_id);
             $stringChange = array('?USERNAME?' => $consumer->name, '?CAMPAIGN?' => $campaign->name, '?MYRESPONSE?' => $idAndStateArray[3]);
             $emailBody = strtr($emailBody, $stringChange);
             $langNamespace = new Zend_Session_Namespace('Lang');
             if ($langNamespace->lang == 'en' || $langNamespace->lang == 'EN') {
                 $mail->setSubject($emailSubject);
             } else {
                 $mail->setSubject("=?UTF-8?B?" . base64_encode($emailSubject) . "?=");
             }
             $mail->setBodyText($emailBody);
             $mail->addTo($consumer->email);
             $mail->setFrom($config->smtp->report->mail->username, $this->view->translate('Wildfire'));
             //				$mail->setFrom('*****@*****.**',$this->view->translate('Wildfire'));
             $mail->send();
             // save email
             $imagereportreplyModel = new ImageReportReply();
             $imagereportreply = $imagereportreplyModel->createRow();
             $imagereportreply->date = date("Y-m-d H:i:s");
             $imagereportreply->subject = $emailSubject;
             $imagereportreply->content = $idAndStateArray[3];
             $imagereportreply->from = $config->smtp->report->mail->username;
             $imagereportreply->to = $consumer->email;
             $imagereportreply->image_report_id = $row->id;
             //2011-04-08 ham.bao separate the sessions with admin
             $imagereportreply->admin_id = $this->_currentAdmin->id;
             $imagereportreply->save();
         }
     }
 }