• » webSPELL.org - Free Content Management System
  • Language switch: English German
  • login



    » lost password?   » register now
  • About webSPELL

    webSPELL is a free Content Management System which was especially developed for the needs of esport related communities. Since a short while we are also offering an optimized and enhanced webSPELL version for the special requirements of non-profit organisations. The purpose of both systems is to offer a professional and free opportunity to create and administrate your own website in an easy and optimized way.

    » Learn more about webSPELL     » Download webSPELL now!
  • Advertisement

    Follow us

  • Sort:     printview
    Author
    Message
    webSPELL newbie
    24 Posts
    22.04.2012, 00:25 offline quote 

    Hello community. Did anyone of you implement this style of captcha?

    Could you tell me - how can i run
    Code:
    1.
    echo $kc_o->render_js();
    in template?

    Here is keycaptcha.php file:
    Code:
    1.
    2.
    3.
    4.
    5.
    6.
    7.
    8.
    9.
    10.
    11.
    12.
    13.
    14.
    15.
    16.
    17.
    18.
    19.
    20.
    21.
    22.
    23.
    24.
    25.
    26.
    27.
    28.
    29.
    30.
    31.
    32.
    33.
    34.
    35.
    36.
    37.
    38.
    39.
    40.
    41.
    42.
    43.
    44.
    45.
    46.
    47.
    48.
    49.
    50.
    51.
    52.
    53.
    54.
    55.
    56.
    57.
    58.
    59.
    60.
    61.
    62.
    63.
    64.
    65.
    66.
    67.
    68.
    69.
    70.
    71.
    72.
    73.
    74.
    75.
    76.
    77.
    78.
    79.
    80.
    81.
    82.
    83.
    84.
    85.
    86.
    87.
    88.
    89.
    90.
    91.
    92.
    93.
    94.
    95.
    96.
    97.
    98.
    99.
    100.
    101.
    102.
    103.
    104.
    105.
    106.
    107.
    <?php
    if ( !class_exists('KeyCAPTCHA_CLASS') )
    {
         class KeyCAPTCHA_CLASS
         {
              private $c_kc_keyword = "accept";
              private $p_kc_visitor_ip = "";
              private $p_kc_session_id = "";
              private $p_kc_web_server_sign = "";
              private $p_kc_web_server_sign2 = "";
              private $p_kc_js_code = "<!-- KeyCAPTCHA code (www.keycaptcha.com)--><script language='JavaScript'>var s_s_c_user_id = '25973';var s_s_c_session_id = '#KC_SESSION_ID#';var s_s_c_captcha_field_id = 'capcode';var s_s_c_submit_button_id = 'postbut';var s_s_c_web_server_sign = '#KC_WSIGN#';var s_s_c_web_server_sign2 = '#KC_WSIGN2#';</script><script language=JavaScript src='http://backs.keycaptcha.com/swfs/cap.js'></script><!-- end of KeyCAPTCHA code-->";
              private $p_kc_private_key = "xxxxxxxxxxxxxxxxxxxxxxxxxx";

              public function get_web_server_sign($use_visitor_ip = 0)
              {
                   return md5($this->p_kc_session_id . (($use_visitor_ip) ? ($this->p_kc_visitor_ip) :("")) . $this->p_kc_private_key);
              }

              function __construct($a_private_key='', $a_js_code='')
              {
                   if ( $a_private_key != '' ) {
                        $this->p_kc_private_key = $a_private_key;
                   }
                   if ( $a_js_code != '' ) {
                        $this->p_kc_js_code = $a_js_code;
                   }
                   $this->p_kc_session_id = uniqid() . '-3.4.0.001';
                   $this->p_kc_visitor_ip = $_SERVER["REMOTE_ADDR"];
              }

              function http_get($path)
              {
                   $arr = parse_url($path);
                   $host = $arr['host'];
                   $page = $arr['path'];
                   if ( $page=='' ) {
                        $page='/';
                   }
                   if ( isset( $arr['query'] ) ) {
                        $page.='?'.$arr['query'];
                   }
                   $errno = 0;
                   $errstr = '';
                   $fp = fsockopen ($host, 80, $errno, $errstr, 30);
                   if (!$fp){ return ""; }
                   $request = "GET $page HTTP/1.0\r\n";
                   $request .= "Host: $host\r\n";
                   $request .= "Connection: close\r\n";
                   $request .= "Cache-Control: no-store, no-cache\r\n";
                   $request .= "Pragma: no-cache\r\n";
                   $request .= "User-Agent: KeyCAPTCHA\r\n";
                   $request .= "\r\n";

                   fwrite ($fp,$request);
                   $out = '';

                   while (!feof($fp)) $out .= fgets($fp, 250);
                   fclose($fp);
                   $ov = explode("close\r\n\r\n", $out);

                   return $ov[1];
              }

              public function check_result($response)
              {
                   $kc_vars = explode("|", $response);
                   if ( count( $kc_vars ) < 4 )
                   {
                        return false;
                   }
                   if ($kc_vars[0] == md5($this->c_kc_keyword . $kc_vars[1] . $this->p_kc_private_key . $kc_vars[2]))
                   {
                        if (stripos($kc_vars[2], "http://") !== 0)
                        {
                             $kc_current_time = time();
                             $kc_var_time = split('[/ :]', $kc_vars[2]);
                             $kc_submit_time = gmmktime($kc_var_time[3], $kc_var_time[4], $kc_var_time[5], $kc_var_time[1], $kc_var_time[2], $kc_var_time[0]);
                             if (($kc_current_time - $kc_submit_time) < 15)
                             {
                                  return true;
                             }
                        }
                        else
                        {
                             if ($this->http_get($kc_vars[2]) == "1")
                             {
                                  return true;
                             }
                        }
                   }
                   return false;
              }

              public function render_js ()
              {
                   if ( isset($_SERVER['HTTPS']) && ( $_SERVER['HTTPS'] == 'on' ) )
                   {
                        $this->p_kc_js_code = str_replace ("http://","https://", $this->p_kc_js_code);
                   }
                   $this->p_kc_js_code = str_replace ("#KC_SESSION_ID#", $this->p_kc_session_id, $this->p_kc_js_code);
                   $this->p_kc_js_code = str_replace ("#KC_WSIGN#", $this->get_web_server_sign(1), $this->p_kc_js_code);
                   $this->p_kc_js_code = str_replace ("#KC_WSIGN2#", $this->get_web_server_sign(), $this->p_kc_js_code);
                   return $this->p_kc_js_code;
              }
         }
    }
    ?>


    Here is register.php file with the modifications:
    Code:
    1.
    2.
    3.
    4.
    5.
    6.
    7.
    8.
    9.
    10.
    11.
    12.
    13.
    14.
    15.
    16.
    17.
    18.
    19.
    20.
    21.
    22.
    23.
    24.
    25.
    26.
    27.
    28.
    29.
    30.
    31.
    32.
    33.
    34.
    35.
    36.
    37.
    38.
    39.
    40.
    41.
    42.
    43.
    44.
    45.
    46.
    47.
    48.
    49.
    50.
    51.
    52.
    53.
    54.
    55.
    56.
    57.
    58.
    59.
    60.
    61.
    62.
    63.
    64.
    65.
    66.
    67.
    68.
    69.
    70.
    71.
    72.
    73.
    74.
    75.
    76.
    77.
    78.
    79.
    80.
    81.
    82.
    83.
    84.
    85.
    86.
    87.
    88.
    89.
    90.
    91.
    92.
    93.
    94.
    95.
    96.
    97.
    98.
    99.
    100.
    101.
    102.
    103.
    104.
    105.
    106.
    107.
    108.
    109.
    110.
    111.
    112.
    113.
    114.
    115.
    116.
    117.
    118.
    119.
    120.
    121.
    122.
    123.
    124.
    125.
    126.
    127.
    128.
    129.
    130.
    131.
    132.
    133.
    134.
    135.
    136.
    137.
    138.
    139.
    140.
    141.
    142.
    143.
    144.
    145.
    146.
    147.
    148.
    149.
    150.
    151.
    152.
    153.
    154.
    155.
    156.
    157.
    158.
    159.
    160.
    161.
    162.
    163.
    164.
    165.
    <?php
    /*
    ##########################################################################
    #                                                                        #
    #           Version 4       /                        /   /               #
    #          -----------__---/__---__------__----__---/---/-               #
    #           | /| /  /___) /   ) (_ `   /   ) /___) /   /                 #
    #          _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___               #
    #                       Free Content / Management System                 #
    #                                   /                                    #
    #                                                                        #
    #                                                                        #
    #   Copyright 2005-2009 by webspell.org                                  #
    #                                                                        #
    #   visit webSPELL.org, webspell.info to get webSPELL for free           #
    #   - Script runs under the GNU GENERAL PUBLIC LICENSE                   #
    #   - It's NOT allowed to remove this copyright-tag                      #
    #   -- http://www.fsf.org/licensing/licenses/gpl.html                    #
    #                                                                        #
    #   Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at),   #
    #   Far Development by Development Team - webspell.org                   #
    #                                                                        #
    #   visit webspell.org                                                   #
    #                                                                        #
    ##########################################################################
    */

    // KeyCaptcha include
    if (!class_exists('KeyCAPTCHA_CLASS')) {
         include('keycaptcha.php');
    }
    $_language->read_module('register');

    eval("\$title_register = \"".gettemplate("title_register")."\";");
    echo $title_register;
    $show = true;
    if(isset($_POST['save'])) {

         //register_globals = off

         $username = mb_substr(trim($_POST['username']), 0, 30);
         $nickname = htmlspecialchars(mb_substr(trim($_POST['nickname']), 0, 30));
         $pwd1 = $_POST['pwd1'];
         $pwd2 = $_POST['pwd2'];
         $mail = $_POST['mail'];
         $sex = $_POST['sex'];
         $country = $_POST['country'];
         $homepage = $_POST['homepage'];
         $firstname = $_POST['firstname'];
         $town = $_POST['town'];

              
              // KeyCaptch Implementation
              $kc_o = new KeyCAPTCHA_CLASS();
              if ($kc_o->check_result($_POST['capcode'])) {
                   $run = 1;
              }
              else 
              {
                   if (!run){
                   $error[]='You did not post captcha or the captcha is wrong!';
              }}
              // End KeyCaptcha
         
         $error = array();
           
      // check nickname
         if(!(mb_strlen(trim($nickname)))) $error[]=$_language->module['enter_nickname'];
         
         // check name
         if(!(mb_strlen(trim($firstname)))) $error[]=$_language->module['enter_name'];
      
      // check nickname inuse
         $ergebnis = safe_query("SELECT * FROM ".PREFIX."user WHERE nickname = '$nickname' ");
         $num = mysql_num_rows($ergebnis);
         if($num) $error[]=$_language->module['nickname_inuse'];
      
      // check username
           if(!(mb_strlen(trim($username)))) $error[]=$_language->module['enter_username'];
         elseif(mb_strlen(trim($username)) > 30 ) $error[]=$_language->module['username_toolong'];
      
      // check username inuse
         $ergebnis = safe_query("SELECT * FROM ".PREFIX."user WHERE username = '$username' ");
         $num = mysql_num_rows($ergebnis);
         if($num) $error[]=$_language->module['username_inuse'];
      
      // check passwort
         if($pwd1 == $pwd2) {
              if(!(mb_strlen(trim($pwd1)))) $error[]=$_language->module['enter_password'];
         }
         else $error[]=$_language->module['repeat_invalid'];
         
         //chech e-mail modification
         if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) $error[]=$_language->module['invalid_mail'];
         
      // check e-mail inuse
         $ergebnis = safe_query("SELECT userID FROM ".PREFIX."user WHERE email = '$mail' ");
         $num = mysql_num_rows($ergebnis);
         if($num) $error[]=$_language->module['mail_inuse'];
      
         
           if(count($error)) {
             $list = implode('<br />&#8226; ', $error);
             $showerror = '<div class="errorbox">
               <b>'.$_language->module['errors_there'].':</b><br /><br />
               &#8226; '.$list.'
             </div>';
         }
         else {
              // insert in db
              $md5pwd = md5(stripslashes($pwd1));
              $registerdate=time();
              $activationkey = 1;

              safe_query("INSERT INTO `".PREFIX."user` (`registerdate`, `lastlogin`, `username`, `password`, `nickname`, `email`, `sex`, `country`, `town`, `homepage`, `firstname`, `newsletter`, `activated`) VALUES ('$registerdate', '$registerdate', '$username', '$md5pwd', '$nickname', '$mail', '$sex', '$country', '$town', '$homepage', '$firstname', '1', '".$activationkey."')");

              $insertid = mysql_insert_id();

              // insert in user_groups
              safe_query("INSERT INTO ".PREFIX."user_groups ( userID ) values('$insertid' )");
              $show=false;
              echo redirect('index.php?site=login', $_language->module['activation_successful']);
         
         }
    }
    if(isset($_GET['key'])) {

         safe_query("UPDATE `".PREFIX."user` SET activated='1' WHERE activated='".$_GET['key']."'");
         if(mysql_affected_rows()) redirect('index.php?site=login',$_language->module['activation_successful'],3);
         else redirect('index.php?site=login',$_language->module['wrong_activationkey'],3);

    }
    elseif(isset($_GET['mailkey'])) {

         safe_query("UPDATE `".PREFIX."user` SET email_activate='1', email=email_change, email_change='' WHERE email_activate='".$_GET['mailkey']."'");
         if(mysql_affected_rows()) redirect('index.php?site=login',$_language->module['mail_activation_successful'],3);
         else redirect('index.php?site=login',$_language->module['wrong_activationkey'],3);

    }
    else {
         if($show == true){
              $bg1=BG_1;
              $bg2=BG_2;
              $bg3=BG_3;
              $bg4=BG_4;
         
              if(!isset($showerror)) $showerror='';
              if(isset($_POST['nickname'])) $nickname=getforminput($_POST['nickname']);
              else $nickname='';
              if(isset($_POST['username'])) $username=getforminput($_POST['username']);
              else $username='';
              if(isset($_POST['pwd1'])) $pwd1=getforminput($_POST['pwd1']);
              else $pwd1='';
              if(isset($_POST['pwd2'])) $pwd2=getforminput($_POST['pwd2']);
              else $pwd2='';
              if(isset($_POST['mail'])) $mail=getforminput($_POST['mail']);
              else $mail='';
         

                   echo $kc_o->render_js();
                   eval("\$register = \"".gettemplate("register")."\";");
                   echo $register;
         }
    }
    ?>


    Thank you for the help.

    website: localhost
    version: 4.2.3
    Sort:     printview


    To start or to reply to a topic you have to be registered and logged in!

    register now
    login
  • » Support

    » Topics
    26.05.2013 - 00:18 - 473 Replies
    » Wettscript 2.1 for 4.2.3a...
    Wettscript 2.1 for 4.2.3a - Betscript
    Last post: Amokossi
    Board: DE - Fertige Skripte
    26.05.2013 - 00:18
    25.05.2013 - 22:46 - 0 Replies
    » Clanwar News!
    Clanwar News!
    Last post: Maverico
    Board: DE - Anfragen
    25.05.2013 - 22:46
    25.05.2013 - 19:01 - 1 Replies
    » Error 1146
    Error 1146
    Last post: Argu
    Board: EN - Technical support
    25.05.2013 - 19:01
    25.05.2013 - 17:51 - 0 Replies
    » Gewinnspiel
    Gewinnspiel
    Last post: Dynamic-Webmedia
    Board: DE - Aus aller Welt
    25.05.2013 - 17:51
    25.05.2013 - 12:35 - 1 Replies
    » Need coder for a design!
    Need coder for a design!
    Last post: wantedJK-
    Board: EN - General
    25.05.2013 - 12:35
    25.05.2013 - 03:18 - 0 Replies
    » ScooterFreakz.com - Motor...
    ScooterFreakz.com - Motorroller Community
    Last post: Tuner77
    Board: DE - Showroom
    25.05.2013 - 03:18
    25.05.2013 - 00:46 - 8 Replies
    » Ändern der Größe php
    Ändern der Größe php
    Last post: andy5116
    Board: DE - Allgemeiner Support
    25.05.2013 - 00:46
    24.05.2013 - 23:39 - 33 Replies
    » [B]Userrank Addon
    [B]Userrank Addon
    Last post: Swordfish3000
    Board: DE - Erweiterungen
    24.05.2013 - 23:39
    24.05.2013 - 15:12 - 19 Replies
    » forum anzeige erweitern
    forum anzeige erweitern
    Last post: Swordfish3000
    Board: DE - Allgemeiner Support
    24.05.2013 - 15:12
    24.05.2013 - 12:03 - 1 Replies
    » Verkaufe prof. Clandesign
    Verkaufe prof. Clandesign
    Last post: Vith3r
    Board: DE - Biete
    24.05.2013 - 12:03
    24.05.2013 - 12:02 - 6 Replies
    » [S] Team/Clan Logos (Upda...
    [S] Team/Clan Logos (Update: 2 new Logos)
    Last post: a--w
    Board: EN - Offers
    24.05.2013 - 12:02
    24.05.2013 - 02:41 - 17 Replies
    » High Quality Website
    High Quality Website
    Last post: Dansjostedt
    Board: EN - Offers
    24.05.2013 - 02:41
    24.05.2013 - 02:24 - 5 Replies
    » [SELL] Gaming Website
    [SELL] Gaming Website
    Last post: hornyst
    Board: EN - Offers
    24.05.2013 - 02:24
    23.05.2013 - 22:37 - 2 Replies
    » Bilder Breite im Forum an...
    Bilder Breite im Forum anpassen
    Last post: nappel.ger
    Board: DE - Vorschläge
    23.05.2013 - 22:37
    23.05.2013 - 15:35 - 6 Replies
    » I cannot upload template ...
    I cannot upload template to my cms .
    Last post: bazic
    Board: EN - General
    23.05.2013 - 15:35
    23.05.2013 - 14:50 - 3 Replies
    » Kalendar-Box
    Kalendar-Box
    Last post: kassor
    Board: DE - Anfragen
    23.05.2013 - 14:50
    23.05.2013 - 10:14 - 12 Replies
    » Mein Forum
    Mein Forum
    Last post: Lordy4007
    Board: DE - Fragen zur Seite
    23.05.2013 - 10:14
    22.05.2013 - 23:06 - 9 Replies
    » When the update?
    When the update?
    Last post: kola60
    Board: EN - General
    22.05.2013 - 23:06
    22.05.2013 - 22:21 - 2 Replies
    » Website For SALE! CODED
    Website For SALE! CODED
    Last post: Osamakillz
    Board: EN - General
    22.05.2013 - 22:21
    22.05.2013 - 21:43 - 3 Replies
    » Slider Links Bitte um Hil...
    Slider Links Bitte um Hilfe
    Last post: bazic
    Board: DE - Allgemein
    22.05.2013 - 21:43
    » Partners
    Bilderkiste.org Image Hosting
    k3rmit.org
    PascalMh.de


    » Blog
    28.03.2013 - derchris
    » Those damn spammers