Guest User

Untitled

a guest
Apr 9th, 2013
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 27.83 KB | None | 0 0
  1.  <?php
  2. /* ############################################################ *\
  3. Copyright (C) 2009 - 2010 jcow.net.  All Rights Reserved.
  4. ------------------------------------------------------------------------
  5. The contents of this file are subject to the Common Public Attribution
  6. License Version 1.0. (the "License"); you may not use this file except in
  7. compliance with the License. You may obtain a copy of the License at
  8. http://www.jcow.net/celicense. The License is based on the Mozilla Public
  9. License Version 1.1, but Sections 14 and 15 have been added to cover use of
  10. software over a computer network and provide for limited attribution for the
  11. Original Developer. In addition, Exhibit A has been modified to be consistent
  12. with Exhibit B.
  13.  
  14. Software distributed under the License is distributed on an "AS IS" basis,
  15. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  16. the specific language governing rights and limitations under the License.
  17. ------------------------------------------------------------------------
  18. The Original Code is Jcow.
  19.  
  20. The Original Developer is the Initial Developer.  The Initial Developer of the
  21. Original Code is jcow.net.
  22.  
  23. \* ############################################################ */
  24. class member {
  25.     function login($need_login = 0, $iid = 0) {
  26.         global $db, $nav, $client, $config, $captcha;
  27.         $atempts = get_tmp($togkey);
  28.         if (!$atempts) $atempts = 0;
  29.         set_title('Log In');
  30.         if ($client['id']) redirect('dashboard');
  31.         if ($need_login) sys_notice(t('You need to login to do this'));
  32.         $nav[] = url('member/login', 'Login');
  33.         section_content('
  34. <script language="javascript" >
  35.            $(document).ready( function(){
  36.                                $("#recaptcha_response_field").attr("tabindex",4);
  37.        });
  38.                                </script>
  39. <form method="post" name="form1" id="form1" action="' . url('member/loginpost') . '" >
  40.                                <table>
  41.                                <tr>
  42.                                <td align="right" valign="top">
  43.                                ' . t('Username or Email') . ':</td><td>
  44.                                <input type="text" size="10" name="username" style="width:120px" value="' . h($_POST['username']) . '" tabindex=1 /><div class="sub">' . url('member/signup', t('Register an account')) . '</div></td>
  45.                                </tr>
  46.                                <tr>
  47.                                <td align="right" valign="top">
  48.                                ' . t('Password') . ':</td><td>
  49.                                <input type="password" size="10" name="password" style="width:120px"  value="' . h($_POST['password']) . '" tabindex=2 />
  50.                                <div class="sub">' . url('member/chpass', t('Forgot password?')) . '</div></td>
  51.                                </tr>
  52.                                </table>                            
  53.                                ');
  54.         if ($atempts > 3) {
  55.             c(recaptcha_get_html($captcha['publickey'], ''));
  56.         }
  57.         c('
  58.                                <p>
  59.                                ( <input type="checkbox" name="remember_me" value="1" ' . $remember_check . ' tabindex=4 /> ' . t('Remember me') . ' )
  60.                                <input type="submit" value="' . t('Login') . '" tabindex=5 />
  61.                                ' . $bakg . '
  62.                                <br />
  63.                                </p>
  64.                                </form>
  65.                                <script language="javascript" >
  66.                    document.form1.username.focus();
  67.                    </script>
  68.            ');
  69.         section_close(t('Log in'));
  70.     }
  71.     function loginpost() {
  72.         global $db, $client, $ss, $ubase, $sid, $captcha;
  73.         if ($client['id']) redirect('dashboard');
  74.         $togkey = 'login' . $client['ip'];
  75.         $atempts = get_tmp($togkey);
  76.         if (!$atempts) $atempts = 0;
  77.         if ($atempts > 3) {
  78.             if ($_POST["recaptcha_challenge_field"]) {
  79.                 $resp = recaptcha_check_answer($captcha['privatekey'], $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
  80.                 if (!$resp->is_valid) {
  81.                     c('<script language="javascript" >
  82.                $(document).ready( function(){
  83.                                    $("#recaptcha_response_field").focus();
  84.            });
  85.                                    </script>');
  86.                     $captchaerror = $resp->error;
  87.                     $hold = 1;
  88.                 }
  89.             } else {
  90.                 c('<script language="javascript" >
  91.                $(document).ready( function(){
  92.                                    $("#recaptcha_response_field").focus();
  93.            });
  94.                                    </script>');
  95.                 $hold = 1;
  96.             }
  97.         }
  98.         if (!$hold) {
  99.             $password = md5($_POST['password'] . 'jcow');
  100.             $res = sql_query("select * from `" . tb() . "accounts` where  (email='" . $_POST['username'] . "' or username='" . $_POST['username'] . "') and password='$password'  limit 1");
  101.             if (sql_counts($res)) {
  102.                 $newss = get_rand(12);
  103.                 $row = sql_fetch_array($res);
  104.                 if ($_POST['remember_me']) {
  105.                     sql_query("UPDATE `" . tb() . "accounts` SET jcowsess='$newss' WHERE id='{$row['id']}' ");
  106.                     setcookie('jcowss', $newss, time() + 3600 * 24 * 365, "/");
  107.                     setcookie('jcowuid', $row['id'], time() + 3600 * 24 * 365, "/");
  108.                 }
  109.                 $_SESSION['uid'] = $row['id'];
  110.                 set_tmp($togkey, 'deleteit');
  111.                 redirect(url('dashboard'));
  112.                 exit;
  113.             } else {
  114.                 $atempts++;
  115.                 $_SESSION['login_cd']--;
  116.                 set_tmp($togkey, $atempts);
  117.                 sys_notice(t('Wrong account or password'));
  118.             }
  119.         }
  120.         set_title('Login');
  121.         if ($_POST['remember_me']) {
  122.             $remember_check = 'checked';
  123.         }
  124.         section_content('
  125.            <script language="javascript" >
  126.            $(document).ready( function(){
  127.                                $("#recaptcha_response_field").attr("tabindex",3);
  128.        });
  129.                                </script>
  130.            <form method="post" name="form1" id="form1" action="' . url('member/loginpost') . '" >
  131.                                <table>
  132.                                <tr>
  133.                                <td align="right" valign="top">
  134.                                ' . t('Username or Email') . ':</td><td>
  135.                                <input type="text" size="10" name="username" style="width:120px" value="' . h($_POST['username']) . '" tabindex=1 /><div class="sub">' . url('member/signup', t('Register an account')) . '</div></td>
  136.                                </tr>
  137.                                <tr>
  138.                                <td align="right" valign="top">
  139.                                ' . t('Password') . ':</td><td>
  140.                                <input type="password" size="10" name="password" style="width:120px"  value="' . h($_POST['password']) . '" tabindex=2 />
  141.                                <div class="sub">' . url('member/chpass', t('Forgot password?')) . '</div></td>
  142.                                </tr>
  143.                                </table>                            
  144.                                ');
  145.         if ($atempts > 3) {
  146.             c(recaptcha_get_html($captcha['publickey'], $captchaerror));
  147.         }
  148.         c('
  149.                                <p>
  150.                                ( <input type="checkbox" name="remember_me" value="1" ' . $remember_check . ' tabindex=4 /> ' . t('Remember me') . ' )
  151.                                <input type="submit" value="' . t('Login') . '" tabindex=5 />
  152.                                ' . $bakg . '
  153.                                <br />
  154.                                </p>
  155.                                </form>
  156.                        ');
  157.         section_close(t('Log in'));
  158.     }
  159.     function logout() {
  160.         global $content, $db, $nav, $sid, $client, $ss, $ubase, $config;
  161.         if ($client['id']) {
  162.             $hooks = check_hooks('logout');
  163.             if ($hooks) {
  164.                 foreach($hooks as $hook) {
  165.                     $hook_func = $hook . '_logout';
  166.                     $hook_func();
  167.                 }
  168.             }
  169.             $_SESSION['uid'] = 0;
  170.             setcookie('jcowuid', '', time() + 3600 * 24 * 365, "/");
  171.             setcookie('jcowss', '', time() + 3600 * 24 * 365, "/");
  172.             redirect(uhome());
  173.         }
  174.         redirect(uhome());
  175.     }
  176.     function chpass() {
  177.         global $client;
  178.         if ($client['id']) {
  179.             die('already logged in');
  180.         }
  181.         c('<h2>' . t('Get back my password') . '</h2>
  182.        <form method="post" name="form1" action="' . url('member/chpasspost') . '" >
  183.                    <p>
  184.                    ' . label(t('Email')) . '
  185.                    <input type="text" name="email" />
  186.                    <div class="sub">' . t('The email address you registered with') . '</div>
  187.                    </p>
  188.                    <p>
  189.                    <input class="button" type="submit" value="' . t('Submit') . '" />
  190.                    </p>
  191.                    </form>
  192.                    <script language="javascript" >
  193.                    document.form1.email.focus();
  194.                    </script>');
  195.     }
  196.     function chpasspost() {
  197.         if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) {
  198.             sys_back(t('Unavailable email address'));
  199.         }
  200.         $res = sql_query("select * from `" . tb() . "accounts` where email='{$_POST['email']}'");
  201.         $row = sql_fetch_array($res);
  202.         if (!$row['id']) {
  203.             sys_back(t('No user registered with this email'));
  204.         }
  205.         $code = get_rand(10);
  206.         sql_query("update `" . tb() . "accounts` set chpass='$code' where id={$row['id']}");
  207.         $link = url('member/chpassdo/' . $code, t('Click Here'));
  208.         jcow_mail($_POST['email'], t('Get your password'), $link);
  209.         c(t('A verification email has been sent to you, please check your email inbox'));
  210.     }
  211.     function chpassdo($code = '') {
  212.         if (!eregi("^[0-9a-z]+", $code)) die('not a valid code');
  213.         $res = sql_query("select * from `" . tb() . "accounts` where chpass='{$code}'");
  214.         $user = sql_fetch_array($res);
  215.         if (!sql_counts($res)) die('wrong code');
  216.         c('<form method="post" name="form1" action="' . url('member/chpassdopost') . '" >
  217.                    <p>
  218.                    ' . label(t('Pick a new password')) . '
  219.                    <input type="password" name="password" />
  220.                    </p>
  221.                    <p>
  222.                    <input type="hidden" name="passcode" value="' . $code . '" />
  223.                    <input type="hidden" name="id" value="' . $user['id'] . '" />
  224.                    <input class="button" type="submit" value="' . t('Submit') . '" />
  225.                    </p>
  226.                    </form>');
  227.     }
  228.     function chpassdopost() {
  229.         $code = $_POST['passcode'];
  230.         if (!eregi("^[0-9a-z]+", $code)) die('not a valid code');
  231.         $res = sql_query("select * from `" . tb() . "accounts` where chpass='{$code}'");
  232.         if (!sql_counts($res)) die('wrong code');
  233.         $newpass = md5($_POST['password'] . 'jcow');
  234.         sql_query("update " . tb() . "accounts set chpass='',password='$newpass' where id='{$_POST['id']}' and chpass='{$code}'");
  235.         redirect('member/login', t('Your password has been changed'));
  236.     }
  237.     function signup($iid) {
  238.         global $db, $client, $uhome, $config, $captcha;
  239.         if ($_POST['onpost']) {
  240.             if ($_POST['iid']) {
  241.                 $res = sql_query("select * from " . tb() . "invites where id='{$_POST['iid']}'");
  242.                 $invite = sql_fetch_array($res);
  243.                 if ($invite['id']) {
  244.                     if ($hold) {
  245.                         $hold = 0;
  246.                         if ($invite['email'] != $_POST['email']) {
  247.                             $errors[] = t('You must use the Email address from which you received the invitation');
  248.                         }
  249.                     }
  250.                 }
  251.             }
  252.             if ($hold) {
  253.                 die('<p>' . t('Only invited people can Sign up this network. If you are invited, please click the link in the inviting email.') . '</p>');
  254.             }
  255.             $resp = recaptcha_check_answer($captcha['privatekey'], $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
  256.             if (!$resp->is_valid) {
  257.                 $captchaerror = $resp->error;
  258.                 $errors[] = t('Wrong Verification code');
  259.             }
  260.             if (!$_POST['agree_rules']) {
  261.                 $errors[] = t('You must agree to our rules for signing up');
  262.             }
  263.             //get_r(array('username','password','password2','email','agree','confirm_code','location'));
  264.             if (strtolower($_COOKIE['cfm']) != strtolower($_POST['confirm_code'])) {
  265.                 $errors[] = t('The string you entered for the code verification did not match what was displayed');
  266.             }
  267.             $_POST['username'] = strtolower($_POST['username']);
  268.             if (strlen($_POST['username']) < 4 || strlen($_POST['username']) > 18 || !ereg("^[0-9a-z]+$", $_POST['username'])) {
  269.                 $errors[] = t('Username') . ': ' . t('from 4 to 18 characters, only 0-9,a-z');
  270.             }
  271.             if (ereg('<', $_POST['fullname'])) {
  272.                 $errors[] = 'Unavailable Full name format';
  273.             }
  274.             if (!$_POST['email'] || !$_POST['fullname'] || !$_POST['username']) {
  275.                 $errors[] = t('Please fill in all the required blanks');
  276.             } else {
  277.                 for ($i = 1;$i <= 7;$i++) {
  278.                     $col = 'var' . $i;
  279.                     $key = 'cf_var' . $i;
  280.                     $key2 = 'cf_var_value' . $i;
  281.                     $key3 = 'cf_var_des' . $i;
  282.                     $key4 = 'cf_var_label' . $i;
  283.                     $key5 = 'cf_var_required' . $i;
  284.                     $ctype = get_gvar($key);
  285.                     if ($ctype != 'disabled' && get_gvar($key5)) {
  286.                         if (!strlen($_POST[$col])) {
  287.                             $errors[] = t('Please fill in all the required blanks');
  288.                         }
  289.                     }
  290.                 }
  291.             }
  292.             if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) {
  293.                 $errors[] = t('Unavailable email address');
  294.             }
  295.             $password = md5($_POST['password'] . 'jcow');
  296.             $timeline = time();
  297.             $res = sql_query("select * from `" . tb() . "accounts` where email='{$_POST['email']}'");
  298.             if (sql_counts($res)) {
  299.                 $errors[] = t('You have registered with this email address before.');
  300.             }
  301.             $res = sql_query("select * from `" . tb() . "accounts` where username='{$_POST['username']}'");
  302.             if (sql_counts($res)) {
  303.                 $errors[] = t('The Username has already been used');
  304.             }
  305.             if (!is_array($errors)) {
  306.                 $reg_code = '';
  307.                 $verify_note = '';
  308.                 // member
  309.                 if ($_POST['hide_age']) {
  310.                     $hide_age = 1;
  311.                 } else {
  312.                     $hide_age = 0;
  313.                 }
  314.                 $newss = get_rand(12);
  315.                 if (get_gvar('pm_enabled')) {
  316.                     $member_disabled = 1;
  317.                 } else {
  318.                     $member_disabled = 0;
  319.                 }
  320.                 sql_query("insert into `" . tb() . "accounts` (about_me,disabled,gender,location,birthyear,birthmonth,birthday,hide_age,password,email,username,fullname,created,lastlogin,ipaddress,var1,var2,var3,var4,var5,var6,var7,reg_code) values('{$_POST['about_me']}',$member_disabled,'{$_POST['gender']}','{$_POST['location']}','{$_POST['birthyear']}','{$_POST['birthmonth']}','{$_POST['birthday']}','{$hide_age}','$password','" . $_POST['email'] . "','{$_POST['username']}','{$_POST['fullname']}',$timeline,$timeline,'{$client['ip']}','{$_POST['var1']}','{$_POST['var2']}','{$_POST['var3']}','{$_POST['var4']}','{$_POST['var5']}','{$_POST['var6']}','{$_POST['var7']}','{$reg_code}')");
  321.                 $uid = insert_id();
  322.                 if ($uid == 1) {
  323.                     sql_query("update " . tb() . "accounts set roles='3' where id='$uid'");
  324.                 }
  325.                 sql_query("insert into `" . tb() . "pages` (uid,uri,type) values($uid,'{$_POST['username']}','u')");
  326.                 $page_id = insert_id();
  327.                 if ($_POST['iid']) {
  328.                     sql_query("update " . tb() . "invites set status=1 where id='{$_POST['iid']}'");
  329.                 }
  330.                 stream_publish(t('Signed Up'), '', '', $uid, $page_id);
  331.                 // welcome email
  332.                 $welcome_email = nl2br(get_text('welcome_email'));
  333.                 $welcome_email = str_replace('%username%', $_POST['username'], $welcome_email);
  334.                 $welcome_email = str_replace('%email%', $_POST['email'], $welcome_email);
  335.                 $welcome_email = str_replace('%password%', $_POST['password'], $welcome_email);
  336.                 $welcome_email = str_replace('%sitelink%', url(uhome(), h(get_gvar('site_name'))), $welcome_email);
  337.                 @jcow_mail($_POST['email'], 'Welcome to "' . h(get_gvar('site_name')) . '"!', $verify_note . $welcome_email);
  338.                 $_SESSION['login_cd'] = 3;
  339.                 redirect(url('member/login'), t('Congratulations! You have successfully signed up. You can now login with your account'));
  340.                 exit;
  341.             } else {
  342.                 foreach($errors as $error) {
  343.                     $error_msg.= '<li>' . $error . '</li>';
  344.                 }
  345.                 sys_notice(t('Errors') . ':<ul>' . $error_msg . '</ul>');
  346.             }
  347.         }
  348.         if ($iid) {
  349.             $res = sql_query("select * from " . tb() . "invites where id='{$iid}'");
  350.             $invite = sql_fetch_array($res);
  351.             if ($invite['id']) {
  352.                 $hold = 0;
  353.                 $use_i_email = t('You must use the Email address from which you received the invitation');
  354.                 $iid_field = '<input type="hidden" name="iid" value="' . $iid . '" />';
  355.             }
  356.         }
  357.         if ($hold) {
  358.             c(t('Sorry, only invited people can sign up'));
  359.             stop_here();
  360.         }
  361.         set_title('Signup');
  362.         if (get_gvar('pm_enabled')) {
  363.             c('<strong>' . t('Join Us') . '</strong><br />
  364.                ' . t('Membership pricing') . ':<ul>');
  365.             if ($pm_1m = get_gvar('pm_1m')) {
  366.                 c('<li>' . $pm_1m . ' ' . get_gvar('pm_currency') . ' ' . t('Per month') . '</li>');
  367.             }
  368.             if ($pm_3m = get_gvar('pm_3m')) {
  369.                 c('<li>' . $pm_3m . ' ' . get_gvar('pm_currency') . ' ' . t('Per Annua') . '</li>');
  370.             }
  371.             if ($pm_12m = get_gvar('pm_12m')) {
  372.                 c('<li>' . $pm_12m . ' ' . get_gvar('pm_currency') . ' ' . t('Per Yeal') . '</li>');
  373.             }
  374.             c('</ul>');
  375.             section_close(t('Paid membership'));
  376.         }
  377.         c('
  378. <script>
  379. $(document).ready( function(){
  380.    objrow = $("tr.row1 td::first-child");
  381.    objrow.attr("valign","top");
  382.    objrow.attr("align","right");
  383.    });
  384. </script>
  385.        <form method="post" action="' . url('member/signup') . '" >
  386. <table class="stories">
  387. <tr class="table_line1">
  388. <td colspan="2">' . t('Passport') . '</td>
  389. </tr>
  390. <tr class="row1">
  391. <td>*' . t('Email Address') . ' ' . $use_i_email . '</td>
  392. <td>
  393.                    <input type="text" size="20" name="email" value="' . h($_REQUEST['email']) . '" class="fpost" style="width:180px" />
  394.                    <br /><span class="sub">(' . $invite_msg . t("We won't display your Email Address.") . ')</span>
  395. </tr>
  396. <tr class="row1">
  397. <td>*' . t('Username') . '/' . t('Nickname') . '</td><td>
  398.                    <input type="text" size="18" class="fpost" name="username" value="' . h($_REQUEST['username']) . '" style="width:180px" /><br />
  399.                    <span class="sub">(' . t('4 to 18 characters, made up of 0-9,a-z') . ')</span>
  400. </tr>
  401. <tr class="row1">
  402. <td>*' . t('Password') . '</td><td>
  403.                    <input type="password" name="password"  class="fpost" value="' . h($_REQUEST['password']) . '" style="width:180px" />
  404. </tr>
  405. <tr class="table_line1">
  406. <td colspan="2">' . t('Personal info') . '</td>
  407. </tr>
  408. <tr class="row1">
  409. <td>*' . t('Full Name') . '</td><td>
  410.                    <input type="text" size="20" name="fullname" value="' . h($_REQUEST['fullname']) . '"  class="fpost" style="width:180px" />
  411. </td>
  412. </tr>
  413. <tr class="row1">
  414. <td>*' . t('Birth') . '</td><td>
  415.                    <select name="birthyear" class="fpost">
  416.                    ');
  417.         $year_from = date("Y", time()) - 8;
  418.         $year_to = date("Y", time()) - 100;
  419.         if ($_REQUEST['birthyear']) $yearkey = $_REQUEST['birthyear'];
  420.         else $yearkey = $year_from - 12;
  421.         for ($i = $year_from;$i > $year_to;$i--) {
  422.             $selected = '';
  423.             if ($yearkey == $i) $selected = 'selected';
  424.             c('<option value="' . $i . '" ' . $selected . '>' . $i . '</option>');
  425.         }
  426.         if ($row['hide_age']) $hide_age = 'checked';
  427.         c('
  428.                    </select>
  429.                    <select name="birthmonth" class="fpost">');
  430.         for ($i = 1;$i < 13;$i++) {
  431.             if ($i < 10) $j = '0' . $i;
  432.             else $j = $i;
  433.             $iss = '';
  434.             if ($_REQUEST['birthmonth'] == $j) $iss = 'selected';
  435.             c('<option value="' . $j . '" ' . $iss . ' >' . $j . '</option>');
  436.         }
  437.         c('</select>
  438.                    <select name="birthday" class="fpost">');
  439.         for ($i = 1;$i <= 31;$i++) {
  440.             if ($i < 10) $j = '0' . $i;
  441.             else $j = $i;
  442.             $iss = '';
  443.             if ($_REQUEST['birthday'] == $j) $iss = 'selected';
  444.             c('<option value="' . $j . '" ' . $iss . '>' . $j . '</option>');
  445.         }
  446.         c('</select><br />
  447.                     <input type="checkbox" name="hide_age" value="1" ' . $hide_age . ' />' . t('Hide my age') . '
  448.                    </td></tr>');
  449.         if ($_REQUEST['gender'] == 1) {
  450.             $gender1 = 'checked';
  451.         } elseif ($_REQUEST['gender'] == 2) {
  452.             $gender2 = 'checked';
  453.         } else {
  454.             $gender0 = 'checked';
  455.         }
  456.         c('
  457.                    <tr class="row1"><td>*' . t('Gender') . '</td><td>
  458.                    <input type="radio" name="gender" value="1" ' . $gender1 . ' />' . t('Male') . '
  459.                    <input type="radio" name="gender" value="0" ' . $gender0 . ' />' . t('Female') . '
  460.                    <input type="radio" name="gender" value="2" ' . $gender2 . ' />' . t('Hide') . '
  461.                    </td></tr>');
  462.         c('<tr class="row1"><td>*' . t('Come from') . '</td><td>
  463.                    <select name="location" class="inputText">');
  464.         $locations = explode("\r\n", get_text('locations'));
  465.         $_REQUEST['location'] = trim($_REQUEST['location']);
  466.         foreach($locations as $location) {
  467.             if ($_REQUEST['location'] == trim($location)) {
  468.                 $selected = 'selected';
  469.             } else {
  470.                 $selected = '';
  471.             }
  472.             c('<option value="' . $location . '" ' . $selected . ' >' . $location . '</option>');
  473.         }
  474.         c('</select>
  475. </td>
  476. </tr>
  477. <tr class="row1">
  478. <td>' . t('About me') . '</td><td>
  479.                    <textarea rows="5" name="about_me">' . htmlspecialchars($client['about_me']) . '</textarea>
  480. </td>
  481. </tr>
  482.            ');
  483.         // custom fields
  484.         $profile = array();
  485.         for ($i = 1;$i <= 7;$i++) {
  486.             $col = 'var' . $i;
  487.             $key = 'cf_var' . $i;
  488.             $key2 = 'cf_var_value' . $i;
  489.             $key3 = 'cf_var_des' . $i;
  490.             $key4 = 'cf_var_label' . $i;
  491.             $key5 = 'cf_var_required' . $i;
  492.             $ctype = get_gvar($key);
  493.             $value = get_gvar($key2);
  494.             $des = get_gvar($key3);
  495.             $label = get_gvar($key4);
  496.             $required = get_gvar($key5);
  497.             if ($required) $required = '*';
  498.             if ($ctype != 'disabled') {
  499.                 if ($ctype == 'text') {
  500.                     if (strlen($profile[$col])) {
  501.                         $value = htmlspecialchars($profile[$col]);
  502.                     }
  503.                     if (strlen($_POST[$col])) {
  504.                         $value = h($_POST[$col]);
  505.                     }
  506.                     c('<tr class="row1"><td>
  507.                                ' . $required . $label . '</td><td><input type="text" name="' . $col . '" value="' . $value . '" />
  508.                                <br /><span class="sub">' . $des . '</span></td></tr>');
  509.                 } elseif ($ctype == 'textarea') {
  510.                     if (strlen($profile[$col])) {
  511.                         $value = htmlspecialchars($profile[$col]);
  512.                     }
  513.                     if (strlen($_POST[$col])) {
  514.                         $value = h($_POST[$col]);
  515.                     }
  516.                     c('<tr class="row1"><td>' . $required . $label . '</td><td>
  517.                                <textarea rows="3" name="' . $col . '" />' . $value . '</textarea><br />
  518.                                <br /><span class="sub">' . $des . '</span></td></tr>');
  519.                 } elseif ($ctype == 'select_box') {
  520.                     $tarr = explode("\r\n", $value);
  521.                     c('<tr class="row1">
  522.                                <td>' . $label . '</td><td>
  523.                                <select name="' . $col . '">
  524.                                ');
  525.                     if (strlen($_POST[$col])) {
  526.                         $value = h($_POST[$col]);
  527.                     }
  528.                     foreach($tarr as $val) {
  529.                         if ($val == $value) {
  530.                             $selected = 'selected';
  531.                         } else {
  532.                             $selected = '';
  533.                         }
  534.                         c('<option value="' . $val . '" ' . $selected . '>' . $val . '</option>');
  535.                     }
  536.                     c('</select><br /><span class="sub">' . $des . '</span></td></tr>');
  537.                 }
  538.             }
  539.         }
  540.         c('
  541.  
  542.            ' . $iid_field . '
  543.            <tr class="row1">
  544.            <td>' . t('Image verification') . '</td><td>
  545.            ' . recaptcha_get_html($captcha['publickey'], $captchaerror) . '
  546.            </td>
  547.            </tr>
  548.            <tr class="row2">
  549.            <td colspan="2"><strong>' . t('Rules & Conditions') . '</strong>
  550.            <div style="width:700px;height:200px;overflow:scroll;border:white 2px solid;padding:5px;">
  551.            ' . nl2br(h(get_text('rules_conditions'))) . '
  552.            </div></td>
  553.            </tr>
  554.            <tr class="row2">
  555.            <td colspan="2" align="center">
  556.            <input type="hidden" name="g" value="' . $_REQUEST['g'] . '" />
  557.            <input type="hidden" name="onpost" value="1" />
  558.            <input type="checkbox" name="agree_rules" value="1" checked /> ' . t('I have read, and agree to abide by the Rules & Conditions.') . '
  559.                        <input type="submit" style="background:#5BA239;color:white;font-size:1.5em;font-weight:bold" value="' . t('Signup Now') . '" />
  560.                        </td></tr>
  561.  
  562.                        
  563.            </table>
  564.        </form>    
  565.            ');
  566.     }
  567. }
Advertisement
Add Comment
Please, Sign In to add comment