Пример #1
0
function unsubscribePage($id)
{
    $pagedata = pageData($id);
    if (isset($pagedata['language_file']) && is_file(dirname(__FILE__) . '/texts/' . $pagedata['language_file'])) {
        @(include dirname(__FILE__) . '/texts/' . $pagedata['language_file']);
    }
    global $tables;
    $res .= '<title>' . $GLOBALS["strUnsubscribeTitle"] . '</title>';
    $res = $pagedata["header"];
    if (isset($_GET["uid"])) {
        $req = Sql_Query("select * from {$tables['user']} where uniqid = \"" . $_GET["uid"] . "\"");
        $userdata = Sql_Fetch_Array($req);
        $email = $userdata["email"];
        if (UNSUBSCRIBE_JUMPOFF) {
            $_POST["unsubscribe"] = 1;
            $_POST["email"] = $email;
            $_POST["unsubscribereason"] = '"Jump off" set, reason not requested';
        }
    }
    if (isset($_POST["unsubscribe"]) && (isset($_POST["email"]) || isset($_POST["unsubscribeemail"])) && isset($_POST["unsubscribereason"])) {
        if (isset($_POST["email"])) {
            $email = trim($_POST["email"]);
        } else {
            $email = $_POST["unsubscribeemail"];
        }
        $query = Sql_Fetch_Row_Query("select id,email from {$tables["user"]} where email = \"{$email}\"");
        $userid = $query[0];
        $email = $query[1];
        if (!$userid) {
            $res .= 'Error: ' . $GLOBALS["strUserNotFound"];
            logEvent("Request to unsubscribe non-existent user: "******"email"], 0, 150));
        } else {
            $result = Sql_query("delete from {$tables["listuser"]} where userid = \"{$userid}\"");
            $lists = "  * " . $GLOBALS["strAllMailinglists"] . "\n";
            # add user to blacklist
            addUserToBlacklist($email, nl2br(strip_tags($_POST['unsubscribereason'])));
            addUserHistory($email, "Unsubscription", "Unsubscribed from {$lists}");
            $unsubscribemessage = ereg_replace("\\[LISTS\\]", $lists, getUserConfig("unsubscribemessage", $userid));
            sendMail($email, getConfig("unsubscribesubject"), stripslashes($unsubscribemessage), system_messageheaders($email));
            $reason = $_POST["unsubscribereason"] ? "Reason given:\n" . stripslashes($_POST["unsubscribereason"]) : "No Reason given";
            sendAdminCopy("List unsubscription", $email . " has unsubscribed\n{$reason}");
            addSubscriberStatistics('unsubscription', 1);
        }
        if ($userid) {
            $res .= '<h1>' . $GLOBALS["strUnsubscribeDone"] . "</h1><P>";
        }
        $res .= $GLOBALS["PoweredBy"] . '</p>';
        $res .= $pagedata["footer"];
        return $res;
    } elseif (isset($_POST["unsubscribe"]) && !$_POST["unsubscribeemail"]) {
        $msg = '<span class="error">' . $GLOBALS["strEnterEmail"] . "</span><br>";
    } elseif (!empty($_GET["email"])) {
        $email = trim($_GET["email"]);
    } else {
        if (isset($_REQUEST["email"])) {
            $email = $_REQUEST["email"];
        } elseif (isset($_REQUEST['unsubscribeemail'])) {
            $email = $_REQUEST['unsubscribeemail'];
        } elseif (!isset($email)) {
            $email = '';
        }
    }
    if (!isset($msg)) {
        $msg = '';
    }
    $res .= '<b>' . $GLOBALS["strUnsubscribeInfo"] . '</b><br>' . $msg . formStart();
    $res .= '<table>
  <tr><td>' . $GLOBALS["strEnterEmail"] . ':</td><td colspan=3><input type=text name="unsubscribeemail" value="' . $email . '" size=40></td></tr>
  </table>';
    if (!$email) {
        $res .= "<input type=submit name=unsubscribe value=\"{$GLOBALS['strContinue']}\"></form>\n";
        $res .= $GLOBALS["PoweredBy"];
        $res .= $pagedata["footer"];
        return $res;
    }
    $current = Sql_Fetch_Array_query("SELECT list.id as listid,user.uniqid as userhash, user.password as password FROM {$tables['list']} as list,{$tables['listuser']} as listuser,{$tables['user']} as user where list.id = listuser.listid and user.id = listuser.userid and user.email = \"{$email}\"");
    $some = $current["listid"];
    if (ASKFORPASSWORD && !empty($user['password'])) {
        # it is safe to link to the preferences page, because it will still ask for
        # a password
        $hash = $current["userhash"];
    } elseif (isset($_GET['uid']) && $_GET['uid'] == $current['userhash']) {
        # they got to this page from a link in an email
        $hash = $current['userhash'];
    } else {
        $hash = '';
    }
    $finaltext = $GLOBALS["strUnsubscribeFinalInfo"];
    $pref_url = getConfig("preferencesurl");
    $sep = ereg('\\?', $pref_url) ? '&' : '?';
    $finaltext = eregi_replace('\\[preferencesurl\\]', $pref_url . $sep . 'uid=' . $hash, $finaltext);
    if (!$some) {
        $res .= "<b>" . $GLOBALS["strNoListsFound"] . "</b></ul>";
        $res .= '<p><input type=submit value="' . $GLOBALS["strResubmit"] . '">';
    } else {
        list($r, $c) = explode(",", getConfig("textarea_dimensions"));
        if (!$r) {
            $r = 5;
        }
        if (!$c) {
            $c = 65;
        }
        $res .= $GLOBALS["strUnsubscribeRequestForReason"];
        $res .= sprintf('<br/><textarea name="unsubscribereason" cols="%d" rows="%d" wrap="virtual"></textarea>', $c, $r) . '

    ' . $finaltext . '

    <p><input type=submit name="unsubscribe" value="' . $GLOBALS["strUnsubscribe"] . '"></p>';
    }
    $res .= '<p>' . $GLOBALS["PoweredBy"] . '</p>';
    $res .= $pagedata["footer"];
    return $res;
}
Пример #2
0
function unsubscribePage($id) {
	$pagedata = pageData($id);
	global $tables;
  $res = $pagedata["header"];
  $res .= '<title>'.$GLOBALS["strUnsubscribeTitle"].'</title>';
  if ($_POST["unsubscribe"] && eregi(".+\@.+\..+",$_POST["email"]) && $_POST["list"]) {
  	$email = trim($_POST["email"]);
    $result = Sql_query("SELECT * FROM $tables[list]");
    while ($row = Sql_fetch_array($result)) {
      if ($row["active"])
        $availlists[$row["id"]] = $row["name"];
    }

    $query = Sql_Fetch_Row_Query("select id from {$tables["user"]} where email = \"$email\"");
    $userid = $query[0];

    if ($_POST["list"] && !$_POST["list"]["none"]) {
      if ($_POST["list"]["all"]) {
        $result = Sql_query("delete from {$tables["listuser"]} where userid = \"$userid\"");
        $lists = "  * $strAllMailinglists\n";
      } else {
        while(list($key,$val)= each($_POST["list"])) {
          if ($val == "signoff") {
            $result = Sql_query("delete from $tables[listuser] where userid = \"$userid\" and listid = \"$key\"");
            $lists .= "  * ".$availlists[$key] . "\n";
          }
        }
      }
      $unsubscribemessage = ereg_replace("\[LISTS\]", $lists,getUserConfig("unsubscribemessage",$userid));
      sendMail($email, getConfig("unsubscribesubject"), $unsubscribemessage, system_messageheaders($email));
      sendAdminCopy("List unsubscription",$email . " has unsubscribed from\n $lists");
    }

    $res .= '<h1>'.$GLOBALS["strUnsubscribeDone"] ."</h1><P>";
    $res .= $GLOBALS["PoweredBy"].'</p>';
    $res .= $pagedata["footer"];
    return $res;
  } elseif ($_POST["unsubscribe"] && !$_POST["email"]) {
    $msg = '<span class="error">'.$GLOBALS["strEnterEmail"]."</span><br>";
  } elseif ($_GET["uid"]) {
    $req = Sql_Query("select * from $tables[user] where uniqid = \"".$_GET["uid"]."\"");
    $userdata = Sql_Fetch_Array($req);
    $email = $userdata["email"];
  } elseif ($_GET["email"]) {
    $email = trim($_GET["email"]);
  } else {
    $email = $_POST["email"];
  }
    
  $res .= '<b>'. $GLOBALS["strUnsubscribeInfo"].'</b><br>'.
  $msg.formStart();
  $res .= '<table>
  <tr><td>'.$GLOBALS["strEnterEmail"].':</td><td colspan=3><input type=text name=email value="'.$email.'" size=40></td></tr>
  </table>';

  if (!$email) {
    $res .= "<input type=submit name=unsubscribe value=\"$GLOBALS[strContinue]\"></form>\n";
    $res .= $GLOBALS["PoweredBy"];
    $res .= $pagedata["footer"];
    return $res;
  }

  $res .= $GLOBALS["strUnsubscribeSelect"].':';
  $res .= '<ul>';
  $result = Sql_query("SELECT $tables[list].id as id, $tables[list].name as name, $tables[list].description as description FROM $tables[list],$tables[listuser],$tables[user] where $tables[list].id = $tables[listuser].listid and $tables[user].id = $tables[listuser].userid and $tables[user].email = \"$email\"");
  $num = Sql_Affected_Rows();
	$hidesinglelist = getConfig("hide_single_list");
  $hide =  $num == 1 && $hidesinglelist == "true";

  if (!$hide) {
    $out = ' <li><input type=checkbox name=list[all] value=signoff>'.$GLOBALS["strAllLists"].'
      <li><input type=checkbox name=list[none] value=signoff>'.$GLOBALS["strNoLists"];
  }

  while ($row = Sql_fetch_array($result)) {
  	if (!$hide) {
      $out .= "<li><input type=checkbox name=list[".$row["id"] . "] value=signoff>".$row["name"] ." \n";
      $desc = nl2br(StripSlashes($row["description"]));
      $out .= "<dd>$desc\n";
    } else {
    	$out .= "<input type=hidden name=list[".$row["id"] . "] value=signoff>";
    }
    $some = 1;
  }

  if (!$some) {
    $res .= "<b>".$GLOBALS["strNoListsFound"]."</b>";
    $res .= '<p><input type=submit value="'.$GLOBALS["strResubmit"].'">';
  } else {
    $res .= $out;
    $res .= '</ul>
    <p><input type=submit name=unsubscribe value="'.$GLOBALS["strUnsubscribeSubmit"].'">';
  }

  $res .= '<p>'.$GLOBALS["PoweredBy"].'</p>';
  $res .= $pagedata["footer"];
  return $res;
}
Пример #3
0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
require_once "utils.inc";
require_once "pages.inc";
$gUrl = getParam('u');
$gLabel1 = getParam('label1');
$gLabel2 = getParam('label2');
$gWptid2 = getParam('wptid2');
if ($gUrl && $gLabel1 && $gLabel2 && $gWptid2) {
    $pageData = pageData(null, $gUrl, $gLabel1);
    if (!$pageData) {
        header('Location: websites.php?1');
        return;
    } else {
        $gWptid1 = $pageData['wptid'];
        header("Location: http://httparchive.webpagetest.org/video/compare.php?tests={$gWptid1}-l:{$gLabel1},{$gWptid2}-l:{$gLabel2}");
    }
} else {
    // should never reach here
    header("Location: websites.php?u={$gUrl}&l1={$gLabel1}&l2={$gLabel2}&w2={$gWptid2}");
}
Пример #4
0
    $gPageid = getParam('pageid');
    $pageData = pageData($gPageid);
} else {
    if (!isset($gPageid) && getParam('u') && getParam('l')) {
        $url = getParam('u');
        $gLabel = getParam('l');
        $pageData = pageData(null, $url, $gLabel);
    } else {
        if (!isset($gPageid) && getParam('u')) {
            $url = getParam('u');
            $pageData = pageData(null, $url, null, getParam('h'));
        } else {
            if (getParam('rand')) {
                $crawl = latestCrawl();
                $gPageid = randomPageid($crawl);
                $pageData = pageData($gPageid);
            } else {
                // should never reach here
                header('Location: websites.php');
                return;
            }
        }
    }
}
// TODO - better error handling starting here!
// Changed to select * to allow summary paragraph
if (!$pageData) {
    header('Location: websites.php');
    return;
}
// Flush any currently open buffers.