00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: editsshkeys.php 4977 2005-11-15 17:38:40Z yeupou $
00006 #
00007 # Copyright 1999-2000 (c) The SourceForge Crew
00008 # Copyright 2000-2002 (c) Free Software Foundation
00009 #
00010 # Copyright 2004 (c) Mathieu Roy <yeupou--at--gnu.org>
00011 #
00012 # The Savane project is free software; you can redistribute it and/or
00013 # modify it under the terms of the GNU General Public License
00014 # as published by the Free Software Foundation; either version 2
00015 # of the License, or (at your option) any later version.
00016 #
00017 # The Savane project is distributed in the hope that it will be useful,
00018 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00020 # GNU General Public License for more details.
00021 #
00022 # You should have received a copy of the GNU General Public License
00023 # along with the Savane project; if not, write to the Free Software
00024 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00025
00026 require '../../include/pre.php';
00027 require '../../include/account.php';
00028 session_require(array(isloggedin=>1));
00029
00030
00031 if ($update)
00032 {
00033 unset($keys);
00034 # Build the key string
00035 # Key limit is set to 25
00036 for ($i = 1; $i < 26; $i++)
00037 {
00038 $thiskey = "form_authorized_keys_$i";
00039 # Remove useless blank spaces
00040 $$thiskey = trim($$thiskey);
00041 # Remove line breaks
00042 $$thiskey = str_replace("\n", "", $$thiskey);
00043 if ($$thiskey != "")
00044 {
00045 fb(sprintf(_("Key #%s seen"), $i));
00046 $keys .= $$thiskey."###";
00047 }
00048 }
00049
00050 # Update the database
00051 $success = db_query("UPDATE user SET authorized_keys='".addslashes($keys)."' WHERE user_id=" . user_getid());
00052
00053 if ($success)
00054 { fb(_("Keys registered")); }
00055 else
00056 { fb(_("Error while registering keys"), 1); }
00057 }
00058 else
00059 {
00060 # Grab keys from the database
00061 $res_keys = db_query("SELECT authorized_keys FROM user WHERE user_id=".user_getid());
00062 $row_keys = db_fetch_array($res_keys);
00063
00064 list($form_authorized_keys_1,
00065 $form_authorized_keys_2,
00066 $form_authorized_keys_3,
00067 $form_authorized_keys_4,
00068 $form_authorized_keys_5,
00069 $form_authorized_keys_6,
00070 $form_authorized_keys_7,
00071 $form_authorized_keys_8,
00072 $form_authorized_keys_9,
00073 $form_authorized_keys_10,
00074 $form_authorized_keys_11,
00075 $form_authorized_keys_12,
00076 $form_authorized_keys_13,
00077 $form_authorized_keys_14,
00078 $form_authorized_keys_15,
00079 $form_authorized_keys_16,
00080 $form_authorized_keys_17,
00081 $form_authorized_keys_18,
00082 $form_authorized_keys_19,
00083 $form_authorized_keys_20,
00084 $form_authorized_keys_21,
00085 $form_authorized_keys_22,
00086 $form_authorized_keys_23,
00087 $form_authorized_keys_24,
00088 $form_authorized_keys_25) = split("###", $row_keys['authorized_keys'], 25);
00089
00090 }
00091
00092
00093 # not valid registration, or first time to page
00094 site_user_header(array('title'=>_("Change Authorized Keys"),'context'=>'account'));
00095
00096
00097 # we get site-specific content
00098 utils_get_content("account/editsshkeys");
00099
00100
00101 print '<form action="editsshkeys.php" method="post">';
00102
00103 print '<h3>'._("Authorized keys:").'</h3>';
00104
00105 print '<p>'._("Copy each the public key of each key you want to register in a text field. After submitting, verify that the number of keys registered is what you expected.").'</p>';
00106
00107 # Key limit is set to 25
00108 # By default, show only 6 fields
00109 for ($i = 1; $i < 26; $i++)
00110 {
00111 $thiskey="form_authorized_keys_$i";
00112 $$thiskey=trim($$thiskey);
00113 print '<span class="preinput">'.sprintf(_("Key #%s:"), $i).'</span> <input type="text" size="60" name="form_authorized_keys_'.$i.'" value="'.$$thiskey.'" /><br />';
00114 if ($i > 6 && $$thiskey == "")
00115 { break; }
00116 }
00117
00118 print '<br /><br /><input type="submit" name="update" value="'._("Update").'" /></p>';
00119 print '</form>';
00120
00121
00122 site_user_footer(array());
00123
00124 ?>