/** * Blacklist an email address, not a subscriber specifically * @param string $email_address * @param string $reason * @param string $date */ public function blacklistEmail($email_address, $reason = '', $date = '') { if (empty($date)) { $sqldate = 'CURRENT_TIMESTAMP'; } else { $sqldate = '"' . $date . '"'; } $email_address = String::sqlEscape($email_address); #0012262: blacklist only email when email bounces. (not subscribers): Function split so email can be blacklisted without blacklisting subscriber $this->db->query(sprintf('INSERT IGNORE INTO %s (email,added) VALUES("%s",%s)', $this->config->getTableName('user_blacklist'), String::sqlEscape($email_address), $sqldate)); # save the reason, and other data $this->db->query(sprintf('INSERT IGNORE INTO %s (email, name, data) VALUES("%s","%s","%s"), ("%s","%s","%s")', $this->config->getTableName('user_blacklist_data'), $email_address, 'reason', addslashes($reason), $email_address, 'REMOTE_ADDR', addslashes($_SERVER['REMOTE_ADDR']))); /*foreach (array("REMOTE_ADDR") as $item ) { # @@@do we want to know more? if (isset($_SERVER['REMOTE_ADDR'])) { $this->db->Sql_Query(sprintf( 'INSERT IGNORE INTO %s (email, name, data) VALUES("%s","%s","%s")', $this->config->getTableName('user_blacklist_data'),addslashes($email_address), $item,addslashes($_SERVER['REMOTE_ADDR']))); } }*/ //when blacklisting only an email address, don't add this to the history, only do this when blacklisting a subscriber //addSubscriberHistory($email_address,s('Added to blacklist'),s('Added to blacklist for reason %s',$reason)); }
/** * Get an array of Campaigns by searching its status and subject * When $owner is provided, only returns the campaigns for the given owner * @param string|array $status * @param string $subject * @param int $owner * @param string $order * @param int $offset * @param int $limit * @return array CampaignEntity */ public function getCampaignsBy($status, $subject = '', $owner = 0, $order = '', $offset = 0, $limit = 0) { $return = array(); $condition = 'status IN ('; $condition .= is_array($status) ? implode(',', $status) : $status; $condition .= ') '; if ($subject != '') { $condition .= ' AND subject LIKE "%' . String::sqlEscape($subject) . '%" '; } if ($owner != 0) { $condition .= sprintf(' AND owner = %d', $owner); } switch ($order) { case 'sentasc': $sortBySql = ' ORDER BY sent ASC'; break; case 'sentdesc': $sortBySql = ' ORDER BY sent DESC'; break; case 'subjectasc': $sortBySql = ' ORDER BY subject ASC'; break; case 'subjectdesc': $sortBySql = ' ORDER BY subject DESC'; break; case 'enteredasc': $sortBySql = ' ORDER BY entered ASC'; break; case 'entereddesc': $sortBySql = ' ORDER BY entered DESC'; break; case 'embargoasc': $sortBySql = ' ORDER BY embargo ASC'; break; case 'embargodesc': $sortBySql = ' ORDER BY embargo DESC'; break; default: $sortBySql = ' ORDER BY embargo DESC, entered DESC'; } $result = $this->db->query(sprintf('SELECT COUNT(*) FROM % WHERE %s %s', $this->config->getTableName('message'), $condition, $sortBySql)); $return['total'] = $result->fetch(); $result = $this->db->query(sprintf('SELECT * FROM %s WHERE %s %s LIMIT %d OFFSET %d', $this->config->getTableName('message'), $condition, $sortBySql, $limit, $offset)); while ($msg = $result->fetch(\PDO::FETCH_ASSOC)) { $return['messages'][] = $this->campaignFromArray($msg); } return $return; }
/** * Update back to db * $modifiedby can be any string to see who has changed the record * @param string $modifiedby */ public function update($modifiedby) { $privileges = String::sqlEscape(serialize($this->privileges)); phpList::DB()->query(sprintf('UPDATE %s SET loginname = "%s", namelc = "%s", email = "%s", modified = CURRENT_TIMESTAMP, modifiedby = "%s", superuser = %d, disabled = %d, privileges = "%s"', Config::getTableName('admin'), $this->loginname, $this->namelc, $this->email, $modifiedby, $this->superuser, $this->disabled, $privileges)); }