function setMessageData($msgid, $name, $value) { if ($name == 'PHPSESSID') { return; } if ($name == session_name()) { return; } if ($name == 'targetlist' && is_array($value)) { Sql_query(sprintf('delete from %s where messageid = %d', $GLOBALS['tables']["listmessage"], $msgid)); if (!empty($value["all"]) || !empty($value["allactive"])) { $res = Sql_query('select * from ' . $GLOBALS['tables']['list'] . ' ' . $GLOBALS['subselect']); while ($row = Sql_Fetch_Array($res)) { $listid = $row["id"]; if ($row["active"] || !empty($value["all"])) { $result = Sql_query("insert ignore into " . $GLOBALS['tables']["listmessage"] . " (messageid,listid,entered) values({$msgid},{$listid},current_timestamp)"); } } } else { foreach ($value as $listid => $val) { $query = ' insert into ' . $GLOBALS['tables']["listmessage"] . ' (messageid,listid,entered)' . ' values' . ' (?, ?, current_timestamp)'; $result = Sql_Query_Params($query, array($msgid, $listid)); } } } if (is_array($value) || is_object($value)) { $value = 'SER:' . serialize($value); } Sql_Replace($GLOBALS['tables']['messagedata'], array('id' => $msgid, 'name' => $name, 'data' => $value), array('name', 'id')); # print "<br/>setting $name for $msgid to $value"; # exit; }
function clickTrackLinkId($messageid, $userid, $url, $link) { global $cached; if (!isset($cached['linktrack']) || !is_array($cached['linktrack'])) { $cached['linktrack'] = array(); } if (!isset($cached['linktracksent']) || !is_array($cached['linktracksent'])) { $cached['linktracksent'] = array(); } if (!isset($cached['linktrack'][$link])) { $query = ' select id' . ' from ' . $GLOBALS['tables']['linktrack_forward'] . ' where url = ?'; $rs = Sql_Query_Params($query, array($url)); $exists = Sql_Fetch_Row($rs); if (!$exists[0]) { $personalise = preg_match('/uid=/', $link); $query = ' insert into ' . $GLOBALS['tables']['linktrack_forward'] . ' (url, personalise)' . ' values' . ' (?, ?)'; Sql_Query_Params($query, array($url, $personalise)); $fwdid = Sql_Insert_Id($GLOBALS['tables']['linktrack_forward'], 'id'); } else { $fwdid = $exists[0]; } $cached['linktrack'][$link] = $fwdid; } else { $fwdid = $cached['linktrack'][$link]; } if (!isset($cached['linktracksent'][$messageid]) || !is_array($cached['linktracksent'][$messageid])) { $cached['linktracksent'][$messageid] = array(); } if (!isset($cached['linktracksent'][$messageid][$fwdid])) { $query = ' select total' . ' from ' . $GLOBALS['tables']['linktrack_ml'] . ' where messageid = ?' . ' and forwardid = ?'; $rs = Sql_Query_Params($query, array($messageid, $fwdid)); if (!Sql_Num_Rows($rs)) { $total = 1; ## first time for this link/message # BCD: Isn't this just an insert? Sql_Replace($GLOBALS['tables']['linktrack_ml'], array('total' => $total, 'messageid' => $messageid, 'forwardid' => $fwdid), array('messageid', 'forwardid')); } else { $tot = Sql_Fetch_Row($rs); $total = $tot[0] + 1; Sql_Query(sprintf('update %s set total = %d where messageid = %d and forwardid = %d', $GLOBALS['tables']['linktrack_ml'], $total, $messageid, $fwdid)); } $cached['linktracksent'][$messageid][$fwdid] = $total; } else { $cached['linktracksent'][$messageid][$fwdid]++; ## write every so often, to make sure it's saved when interrupted if ($cached['linktracksent'][$messageid][$fwdid] % 100 == 0) { Sql_Query(sprintf('update %s set total = %d where messageid = %d and forwardid = %d', $GLOBALS['tables']['linktrack_ml'], $cached['linktracksent'][$messageid][$fwdid], $messageid, $fwdid)); } } /* $req = Sql_Query(sprintf('insert ignore into %s (messageid,userid,forwardid) values(%d,%d,"%s","%s")',$GLOBALS['tables']['linktrack'],$messageid,$userdata['id'],$url,addslashes($link))); $req = Sql_Fetch_Row_Query(sprintf('select linkid from %s where messageid = %s and userid = %d and forwardid = %d ',$GLOBALS['tables']['linktrack'],$messageid,$userid,$fwdid));*/ return $fwdid; }
function SaveConfig($item, $value, $editable = 1, $ignore_errors = 0) { global $tables; ## in case DB hasn't been initialised if (empty($_SESSION['hasconf'])) { $_SESSION['hasconf'] = Sql_Table_Exists($tables["config"]); } if (empty($_SESSION['hasconf'])) { return; } if (isset($GLOBALS['default_config'][$item])) { $configInfo = $GLOBALS['default_config'][$item]; } else { $configInfo = array('type' => 'unknown', 'allowempty' => true, 'value' => ''); } ## to validate we need the actual values $value = str_ireplace('[domain]', $GLOBALS['domain'], $value); $value = str_ireplace('[website]', $GLOBALS['website'], $value); switch ($configInfo['type']) { case 'boolean': if ($value == "false" || $value == "no") { $value = 0; } elseif ($value == "true" || $value == "yes") { $value = 1; } break; case 'integer': $value = sprintf('%d', $value); if ($value < $configInfo['min']) { $value = $configInfo['min']; } if ($value > $configInfo['max']) { $value = $configInfo['max']; } break; case 'email': if (!is_email($value)) { ## hmm, this is displayed only later # $_SESSION['action_result'] = s('Invalid value for email address'); return $configInfo['description'] . ': ' . s('Invalid value for email address'); $value = ''; } break; case 'emaillist': $valid = array(); $hasError = false; $emails = explode(',', $value); foreach ($emails as $email) { if (is_email($email)) { $valid[] = $email; } else { $hasError = true; } } $value = join(',', $valid); /* * hmm, not sure this is good or bad for UX * */ if ($hasError) { return $configInfo['description'] . ': ' . s('Invalid value for email address'); } break; } ## reset to default if not set, and required if (empty($configInfo['allowempty']) && empty($value)) { $value = $configInfo['value']; } if (!empty($configInfo['hidden'])) { $editable = false; } ## force reloading config values in session unset($_SESSION['config']); ## and refresh the config immediately https://mantis.phplist.com/view.php?id=16693 unset($GLOBALS['config']); Sql_Replace($tables["config"], array('item' => $item, 'value' => $value, 'editable' => $editable), 'item'); return false; ## true indicates error, and which one }
$success = sendEmailTest($messageid, $useremail); } ############################# # tried to send email , process succes / failure if ($success) { if (USE_DOMAIN_THROTTLE) { list($mailbox, $domainname) = explode('@', $useremail); if ($domainthrottle[$domainname]['interval'] != $interval) { $domainthrottle[$domainname]['interval'] = $interval; $domainthrottle[$domainname]['sent'] = 0; } else { $domainthrottle[$domainname]['sent']++; } } $sent++; $um = Sql_Replace($tables['usermessage'], array('entered' => 'current_timestamp', 'userid' => $userid, 'messageid' => $messageid, 'status' => "sent"), array('userid', 'messageid'), false); //obsolete, moved to rssmanager plugin // if (ENABLE_RSS && $pxrocessrss) { // foreach ($rssitems as $rssitemid) { // $status = Sql_query("update {$tables['rssitem']} set processed = processed +1 where id = $rssitemid"); // $um = Sql_query("replace into {$tables['rssitem_user']} (userid,itemid) values($userid,$rssitemid)"); // } // Sql_Query("replace into {$tables["user_rss"]} (userid,last) values($userid,date_sub(current_timestamp,interval 15 minute))"); // // } } else { $failed_sent++; ## need to check this, the entry shouldn't be there in the first place, so no need to delete it ## might be a cause for duplicated emails if (defined('MESSAGEQUEUE_PREPARE') && MESSAGEQUEUE_PREPARE) { Sql_Query_Params(sprintf('update %s set status = "todo" where userid = ? and messageid = ? and status = "active"', $tables['usermessage']), array($userid, $messageid));
function updateDBtranslations($translations, $time, $language = '') { if (empty($language)) { $language = $this->language; } if (sizeof($translations)) { foreach ($translations as $orig => $trans) { Sql_Replace($GLOBALS['tables']['i18n'], array('lan' => $language, 'original' => $orig, 'translation' => $trans), ''); } } $this->resetCache(); saveConfig('lastlanguageupdate-' . $language, $time, 0); }
# remember the users attributes $res = Sql_Query("select * from {$tables['attribute']}"); while ($row = Sql_Fetch_Array($res)) { $fieldname = "attribute" . $row["id"]; $value = $_POST[$fieldname]; if (is_array($value)) { $newval = array(); foreach ($value as $val) { array_push($newval, sprintf('%0' . $checkboxgroup_storesize . 'd', $val)); } $value = join(",", $newval); } $res1 = Sql_Replace($tables['user_attribute'], array('attributeid' => $row['id'], 'userid' => $userid, 'value' => $value), 'id'); } } else { $res2 = Sql_Replace($tables['listuser'], array('userid' => "'" . $_REQUEST['doadd'] . "'", 'listid' => $id, 'entered' => 'current_timestamp'), array('userid', 'listid'), false); } if ($database_module == 'adodb.inc') { Sql_Commit_Transaction(); } print "<br />" . $GLOBALS['I18N']->get("User added") . "<br />"; } if (isset($_REQUEST["delete"])) { $delete = sprintf('%d', $_REQUEST["delete"]); # single delete the index in delete $_SESSION['action_result'] = s("Removing %d from this list ", $delete) . " ..\n"; $query = ' delete from ' . $tables['listuser'] . ' where listid = ?' . ' and userid = ?'; $result = Sql_Query_Params($query, array($id, $delete)); $_SESSION['action_result'] .= "... " . $GLOBALS['I18N']->get("Done") . "<br />\n"; Redirect("members&{$pagingKeep}&id={$id}"); }
$att["value"] .= $valueid[0] . ","; } } $att["value"] = substr($att["value"], 0, -1); break; } if ($att["value"]) { Sql_Replace($tables["user_attribute"], array('attributeid' => $localattid, 'userid' => $userid, 'value' => $att['value']), array('attributeid', 'userid')); } } } } if (is_array($userlists)) { foreach ($userlists as $list) { if ($listmap[$list["listid"]]) { Sql_Replace($tables["listuser"], array('listid' => $listmap[$list["listid"]], 'userid' => $userid), array('userid', 'listid')); } else { print $GLOBALS['I18N']->get('Error, no local list defined for') . " " . $list["name"] . "<br/>"; } } } } print "{$totalusers} / {$totalusers}<br/>"; flush(); # @@@@ Not sure about this one: printf('%s %d %s %s %d %s<br/>', $GLOBALS['I18N']->get('Done'), $newcnt, $GLOBALS['I18N']->get('new users'), $GLOBALS['I18N']->get('and'), $existcnt, $GLOBALS['I18N']->get('existing users')); } ?>
if ($success) { $_SESSION['hasconf'] = true; } ## initialise plugins that are already here foreach ($GLOBALS['plugins'] as $pluginName => $plugin) { print s('Initialise plugin') . ' ' . $pluginName . '<br/>'; if (method_exists($plugin, 'initialise')) { $plugin->initialise(); } SaveConfig(md5('plugin-' . $pluginName . '-initialised'), time(), 0); } if ($success) { # mark the database to be our current version SaveConfig('version', VERSION, 0); # mark now to be the last time we checked for an update Sql_Replace($tables['config'], array('item' => "updatelastcheck", 'value' => 'current_timestamp', 'editable' => '0'), 'item', false); SaveConfig('admin_address', $_REQUEST['adminemail'], 1); SaveConfig('message_from_name', strip_tags($_REQUEST['adminname']), 1); if (!empty($_REQUEST['orgname'])) { SaveConfig('organisation_name', strip_tags($_REQUEST['orgname']), 1); } elseif (!empty($_REQUEST['adminname'])) { SaveConfig('organisation_name', strip_tags($_REQUEST['adminname']), 1); } else { SaveConfig('organisation_name', strip_tags($_REQUEST['adminemail']), 1); } # add a testlist $info = $GLOBALS['I18N']->get("List for testing."); $stmt = ' insert into ' . $tables['list'] . ' (name, description, entered, active, owner)' . ' values' . ' (?, ?, current_timestamp, ?, ?)'; $result = Sql_Query_Params($stmt, array('test', $info, '0', '1')); # add public newsletter list $info = s("Sign up to our newsletter");
if ($needscheck[0] != "0") { @ini_set("user_agent", NAME . " (phplist version " . VERSION . ")"); @ini_set("default_socket_timeout", 5); if ($fp = @fopen("https://www.phplist.com/files/LATESTVERSION", "r")) { $latestversion = fgets($fp); $latestversion = preg_replace("/[^\\.\\d]/", "", $latestversion); @fclose($fp); if (!versionCompare($thisversion, $latestversion)) { ## remember this, so we can remind about the update, without the need to check the phplist site $values = array('item' => "updateavailable", 'value' => $latestversion, 'editable' => '0'); Sql_Replace($tables['config'], $values, 'item', false); $showUpdateAvail = true; } } $values = array('item' => "updatelastcheck", 'value' => 'current_timestamp', 'editable' => '0'); Sql_Replace($tables['config'], $values, 'item', false); } } if ($showUpdateAvail) { print '<div class="newversion note">'; print $GLOBALS['I18N']->get('A new version of phpList is available!'); print '<br/>'; print '<br/>' . $GLOBALS['I18N']->get('The new version may have fixed security issues,<br/>so it is recommended to upgrade as soon as possible'); print '<br/>' . $GLOBALS['I18N']->get('Your version') . ': <b>' . $thisversion . '</b>'; print '<br/>' . $GLOBALS['I18N']->get('Latest version') . ': <b>' . $latestversion . '</b><br/> '; print '<a href="https://www.phplist.com/latestchanges?utm_source=pl' . $thisversion . '&utm_medium=updatenews&utm_campaign=phpList" title="' . s('Read what has changed in the new version') . '" target="_blank">' . $GLOBALS['I18N']->get('View what has changed') . '</a> '; print '<a href="https://www.phplist.com/download?utm_source=pl' . $thisversion . '&utm_medium=updatedownload&utm_campaign=phpList" title="' . s('Download the new version') . '" target="_blank">' . $GLOBALS['I18N']->get('Download') . '</a></div>'; } print '<div class="accordion">'; $some = 0; $ls = new WebblerListing('');