Advertisement
Guest User

Untitled

a guest
Jun 11th, 2017
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.35 KB | None | 0 0
  1. diff --git a/server/lib/user.php b/server/lib/user.php
  2. old mode 100644
  3. new mode 100755
  4. index 064b4ea..efa1df3
  5. --- a/server/lib/user.php
  6. +++ b/server/lib/user.php
  7. @@ -68,6 +68,9 @@ class PersonaUser
  8. var $_privs = 0;
  9. var $_errors = array();
  10. var $_no_signup = 0;
  11. + var $_location = null;
  12. + var $_homepage = null;
  13. + var $_public_mail = 0;
  14.  
  15. function __construct($username = null, $password = null, $hostname = null, $dbname = null)
  16. {
  17. @@ -161,7 +164,7 @@ class PersonaUser
  18.  
  19. try
  20. {
  21. - $select_stmt = 'select username, display_username, email, privs, description from users where username = :username';
  22. + $select_stmt = 'select username, display_username, email, privs, description, location, homepage, public_mail from users where username = :username';
  23. $sth = $this->_dbh->prepare($select_stmt);
  24. $sth->bindParam(':username', $username);
  25. $sth->execute();
  26. @@ -245,6 +248,63 @@ class PersonaUser
  27. }
  28.  
  29. #####
  30. +# Get the users public email preference. If called without a username, uses the record of the authed user.
  31. +
  32. + function get_public_email($username = null)
  33. + {
  34. + if(!$username)
  35. + return $this->_public_mail;
  36. +
  37. + $data = $this->get_user_data($username);
  38. + return $data['public_mail'];
  39. + }
  40. +
  41. +#####
  42. +# Get the users location. If called without a username, uses the record of the authed user.
  43. +
  44. + function get_location($username = null)
  45. + {
  46. + if(!$username)
  47. + return $this->_location;
  48. +
  49. + $data = $this->get_user_data($username);
  50. + return $data['location'];
  51. + }
  52. +
  53. +#####
  54. +# Get the users homepage. If called without a username, uses the record of the authed user.
  55. +
  56. + function get_homepage($username = null)
  57. + {
  58. + if(!$username)
  59. + return $this->_homepage;
  60. +
  61. + $data = $this->get_user_data($username);
  62. + return $data['homepage'];
  63. + }
  64. +
  65. +#####
  66. +# Get the users picture. If the user doesn't have a picture, default_picture is shown
  67. +
  68. + function get_picture($username)
  69. + {
  70. + $user_picture = PERSONAS_STORAGE_PREFIX . "/user_pictures/" . $username . ".png";
  71. + if(!(file_exists($user_picture) && is_file($user_picture)))
  72. + return STATIC_BASE_URL.PERSONAS_LIVE_PREFIX . "/user_pictures/" . "default_picture.png";
  73. +
  74. + return STATIC_BASE_URL.PERSONAS_LIVE_PREFIX . "/user_pictures/" . $username . ".png";
  75. + }
  76. +
  77. +#####
  78. +# Resizes and moves the user picture
  79. +
  80. + function resize_picture($avatar_file, $username = null)
  81. + {
  82. + $conv_cmd = "convert " . $avatar_file . " -resize 150x150 " . PERSONAS_STORAGE_PREFIX . "/user_pictures/" . $username . ".png";
  83. + exec($conv_cmd);
  84. + }
  85. +
  86. +#####
  87. # Returns the contents of the error array, if anything has been written to it.
  88.  
  89. function get_errors()
  90. @@ -289,7 +349,7 @@ class PersonaUser
  91. #####
  92. # Adds a user to the database
  93.  
  94. - function create_user($username, $password, $display_username = null, $email = "", $description = "", $news = 0)
  95. + function create_user($username, $password, $display_username = null, $email = "", $description = "", $news = 0, $location = "", $homepage = "", $public_mail = 0)
  96. {
  97. if (!$username)
  98. throw new Exception("No username", 404);
  99. @@ -305,7 +365,7 @@ class PersonaUser
  100.  
  101. try
  102. {
  103. - $insert_stmt = 'insert into users (username, display_username, md5, email, description, news, privs) values (:username, :display_username, :md5, :email, :description, :news, 1)';
  104. + $insert_stmt = 'insert into users (username, display_username, md5, email, description, news, privs, location, homepage, public_mail) values (:username, :display_username, :md5, :email, :description, :news, 1, :location, :homepage, :public_mail)';
  105. $sth = $this->_dbh_master->prepare($insert_stmt);
  106. $sth->bindParam(':username', $username);
  107. $sth->bindParam(':display_username', $display_username);
  108. @@ -313,6 +373,9 @@ class PersonaUser
  109. $sth->bindParam(':email', $email);
  110. $sth->bindParam(':description', $description);
  111. $sth->bindParam(':news', $news);
  112. + $sth->bindParam(':location', $location);
  113. + $sth->bindParam(':homepage', $homepage);
  114. + $sth->bindParam(':public_mail', $public_mail);
  115. $sth->execute();
  116. }
  117. catch( PDOException $exception )
  118. @@ -328,6 +391,9 @@ class PersonaUser
  119. $this->_display_username = $display_username;
  120. $this->_description = $description;
  121. $this->_email = $email;
  122. + $this->_location = $location;
  123. + $this->_homepage = $homepage;
  124. + $this->_public_mail = $public_mail;
  125. $this->_cookie_value = $username . " " . md5($username . md5($password) . PERSONAS_LOGIN_SALT);
  126. setcookie('PERSONA_USER', $this->_cookie_value, time() + 60*60*24*365, '/');
  127.  
  128. @@ -349,7 +415,7 @@ class PersonaUser
  129.  
  130. try
  131. {
  132. - $insert_stmt = 'insert into users (username, display_username, md5, email, description, news, privs) values (:username, :display_username, "", "", "", 0, 0)';
  133. + $insert_stmt = 'insert into users (username, display_username, md5, email, description, news, privs, location, homepage, public_mail) values (:username, :display_username, "", "", "", 0, 0, "", "", 0)';
  134. $sth = $this->_dbh_master->prepare($insert_stmt);
  135. $sth->bindParam(':username', $username);
  136. $sth->bindParam(':display_username', $username);
  137. @@ -367,7 +433,7 @@ class PersonaUser
  138. #####
  139. # Updates a user record
  140.  
  141. - function update_user($username, $display_username = null, $email = "", $description = "", $news = 0)
  142. + function update_user($username, $display_username = null, $email = "", $description = "", $news = 0, $location = "", $homepage = "", $public_mail = 0)
  143. {
  144. if (!$username)
  145. throw new Exception("No username", 404);
  146. @@ -380,13 +446,16 @@ class PersonaUser
  147.  
  148. try
  149. {
  150. - $insert_stmt = 'update users set display_username = :display_username, email = :email, description = :description, news = :news where username = :username';
  151. + $insert_stmt = 'update users set display_username = :display_username, email = :email, description = :description, news = :news, location = :location, homepage = :homepage, public_mail = :public_mail where username = :username';
  152. $sth = $this->_dbh_master->prepare($insert_stmt);
  153. $sth->bindParam(':username', $username);
  154. $sth->bindParam(':display_username', $display_username);
  155. $sth->bindParam(':email', $email);
  156. $sth->bindParam(':description', $description);
  157. $sth->bindParam(':news', $news);
  158. + $sth->bindParam(':location', $location);
  159. + $sth->bindParam(':homepage', $homepage);
  160. + $sth->bindParam(':public_mail', $public_mail);
  161. $sth->execute();
  162. }
  163. catch( PDOException $exception )
  164. @@ -400,6 +469,9 @@ class PersonaUser
  165. $this->_email = $email;
  166. $this->_display_username = $display_username;
  167. $this->_description = $description;
  168. + $this->_location = $location;
  169. + $this->_homepage = $homepage;
  170. + $this->_public_mail = $public_mail;
  171.  
  172. if ($this->_memcache)
  173. $this->_memcache->delete('user:' . $username);
  174. @@ -532,6 +604,9 @@ class PersonaUser
  175. $this->_email = $result['email'];
  176. $this->_description = $result['description'];
  177. $this->_news = $result['news'];
  178. + $this->_location = $result['location'];
  179. + $this->_homepage = $result['homepage'];
  180. + $this->_public_mail = $result['public_mail'];
  181. return 1;
  182. }
  183. return 0;
  184. @@ -579,6 +654,9 @@ class PersonaUser
  185. $this->_email = $result['email'];
  186. $this->_description = $result['description'];
  187. $this->_news = $result['news'];
  188. + $this->_location = $result['location'];
  189. + $this->_homepage = $result['homepage'];
  190. + $this->_public_mail = $result['public_mail'];
  191. return 1;
  192. }
  193. return 0;
  194. diff --git a/server/profile.php b/server/profile.php
  195. index 32465dc..7d1791f 100755
  196. --- a/server/profile.php
  197. +++ b/server/profile.php
  198. @@ -24,10 +24,16 @@
  199. $create['description'] = array_key_exists('create_description', $_POST) ? (ini_get('magic_quotes_gpc') ? stripslashes($_POST['create_description']) : $_POST['create_description']) : null;
  200. $create['news'] = array_key_exists('news', $_POST);
  201. $create['display_username'] = trim($create['display_username']);
  202. + $create['location'] = array_key_exists('create_location', $_POST) ? (ini_get('magic_quotes_gpc') ? stripslashes($_POST['create_location']) : $_POST['create_location']) : null;
  203. + $create['homepage'] = array_key_exists('create_homepage', $_POST) ? (ini_get('magic_quotes_gpc') ? stripslashes($_POST['create_homepage']) : $_POST['create_homepage']) : null;
  204. + $create['public_mail'] = array_key_exists('public_mail', $_POST);
  205. + $create['picture'] = array_key_exists('picture', $_FILES);
  206.  
  207. $create['display_username'] = htmlspecialchars($create['display_username']);
  208. $create['description'] = htmlspecialchars($create['description']);
  209. $create['email'] = htmlspecialchars($create['email']);
  210. + $create['location'] = htmlspecialchars($create['location']);
  211. + $create['homepage'] = htmlspecialchars($create['homepage']);
  212.  
  213. if (!preg_match('/^[A-Z0-9\._%+-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}$/i', $create['email']))
  214. $_errors['create_email'] = _("Invalid email address");
  215. @@ -38,9 +44,24 @@
  216. if (strlen($create['description']) > 256)
  217. $_errors['create_description'] = _("Please limit your description to 256 characters or less");
  218.  
  219. - if (count($_errors) == 0 && $user->update_user($user->get_username(), $create['display_username'], $create['email'], $create['description'], $create['news']))
  220. + if (strlen($create['location']) > 32)
  221. + $_errors['create_location'] = _("Please limit your location to 32 characters or less");
  222. +
  223. + if (strlen($create['homepage']) > 32)
  224. + $_errors['create_homepage'] = _("Please limit your homepage to 32 characters or less");
  225. +
  226. + if ($_FILES['picture']['size'] > 307200)
  227. + $_errors['create_picture'] = _("Please limit your profile picture file size to 300K");
  228. +
  229. + $img_identify_cmd = "identify -format \"%m\" ";
  230. + $picture_ftype = exec($img_identify_cmd . $_FILES['picture']['tmp_name']);
  231. + if (!($picture_ftype == 'JPEG' || $picture_ftype == 'PNG'))
  232. + $_errors['create_picture'] = sprintf(/*L10N: %s is an email address*/_("We do not recognize the format of your profile picture. Please let us know at %s if you think this is in error."), 'persona-devel@mozilla.com');
  233. +
  234. + if (count($_errors) == 0 && $user->update_user($user->get_username(), $create['display_username'], $create['email'], $create['description'], $create['news'], $create['location'], $create['homepage'], $create['public_mail']))
  235. {
  236. $db->update_display_username($user->get_username(), $create['display_username']);
  237. + $user->resize_picture($_FILES['picture']['tmp_name'], $user->get_username());
  238. $updated = 1;
  239. }
  240. }
  241. @@ -50,6 +71,9 @@
  242. $create['display_username'] = $user->_display_username;
  243. $create['description'] = $user->_description;
  244. $create['news'] = $user->_news;
  245. + $create['location'] = $user->_location;
  246. + $create['homepage'] = $user->_homepage;
  247. + $create['public_mail'] = $user->_public_mail;
  248. }
  249.  
  250. $title = _("Change User Details");
  251. diff --git a/server/templates/change_user_details.php b/server/templates/change_user_details.php
  252. old mode 100644
  253. new mode 100755
  254. index 22ad46b..97dbaa6
  255. --- a/server/templates/change_user_details.php
  256. +++ b/server/templates/change_user_details.php
  257. @@ -1,6 +1,6 @@
  258. <div id="signup">
  259. <h4><?= _("Change User Details");?></h3>
  260. - <form action="profile" method="post">
  261. + <form action="profile" method="post" enctype="multipart/form-data">
  262. <input type="hidden" name="update" value="1">
  263. <p><label for="username"><?=_("Login Name:");?> <?= $user->get_username() ?></label>
  264.  
  265. @@ -11,19 +11,40 @@
  266. <?php if (array_key_exists('create_email', $_errors)) echo '<span class="error-message">' . $_errors['create_email'] . '</span>' ?>
  267. </p>
  268.  
  269. - <p><label for="username"><?= _("Display Username");?>*</label>
  270. + <p><label for="username"><?= _("Display Username (optional)");?></label>
  271. <input type="text" name="create_display_username" value="<?= $create['display_username'] ?>" id="" <?php if (array_key_exists('create_display_username', $_errors)) echo 'class="error"' ?>/>
  272. <?php if (array_key_exists('create_display_username', $_errors)) echo '<span class="error-message">' . $_errors['create_display_username'] . '</span>' ?>
  273. </p>
  274.  
  275. <p>
  276. - <label for="description"><?=_("User Description");?>*</label>
  277. + <label for="description"><?=_("Bio (optional)");?></label>
  278. <textarea name="create_description" id="create_description" <?php if (array_key_exists('create_description', $_errors)) echo 'class="error"' ?> ><?= $create['description'] ?></textarea>
  279. <?php if (array_key_exists('create_description', $_errors)) echo '<span class="error-message">' . $_errors['create_description'] . '</span>' ?>
  280. </p>
  281.  
  282. + <p>
  283. + <label for="location"><?= _("Location (optional)");?></label>
  284. + <input type="text" name="create_location" value="<?= $create['location'] ?>" id="" <?php if (array_key_exists('create_location', $_errors)) echo 'class="error"' ?>/>
  285. + <?php if (array_key_exists('create_location', $_errors)) echo '<span class="error-message">' . $_errors['create_location'] . '</span' ?>
  286. + </p>
  287. +
  288. + <p>
  289. + <label for="homepage"><?= _("Homepage (optional)");?></label>
  290. + <input type="text" name="create_homepage" value="<?= $create['homepage'] ?>" id="" <?php if (array_key_exists('create_homepage', $_errors)) echo 'class="error"' ?>/>
  291. + <?php if (array_key_exists('create_homepage', $_errors)) echo '<span class="error-message">' . $_errors['create_homepage'] . '</span' ?>
  292. + </p>
  293. +
  294. + <p>
  295. + <label for="public_mail"><input type="checkbox" name="public_mail" id="public_mail" value="" <?= $create['public_mail'] ? "checked" : "" ?>/> <?=_("Publicly display my email address (optional)");?></label>
  296. + </p>
  297. +
  298. + <p>
  299. + <label for="picture"><?= _("Picture (optional)");?></label>
  300. + <span><input type="file" name="picture" value="" id="picture" <?php if (array_key_exists('create_picture', $_errors)) echo 'class="error"' ?>/></span>
  301. + <?php echo $_errors['create_picture'];?>
  302. + </p>
  303. +
  304. <p class="news"><label for="news"><input type="checkbox" name="news" id="news" value="" <?= $create['news'] ? "checked" : "" ?>/> <?=_("I'd like to receive news and information about Personas");?></label></p>
  305. - <p>* <i><?=_("denotes an optional field. These entries will be displayed in the personas gallery.");?></i></p>
  306. <button type="submit" class="button"><span><?=_("change");?></span><span class="arrow"></span></button>
  307. </form>
  308. </div>
  309. diff --git a/server/templates/gallery.php b/server/templates/gallery.php
  310. old mode 100644
  311. new mode 100755
  312. index 27ba53b..b50adb9
  313. --- a/server/templates/gallery.php
  314. +++ b/server/templates/gallery.php
  315. @@ -6,16 +6,64 @@
  316. <div id="inner-wrapper">
  317. <?php include 'nav.php'; ?>
  318. <?php
  319. - if (!($category == 'Designer' && $header_text = $user->get_description($tab)))
  320. - {
  321. $header_text = _("Your browser, your style! Dress it up with easy-to-use themes for your Firefox.");
  322. - }
  323. ?>
  324. <div id="header">
  325. <h2><?= htmlentities($page_header, ENT_QUOTES, 'UTF-8', false) ?></h2>
  326. <h3><?= $header_text ?></h3>
  327. </div>
  328. <div id="maincontent">
  329. +<?php
  330. + if ($category == 'Designer')
  331. + { ?>
  332. + <div class="featured">
  333. + <div class="featured-inner object-lead">
  334. + <h3><?php printf(/*L10N: %s is the author name*/_("About %s") , $tab); ?></h3>
  335. + <img class="avatar thumbnail" src="<?= $user->get_picture($tab); ?>" alt="">
  336. + <div class="user-info">
  337. + <?php if ($tab == $user->get_unauthed_username()) { ?>
  338. + <p class="edit-profile"><?printf("<a href=\"%s\">" . _("Edit my info") . "</a>", $locale_conf->url('/profile'));?></p>
  339. + <?php } ?>
  340. + <div>
  341. + <table class="designerinfo" summary="Designer Information">
  342. + <tbody>
  343. + <tr>
  344. + <th><?= _("Name");?></th>
  345. + <td><?= $display_username;?></td>
  346. + </tr>
  347. + <?php if($user->get_public_email($tab)) { ?>
  348. + <tr>
  349. + <th><?= _("Email");?></th>
  350. + <td><?printf("<a href=\"mailto://%s\">" .$user->get_email($tab) . "</a>", $user->get_email($tab));?></td>
  351. + </tr>
  352. + <?php } ?>
  353. + <?php if($user->get_location($tab)) { ?>
  354. + <tr>
  355. + <th><?= _("Location");?></th>
  356. + <td><?= $user->get_location($tab);?></td>
  357. + </tr>
  358. + <?php } ?>
  359. + <?php if($user->get_homepage($tab)) {
  360. + $homepage = preg_replace('/(https?\:\/\/[^ ]+[A-Za-z0-9\/])/e', '"<a href=\"".external_link(\'\\1\')."\">\\1</a>"', $user->get_homepage($tab)); ?>
  361. + <tr>
  362. + <th><?= _("Homepage");?></th>
  363. + <td><?= $homepage ?></td>
  364. + </tr>
  365. + <?php } ?>
  366. + <?php if($user->get_description($tab)) { ?>
  367. + <tr>
  368. + <th><?= _("Bio");?></th>
  369. + <td><?= $user->get_description($tab);?>
  370. + </tr>
  371. + <?php } ?>
  372. + </tbody>
  373. + </table>
  374. + </div>
  375. + </div>
  376. + </div>
  377. + </div>
  378. +
  379. +<?php } ?>
  380. <div id="gallery">
  381. <?php
  382.  
  383. diff --git a/static/css/style.css b/static/css/style.css
  384. old mode 100644
  385. new mode 100755
  386. index fc08eb7..6d85ac8
  387. --- a/static/css/style.css
  388. +++ b/static/css/style.css
  389. @@ -153,7 +153,7 @@ h4.section {
  390. clear: both;
  391. }
  392.  
  393. -#inner-wrapper:after, #nav ul:after, .mini-gallery:after{
  394. +#inner-wrapper:after, #nav ul:after, .mini-gallery:after .featured:after{
  395. content: '.';
  396. display: block;
  397. clear: both;
  398. @@ -2492,3 +2492,63 @@ div#gsfn_list_widget div#gsfn_content li { text-align:left; margin-bottom:6px; m
  399. div#gsfn_list_widget div#gsfn_content a.gsfn_link { line-height: 1; }
  400. div#gsfn_list_widget div#gsfn_content span.time { font-size: 90%; padding-left: 3px; }
  401. div#gsfn_list_widget div#gsfn_content p.gsfn_summary { margin-top: 2px }
  402. +
  403. +.featured {
  404. + -moz-border-radius: 5px 5px 5px 5px;
  405. + background-color: #B5D9E5;
  406. + border: 4px solid #B5D9E5;
  407. + clear: both;
  408. + margin-bottom: 2em;
  409. +}
  410. +
  411. +.object-lead {
  412. + margin: 0;
  413. + padding: 1em;
  414. + position: relative;
  415. +}
  416. +
  417. +.object-lead h3 {
  418. + margin-top: 0;
  419. +}
  420. +
  421. +.object-lead img.avatar {
  422. + border: 3px solid #C8E8F3;
  423. + float: left;
  424. + margin: 0 15px 15px 0;
  425. + margin-right: 1em;
  426. +}
  427. +
  428. +.object-lead .edit-profile {
  429. + font-size: 0.846em;
  430. + padding: 0.3em 1.18em 0.3em 35px;
  431. + position: absolute;
  432. + right: 0;
  433. + top: 1em;
  434. +}
  435. +
  436. +.object-lead table {
  437. + margin-top: 1em;
  438. + width: 100%;
  439. +}
  440. +
  441. +.object-lead table, .object-lead tbody {
  442. + border-bottom: medium none;
  443. + border-top: medium none;
  444. +}
  445. +
  446. +.object-lead table tr th {
  447. + border-bottom: medium none;
  448. + color: #444444;
  449. + background: #FFFFFF;
  450. + font-weight: bold;
  451. +}
  452. +
  453. +.featured-inner {
  454. + -moz-border-radius: 3px 3px 3px 3px;
  455. + background-color: #FFFFFF;
  456. + border: 1px solid #2E5186;
  457. +}
  458. +
  459. +.object-content {
  460. + margin-left: 220px;
  461. +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement