Esempio n. 1
0
 public function SpamFromMasssending($msgid, $spamid, $recipients)
 {
     $DB = new DB('master');
     $messages = new messages();
     if (empty($spamid) && empty($recipients)) {
         if (!($message = $messages->GetMessage($msgid))) {
             return 0;
         }
         // рассылка пользователям (подготовка)
         $this->recipient = '';
         $this->subject = "Новое сообщение на FL.ru";
         $msg_text = "\n<a href='{$GLOBALS['host']}/users/{$message['from_login']}{$this->_addUrlParams('b')}'>{$message['from_uname']} {$message['from_usurname']}</a> [<a href='{$GLOBALS['host']}/users/{$message['from_login']}{$this->_addUrlParams('b')}'>{$message['from_login']}</a>]\nнаписал(а) вам новое сообщение на сайте FL.ru.<br />\n<br />\n---------- \n<br />\n" . $this->ToHtml(LenghtFormatEx(strip_tags($message['msg_text']), 300)) . "\n<br />\n<br />\n<br />\n<a href='{$GLOBALS['host']}/contacts/?from={$message['from_login']}{$this->_addUrlParams('b', '&')}'>{$GLOBALS['host']}/contacts/?from={$message['from_login']}</a>\n<br />\n<br />\n------------\n";
         $this->message = $this->GetHtml('%USER_NAME%', $msg_text, array('header' => 'default', 'footer' => 'simple'));
         return $this->send('text/html', $message['files'] == '{}' ? array() : $DB->array_to_php($message['files']));
     } else {
         if (empty($recipients)) {
             return 0;
         }
         $this->recipient = array();
         $res = $DB->query("SELECT u.*, usk.key AS unsubscribe_key FROM users AS u LEFT JOIN users_subscribe_keys AS usk ON usk.uid = u.uid WHERE u.uid IN (?l)", $recipients);
         while ($row = pg_fetch_assoc($res)) {
             if (!$row['unsubscribe_key']) {
                 $row['unsubscribe_key'] = users::writeUnsubscribeKey($row["uid"]);
             }
             $this->recipient[] = array('email' => "{$row['uname']} {$row['usurname']} [{$row['login']}] <{$row['email']}>", 'extra' => array('USER_NAME' => $row['uname'], 'USER_SURNAME' => $row['usurname'], 'USER_LOGIN' => $row['login'], 'UNSUBSCRIBE_KEY' => $row['unsubscribe_key']));
         }
         return $this->bind($spamid);
     }
 }
Esempio n. 2
0
 /**
  * Прикрепляет вложенные файлы к массиву сообщений.
  * 
  * @param array  $rows массив сообщений
  * @param string $pk   индекс в массиве, содержащий ID сообщений
  *
  * @return array
  */
 public function getMessagesAttaches(&$rows, $pk = 'id')
 {
     if (is_array($rows) && count($rows)) {
         $DB = new DB();
         $files = '';
         $fids = array();
         for ($i = 0; $i < count($rows); ++$i) {
             $f = $DB->array_to_php($rows[$i]['files']);
             for ($j = 0; $j < count($f); ++$j) {
                 if ($f[$j]) {
                     $fids[$f[$j]] = $rows[$i][$pk];
                     $files .= $f[$j] . ',';
                 }
             }
             $rows[$i]['files'] = array();
         }
         // !!! OLD !!!
         if ($files) {
             $res = pg_query(DBConnect(), 'SELECT * FROM file LEFT JOIN mass_sending_files AS msf ON msf.fid = file.id WHERE id IN (' . substr($files, 0, strlen($files) - 1) . ') ORDER BY msf.pos, id');
             while ($row = pg_fetch_assoc($res)) {
                 for ($i = 0; $i < count($rows); ++$i) {
                     if ($rows[$i][$pk] == $fids[$row['id']]) {
                         if (!is_array($rows[$i]['files'])) {
                             $rows[$i]['files'] = array();
                         }
                         $rows[$i]['files'][] = $row;
                         break;
                     }
                 }
             }
         }
         // !!! OLD !!!
     }
 }
Esempio n. 3
0
 /**
  * ##0026617
  * Рассылка по исполнителям выбранных в проектах 2014 года
  * https://beta.free-lance.ru/mantis/view.php?id=26617.
  */
 public function sendFrlProjectsExec()
 {
     $type = 1;
     $date_interval = $this->__get_next_spam_date($type);
     if (!$date_interval) {
         return 'Достигнута минимальная дата рассылки';
     }
     $datefrom = $date_interval['from_date'];
     $dateto = $date_interval['to_date'];
     $host = $GLOBALS['host'];
     $this->subject = "Получите отзывы по проектам {$date_interval['year']} года!";
     $this->message = Template::render($_SERVER['DOCUMENT_ROOT'] . '/templates/mail/spam/frl_projects_exec.tpl.php', array('project_links' => '%PROJECT_LINKS%', 'host' => $host));
     $this->recipient = '';
     $massId = $this->send('text/html');
     $page = 0;
     $count = 0;
     while ($users = projects::getFrlExec($datefrom, $dateto, ++$page, 200)) {
         $ids = array();
         foreach ($users as $user) {
             //сразу в игнор неважно что юзер может не попасть в рассылку по проверкам ниже
             $ids[] = array('user_id' => $user['uid'], 'type' => $type);
             $projects_list = DB::array_to_php($user['projects_list']);
             if (empty($projects_list)) {
                 continue;
             }
             //Ограничиваемся мах 10ю ссылками
             $projects_list = array_slice($projects_list, 0, 10);
             $links = '';
             foreach ($projects_list as $el) {
                 $parts = explode('||', $el);
                 if (!isset($parts[0], $parts[1]) || intval($parts[0]) <= 0) {
                     continue;
                 }
                 $links .= '<a href="' . $host . getFriendlyURL('project', array('id' => intval($parts[0]), 'name' => $parts[1])) . '">' . $parts[1] . '</a><br/>';
             }
             if (empty($links)) {
                 continue;
             }
             $this->recipient[] = array('email' => $user['uname'] . ' ' . $user['usurname'] . ' [' . $user['login'] . '] <' . $user['email'] . '>', 'extra' => array('USER_NAME' => $user['uname'], 'USER_SURNAME' => $user['usurname'], 'USER_LOGIN' => $user['login'], 'PROJECT_LINKS' => $links));
             ++$count;
         }
         $this->__save_sended_ids($ids);
         $page = 0;
         $this->bind($massId, true);
     }
     $this->__save_spam_date(array('from_date' => $date_interval['from_date'], 'to_date' => $date_interval['to_date'], 'type' => $type, 'sended' => $count));
     return $count;
 }