function saveConfig($key, $val, $editable = 1) { Sql_Query(sprintf('update %s set value = "%s",editable = %d where item = "%s"', $this->tables["config"], $val, $editable, $key)); if (!Sql_Affected_Rows()) { Sql_Query(sprintf('insert into %s (item,value,editable) values("%s","%s",%d)', $this->tables["config"], $key, $val, $editable)); } }
function rssUserHasContent($userid,$messageid,$frequency) { global $tables; switch ($frequency) { case "weekly": $interval = 'interval 7 day';break; case "monthly": $interval = 'interval 1 month';break; case "daily": default: $interval = 'interval 1 day';break; } $cansend_req = Sql_Query(sprintf('select date_add(last,%s) < now() from %s where userid = %d', $interval,$tables["user_rss"],$userid)); $exists = Sql_Affected_Rows(); $cansend = Sql_Fetch_Row($cansend_req); if (!$exists || $cansend[0]) { # we can send this user as far as the frequency is concerned # now check whether there is actually some content # check what lists to use. This is the intersection of the lists for the # user and the lists for the message $lists = array(); $listsreq = Sql_Query(sprintf(' select %s.listid from %s,%s where %s.listid = %s.listid and %s.userid = %d and %s.messageid = %d', $tables["listuser"],$tables["listuser"],$tables["listmessage"], $tables["listuser"],$tables["listmessage"], $tables["listuser"],$userid,$tables["listmessage"],$messageid)); while ($row = Sql_Fetch_Row($listsreq)) { array_push($lists,$row[0]); } if (!sizeof($lists)) return 0; $liststosend = join(",",$lists); # request the rss items that match these lists and that have not been sent to this user $itemstosend = array(); $max = sprintf('%d',getConfig("rssmax")); if (!$max) { $max = 30; } $itemreq = Sql_Query("select {$tables["rssitem"]}.* from {$tables["rssitem"]} where {$tables["rssitem"]}.list in ($liststosend) order by added desc, list,title limit $max"); while ($item = Sql_Fetch_Array($itemreq)) { Sql_Query("select * from {$tables["rssitem_user"]} where itemid = {$item["id"]} and userid = $userid"); if (!Sql_Affected_Rows()) { array_push($itemstosend,$item["id"]); } } # print "<br/>Items to send for user $userid: ".sizeof($itemstosend); # if it is less than the treshold return nothing $treshold = getConfig("rsstheshold"); if (sizeof($itemstosend) >= $treshold) return $itemstosend; else return array(); } return array(); }
public function getPassword($email) { $email = preg_replace("/[;,\"\\']/", '', $email); $req = Sql_Query('select email,password,loginname from ' . $GLOBALS['tables']['admin'] . ' where email = "' . sql_escape($email) . '"'); if (Sql_Affected_Rows()) { $row = Sql_Fetch_Row($req); return $row[1]; } }
function mysql_session_read($SessionID) { # dbg("Reading session info for $SessionID"); $SessionTableName = $GLOBALS["SessionTableName"]; $SessionID = addslashes($SessionID); $session_data_req = sql_query("SELECT data FROM {$SessionTableName} WHERE sessionid = '{$SessionID}'"); if (Sql_Affected_Rows() == 1) { $data = Sql_Fetch_Row($session_data_req); return $data[0]; } else { return false; } }
function accessLevel($page) { global $tables, $access_levels; if (!$GLOBALS["require_login"] || isSuperUser()) { return "all"; } if (!isset($_SESSION["adminloggedin"])) { return 0; } if (!is_array($_SESSION["logindetails"])) { return 0; } # check whether it is a page to protect Sql_Query("select id from {$tables["task"]} where page = \"{$page}\""); if (!Sql_Affected_Rows()) { return "all"; } $req = Sql_Query(sprintf('select level from %s,%s where adminid = %d and page = "%s" and %s.taskid = %s.id', $tables["task"], $tables["admin_task"], $_SESSION["logindetails"]["id"], $page, $tables["admin_task"], $tables["task"])); $row = Sql_Fetch_Row($req); return $access_levels[$row[0]]; }
<p>На этой странице Вы можете подготовить письмо для дальнейшей отправки. Можно указать всю необходимую информацию, исключая списки рассылки для отправки. Затем, в момент отправки подготовленного письма, можно будет выбрать списки рассылки и письмо будет отправлено. </p> <p>Ваше подготовленное письмо постоянно, то есть оно не исчезнет после отправки и может быть использовано много раз повторно. Будьте осторожны, пользуясь этой возможностью, потому что это может привести к тому, что Вы будете отправлять одни и те же письма Вашим подписчикам несколько раз.</p> <p> Эта функциональность специально реализована с целью использовать при совместной работе в системе нескольких администраторов. Если главный администратор готовит такое письмо, простые администраторы могут отправлять его по своим спискам рассылки. В этом случае, Вы можете использовать дополнительные метки в письме: атрибуты администратора.</p> <p>Для примера, если у Вас есть атрибут администратора <b>Name</b> (Имя), Вы можете добавить метку [LISTOWNER.NAME], она будет заменена на <b>Имя</b> владельца списка, кому производится отправка этого письма. Значение будет установлено вне зависимости от того, кто отправляет письмо. Таким образом, если главный администратор отправляет письмо по списку, которые принадлежит кому-то ещё, метка [LISTOWNER] будет заменена на значение владельца списка, а не значения главного администратора.</p> <p>Для справки:<br/> Метка [LISTOWNER] задаётся в формате <b>[LISTOWNER.АТРИБУТ]</b></p> <p>На текущий момент заданы следующие атрибуты администратора: <table border=1><tr><td><b>Атрибут</b></td><td><b>Метка</b></td></tr> <?php $req = Sql_query("select name from {$tables['adminattribute']} order by listorder"); if (!Sql_Affected_Rows()) { print '<tr><td colspan=2>Атрибутов администратора нет</td></tr>'; } while ($row = Sql_Fetch_Row($req)) { if (strlen($row[0]) < 20) { printf('<tr><td>%s</td><td>[LISTOWNER.%s]</td></tr>', $row[0], strtoupper($row[0])); } } ?> </p>
function getNewAttributeTablename($name) { $lc_name = substr(preg_replace("/\W/","", strtolower($name)),0,10); # if ($lc_name == "") Fatal_Error("Name cannot be empty: $lc_name"); if (!$lc_name) $lc_name = "attribute"; Sql_Query("select * from attribute where tablename = \"$lc_name\""); # if (Sql_Affected_Rows()) Fatal_Error("Name is not unique enough"); $c = 1; $basename = $lc_name; while (Sql_Affected_Rows() && $c < 100) { $lc_name = $basename.$c; Sql_Query("select * from attribute where tablename = \"$lc_name\""); $c++; } return $lc_name; }
if ($usetwo) { Sql_query(sprintf('replace into %s (attributeid,userid,value) values(%d,%d,"%s")', $tables["user_attribute"], $firstname_att_id, $userid, $importuser["firstname"])); Sql_query(sprintf('replace into %s (attributeid,userid,value) values(%d,%d,"%s")', $tables["user_attribute"], $lastname_att_id, $userid, $importuser["lastname"])); } else { Sql_query(sprintf('replace into %s (attributeid,userid,value) values(%d,%d,"%s")', $tables["user_attribute"], $name_att_id, $userid, $importuser["personal"])); } } #add this user to the lists identified reset($lists); $addition = 0; $listoflists = ""; while (list($key, $listid) = each($lists)) { $query = "replace INTO " . $tables["listuser"] . " (userid,listid,entered) values({$userid},{$listid},current_timestamp)"; $result = Sql_query($query); # if the affected rows is 2, the user was already subscribed $addition = $addition || Sql_Affected_Rows() == 1; $listoflists .= " * " . $available_lists[$listid] . "\n"; } if ($addition) { $additional_emails++; } if (!TEST && $_POST["notify"] == "yes" && $addition) { $subscribemessage = str_replace('[LISTS]', $listoflists, getUserConfig("subscribemessage", $userid)); sendMail($email, getConfig("subscribesubject"), $subscribemessage, system_messageheaders(), $envelope); } } // end if } // end foreach $num_lists = sizeof($lists); # be grammatically correct :-)
switch ($_GET['action']) { case 'suspall': $action_result .= $GLOBALS['I18N']->get('Suspending all') . ' ..'; $result = Sql_query(sprintf('update %s set status = "suspended" where (status = "inprocess" or status = "submitted") %s', $tables['message'], $ownerselect_and)); $suc6 = Sql_Affected_Rows(); if ($suc6) { $action_result .= "... {$suc6} " . $GLOBALS['I18N']->get('Done'); } else { $action_result .= '... ' . $GLOBALS['I18N']->get('Failed'); } $action_result .= '<br /><hr /><br />'; break; case 'markallsent': $action_result .= $GLOBALS['I18N']->get('Marking all as sent ') . ' ..'; $result = Sql_query(sprintf('update %s set status = "sent", repeatinterval = 0,requeueinterval = 0 where (status = "suspended") %s', $tables['message'], $markSent, $ownerselect_and)); $suc6 = Sql_Affected_Rows(); if ($suc6) { $action_result .= "... {$suc6} " . $GLOBALS['I18N']->get('Done'); } else { $action_result .= '... ' . $GLOBALS['I18N']->get('Failed'); } $action_result .= '<br /><hr /><br />'; break; } } if (!empty($action_result)) { #print ActionResult($action_result); $_SESSION['action_result'] = $action_result; Redirect('messages'); exit; }
break; default: $column = 'user.modified'; break; } } ##$subselect .= ' limit 500'; // just to test the progress meter if ($list) { $result = Sql_query(sprintf('select * from %s where user.id = listuser.userid and listuser.listid = %d and %s >= "%s 00:00:00" and %s <= "%s 23:59:59" %s ', $querytables, $list, $column, $fromdate, $column, $todate, $subselect)); } else { $result = Sql_query(sprintf(' select * from %s where %s >= "%s 00:00:00" and %s <= "%s 23:59:59" %s', $querytables, $column, $fromdate, $column, $todate, $subselect)); } $todo = Sql_Affected_Rows(); $done = 0; fwrite($exportfile, $GLOBALS['I18N']->get('List Membership') . $row_delim); while ($user = Sql_fetch_array($result)) { ## re-verify the blacklist status if (empty($user['blacklisted']) && isBlackListed($user['email'])) { $user['blacklisted'] = 1; Sql_Query(sprintf('update %s set blacklisted = 1 where email = "%s"', $GLOBALS['tables']['user'], $user['email'])); } set_time_limit(500); if ($done % 50 == 0) { print '<script type="text/javascript"> var parentJQuery = window.parent.jQuery; parentJQuery("#progressbar").updateProgress("' . $done . ',' . $todo . '"); </script>'; flush();
print $tabs->display(); } $countquery = ' select *' . ' from ' . $tables['list'] . $subselect; $countresult = Sql_query($countquery); $total = Sql_Num_Rows($countresult); if ($total == 0 && sizeof($aListCategories) && $current == '' && empty($_GET['tab'])) { ## reload to first category, if none found by default (ie all lists are categorised) if (!empty($aListCategories[0])) { Redirect('list&tab=' . $aListCategories[0]); } } print '<p class="total">' . $total . ' ' . $GLOBALS['I18N']->get('Lists') . '</p>'; $limit = ''; $query = ' select *' . ' from ' . $tables['list'] . $subselect . ' order by listorder ' . $limit; $result = Sql_query($query); $numlists = Sql_Affected_Rows($result); $ls = new WebblerListing(s('Lists')); if ($numlists > 15) { Info(s('You seem to have quite a lot of lists, do you want to organise them in categories? ') . ' ' . PageLinkButton('catlists', $GLOBALS['I18N']->get('Great idea!'))); /* @@TODO add paging when there are loads of lists, because otherwise the page is very slow $limit = ' limit 50'; $query = ' select *' . ' from ' . $tables['list'] . $subselect . ' order by listorder '.$limit; $result = Sql_query($query); */ } while ($row = Sql_fetch_array($result)) { ## we only consider confirmed and not blacklisted subscribers members of a list
print Sql_Affected_Rows() . " " . $GLOBALS['I18N']->get('entries apply') . "<br/>"; while ($row = Sql_Fetch_Row($req)) { Sql_Query("delete from {$tables["user_attribute"]} where userid = {$row['0']}"); } $req = Sql_Verbose_Query("select {$tables["listuser"]}.userid\n from {$tables["listuser"]} left join {$tables["user"]} on {$tables["listuser"]}.userid = {$tables["user"]}.id\n where {$tables["user"]}.id IS NULL group by {$tables["listuser"]}.userid"); print Sql_Affected_Rows() . " " . $GLOBALS['I18N']->get('entries apply') . "<br/>"; while ($row = Sql_Fetch_Row($req)) { Sql_Query("delete from {$tables["listuser"]} where userid = {$row['0']}"); } $req = Sql_Verbose_Query("select {$tables["usermessage"]}.userid\n from {$tables["usermessage"]} left join {$tables["user"]} on {$tables["usermessage"]}.userid = {$tables["user"]}.id\n where {$tables["user"]}.id IS NULL group by {$tables["usermessage"]}.userid"); print Sql_Affected_Rows() . " " . $GLOBALS['I18N']->get('entries apply') . "<br/>"; while ($row = Sql_Fetch_Row($req)) { Sql_Query("delete from {$tables["usermessage"]} where userid = {$row['0']}"); } $req = Sql_Verbose_Query("select {$tables["user_message_bounce"]}.user\n from {$tables["user_message_bounce"]} left join {$tables["user"]} on {$tables["user_message_bounce"]}.user = {$tables["user"]}.id\n where {$tables["user"]}.id IS NULL group by {$tables["user_message_bounce"]}.user"); print Sql_Affected_Rows() . " " . $GLOBALS['I18N']->get('entries apply') . "<br/>"; while ($row = Sql_Fetch_Row($req)) { Sql_Query("delete from {$tables["user_message_bounce"]} where user = {$row['0']}"); } } $table_list = $tables["user"] . $findtables; if ($find) { $listquery = "select {$tables["user"]}.id,{$findfield},{$tables["user"]}.confirmed from " . $table_list . " where {$findbyselect}"; $count = Sql_query("SELECT count(*) FROM " . $table_list . " where {$findbyselect}"); $unconfirmedcount = Sql_query("SELECT count(*) FROM " . $table_list . " where !confirmed && {$findbyselect}"); if ($_GET["unconfirmed"]) { $listquery .= ' and !confirmed'; } } else { $listquery = "select {$tables["user"]}.id,{$findfield},{$tables["user"]}.confirmed from " . $table_list; $count = Sql_query("SELECT count(*) FROM " . $table_list);
function ListAvailableLists($userid = 0, $lists_to_show = "") { global $tables; if (isset($_POST['list'])) { $list = $_POST["list"]; } else { $list = ''; } $subselect = ""; $listset = array(); $subscribed = array(); $showlists = explode(",", $lists_to_show); if (PREFERENCEPAGE_SHOW_PRIVATE_LISTS && !empty($userid)) { ## merge with the subscribed lists, regardless of public state $req = Sql_Query(sprintf('select listid from %s where userid = %d', $tables['listuser'], $userid)); while ($row = Sql_Fetch_Row($req)) { $subscribed[] = $row[0]; } $showlists = array_unique(array_merge($showlists, $subscribed)); } foreach ($showlists as $listid) { if (preg_match("/^\\d+\$/", $listid)) { array_push($listset, $listid); } } if (sizeof($listset) >= 1) { $subselect = "where id in (" . join(",", $listset) . ") "; } $some = 0; $html = '<ul class="list">'; $result = Sql_query("SELECT * FROM {$GLOBALS["tables"]["list"]} {$subselect} order by listorder, name"); while ($row = Sql_fetch_array($result)) { if ($row["active"] || in_array($row['id'], $subscribed)) { $html .= '<li class="list"><input type="checkbox" name="list[' . $row["id"] . ']" value="signup" '; if (isset($list[$row["id"]]) && $list[$row['id']] == "signup") { $html .= 'checked="checked"'; } if ($userid) { $req = Sql_Fetch_Row_Query(sprintf('select userid from %s where userid = %d and listid = %d', $GLOBALS["tables"]["listuser"], $userid, $row["id"])); if (Sql_Affected_Rows()) { $html .= 'checked="checked"'; } } $html .= " /><b>" . stripslashes($row["name"]) . '</b><div class="listdescription">'; $desc = nl2br(stripslashes($row["description"])); # $html .= '<input type="hidden" name="listname['.$row["id"] . ']" value="'.htmlspecialchars(stripslashes($row["name"])).'"/>'; $html .= $desc . '</div></li>'; $some++; if ($some == 1) { $singlelisthtml = sprintf('<input type="hidden" name="list[%d]" value="signup" />', $row["id"]); $singlelisthtml .= '<input type="hidden" name="listname[' . $row["id"] . ']" value="' . htmlspecialchars(stripslashes($row["name"])) . '"/>'; } } } $html .= '</ul>'; $hidesinglelist = getConfig("hide_single_list"); if (!$some) { global $strNotAvailable; return '<p class="information">' . $strNotAvailable . '</p>'; } elseif ($some == 1 && ($hidesinglelist == "true" || $hidesinglelist === true || $hidesinglelist === "1")) { return $singlelisthtml; } else { global $strPleaseSelect; return '<p class="information">' . $strPleaseSelect . ':</p>' . $html; } }
} else { $groups = $_SESSION["groups"]; } if (isset($everyone_groupid) && !in_array($everyone_groupid, $groups)) { array_push($groups, $everyone_groupid); } if (defined('IN_WEBBLER') && is_array($groups)) { #add this user to the groups identified reset($groups); $groupaddition = 0; while (list($key, $groupid) = each($groups)) { if ($groupid) { $query = sprintf('replace INTO user_group (userid,groupid,type) values(%d,%d,%d)', $userid, $groupid, $_SESSION['grouptype']); $result = Sql_query($query); # if the affected rows is 2, the user was already subscribed $groupaddition = $groupaddition || Sql_Affected_Rows() == 1; } } if ($groupaddition) { $count["group_add"]++; } } } } // end else not test if ($_SESSION["test_import"] && $c > 50) { break; } } $report = ""; if (empty($some) && !$count["list_add"]) {
function image_exists($templateid, $filename) { $req = Sql_Query(sprintf('select * from %s where template = %d and (filename = "%s" or filename = "%s")', $GLOBALS["tables"]["templateimage"], $templateid, $filename, basename($filename))); return Sql_Affected_Rows(); }
function PageData($id) { global $tables; $req = Sql_Query(sprintf('select * from %s where id = %d', $tables['subscribepage_data'], $id)); if (!Sql_Affected_Rows()) { $data = array(); $data['header'] = getConfig('pageheader'); $data['footer'] = getConfig('pagefooter'); $data['button'] = 'Subscribe'; $data['attributes'] = ''; $req = Sql_Query(sprintf('select * from %s order by listorder', $GLOBALS['tables']['attribute'])); while ($row = Sql_Fetch_Array($req)) { $data['attributes'] .= $row['id'] . '+'; $data[sprintf('attribute%03d', $row['id'])] = ''; foreach (array('id', 'default_value', 'listorder', 'required') as $key) { $data[sprintf('attribute%03d', $row['id'])] .= $row[$key] . '###'; } } $data['attributes'] = substr($data['attributes'], 0, -1); $data['htmlchoice'] = 'checkforhtml'; $lists = array(); $req = Sql_Query(sprintf('select * from %s where active order by listorder', $GLOBALS['tables']['list'])); while ($row = Sql_Fetch_Array($req)) { array_push($lists, $row['id']); } $data['lists'] = implode(',', $lists); $data['intro'] = $GLOBALS['strSubscribeInfo']; $data['emaildoubleentry'] = 'yes'; $data['thankyoupage'] = ''; foreach ($data as $key => $val) { $data[$key] = str_ireplace('[organisation_name]', $GLOBALS['organisation_name'], $val); } return $data; } while ($row = Sql_Fetch_Array($req)) { if (in_array($row['name'], array('title', 'language_file', 'intro', 'header', 'footer', 'thankyoupage', 'button', 'htmlchoice', 'emaildoubleentry', 'ajax_subscribeconfirmation'))) { $data[$row['name']] = stripslashes($row['data']); } else { $data[$row['name']] = $row['data']; } $data[$row['name']] = preg_replace('/<\\?=VERSION\\?>/i', VERSION, $data[$row['name']]); $data[$row['name']] = str_ireplace('[organisation_name]', $GLOBALS['organisation_name'], $data[$row['name']]); $data[$row['name']] = str_ireplace('[website]', $GLOBALS['website'], $data[$row['name']]); $data[$row['name']] = str_ireplace('[website]', $GLOBALS['domain'], $data[$row['name']]); //@@ TODO, add call to plugins here? } if (!isset($data['lists'])) { $data['lists'] = ''; } if (!isset($data['emaildoubleentry'])) { $data['emaildoubleentry'] = ''; } if (!isset($data['rssdefault'])) { $data['rssdefault'] = ''; } if (!isset($data['rssintro'])) { $data['rssintro'] = ''; } if (!isset($data['rss'])) { $data['rss'] = ''; } if (!isset($data['lists'])) { $data['lists'] = ''; } return $data; }
function addAttachments($msgid, &$mail, $type) { global $attachment_repository, $website; $hasError = false; $totalSize = 0; $memlimit = phpcfgsize2bytes(ini_get('memory_limit')); if (ALLOW_ATTACHMENTS) { $req = Sql_Query("select * from {$GLOBALS["tables"]["message_attachment"]},{$GLOBALS["tables"]["attachment"]}\n where {$GLOBALS["tables"]["message_attachment"]}.attachmentid = {$GLOBALS["tables"]["attachment"]}.id and\n {$GLOBALS["tables"]["message_attachment"]}.messageid = {$msgid}"); if (!Sql_Affected_Rows()) { return true; } if ($type == "text") { $mail->append_text($GLOBALS["strAttachmentIntro"] . "\n"); } while ($att = Sql_Fetch_array($req)) { $totalSize += $att['size']; if ($memlimit > 0 && 3 * $totalSize > $memlimit) { ## the 3 is roughly the size increase to encode the string # $_SESSION['action_result'] = s('Insufficient memory to add attachment'); logEvent(s("Insufficient memory to add attachment to campaign %d %d - %d", $msgid, $totalSize, $memlimit)); $hasError = true; } if (!$hasError) { switch ($type) { case "HTML": if (is_file($GLOBALS["attachment_repository"] . "/" . $att["filename"]) && filesize($GLOBALS["attachment_repository"] . "/" . $att["filename"])) { $fp = fopen($GLOBALS["attachment_repository"] . "/" . $att["filename"], "r"); if ($fp) { $contents = fread($fp, filesize($GLOBALS["attachment_repository"] . "/" . $att["filename"])); fclose($fp); $mail->add_attachment($contents, basename($att["remotefile"]), $att["mimetype"]); } } elseif (is_file($att["remotefile"]) && filesize($att["remotefile"])) { # handle local filesystem attachments $fp = fopen($att["remotefile"], "r"); if ($fp) { $contents = fread($fp, filesize($att["remotefile"])); fclose($fp); $mail->add_attachment($contents, basename($att["remotefile"]), $att["mimetype"]); list($name, $ext) = explode(".", basename($att["remotefile"])); # create a temporary file to make sure to use a unique file name to store with $newfile = tempnam($GLOBALS["attachment_repository"], $name); $newfile .= "." . $ext; $newfile = basename($newfile); $fd = fopen($GLOBALS["attachment_repository"] . "/" . $newfile, "w"); fwrite($fd, $contents); fclose($fd); # check that it was successful if (filesize($GLOBALS["attachment_repository"] . "/" . $newfile)) { Sql_Query(sprintf('update %s set filename = "%s" where id = %d', $GLOBALS["tables"]["attachment"], $newfile, $att["attachmentid"])); } else { # now this one could be sent many times, so send only once per run if (!isset($GLOBALS[$att["remotefile"] . "_warned"])) { logEvent("Unable to make a copy of attachment " . $att["remotefile"] . " in repository"); $msg = s("Error, when trying to send campaign %d the attachment (%s) could not be copied to the repository. Check for permissions.", $msgid, $att["remotefile"]); sendMail(getConfig("report_address"), s("phpList system error"), $msg, ""); $GLOBALS[$att["remotefile"] . "_warned"] = time(); } } } else { logEvent(s("failed to open attachment (%s) to add to campaign %d", $att["remotefile"], $msgid)); $hasError = true; } } else { ## as above, avoid sending it many times if (!isset($GLOBALS[$att["remotefile"] . "_warned"])) { logEvent(s("Attachment %s does not exist", $att["remotefile"])); $msg = s("Error, when trying to send campaign %d the attachment (%s) could not be found in the repository", $msgid, $att["remotefile"]); sendMail(getConfig("report_address"), s("phpList system error"), $msg, ""); $GLOBALS[$att["remotefile"] . "_warned"] = time(); } $hasError = true; } break; case "text": $viewurl = $GLOBALS["public_scheme"] . "://" . $website . $GLOBALS["pageroot"] . '/dl.php?id=' . $att["id"]; $mail->append_text($att["description"] . "\n" . $GLOBALS["strLocation"] . ": " . $viewurl . "\n"); break; } } } } ## keep track of an error count, when sending the queue if ($GLOBALS['counters']['add attachment error'] > 20) { Sql_Query(sprintf('update %s set status = "suspended" where id = %d', $GLOBALS['tables']['message'], $msgid)); logEvent(s('Campaign %d suspended for too many errors with attachments', $msgid)); foreach ($GLOBALS['plugins'] as $pluginname => $plugin) { $plugin->processError(s('Campaign %d suspended for too many errors with attachments', $msgid)); } } if ($hasError) { $GLOBALS['counters']['add attachment error']++; } return !$hasError; }
function addUserToList($userid, $listid) { $lv_result = Sql_Query(sprintf('replace into %s (userid,listid,entered) values(%d,%d,current_timestamp)', $this->tables["listuser"], $userid, $listid)); return Sql_Affected_Rows(); /* $lv_result = Sql_Affected_Rows(); if ($lv_result > 0) return 1; else return 0; */ }
require_once dirname(__FILE__) . '/accesscheck.php'; if (!$_SESSION['logindetails']['superuser']) { print $GLOBALS['I18N']->get('Sorry, this page can only be used by super admins'); return; } if (!empty($_POST['unsubscribe'])) { $emails = explode("\n", $_POST['unsubscribe']); $count = 0; $unsubbed = $blacklisted = 0; foreach ($emails as $email) { $email = trim($email); ++$count; set_time_limit(30); Sql_Query(sprintf('update %s set confirmed = 0 where email = "%s"', $GLOBALS['tables']['user'], $email)); $unsubbed += Sql_Affected_Rows(); if (!empty($_POST['blacklist'])) { ++$blacklisted; addUserToBlackList($email, $GLOBALS['I18N']->get('Blacklisted by') . ' ' . $_SESSION['logindetails']['adminname']); } } printf($GLOBALS['I18N']->get('All done, %d emails processed, %d emails marked unconfirmed, %d emails blacklisted<br/>'), $count, $unsubbed, $blacklisted); print PageLinkButton('suppressionlist', s('Add more')); return; } ?> <form method="post" action=""> <h3><?php echo $GLOBALS['I18N']->get('Manage suppression list'); ?>
function deleteMessage($id = 0) { if (!$GLOBALS['require_login'] || $_SESSION['logindetails']['superuser']) { $ownerselect_and = ''; $ownerselect_where = ''; } else { $ownerselect_where = ' WHERE owner = ' . $_SESSION['logindetails']['id']; $ownerselect_and = ' and owner = ' . $_SESSION['logindetails']['id']; } # delete the message in delete $result = Sql_query('select id from ' . $GLOBALS['tables']['message'] . " where id = {$id} {$ownerselect_and}"); while ($row = Sql_Fetch_Row($result)) { $result = Sql_query('delete from ' . $GLOBALS['tables']['message'] . " where id = {$row['0']}"); $suc6 = Sql_Affected_Rows(); $result = Sql_query('delete from ' . $GLOBALS['tables']['usermessage'] . " where messageid = {$row['0']}"); $result = Sql_query('delete from ' . $GLOBALS['tables']['listmessage'] . " where messageid = {$row['0']}"); return $suc6; } }
function getNewAttributeTablename($name) { global $table_prefix, $tables; if ($tables["attribute"]) { $table = $tables["attribute"]; } else { $table = "attribute"; } $lc_name = substr(preg_replace("/\\W/", "", strtolower($name)), 0, 10); # if ($lc_name == "") Fatal_Error("Name cannot be empty: $lc_name"); if (!$lc_name) { $lc_name = "attribute"; } Sql_Query("select * from {$table} where tablename = \"{$lc_name}\""); # if (Sql_Affected_Rows()) Fatal_Error("Name is not unique enough"); $c = 1; $basename = $lc_name; while (Sql_Affected_Rows() && $c < 100) { $lc_name = $basename . $c; Sql_Query("select * from {$table} where tablename = \"{$lc_name}\""); $c++; } return $lc_name; }
$attributes[$entry] = $file; } } closedir($dir); if (is_array($selected)) { while(list($key,$val) = each($selected)) { $entry = readentry("data/$val"); list($name,$desc) = explode(":",$entry); print "<br/><br/>Loading $desc<br>\n"; $lc_name = str_replace(" ","", strtolower(str_replace(".txt","",$val))); $lc_name = ereg_replace("[^[:alnum:]]","",$lc_name); if ($lc_name == "") Fatal_Error("Name cannot be empty: $lc_name"); Sql_Query("select * from {$tables['attribute']} where tablename = \"$lc_name\""); if (Sql_Affected_Rows()) Fatal_Error("Name is not unique enough"); $query = sprintf('insert into %s (name,type,required,tablename) values("%s","%s",%d,"%s")', $tables["attribute"],addslashes($name),"select",1,$lc_name); Sql_Query($query); $insertid = Sql_Insert_id(); $query = "create table $table_prefix"."listattr_$lc_name (id integer not null primary key auto_increment, name varchar(255) unique,listorder integer default 0)"; Sql_Query($query); $fp = fopen("data/$val","r"); $header = ""; while (!feof ($fp)) { $buffer = fgets($fp, 4096); if (!ereg("#",$buffer)) { if (!$header) $header = $buffer;
function addSubscriberStatistics($item = '', $amount, $list = 0) { switch (STATS_INTERVAL) { case 'monthly': # mark everything as the first day of the month $time = mktime(0, 0, 0, date('m'), 1, date('Y')); break; case 'weekly': # mark everything for the first sunday of the week $time = mktime(0, 0, 0, date('m'), date('d') - date('w'), date('Y')); break; case 'daily': $time = mktime(0, 0, 0, date('m'), date('d'), date('Y')); break; } Sql_Query(sprintf('update %s set value = value + %d where unixdate = %d and item = "%s" and listid = %d', $GLOBALS['tables']['userstats'], $amount, $time, $item, $list)); $done = Sql_Affected_Rows(); if (!$done) { Sql_Query(sprintf('insert into %s set value = %d,unixdate = %d,item = "%s",listid = %d', $GLOBALS['tables']['userstats'], $amount, $time, $item, $list)); } }
print Sql_Affected_Rows() . ' ' . $GLOBALS['I18N']->get('entries apply') . '<br/>'; while ($row = Sql_Fetch_Row($req)) { Sql_Query("delete from {$tables['user_attribute']} where userid = {$row['0']}"); } $req = Sql_Verbose_Query("select {$tables['listuser']}.userid\n from {$tables['listuser']} left join {$tables['user']} on {$tables['listuser']}.userid = {$tables['user']}.id\n where {$tables['user']}.id IS NULL group by {$tables['listuser']}.userid"); print Sql_Affected_Rows() . ' ' . $GLOBALS['I18N']->get('entries apply') . '<br/>'; while ($row = Sql_Fetch_Row($req)) { Sql_Query("delete from {$tables['listuser']} where userid = {$row['0']}"); } $req = Sql_Verbose_Query("select {$tables['usermessage']}.userid\n from {$tables['usermessage']} left join {$tables['user']} on {$tables['usermessage']}.userid = {$tables['user']}.id\n where {$tables['user']}.id IS NULL group by {$tables['usermessage']}.userid"); print Sql_Affected_Rows() . ' ' . $GLOBALS['I18N']->get('entries apply') . '<br/>'; while ($row = Sql_Fetch_Row($req)) { Sql_Query("delete from {$tables['usermessage']} where userid = {$row['0']}"); } $req = Sql_Verbose_Query("select {$tables['user_message_bounce']}.user\n from {$tables['user_message_bounce']} left join {$tables['user']} on {$tables['user_message_bounce']}.user = {$tables['user']}.id\n where {$tables['user']}.id IS NULL group by {$tables['user_message_bounce']}.user"); print Sql_Affected_Rows() . ' ' . $GLOBALS['I18N']->get('entries apply') . '<br/>'; while ($row = Sql_Fetch_Row($req)) { Sql_Query("delete from {$tables['user_message_bounce']} where user = {$row['0']}"); } } $table_list = $tables['user'] . $findtables; if ($find) { $listquery = "select {$tables['user']}.id,{$findfield},{$tables['user']}.confirmed from " . $table_list . " where {$findbyselect}"; $count = Sql_query('SELECT count(*) FROM ' . $table_list . " where {$findbyselect}"); $unconfirmedcount = Sql_query('SELECT count(*) FROM ' . $table_list . " where !confirmed && {$findbyselect}"); if ($_GET['unconfirmed']) { $listquery .= ' and !confirmed'; } } else { $listquery = "select {$tables['user']}.id,{$findfield},{$tables['user']}.confirmed from " . $table_list; $count = Sql_query('SELECT count(*) FROM ' . $table_list);
<script language="Javascript" type="text/javascript"> var values = Array(); var operators = Array(); var value_divs = Array(); var value_default = Array(); '; if (sizeof($used_attributes)) { $already_used = ' and id not in (' . join(',', $used_attributes) . ')'; } else { $already_used = ""; } $att_drop = ''; $attreq = Sql_Query(sprintf('select * from %s where type in ("select","radio","date","checkboxgroup","checkbox") %s', $tables["attribute"], $already_used)); while ($att = Sql_Fetch_array($attreq)) { $att_drop .= sprintf('<option value="%d" %s>%s</option>', $att["id"], "", $att["name"]); $num = Sql_Affected_Rows(); switch ($att["type"]) { case "select": case "radio": case "checkboxgroup": $att_js .= sprintf('value_divs[%d] = "criteria_values_select";' . "\n", $att["id"]); $att_js .= sprintf('value_default[%d] = "";' . "\n", $att["id"]); $value_req = Sql_Query(sprintf('select * from %s order by listorder,name', $GLOBALS["table_prefix"] . "listattr_" . $att["tablename"])); $num = Sql_Num_Rows($value_req); $att_js .= sprintf('values[%d] = new Array(%d);' . "\n", $att["id"], $num + 1); #$att_js .= sprintf('values[%d][0] = new Option("[choose]","0",false,true);'."\n",$att["id"]); $c = 0; while ($value = Sql_Fetch_Array($value_req)) { $att_js .= sprintf('values[%d][%d] = new Option("%s","%d",false,false);' . "\n", $att["id"], $c, $value["name"], $value["id"]); $c++; }
# send in batches of $counters['num_per_batch'] users $batch_total = $counters['total_users_for_message ' . $messageid]; if ($counters['num_per_batch'] > 0) { $query .= sprintf(' limit 0,%d', $counters['num_per_batch']); if (VERBOSE) { processQueueOutput($counters['num_per_batch'] . ' query -> ' . $query); } $userids = Sql_Query($query); if (Sql_Has_Error($database_connection)) { ProcessError(Sql_Error($database_connection)); } } else { processQueueOutput($GLOBALS['I18N']->get('No users to process for this batch'), 0, 'progress'); $userids = Sql_Query("select * from {$tables['user']} where id = 0"); } $affrows = Sql_Affected_Rows(); processQueueOutput($GLOBALS['I18N']->get('Processing batch of ') . ': ' . $affrows, 0, 'progress'); } while ($userdata = Sql_Fetch_Row($userids)) { $userid = $userdata[0]; # id of the user ++$counters['processed_users_for_message ' . $messageid]; if ($counters['processed_users_for_message ' . $messageid] > $counters['max_users_for_message ' . $messageid]) { if (VERBOSE) { cl_output(s('Over limit for this campaign: %d is more than %d', $counters['processed_users_for_message ' . $messageid], $counters['max_users_for_message ' . $messageid])); } break; } $failure_reason = ''; if ($counters['num_per_batch'] && $counters['sent'] >= $counters['num_per_batch']) { processQueueOutput(s('batch limit reached') . ': ' . $counters['sent'] . ' (' . $counters['num_per_batch'] . ')', 1, 'progress');
} #print '<h3>'.$GLOBALS['I18N']->get('View Details for a Message').'</h3>'; $messagedata = Sql_Fetch_Array_query("SELECT * FROM {$tables['message']} where id = {$id} {$subselect}"); print '<table class="mviewsDetails"> <tr><td>' . $GLOBALS['I18N']->get('Subject') . '<td><td>' . $messagedata['subject'] . '</td></tr> <tr><td>' . $GLOBALS['I18N']->get('Entered') . '<td><td>' . $messagedata['entered'] . '</td></tr> <tr><td>' . $GLOBALS['I18N']->get('Sent') . '<td><td>' . $messagedata['sent'] . '</td></tr> </table><hr/>'; if ($download) { header('Content-disposition: attachment; filename="phpList Message open statistics for ' . $messagedata['subject'] . '.csv"'); } $ls = new WebblerListing(ucfirst($GLOBALS['I18N']->get('Open statistics'))); $req = Sql_Query(sprintf('select um.userid from %s um,%s msg where um.messageid = %d and um.messageid = msg.id and um.viewed is not null %s group by userid', $GLOBALS['tables']['usermessage'], $GLOBALS['tables']['message'], $id, $subselect)); $total = Sql_Affected_Rows(); if (isset($start) && $start > 0) { $listing = sprintf($GLOBALS['I18N']->get("Listing user %d to %d"), $start, $start + MAX_USER_PP); $limit = "limit {$start}," . MAX_USER_PP; } else { $listing = sprintf($GLOBALS['I18N']->get("Listing user %d to %d"), 1, MAX_USER_PP); $limit = "limit 0," . MAX_USER_PP; $start = 0; $limit = "limit 0," . MAX_USER_PP; } ## hmm, this needs more work, as it'll run out of memory, because it's building the entire ## listing before pushing it out. ## would be best to not have a limit, but putting one to avoid that if ($download) { $limit = ' limit 100000'; }
function ListAvailableLists($userid = 0,$lists_to_show = "") { global $tables; $list = $_POST["list"]; $subselect = "";$listset = array(); $showlists = explode(",",$lists_to_show); foreach ($showlists as $listid) if (preg_match("/^\d+$/",$listid)) array_push($listset,$listid); if (sizeof($listset) >= 1) { $subselect = "where id in (".join(",",$listset).") "; } $some = 0; $html = '<ul class="list">'; $result = Sql_query("SELECT * FROM {$tables["list"]} $subselect order by listorder"); while ($row = Sql_fetch_array($result)) { if ($row["active"]) { $html .= '<li class="list"><input type="checkbox" name="list['.$row["id"] . ']" value=signup '; if ($list[$row["id"]] == "signup") $html .= "checked"; if ($userid) { $req = Sql_Fetch_Row_Query(sprintf('select userid from %s where userid = %d and listid = %d', $tables["listuser"],$userid,$row["id"])); if (Sql_Affected_Rows()) $html .= "checked"; } $html .= "/><b>".$row["name"].'</b><div class="listdescription">'; $desc = nl2br(StripSlashes($row["description"])); $html .= '<input type=hidden name="listname['.$row["id"] . ']" value="'.$row["name"].'"/>'; $html .= $desc.'</div></li>'; $some++; if ($some == 1) { $singlelisthtml = sprintf('<input type="hidden" name="list[%d]" value="signup">',$row["id"]); $singlelisthtml .= '<input type="hidden" name="listname['.$row["id"] . ']" value="'.$row["name"].'"/>'; } } } $html .= '</ul>'; $hidesinglelist = getConfig("hide_single_list"); if (!$some) { global $strNotAvailable; return '<p>'.$strNotAvailable.'</p>'; } elseif ($some == 1 && $hidesinglelist == "true") { return $singlelisthtml; } else { global $strPleaseSelect; return '<p>'.$strPleaseSelect .':</p>'.$html; } }
switch ($access) { case 'owner': $subselect = ' where owner = ' . $_SESSION['logindetails']['id']; break; case 'all': $subselect = ''; break; case 'none': default: $subselect = ' where id = 0'; break; } } $result = Sql_query('SELECT id,name FROM ' . $tables['list'] . "{$subselect} ORDER BY listorder"); $c = 0; if (Sql_Affected_Rows() == 1) { $row = Sql_fetch_array($result); printf('<input type="hidden" name="listname[%d]" value="%s"><input type="hidden" name="importlists[%d]" value="%d">' . $GLOBALS['I18N']->get('adding_users') . ' <b>%s</b>', $c, stripslashes($row['name']), $c, $row['id'], stripslashes($row['name'])); } else { print '<h3>' . s('Select the lists to add the emails to') . '</h3>'; print ListSelectHTML($import_lists, 'importlists', $subselect); } ?> <script language="Javascript" type="text/javascript"> var fieldstocheck = new Array(); var fieldnames = new Array(); function addFieldToCheck(value,name) { fieldstocheck[fieldstocheck.length] = value;
function confirmPage($id) { global $tables, $envelope; if (!$_GET['uid']) { FileNotFound(); } $req = Sql_Query(sprintf('select * from %s where uniqid = "%s"', $tables['user'], sql_escape($_GET['uid']))); $userdata = Sql_Fetch_Array($req); if ($userdata['id']) { $html = '<ul>'; $lists = ''; $currently = Sql_Fetch_Assoc_Query("select confirmed from {$tables['user']} where id = " . $userdata['id']); $blacklisted = isBlackListed($userdata['email']); foreach ($GLOBALS['plugins'] as $pluginname => $plugin) { $plugin->subscriberConfirmation($id, $userdata); } Sql_Query("update {$tables['user']} set confirmed = 1,blacklisted = 0, optedin = 1 where id = " . $userdata['id']); $subscriptions = array(); $req = Sql_Query(sprintf('select list.id,name,description from %s list, %s listuser where listuser.userid = %d and listuser.listid = list.id and list.active', $tables['list'], $tables['listuser'], $userdata['id'])); if (!Sql_Affected_Rows()) { $lists = "\n * " . $GLOBALS['strNoLists']; $html .= '<li>' . $GLOBALS['strNoLists'] . '</li>'; } while ($row = Sql_fetch_array($req)) { array_push($subscriptions, $row['id']); $lists .= "\n *" . stripslashes($row['name']); $html .= '<li class="list">' . stripslashes($row['name']) . '<div class="listdescription">' . stripslashes($row['description']) . '</div></li>'; } $html .= '</ul>'; if ($blacklisted) { unBlackList($userdata['id']); addUserHistory($userdata['email'], 'Confirmation', s('Subscriber removed from Blacklist for manual confirmation of subscription')); } if (empty($_SESSION['subscriberConfirmed'])) { $_SESSION['subscriberConfirmed'] = array(); } ## 17513 - don't process confirmation if the subscriber is already confirmed if (empty($currently['confirmed']) && empty($_SESSION['subscriberConfirmed'][$userdata['email']])) { addUserHistory($userdata['email'], 'Confirmation', "Lists: {$lists}"); $confirmationmessage = str_ireplace('[LISTS]', $lists, getUserConfig("confirmationmessage:{$id}", $userdata['id'])); if (!TEST) { sendMail($userdata['email'], getConfig("confirmationsubject:{$id}"), $confirmationmessage, system_messageheaders(), $envelope); $adminmessage = $userdata['email'] . ' has confirmed their subscription'; if ($blacklisted) { $adminmessage .= "\n\n" . s('Subscriber has been removed from blacklist'); } sendAdminCopy('List confirmation', $adminmessage, $subscriptions); addSubscriberStatistics('confirmation', 1); } } else { $html = $GLOBALS['strAlreadyConfirmed']; } $_SESSION['subscriberConfirmed'][$userdata['email']] = time(); $info = $GLOBALS['strConfirmInfo']; } else { logEvent('Request for confirmation for invalid user ID: ' . substr($_GET['uid'], 0, 150)); $html = 'Error: ' . $GLOBALS['strUserNotFound']; $info = $GLOBALS['strConfirmFailInfo']; } $res = '<title>' . $GLOBALS['strConfirmTitle'] . '</title>'; $res .= $GLOBALS['pagedata']['header']; $res .= '<h3>' . $info . '</h3>'; $res .= $html; $res .= '<p>' . $GLOBALS['PoweredBy'] . '</p>'; $res .= $GLOBALS['pagedata']['footer']; return $res; }