~psiphon-inc/psiphon/trunk

« back to all changes in this revision

Viewing changes to trunk/www/proxies.php

  • Committer: Adam Kruger
  • Date: 2011-02-07 20:43:10 UTC
  • mfrom: (157.1.3 psiphon-with-psiphonx)
  • Revision ID: akruger@kruger-xps-20110207204310-6ph82r21rce8ldze
Merge PsiphonX.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
    $name = trim($_POST['name']);
65
65
    $notes = trim($_POST['notes']);
66
66
 
 
67
    $http_proxy_port_number = trim($_POST['http_proxy_port_number']);
 
68
    $ssh_server_port_number = trim($_POST['ssh_server_port_number']);
 
69
    $ssh_server_fingerprint = trim($_POST['ssh_server_fingerprint']);
 
70
    $ssh_user_name = trim($_POST['ssh_user_name']);
 
71
    $ssh_user_password = trim($_POST['ssh_user_password']);
 
72
 
67
73
    // NOTE: Because we don't have transactions, there is a race condition between
68
74
    // the address conflict check and the insert/update attempt. If a conflict is
69
75
    // introduced between the check and the insert/update, a DB error will occur.
77
83
        break;
78
84
    }
79
85
 
80
 
    $query = "INSERT INTO proxy (hostname, login_url, name, notes) VALUES (:hostname, :login_url, :name, :notes)";
81
 
    db_query_execute($config, $query, convert_null_array(array(":hostname" => $hostname, ":login_url" => $proxy_login_url, ":name" => $name, ":notes" => $notes)));
 
86
    $query = "INSERT INTO proxy ".
 
87
             "(hostname, login_url, name, notes, http_proxy_port_number, ssh_server_port_number, ".
 
88
             " ssh_server_fingerprint, ssh_user_name, ssh_user_password) ".
 
89
             "VALUES ".
 
90
             "(:hostname, :login_url, :name, :notes, :http_proxy_port_number, :ssh_server_port_number, ".
 
91
             " :ssh_server_fingerprint, :ssh_user_name, :ssh_user_password)";
 
92
    db_query_execute($config, $query, convert_null_array(array(
 
93
            ":hostname" => $hostname,
 
94
            ":login_url" => $proxy_login_url,
 
95
            ":name" => $name,
 
96
            ":notes" => $notes,
 
97
            ":http_proxy_port_number" => $http_proxy_port_number,
 
98
            ":ssh_server_port_number" => $ssh_server_port_number,
 
99
            ":ssh_server_fingerprint" => $ssh_server_fingerprint,
 
100
            ":ssh_user_name" => $ssh_user_name,
 
101
            ":ssh_user_password" => $ssh_user_password)));
82
102
 
83
103
    $last = db_get_last_insert_id($config);
84
104
    break;
117
137
    $notes = trim($_POST['notes']);
118
138
    $update_stats = isset($_POST['update_stats']);
119
139
 
 
140
    $http_proxy_port_number = trim($_POST['http_proxy_port_number']);
 
141
    $ssh_server_port_number = trim($_POST['ssh_server_port_number']);
 
142
    $ssh_server_fingerprint = trim($_POST['ssh_server_fingerprint']);
 
143
    $ssh_user_name = trim($_POST['ssh_user_name']);
 
144
    $ssh_user_password = trim($_POST['ssh_user_password']);
 
145
 
120
146
    // NOTE: Because we don't have transactions, there is a race condition between
121
147
    // the conflict check and the insert/update attempt. If a conflict is
122
148
    // introduced between the check and the insert/update, a DB error will occur.
136
162
        break;
137
163
    }
138
164
 
139
 
    $query = "UPDATE proxy SET hostname = :hostname, login_url = :login_url, name = :name, notes = :notes WHERE id = :id";
140
 
    db_query_execute($config, $query, convert_null_array(array(":hostname" => $hostname, ":login_url" => $proxy_login_url, ":name" => $name, ":notes" => $notes, ":id" => $_POST['id'])));
 
165
    $query = "UPDATE proxy SET hostname = :hostname, login_url = :login_url, name = :name, notes = :notes, ".
 
166
             "http_proxy_port_number = :http_proxy_port_number, ssh_server_port_number = :ssh_server_port_number, ".
 
167
             "ssh_server_fingerprint = :ssh_server_fingerprint, ssh_user_name = :ssh_user_name, ".
 
168
             "ssh_user_password = :ssh_user_password WHERE id = :id";
 
169
    db_query_execute($config, $query, convert_null_array(array(
 
170
            ":hostname" => $hostname,
 
171
            ":login_url" => $proxy_login_url,
 
172
            ":name" => $name,
 
173
            ":notes" => $notes,
 
174
            ":http_proxy_port_number" => $http_proxy_port_number,
 
175
            ":ssh_server_port_number" => $ssh_server_port_number,
 
176
            ":ssh_server_fingerprint" => $ssh_server_fingerprint,
 
177
            ":ssh_user_name" => $ssh_user_name,
 
178
            ":ssh_user_password" => $ssh_user_password,
 
179
            ":id" => $_POST['id'])));
141
180
 
142
181
    // Proxy notes were added after stats had already been gathered, so we'll give
143
182
    // the user the option of copying the notes from the current edit to the stats
193
232
 
194
233
<!--<th><?=msg("last_user_request")?></th>
195
234
<th><?=msg("average_daily_requests")?></th>-->
 
235
<th><?=msg("http_proxy_port_number")?></th>
 
236
<th><?=msg("ssh_server_port_number")?></th>
 
237
<th><?=msg("ssh_server_fingerprint")?></th>
 
238
<th><?=msg("ssh_user_name")?></th>
 
239
<th><?=msg("ssh_user_password")?></th>
196
240
<th><a href="<?=getenv("SCRIPT_NAME")?>?add=1"><?=msg("add")?></a></th>
197
241
</tr>
198
242
 
212
256
<td><textarea name="notes" rows="10" cols="60" wrap="off" style="width:100%"><?=escape_html($_POST['notes'])?></textarea></td>
213
257
<!--<td></td>
214
258
<td></td>-->
 
259
<td></td>
 
260
<td><input type="text" name="http_proxy_port_number" maxlength="10" size="10" value="<?=escape_html($_POST['http_proxy_port_number'])?>"></td>
 
261
<td><input type="text" name="ssh_server_port_number" maxlength="10" size="10" value="<?=escape_html($_POST['ssh_server_port_number'])?>"></td>
 
262
<td><input type="text" name="ssh_server_fingerprint" maxlength="100" size="40" value="<?=escape_html($_POST['ssh_server_fingerprint'])?>"></td>
 
263
<td><input type="text" name="ssh_user_name" maxlength="100" size="15" value="<?=escape_html($_POST['ssh_user_name'])?>"></td>
 
264
<td><input type="text" name="ssh_user_password" maxlength="100" size="15" value="<?=escape_html($_POST['ssh_user_password'])?>"></td>
215
265
<td><input type="submit" value="<?=msg("add")?>"> &nbsp; <a href="<?=getenv("SCRIPT_NAME")?>"><?=msg("cancel")?></a></td>
216
266
</tr>
217
267
 
308
358
        }
309
359
//        echo "<td>{$_p}{$last_user_request}{$_s}</td>\n";
310
360
//        echo "<td>{$_p}{$average_daily_requests}{$_s}</td>\n";
 
361
        echo "<td>{$_p}".escape_html($record['http_proxy_port_number'])."{$_s}</td>\n";
 
362
        echo "<td>{$_p}".escape_html($record['ssh_server_port_number'])."{$_s}</td>\n";
 
363
        echo "<td>{$_p}".escape_html($record['ssh_server_fingerprint'])."{$_s}</td>\n";
 
364
        echo "<td>{$_p}".escape_html($record['ssh_user_name'])."{$_s}</td>\n";
 
365
        echo "<td>{$_p}".escape_html($record['ssh_user_password'])."{$_s}</td>\n";
311
366
        echo "<td><a href=\"".getenv("SCRIPT_NAME")."?edit={$record[id]}\">{$_p}".msg("edit")."{$_s}</a> &nbsp;";
312
367
        echo "</td>\n";
313
368
    }
330
385
//        echo "<td>{$last_user_request}</td>";
331
386
//        echo "<td>{$average_daily_requests}</td>";
332
387
        echo "<td>";
 
388
        echo "<input type=\"text\" name=\"http_proxy_port_number\" maxlength=\"10\" size=\"10\" value=\"".escape_html($record['http_proxy_port_number'])."\">";
 
389
        echo "</td>\n";
 
390
        echo "<td>";
 
391
        echo "<input type=\"text\" name=\"ssh_server_port_number\" maxlength=\"10\" size=\"10\" value=\"".escape_html($record['ssh_server_port_number'])."\">";
 
392
        echo "</td>\n";
 
393
        echo "<td>";
 
394
        echo "<input type=\"text\" name=\"ssh_server_fingerprint\" maxlength=\"100\" size=\"40\" value=\"".escape_html($record['ssh_server_fingerprint'])."\">";
 
395
        echo "</td>\n";
 
396
        echo "<td>";
 
397
        echo "<input type=\"text\" name=\"ssh_user_name\" maxlength=\"100\" size=\"15\" value=\"".escape_html($record['ssh_user_name'])."\">";
 
398
        echo "</td>\n";
 
399
        echo "<td>";
 
400
        echo "<input type=\"text\" name=\"ssh_user_password\" maxlength=\"100\" size=\"15\" value=\"".escape_html($record['ssh_user_password'])."\">";
 
401
        echo "</td>\n";
 
402
        echo "<td>";
333
403
        echo "<input type=\"submit\" value=\"".msg("update")."\"> &nbsp; <a href=\"".getenv("SCRIPT_NAME")."\">".msg("cancel")."</a>";
334
404
        echo "<br><br><input type='checkbox' name='update_stats' ".($_POST['update_stats'] ? 'checked=1' : '')." /><font size='small'>".msg("proxies_update_stats")."</font>";
335
405
        echo "</td>\n";