Changeset 1349

Show
Ignore:
Timestamp:
02/28/07 01:08:08 (2 years ago)
Author:
jm3
Message:

cleaned up ASP style tags, added cleaned js funcs for bulk management, locked out config, added IM field to DB, entry/updating, and validation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • feedmelinks/_config/.htaccess

    r920 r1349  
    11Options -Indexes  
     2<Limit GET POST PUT> 
     3        require user jm3 
     4</Limit> 
    25 
     6 
  • feedmelinks/account.php

    r1334 r1349  
    1 <% 
     1<?php 
    22        # $Id$ 
    33        include_once( "modules/utils.inc.php" ); 
    44        $site = getSiteUrl(); 
    55        $max_profile_image_size = 500000; 
    6 %
     6?
    77<title> Feed Me Links : My Profile </title> 
    8 <% include( "$modules/header.inc.php" ); %
     8<?php include( "$modules/header.inc.php" ); ?
    99<br /> 
    10 <% 
     10<?php 
    1111        if( $tok && $tok == md5( getPasswdForUser( $u )) ) { 
    1212    $con_account = mysql_connect(); 
    1313    mysql_selectdb( getDBName() ); 
    1414 
    15                 if( $op == "update-email" ) { 
     15                if( $op == "update-im" ) { 
     16                                if( !$im ) 
     17                                        return; 
     18                                $im = urlencode( $im ); 
     19                                $success = run_query( "UPDATE users SET im = '$im' WHERE userId = '$u'" ); 
     20                                insert_message( "Updating your AIM name to $im..." . ($success ? "complete!" : "failed. :-(" )); 
     21                                $showForm = 1; 
     22                } else if( $op == "update-email" ) { 
    1623                                if( $email ) { 
    1724                                        $email = urlencode( $email ); 
     
    1926                                        $successEmail = mysql_query( $qs ); 
    2027                                        $showForm = 1; 
    21 %
     28?
    2229<div class="attention"> 
    2330        <div class="warning"> 
    24                 Updating your email address to <u><%= urldecode( $email ) %></u> ... 
    25 <% 
     31                Updating your email address to <u><?= urldecode( $email ) ?></u> ... 
     32<?php 
    2633                                        if( $successEmail )  
    2734                                                echo "DONE!"; 
     
    2936                                                echo "failed."; 
    3037                                        $showForm = 1; 
    31 %
     38?
    3239        </div> 
    3340</div> 
    34 <% 
     41<?php 
    3542                                } else { 
    3643                                        $showForm = 1; 
     
    4350                                        $qs = "UPDATE users SET password = '$password' WHERE userId = '$u'"; 
    4451                                        $successPass = mysql_query( $qs ); 
    45 %
     52?
    4653<div class="attention"> 
    4754        <div class="warning"> 
    4855                Updating your password... 
    49 <%  
     56<?php  
    5057                                                # SLOPPY / WRONG: 
    5158                                                if( $successPass )  
     
    5461                                                        echo "failed."; 
    5562                                                $showForm = 1; 
    56 %
     63?
    5764                </div> 
    5865        </div> 
    59 <% 
     66<?php 
    6067                                        } else { 
    6168                                                warn( "Sorry, the password you typed doesn't match what we have on file." 
     
    8895                                                        # fix perms: 
    8996                                                        chmod( $uploadFile, 0666 ); 
    90 %
     97?
    9198 
    9299<div class="attention"> 
     
    95102<br /> 
    96103 
    97 <% 
     104<?php 
    98105                                                        showUserImage( $u ); 
    99 %
     106?
    100107<h2><a style="color: #ff6600;" href="/account">&laquo; Back to your profile.</a></h2> 
    101108or <h2><a style="color: #ff6600;" href="/">&laquo; Back to your links.</a></h2> 
    102 <% 
     109<?php 
    103110                                                } else { 
    104111                                                        warn( "Owch, invalid file upload! Try a smaller image (less than 500k)." ); 
     
    133140                        } 
    134141                        conClose( $con_account ); 
    135 %
     142?
    136143 
    137144  <script type="text/javascript"> 
     
    146153                        } else if( ! filter.test( e ))  { 
    147154                                alert( "Please double-check your email address." ); 
     155                                return false; 
     156                        } else { 
     157                                return true; 
     158                        } 
     159                } 
     160 
     161                function check_im( f ) { 
     162                        var e = f.im.value; 
     163                        var filter  = /^[a-zA-Z0-9_\.\-\@]+$/; 
     164                        if( e == '' ) { 
     165                                alert( "Please enter your AIM name." ); 
     166                                return false; 
     167                        } else if( ! filter.test( e ))  { 
     168                                alert( "Please double-check that your AIM name is correct." ); 
    148169                                return false; 
    149170                        } else { 
     
    176197  </script> 
    177198 
    178 <form method="post" action="/account" name="profile_email_form"  
    179         onSubmit="return check_email(document.forms.profile_email_form);"> 
    180         <input type="hidden" name="op" value="update-email" /> 
    181  
    182199        <div id="accountBox" style="width: 48em;"> 
    183                 <div class="subhead"> 
    184                         MY PROFILE: 
    185                 </div> 
    186                 <div class="r0" style="width: 47em; height: 34em;"> 
     200                        <h1>MY PROFILE:</h1> 
     201                <div class="r0" style="width: 47em; height: 49em; margin-left: auto; margin-right: auto;"> 
    187202 
    188203                        <div style="float: left;"> 
    189204 
    190205                                <table border="0" width="450" cellspacing="0" cellpadding="7"> 
     206 
     207                                <form method="post" action="/account" name="profile_email_form"  
     208                                        onSubmit="return check_email(document.forms.profile_email_form);"> 
     209                                        <input type="hidden" name="op" value="update-email" /> 
    191210                                        <tr> 
    192211                                                <td> 
     
    194213                                                </td> 
    195214                                                <td>  
    196                                                         <%= getEmailAddressForUser( $u ) %
     215                                                        <big><big><?= getEmailAddressForUser( $u ) ?></big></big
    197216                                                </td> 
    198217                                        </tr> 
    199218                                        <tr height="40" valign="top"> 
    200219                                                <td align="right"> 
    201                                                         New Email: 
     220                                                        Change Email: 
    202221                                                </td> 
    203222                                                <td> 
     
    205224                                                        <input type="submit" class="default button" value="Update" /> 
    206225                                                        <br /> 
     226                                                        <br /> 
     227                                                        <br /> 
     228                                                </td> 
     229                                        </tr> 
     230                                </form> 
     231                                <br /> 
     232 
     233                                <form method="post" action="/account" name="profile_im_form"  
     234                                        onSubmit="return check_im(document.forms.profile_im_form);"> 
     235                                        <input type="hidden" name="op" value="update-im" /> 
     236                                        <tr> 
     237                                                <td> 
     238                                                        <b>MY <abbr title="AOL Instant Messenger">A.I.M.</abbr> NAME:</b> 
     239                                                </td> 
     240                                                <td>  
     241                                                        <big><big><?= get_IM_address_for_user( $u ) ?></big></big> 
     242                                                        <span class="subtle"><?= IM_address_is_validated( $u ) ? "" : "(not validated)" ?></span> 
     243                                                </td> 
     244                                        </tr> 
     245                                        <tr height="40" valign="top"> 
     246                                                <td align="right"> 
     247                                                        Change AIM name: 
     248                                                </td> 
     249                                                <td> 
     250                                                        <input type="text" name="im" size="24" value="" /> 
     251                                                        <input type="submit" class="default button" value="Update" /> 
     252                                                        <br /> 
     253                                                        (not displayed publicly) 
    207254                                                        <br /> 
    208255                                                        <br /> 
     
    222269                                        <tr> 
    223270                                                <td align="right"> 
    224                                                         New Password: 
    225                                                 </td> 
    226                                                 <td> 
    227                                                         <input type="password" name="password1" size="24" value="<%= $password %>" /> 
     271                                                        Change Password: 
     272                                                </td> 
     273                                                <td> 
     274                                                        <input type="password" name="password1" size="24" value="<?= $password ?>" /> 
    228275                                                </td> 
    229276                                        </tr> 
     
    233280                                                </td> 
    234281                                                <td> 
    235                                                         <input type="password" name="password2" size="24" value="<%= $password %>" /> 
     282                                                        <input type="password" name="password2" size="24" value="<?= $password ?>" /> 
    236283                                                        <input type="submit" class="default button" value="Update" /> 
    237284                                                        <br /> 
     
    243290 
    244291                                <form method="post" action="/account" enctype="multipart/form-data" name="profile_image_form"> 
    245                                         <input type="hidden" name="MAX_FILE_SIZE" value="<%= $max_profile_image_size %>" /> 
     292                                        <input type="hidden" name="MAX_FILE_SIZE" value="<?= $max_profile_image_size ?>" /> 
    246293                                        <input type="hidden" name="op" value="update-profile-image" /> 
    247294                                        <tr> 
    248                                                 <td colspan="2"
     295                                                <td
    249296                                                        <b>MY PROFILE IMAGE:</b> 
    250297                                                </td> 
     298                                                <td> 
     299                                                <img src="/<?= get_thumbnail_image( $u ) ?>" style="padding: 5px;" /> 
     300                                                </td> 
     301 
    251302                                        </tr> 
    252303                                        <tr> 
     
    277328 
    278329<!-- div> 
    279         <% #include_once( "$modules/user-fields.inc.php" ); %
     330        <?php #include_once( "$modules/user-fields.inc.php" ); ?
    280331</div --> 
    281332 
    282 <%  
     333<?php  
    283334                }  
    284335                include( "$modules/footer.inc.php" ); 
     
    286337                echo bounceTo( $site . "/login?bounceToPage=" . urlencode( "account" )); 
    287338        } 
    288 %
     339?
  • feedmelinks/login.php

    r1269 r1349  
    1 <% 
     1<?php 
    22        # $Id$  
    33 
     
    4747                                                touch_user( $dbUserId ); 
    4848 
    49 %
    50 <div class="welcome">Welcome, <b><%= $userId %></b>!<br /> 
     49?
     50<div class="welcome">Welcome, <b><?= $userId ?></b>!<br /> 
    5151        <small> 
    5252                <small> 
     
    5858        </small> 
    5959</div> 
    60 <% 
     60<?php 
    6161                                        $shouldShowLoginForm = 0; 
    6262                                        $noFooter = true; 
     
    126126                                                $shouldShowLoginForm = 0; 
    127127                                                $shouldShowCreateForm = 0; 
     128 
     129 
     130                                                # function accepts: 
     131                                                # $argUserId, $argEmail, $argPassword, $argName, $argPostCode, $argIM, $argIMType, $argPostCode, $argIM, $argIMType  
     132 
    128133                                                $userAdded = addUser( $userId, $email, $password, "" ); 
    129134                                                if( $userAdded ) { 
     
    194199                        $mesg = "Dang. Login failed. Please double-check your username and password and try again, or email the <a href='mailto:" . get_spamsafe_email() . "'>admins</a> if you need help."; 
    195200        } 
    196 %
    197  
    198 <% include( "$modules/header.insecure.inc.php" ); %
    199  
    200 <% if( $shouldShowLoginForm || $shouldShowCreateForm ) { %
     201?
     202 
     203<?php include( "$modules/header.insecure.inc.php" ); ?
     204 
     205<?php if( $shouldShowLoginForm || $shouldShowCreateForm ) { ?
    201206<title> Feed me your password! </title> 
    202207</head> 
    203208<body onLoad="if( document.forms['login_form'] )  document.forms['login_form'].userId.focus();" > 
    204209<img src="img/login-logo.gif" /> 
    205 <% } %
    206  
    207 <% if( $shouldShowLoginForm ) { %
    208 <% include( "$modules/announce.inc.php" ); %
    209  
    210 <br /> 
    211 <form name="login_form" action="<%= $page %>" method="POST"> 
     210<?php } ?
     211 
     212<?php if( $shouldShowLoginForm ) { ?
     213<?php include( "$modules/announce.inc.php" ); ?
     214 
     215<br /> 
     216<form name="login_form" action="<?= $page ?>" method="POST"> 
    212217        <input type="hidden" name="op" value="login" /> 
    213         <input type="hidden" name="debug" value="<%= $debug %>" /> 
    214 <% if( $bounceToPage ) { %
    215 <input type="hidden" name="bounceToPage" value="<%= $bounceToPage %>" /> 
    216 <% } %
    217         <% if( $name || $url ) { %
     218        <input type="hidden" name="debug" value="<?= $debug ?>" /> 
     219<? if( $bounceToPage ) { ?
     220<input type="hidden" name="bounceToPage" value="<?= $bounceToPage ?>" /> 
     221<?php } ?
     222        <?php if( $name || $url ) { ?
    218223        <input type="hidden" name="passThroughURL" value="1" /> 
    219         <input type="hidden" name="name" value="<%= urlencode( $name ) %>" /> 
     224        <input type="hidden" name="name" value="<?= urlencode( $name ) ?>" /> 
    220225        <input type="hidden" name="loggedIn" value="wasnt" /> 
    221         <input type="hidden" name="url"  value="<%= urlencode( $url  ) %>" /> 
    222         <input type="hidden" name="ref"  value="<%= urlencode( $ref  ) %>" /> 
    223         <% } %
    224         <% if( $from ) { %
    225         <input type="hidden" name="from" value="<%= urlencode( $from ) %>" /> 
    226         <% } %
     226        <input type="hidden" name="url"  value="<?= urlencode( $url  ) ?>" /> 
     227        <input type="hidden" name="ref"  value="<?= urlencode( $ref  ) ?>" /> 
     228        <?php } ?
     229        <?php if( $from ) { ?
     230        <input type="hidden" name="from" value="<?= urlencode( $from ) ?>" /> 
     231        <?php } ?
    227232 
    228233        <div> 
    229234                <div style="float: left; margin-right: 1em;"> 
    230                        <% include_once( "$modules/mascot-image.inc.php" ); %
     235<?php include_once( "$modules/mascot-image.inc.php" ); ?
    231236                </div> 
    232237                <div style="float: right;"> 
    233238                        <table width="310" border="0"> 
    234239 
    235                                 <% if( $mesg ) { %
     240                                <?php if( $mesg ) { ?
    236241 
    237242                                <tr> 
    238243                                        <td colspan="2"> 
    239244                                                <div class="warning"> 
    240                                                 <b><%= $mesg %></b> 
     245                                                <b><?= $mesg ?></b> 
    241246                                                </div> 
    242247                                                <br /> 
     
    244249                                        </td> 
    245250                                </tr> 
    246                                 <% } %
     251                                <?php } ?
    247252 
    248253                                <tr> 
    249254                                        <td align="right"><b>Username</b>:</td> 
    250                                         <td><input name="userId" value="<%= $pass_user ? $pass_user : $userId %>" class="nfield" /></td> 
     255                                        <td><input name="userId" value="<?= $pass_user ? $pass_user : $userId ?>" class="nfield" /></td> 
    251256                                </tr> 
    252257                                <tr> 
    253258                                        <td align="right"><b>Password</b>:</td> 
    254                                         <td><input name="password" value="<%= $password %>" type="password" class="nfield" /></td> 
     259                                        <td><input name="password" value="<?= $password ?>" type="password" class="nfield" /></td> 
    255260                                </tr> 
    256261                                <tr> 
     
    259264                                                <input type="submit" class="button" value="Log In Now" /> 
    260265                                                or 
    261                                                 <input type="button" onClick="window.location='<%= $page %>?op=inputNewAccount';" class="button" value="Register" /> 
     266                                                <input type="button" onClick="window.location='<?= $page ?>?op=inputNewAccount';" class="button" value="Register" /> 
    262267                                        </td> 
    263268                                </tr> 
     
    275280<br /> 
    276281 
    277 <% } else if( $shouldShowCreateForm ) { 
     282<?php } else if( $shouldShowCreateForm ) { 
    278283        if( ! $errors )  
    279284                $mesg = "&nbsp;<h1>One-step signup</h1><br />"; 
    280 %
    281 <%= $mesg %
     285?
     286<?= $mesg ?
    282287<br /> 
    283288 
     
    324329</script> 
    325330 
    326 <%= $debug == 1 ? "<h1 style='color: red;'>* * * DEBUG IS ON * * *</h1>" : "" %
    327 <% if( $errors ) { %
     331<?= $debug == 1 ? "<h1 style='color: red;'>* * * DEBUG IS ON * * *</h1>" : "" ?
     332<?php if( $errors ) { ?
    328333 
    329334<div class="alert" style="margin-bottom: 15px;"> 
    330335        <h3>PLEASE CORRECT THE FOLLOWING:</h3> 
    331         <div class="warning"><%= $errors %></span> 
     336        <div class="warning"><?= $errors ?></span> 
    332337</div> 
    333338<br /> 
    334339 
    335 <% } %
    336  
    337 <form name="create_account_form" action="<%= $page %>" method="POST" onSubmit="return(validateForm(this));"> 
    338         <input type="hidden" name="debug" value="<%= $debug %>" /> 
     340<?php } ?
     341 
     342<form name="create_account_form" id="create_account_form" action="<?= $page ?>" method="POST" onSubmit="return(validateForm(this));"> 
     343        <input type="hidden" name="debug" value="<?= $debug ?>" /> 
    339344        <input type="hidden" name="op" value="createAccount" /> 
    340345        <input type="hidden" name="errors" value="" /> 
     
    342347        <tr> 
    343348                <td align="right">Pick a <b>user name</b>:</td> 
    344                 <td><input name="userId" maxlength="16" value="<%= $userId %>" class="text" /> 
     349                <td><input name="userId" maxlength="16" value="<?= $userId ?>" class="text" /> 
    345350                        <span class="subtle"> 
    346351                                (letters, numbers, underscores only) 
     
    350355        <tr> 
    351356                <td align="right">Enter your <b>email address</b>:</td> 
    352                 <td><input name="email" maxlength="48" value="<%= $email %>" 
     357                <td><input name="email" maxlength="48" value="<?= $email ?>" 
    353358                class="text" /> <span class="subtle">(we 
    354359                NEVER sell or share emails)</span></td> 
     
    356361        <tr> 
    357362                <td align="right">Pick a <b>password</b>:</td> 
    358                 <td><input name="password" value="<%= $password %>" type="password"  size="16" maxlength="16" class="text"/> 
     363                <td><input name="password" value="<?= $password ?>" type="password"  size="16" maxlength="16" class="text"/> 
    359364                        <span class="subtle"> 
    360365                                (16 letters or fewer) 
     
    364369        <tr> 
    365370                <td align="right">Re-type your password:</td> 
    366                 <td><input name="password2" value="<%= $password2 %>" type="password" size="16" maxlength="16" class="text" /> </td> 
     371                <td><input name="password2" value="<?= $password2 ?>" type="password" size="16" maxlength="16" class="text" /> </td> 
    367372        </tr> 
    368373        <tr> 
     
    373378        </tr> 
    374379</table> <br /> 
    375 </form> <% } %>  
    376  
    377 <%  
     380</form> <?php } ?>  
     381 
     382<?php  
    378383        $noXML = true; 
    379384        if( ! $noFooter ) 
    380385                include_once( "$modules/footer.inc.php" );  
    381 %
     386?
    382387 
    383388</body> </html> 
  • feedmelinks/modules/utils.inc.php

    r1348 r1349  
    66include_once( "env.inc.php" ); 
    77include( get_root() . "/modules/prep-cache.inc.php" ); 
     8 
     9function IM_address_is_validated( $user ) { 
     10        if( ! $user ) 
     11                return false; 
     12        return false; 
     13} 
     14function get_IM_address_for_user( $user ) { 
     15        if( ! $user ) 
     16                return ""; 
     17        return getFieldForUser( $user, "im" ); 
     18} 
    819 
    920function show_peeps_feed( $user ) { 
     
    29222933# this depends on the next being a closure: function is_banned( $u, $mesg ) { } 
    29232934 
    2924 function addUser( $argUserId, $argEmail, $argPassword, $argName ) { 
     2935function addUser( $argUserId, $argEmail, $argPassword, $argName, $argPostCode, $argIM, $argIMType, $argPostCode, $argIM, $argIMType ) { 
    29252936 
    29262937  # check to see if weve seen any new accounts from this IP recently 
     
    29382949  } 
    29392950 
    2940   $userId   = urlencode( $argUserId ); 
    2941   $email    = urlencode( $argEmail ); 
    2942   $password = urlencode( $argPassword ); 
    2943   $name     = urlencode( $argName ); 
    2944  
    2945   $qs = "INSERT INTO users VALUES(NULL,'$userId','$email', '$password', '$name','', 2, 1, NULL, now(), now());"; 
     2951  $userId    = urlencode( $argUserId ); 
     2952  $email     = urlencode( $argEmail ); 
     2953  $password  = urlencode( $argPassword ); 
     2954  $name      = urlencode( $argName ); 
     2955  $post_code = urlencode( $argPostCode ); 
     2956  $im        = urlencode( $argIM ); 
     2957  $im_type   = urlencode( $argIMType ); 
     2958 
     2959  $qs = "INSERT INTO users VALUES(NULL,'$userId','$email', '$password', '$name','', 2, 1, NULL, now(), now(), '$post_code', '$im', '$im_type' );"; 
    29462960 
    29472961  l( "new_user: $argUserId, $argEmail" ); 
  • feedmelinks/style/main.css

    r1307 r1349  
    374374        background-color: #EEEEEE; 
    375375} 
    376