[Astrospaces-commits] SF.net SVN: astrospaces: [12] trunk
Brought to you by:
p3net
From: <p3...@us...> - 2007-03-18 22:09:41
|
Revision: 12 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=12&view=rev Author: p3net Date: 2007-03-17 12:55:05 -0700 (Sat, 17 Mar 2007) Log Message: ----------- -Rename edit_profile.tpl by accident :D -Create editprofile script (processor) --Upload icons included! -Edit TODO -Hope everything works... Modified Paths: -------------- trunk/TODO.txt trunk/includes/profile.php trunk/profile.php Added Paths: ----------- trunk/styles/default/editprofile.tpl Removed Paths: ------------- trunk/styles/default/edit_profile.tpl Modified: trunk/TODO.txt =================================================================== --- trunk/TODO.txt 2007-03-17 16:46:30 UTC (rev 11) +++ trunk/TODO.txt 2007-03-17 19:55:05 UTC (rev 12) @@ -1,4 +1,6 @@ TODO: --Edit space.tpl after we have all of our functions done (add comment, send PM, add friend, etc) ---Make edit_profile.tpl (see includes/profile.php for the variables) \ No newline at end of file +--Add as friend function +--Comment function +--PM function \ No newline at end of file Modified: trunk/includes/profile.php =================================================================== --- trunk/includes/profile.php 2007-03-17 16:46:30 UTC (rev 11) +++ trunk/includes/profile.php 2007-03-17 19:55:05 UTC (rev 12) @@ -142,10 +142,11 @@ $_query=$db->array($_query); //Time to TPL assign! - $page =& new template('edit_profile.tpl'); + $page =& new template('editprofile.tpl'); $outer =& new template('outer.tpl'); $page->set('username', $_query["username"]); + $page->set('headline', $_query["headline"]); $page->set('aim', $_query["aim"]); $page->set('msn', $_query["msn"]); $page->set('irc', $_query["irc"]); @@ -153,6 +154,10 @@ $page->set('yahoo', $_query["yahoo"]); $page->set('website', $_query["website"]); $page->set('theme', $_query["themes"]); + $page->set('space_left', $_query["space_left"]); + $page->set('space_right', $_query["space_right"]); + $page->set('icon', $_query["icon"]); + $page->set('id', $_query["id"]); //Theme list $_themes="SELECT * FROM " . DB_THEMES; @@ -167,5 +172,85 @@ $outer->set('content', $page); } + function update($var, $_FILES) + { + //Are we logged in? + if(!logged_in()) + { + redirect('?mode=login'); + } + //Are we updating our space? + if(SESSION_ID != $var["id"]) + { + die("Hacking attempt"); + } + //Before we do anything, we need to move our icon + //if we updated it. We are going to set every + //new icon as our default image, but we can + //change that later... + + if(!(empty($_FILES) && preg_match("/^image/", $_FILES['uploadedfile']['type'])) + { + $target_path="../uploads/"; + + $ext=substr(basename($_FILES['uploadedfile']['tmpname'], strrpos($_FILES['uploadedfile']['tmpname'], '.') + 1); + $name=rand(1,100000000); + $name .= "." . $ext; + + $target_path = $target_path . $name); + if(!move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) + { + die("Icon could not be uploaded"); + } + } + + $update["user"]["fields"]=array( + 'username', + 'headline', + 'aim', + 'msn', + 'irc', + 'icq', + 'website', + 'yahoo', + 'theme', + 'icon'); + $update["space"]["fields"]=array( + 'space_left', + 'space_right'); + + $update["user"]["values"]=array( + $var["username"], + $var["headline"], + $var["aim"], + $var["msn"], + $var["irc"], + $var["icq"], + $var["yahoo"], + $var["website"], + $var["theme"]); + if(!(empty($_FILES["uploadedfile"]["tmpname"]))) $update["users"]["values"][]=$name; + + $update["space"]["fields"]=array( + $var["space_left"], + $var["space_right"]); + + $i=0; + for($i, $i<count($update["users"]["values"]), $i++) + { + $_query .= "UPDATE " . DB_USERS . " SET `" . $update["users"]["fields"][$i] . + "`='" . $update["users"]["values"][$i] . "' WHERE `id`='" . $var["id"] . + " LIMIT 1;"; + } + $i=0; + for($i, $i<count($update["space"]["fields"]), $i++) + { + $_query .= "UPDATE " . DB_SPACE . " SET `" . $update["space"]["fields"][$i] . + "`='" . $update["space"]["values"][$i] . "' WHERE `id`='" . $var["id"] . + " LIMIT 1;"; + } + $db->query($_query); + thankyou("updating your profile", "to your space", "space.php"); + } } ?> \ No newline at end of file Modified: trunk/profile.php =================================================================== --- trunk/profile.php 2007-03-17 16:46:30 UTC (rev 11) +++ trunk/profile.php 2007-03-17 19:55:05 UTC (rev 12) @@ -62,5 +62,8 @@ case 'edit': $profile->edit(); break; + case 'update': + $profile->update($_POST, $_FILES); + break; } ?> \ No newline at end of file Deleted: trunk/styles/default/edit_profile.tpl =================================================================== Added: trunk/styles/default/editprofile.tpl =================================================================== --- trunk/styles/default/editprofile.tpl (rev 0) +++ trunk/styles/default/editprofile.tpl 2007-03-17 19:55:05 UTC (rev 12) @@ -0,0 +1,25 @@ +<form action="?mode=update" method="post"> +<input type="hidden" name="id" value="<?php echo $id; ?>"> +Username: <input type="text" name="username" value="<?php echo $username; ?>"><br> +Headline: <input type="text" name="headline" value="<?php echo $headline; ?>"><br> +AIM: <input type="text" name="aim" value="<?php echo $aim; ?>"><br> +MSN: <input type="text" name="msn" value="<?php echo $msn; ?>"><br> +IRC: <input type="text" name="irc" value="<?php echo $irc; ?>"><br> +ICQ: <input type="text" name="icq" value="<?php echo $icq; ?>"><br> +Yahoo!: <input type="text" name="yahoo" value="<?php echo $yahoo; ?>"><br> +Website: <input type="text" name="website" value="<?php echo $website; ?>"><br> +Theme: <select name="theme"> + <?php + foreach($themes as $theme_arr) + { + $selected = ($theme == $theme_arr) : 'selected="selected"' ? ''; + echo "<option name=\"" . $theme_arr . "\" " . $selected . ">" . $theme_arr . "</option>"; + } + ?> + </select> +<br> +Space (Left): <textarea rows="6" cols="60"><?php echo $space_left; ?></textarea><br> +Space (Right): <textarea rows="60" cols="60"><?php echo $space_right; ?></textarea><br> +<input type="hidden" name="MAX_FILE_SIZE" value="100000"> +Upload an Icon: <input type="file" name="uploadedfile"><br> +<input type="submit" value="Update"></form> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |