1<?php
2
3require_once dirname(__FILE__).'/accesscheck.php';
4
5$content = '';
6if (isset($_POST['usercheck'])) {
7    $lsexist = new WebblerListing(s('Existing subscribers'));
8    $lsnonexist = new WebblerListing(s('Non existing subscribers '));
9    $users = explode("\n", $_POST['usercheck']);
10    foreach ($users as $user) {
11        $user = trim($user);
12        if (isset($_POST['check']) && $_POST['check'] == 'foreignkey') {
13            $exists = Sql_Query(sprintf('select id,foreignkey,email from %s where foreignkey = "%s"', $tables['user'],
14                sql_escape($user)));
15        } else {
16            $exists = Sql_Query(sprintf('select id,foreignkey,email from %s where email = "%s"', $tables['user'],
17                sql_escape($user)));
18        }
19        $element = htmlentities(stripslashes($user));
20        if (Sql_Num_Rows($exists)) {
21            $id = Sql_Fetch_Array($exists);
22
23            $lsexist->setElementHeading(s('Subscriber email'));
24            $lsexist->addElement($element, PageUrl2('user&amp;id='.$id['id']));
25            if (isset($id['foreignkey'])) {
26                $lsexist->addColumn($element, s('Foreign key'), $id['foreignkey']);
27            }
28        } else {
29            if (isset($_POST['check']) && $_POST['check'] == 'foreignkey') {
30                $lsnonexist->setElementHeading(s('Foreign key'));
31            } else {
32                $lsnonexist->setElementHeading(s('Subscriber email'));
33            }
34            $lsnonexist->addElement($element);
35        }
36    }
37    echo $lsexist->display();
38    echo $lsnonexist->display();
39} else {
40    $_POST['usercheck'] = '';
41}
42
43/*
44print $GLOBALS["I18N"]->get("Page to check the existence of users in the database");
45*/
46
47$content .= '<form method="post" action="">';
48$content .= '<table class="usercheckForm">';
49$content .= '<tr><td>'.s('What is the type of information you want to check').'</td></tr>';
50$content .= '<tr><td><label for="foreignkey">'.s('Foreign Key').'</label> <input type="radio" id="foreignkey" name="check" value="foreignkey"></td></tr>';
51$content .= '<tr><td><label for="email">'.s('Email').'</label> <input type="radio" id="email" name="check" value="email" required ></td></tr>';
52$content .= '<tr><td>'.s('Paste the values to check in this box, one per line').'</td></tr>';
53$content .= '<tr><td><textarea name="usercheck" rows=10 cols=65>'.htmlentities(stripslashes($_POST['usercheck'])).'</textarea></td></tr>';
54$content .= '<tr><td><input type="submit" name="continue" value="'.s('Continue').'" class="button"></td></tr>';
55$content .= '</table></form>';
56
57$p = new UIPanel('', $content);
58echo $p->display();
59