Esempio n. 1
0
 /**
  * 测试邮件发送
  */
 public function actionMailTest()
 {
     $data = $this->_gets->getParam('Config');
     try {
         $var['state'] = 'success';
         $var['message'] = '发送成功';
         XMail::send();
         var_dump($data);
     } catch (Exception $e) {
         $var['state'] = 'error';
         $var['message'] = '错误:' . $e->getMessage();
     }
     exit(CJSON::encode($var));
 }
Esempio n. 2
0
 function save($currpass, $newpass)
 {
     $rcmail = rcmail::get_instance();
     list($user, $domain) = explode('@', $_SESSION['username']);
     $xmail = new XMail();
     $xmail->hostname = $rcmail->config->get('xmail_host');
     $xmail->username = $rcmail->config->get('xmail_user');
     $xmail->password = $rcmail->config->get('xmail_pass');
     $xmail->port = $rcmail->config->get('xmail_port');
     if (!$xmail->connect()) {
         rcube::raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Password plugin: Unable to connect to mail server"), true, false);
         return PASSWORD_CONNECT_ERROR;
     } else {
         if (!$xmail->send("userpasswd\t" . $domain . "\t" . $user . "\t" . $newpass . "\n")) {
             $xmail->close();
             rcube::raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Password plugin: Unable to change password"), true, false);
             return PASSWORD_ERROR;
         } else {
             $xmail->close();
             return PASSWORD_SUCCESS;
         }
     }
 }
Esempio n. 3
0
function nulluhr()
{
    global $db;
    update_all_ranks();
    $db->query('DELETE FROM ' . DB_PRE . 'ecp_messages WHERE fromdel = 1 AND del = 1');
    $result = $db->query('SELECT ID FROM ' . DB_PRE . 'ecp_user WHERE (ondelete < ' . time() . ' AND ondelete != 0) OR (status = 0 AND registerdate < ' . (time() - DELETE_UNAKTIV * 86400) . ')');
    while ($row = mysql_fetch_assoc($result)) {
        delete_user($row['ID']);
    }
    $result = $db->query('SELECT ID, money FROM ' . DB_PRE . 'ecp_user LEFT JOIN ' . DB_PRE . 'ecp_ranks ON (rID = rankID)');
    while ($row = mysql_fetch_assoc($result)) {
        if ($row['money'] != '') {
            $db->query('UPDATE ' . DB_PRE . 'ecp_user_stats SET money = money + ' . $row['money'] . ' WHERE userID = ' . $row['ID']);
        }
    }
    if (BACKUP_AKTIV) {
        $last = $db->result(DB_PRE . 'ecp_stats', 'lastdbbackup', '1');
        if (BACKUP_CYCLE == 'day' or $last + (BACKUP_CYCLE == 'month' ? 2592000 : 604800) < time()) {
            $backup_obj = new MySQL_Backup();
            $backup_obj->server = MYSQL_HOST;
            $backup_obj->username = MYSQL_USER;
            $backup_obj->password = MYSQL_PASS;
            $backup_obj->database = MYSQL_DATABASE;
            $backup_obj->tables = array();
            $backup_obj->drop_tables = true;
            $backup_obj->struct_only = false;
            $backup_obj->comments = true;
            $backup_obj->fname_format = 'd_m_y__H_i_s';
            $string = get_random_string(8, 2);
            if ($backup_obj->Execute(MSB_SAVE, 'uploads/forum/' . $string . '.sql.gz', true)) {
                $m = new XMail();
                // set from address and name
                $m->From(SITE_EMAIL);
                // add to address and name
                $m->AddTo(BACKUP_EMAIL);
                // set subject
                $m->Subject(BACKUP_AUTO);
                // set text/plain version of message
                $m->Text(DATE . ': ' . date('d.m.Y H:i:s'));
                // add attachment ('text/plain' file)
                $m->Attach(date('Y_m_d') . '.sql.gz', 'application/x-gzip');
                $f = 'uploads/forum/' . $string . '.sql.gz';
                $id = MIME::unique();
                // add inline attachment '$f' file with ID '$id'
                $m->Attach(file_get_contents($f), FUNC::mime_type($f), null, null, null, 'attachment', $id);
                if (SMTP_AKTIV) {
                    $c = $m->Connect(SMTP_HOST, (int) SMTP_PORT, SMTP_USER, SMTP_PASS, 'tls', 10, 'localhost', null, 'plain');
                    //or die(print_r($m->Result));
                }
                if ($m->Send(SMTP_AKTIV ? $c : null)) {
                    $db->query('UPDATE ' . DB_PRE . 'ecp_stats SET lastdbbackup = ' . strtotime('today 00:00:00'));
                }
                unlink('uploads/forum/' . $string . '.sql.gz');
            }
        }
    }
    $result = $db->query('SELECT attachID, strname FROM ' . DB_PRE . 'ecp_forum_attachments WHERE (tID = 0 OR bID = 0) AND uploadzeit < ' . (time() - 1000));
    while ($row = $db->fetch_assoc()) {
        @unlink('upload/forum/' . $row['attachID'] . '_' . $row['strname']);
    }
    $db->query('DELETE FROM ' . DB_PRE . 'ecp_forum_attachments WHERE (tID = 0 OR bID = 0) AND uploadzeit < ' . (time() - 1000));
    // Buchungen durchf�hren
    $buchresult = $db->query('SELECT `ID`, `verwendung`, `intervall`, `betrag`, `nextbuch`, `tagmonat` FROM ' . DB_PRE . 'ecp_clankasse_auto WHERE nextbuch <= \'' . time() . '\'');
    while ($row = mysql_fetch_assoc($buchresult)) {
        $db->query('INSERT INTO ' . DB_PRE . 'ecp_clankasse_transaktion (`geld`, `verwendung`, `datum`, `userID`) VALUES
                 (-' . $row['betrag'] . ', \'' . mysql_real_escape_string($row['verwendung']) . '\', ' . time() . ', 0)');
        $db->query('UPDATE ' . DB_PRE . 'ecp_clankasse SET kontostand = kontostand - ' . $row['betrag']);
        switch ($row['tagmonat']) {
            case 1:
                $nextdate = strtotime('+ ' . (int) $row['intervall'] . ' month');
                break;
            case 15:
                $nextdate = strtotime('+ ' . (int) $row['intervall'] . ' month');
                break;
            case 28:
                $nextdate = strtotime('+ ' . (int) $row['intervall'] . ' month');
        }
        $db->query('UPDATE ' . DB_PRE . 'ecp_clankasse_auto SET `nextbuch` = \'' . $nextdate . '\'');
    }
    $db->query('DELETE FROM ' . DB_PRE . 'ecp_forum_search WHERE datum < ' . (time() - 86400));
    $result = $db->query('SELECT COUNT(sID) as anzahl, sID FROM ' . DB_PRE . 'ecp_server_stats GROUP BY sID');
    while ($row = mysql_fetch_assoc($result)) {
        if ($row['anzahl'] > SERVER_MAX_LOG) {
            $db->query('DELETE FROM ' . DB_PRE . 'ecp_server_stats WHERE sID = ' . $row['sID'] . ' ORDER BY datum ASC LIMIT ' . ($row['anzahl'] - SERVER_MAX_LOG));
        }
    }
}
 protected function sendemail($title, $mailbody)
 {
     $mail = new XMail();
     return $mail->SendEmail($this->mailto, $title, $mailbody);
 }