$val) { $$key = $val; } } /* We request you retain the inclusion of pagetop below. This will add invisible additional information to your public pages. This not only gives respect to the large amount of time given freely by the developers but also helps build interest, traffic and use of PHPlist, which is beneficial to it's future development. Michiel Dethmers, Tincan Ltd 2003 */ include "admin/pagetop.php"; if ($uid && !$id) { $req = Sql_Fetch_Row_Query(sprintf('select subscribepage,id from %s where uniqid = "%s"', $tables["user"],$uid)); $id = $req[0]; $userid = $req[1]; } if (!$id) { # pick one $req = Sql_Fetch_row_Query(sprintf('select ID from %s where active',$tables["subscribepage"])); $id = $req[0]; } if (preg_match("/(\w+)/",$p,$regs)) { if ($id) { switch ($p) { case "subscribe": require "admin/subscribelib2.php"; print SubscribePage($id); break; case "preferences": require "admin/subscribelib2.php"; print PreferencesPage($id,$userid); break; case "confirm": print ConfirmPage($id); break; case "unsubscribe": print UnsubscribePage($id); break; default: if (is_file($regs[1].".php")) { include $regs[1].".php"; } else { print "Error: no such page: $p"; } } } else { # backward compatible, dramatically depricated, and should be taken out. if (is_file($regs[1].".php")) { include $regs[1].".php"; } else { print "Error: no such page: $p"; } } } else { $req = Sql_Query(sprintf('select * from %s where active',$tables["subscribepage"])); if (Sql_Affected_Rows()) { while ($row = Sql_Fetch_Array($req)) { printf('

%s

',$row["id"],$row["title"]); } } else { printf('

%s

',$strSubscribeTitle); } printf('

%s

',$strUnsubscribeTitle); print $PoweredBy; } function preferencesPage($id,$userid) { $data = PageData($id); list($attributes,$attributedata) = PageAttributes($data); $selected_lists = explode(',',$data["lists"]); $html = ''.$GLOBALS["strPreferencesTitle"].''; $html .= $data["header"]; $html .= ''.$GLOBALS["strPreferencesInfo"].''; $html .= '
'.$GLOBALS["strRequired"].'
'.$GLOBALS["msg"].' '; $html .= formStart('name="subscribeform"'); $html .= ''; $html .= ListAttributes($attributes,$attributedata,$data["htmlchoice"],$userid); $html .= '
'; if (ENABLE_RSS) { $html .= RssOptions($data,$userid); } $html .= ListAvailableLists($userid,$data["lists"]); $html .= '



'.$GLOBALS["strUnsubscribe"].'

'.$GLOBALS["PoweredBy"]; $html .= $data["footer"]; return $html; } function subscribePage($id) { $data = PageData($id); list($attributes,$attributedata) = PageAttributes($data); $selected_lists = explode(',',$data["lists"]); $html = ''.$GLOBALS["strSubscribeTitle"].''; $html .= $data["header"]; $html .= $data["intro"]; $html .= '
'.$GLOBALS["strRequired"].'
'.$GLOBALS["msg"].' '; $html .= formStart('name="subscribeform"'); if ($_SESSION["adminloggedin"]) { $html .= '

You are logged in as '.$_SESSION["logindetails"]["adminname"].'

'; $html .= '

Please choose:
Make confirmed immediately
Send request for confirmation email

'; } $html .= ''; $html .= ListAttributes($attributes,$attributedata,$data["htmlchoice"]); $html .= '
'; if (ENABLE_RSS) { $html .= RssOptions($data); } $html .= ListAvailableLists("",$data["lists"]); $html .= '



'.$GLOBALS["strUnsubscribe"].'

'.$GLOBALS["PoweredBy"]; $html .= $data["footer"]; return $html; } function confirmPage($id) { global $uid,$tables,$envelope; if (!$uid) return 0; $req = Sql_Query("select * from {$tables["user"]} where uniqid = \"$uid\""); $userdata = Sql_Fetch_Array($req); if ($userdata["id"]) { $html = ''; $spage = $userdata["subscribepage"]; $confirmationmessage = ereg_replace('\[LISTS\]', $lists, getUserConfig("confirmationmessage:$spage",$userdata["id"])); if (!TEST) { sendMail($userdata["email"], getConfig("confirmationsubject:$spage"), $confirmationmessage,system_messageheaders(),$envelope); sendAdminCopy("List confirmation",$userdata["email"] . " has confirmed their subscription"); } } else { $html .= 'Error: '.$GLOBALS["strUserNotFound"]; } $data = PageData($id); $res = ''.$GLOBALS["strConfirmTitle"].''; $res .= $data["header"]; $res .= '

'.$GLOBALS["strConfirmInfo"].'

'; $res .= $html; $res .= "

".$GLOBALS["PoweredBy"].'

'; $res .= $data["footer"]; return $res; } function unsubscribePage($id) { $pagedata = pageData($id); global $unsubscribe, $email,$tables,$list,$uid; $res = $pagedata["header"]; $res .= ''.$GLOBALS["strUnsubscribeTitle"].''; if ($unsubscribe && eregi(".+\@.+\..+",$email)) { $email = trim($email); $result = Sql_query("SELECT * FROM $tables[list]"); while ($row = Sql_fetch_array($result)) { if ($row["active"]) $availlists[$row["id"]] = $row["name"]; } $query = "select id from {$tables["user"]} where email = \"$email\""; $result = Sql_query($query); $userid = array(); while ($row = Sql_fetch_array($result)) { $userid[sizeof($userid)] = $row["id"]; } if ($list && !$list["none"]) { if ($list["all"]) { while (list($key,$id) = each($userid)) { $result = Sql_query("delete from {$tables["listuser"]} where userid = \"$id\""); $lists = " * All mailinglists\n"; } } else { while (list($key2,$id) = each($userid)) { while(list($key,$val)= each($list)) { if ($val == "signoff") { $result = Sql_query("delete from $tables[listuser] where userid = \"$id\" and listid = \"$key\""); $lists .= " * ".$availlists[$key] . "\n"; } } } } $unsubscribemessage = ereg_replace("\[LISTS\]", $lists,getUserConfig("unsubscribemessage",$userid[0])); sendMail($email, getConfig("unsubscribesubject"), $unsubscribemessage, system_messageheaders($email),$envelope); sendAdminCopy("List unsubscription",$email . " has unsubscribed from\n $lists"); } $res .= '

'.$GLOBALS["strUnsubscribeDone"] ."

"; $res .= $GLOBALS["PoweredBy"].'

'; $res .= $pagedata["footer"]; return $res; } elseif ($unsubscribe) { $msg = "".$GLOBALS["strEnterEmail"]."
"; } elseif ($uid) { $req = Sql_Query("select * from $tables[user] where uniqid = \"$uid\""); $userdata = Sql_Fetch_Array($req); $email = $userdata["email"]; } $email = trim($email); $res .= ''. $GLOBALS["strUnsubscribeInfo"].'
'. $msg.formStart(); $res .= '
'.$GLOBALS["strEnterEmail"].':
'; if (!$email) { $res .= "\n"; $res .= $GLOBALS["PoweredBy"]; $res .= $pagedata["footer"]; return $res; } $res .= $GLOBALS["strUnsubscribeSelect"].':'; $res .= '

'; } $res .= '

'.$GLOBALS["PoweredBy"].'

'; $res .= $pagedata["footer"]; return $res; } ?>