doujia1904 2019-07-04 08:36
浏览 66

PHP - 将变量传递给公用文件夹

I have a script for an email sending in php and i have to put it in the public folder. The script is working perfectly but i would like to send variables to my script. The variables are declared in a controller inside the application folder, they are the result of a database. The script has to be executed every morning. How can i pass the variables ?

I want to put the script outside the application because i want to execute the script with cron. If i put the script in the application folder, he wont be executed because the connection in the application require a loginAction.

the script is called emailsuivi.php. The variables to send are called $suiviprodmois and $suiviprodjours. Im using ZendFramework 1.

the app folder :

enter image description here

The script :

 $dateCrea = date('Ym', mktime(0,0,0,date("m"),0,date("Y")));
    $curDate = date("Y-m-d H:i:s");

    ini_set('SMTP','mail.viapost-services.fr');
    $mails = 'Nicolas.BOULEIN@viapost.fr';
    $sujet = 'Suivi de production';
    $message = "
        <html>
        <head>
             <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
        </head>
        <body>
        <style>
        body{
            font-family : Arial;
        }
        h1, h2{
            text-align : center;
        } 
        table {
            font-family : Arial;
            border : 1px solid black;     
            width : 100%;
        }
        table th {
            border : 1px solid white;
            height: 25px;
            text-align: center;
            padding: 0px;
            background: #3A81A7;    
            color: white;
            background-color:#3a81a7;
        }
        table td {
            border : 1px solid black;
            padding: 0 1px 5px 0;
            text-align : center;
        }
        </style>
            <h1> Suivi de production </h1>
            <h2> Le : ".$curDate."</h2>
            <h3> Suivi des dépôts du J-1 </h3>
            <table>
                <thead>
                <tr>
                 <th></th>
                 <th></th> 
                 <th colspan='3'>Résultat admission</th>
                 <th colspan='3'>Résultat PEC</th>
                 <th colspan='3'>Facturation HORS BORD</th>
               </tr>
               <tr>
                 <th>TYPE</th>
                 <th>IMPORT</th> 
                 <th>RADM_OK</th>
                 <th>RADM_REJET</th>
                 <th>RADM_KO</th>
                 <th>RPEC_OK</th>
                 <th>RPEC_REJET</th>
                 <th>RPEC_KO</th>
                 <th>FACTU_OK</th>
                 <th>FACTU_REJET</th>
                 <th>FACTU_KO</th>
               </tr>
               </thead>
               <tbody>";
                foreach ($suiviprodjours as $arr){
                $message .="<tr>";
                   foreach ($arr as $key => $val){
                    $message .="<td>".$arr[$key]."</td>";    
                 }
                 $message .="</tr>";
              }
              $message .="</tbody>
                </table>
                </ br>
                </ br>
                </ br>
                </ br>
              <h3> Suivi des dépôts du M-1 </h3>
              <table>
                <thead>
                <tr>
                  <th>OBJET</th>
                  <th>ATTENTE</th> 
                  <th>ENCOURS</th>
                  <th>FINADM</th>
                  <th>FACTURE</th>
                  <th>ACQUITTE</th>
                </tr>
               </thead>
               <tbody>";
                foreach ($suiviprodmois as $arr){
                $message .="<tr>";
                   foreach ($arr as $key => $val){
                    $message .="<td>".$arr[$key]."</td>";    
                 }
                 $message .="</tr>";
              }
              $message .="</tbody>
                  </table>
            </body>";
    $headers =  'MIME-Version: 1.0' . "
"; 
    $headers .= 'From: SAGAPEC <sagapec@viapost.fr>' . "
";
    $headers .= 'Content-type: text/html; charset=UTF-8' . "
";
    mail($mails,$sujet,$message,$headers)   

The function for the variables :

    public function suiviprodAction(){

    // Connexion au fichier de label
    $this->view->lib = $this->_labelsFile;

    $oDepotAdmin = new Services_DepotAdmin();
    $suiviprodjours = $oDepotAdmin->suiviProdJours();

    $dateCrea = date('Ym', mktime(0,0,0,date("m"),0,date("Y")));
    $curDate = date("Y-m-d H:i:s");

    $suiviprodmois = $oDepotAdmin->suiviProdMois($dateCrea);

    //$_SESSION['suiviprodmois'] = $suiviprodmois;

}

the localisation of this function :

enter image description here

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 名为“Product”的列已属于此 DataTable
    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题