Example #1
0
        //default must be here
        $style_folder = PATH . 'styles/default/';
        if (!($dh = @opendir($style_folder))) {
            redirect(basename(ADMIN_PATH));
        }
        //open bk_template.php to write contents of templates to it.
        $bkf = @fopen(PATH . 'includes/bk_templates.php', 'wb');
        $bkf_contents = "<" . "?php\n//\n//bakup of Kleeja templates\n//Automatically generated from DEV version cp=" . basename(__FILE__, '.php') . "&sty_t=bk\n//\n\n//no for directly open\nif (!defined('IN_COMMON'))\n{";
        $bkf_contents .= "\n\texit();\n}\n\n//for version\n\$bk_version = '" . KLEEJA_VERSION . "';";
        $bkf_contents .= "\n\n//Done in : " . date('d-m-Y H:i a') . "\n\n\$bkup_templates = array(\n";
        $f = 0;
        while (($file = @readdir($dh)) !== false) {
            //exceptions
            if (!in_array(strtolower($file), array('.', '..', 'index.html', 'javascript.js', 'css', '.svn', 'images', '.htaccess', 'ie', 'info.txt'))) {
                $f++;
                $bkf_contents .= "\t'" . $file . "' => '" . kleeja_base64_encode(file_get_contents($style_folder . $file)) . "',\n";
            }
        }
        $bkf_contents .= "\n);";
        //write to bk_template.php
        @ftruncate($bkf, 0);
        @fwrite($bkf, $bkf_contents);
        //...
        @fclose($bkf);
        @closedir($bkf);
        $text = 'Done, ' . $f . ' files !';
        $stylee = 'admin_info';
        break;
}
if (!isset($stylee)) {
    $text = '--------';
Example #2
0
function kleeja_auth_login($name, $pass, $hashed = false, $expire, $loginadm = false, $return_name = false)
{
    global $lang, $config, $usrcp, $userinfo;
    global $script_path, $script_encoding, $script_srv, $script_db, $script_user, $script_pass, $script_prefix;
    //check for last slash /
    if (isset($script_path)) {
        if (isset($script_path[strlen($script_path)]) && $script_path[strlen($script_path)] == '/') {
            $script_path = substr($script_path, 0, strlen($script_path));
        }
        //get some useful data from phbb config file
        if (file_exists(PATH . $script_path . SCRIPT_CONFIG_PATH)) {
            include PATH . $script_path . SCRIPT_CONFIG_PATH;
            $forum_srv = $dbhost;
            $forum_db = $dbname;
            $forum_user = $dbuser;
            $forum_pass = $dbpasswd;
            $forum_prefix = $table_prefix;
            if (empty($dbhost)) {
                $forum_srv = 'localhost';
            }
            if (!empty($dbport)) {
                $forum_srv .= ':' . $dbport;
            }
        } else {
            big_error('Forum path is not correct', sprintf($lang['SCRIPT_AUTH_PATH_WRONG'], 'phpBB3'));
        }
    } else {
        $forum_srv = $script_srv;
        $forum_db = $script_db;
        $forum_user = $script_user;
        $forum_pass = $script_pass;
        $forum_prefix = $script_prefix;
    }
    //if no variables of db
    if (empty($forum_srv) || empty($forum_user) || empty($forum_db)) {
        return;
    }
    //conecting ...
    $SQLBB = new SSQL($forum_srv, $forum_user, $forum_pass, $forum_db, true);
    $SQLBB->set_names('utf8');
    unset($forum_pass);
    // We do not need this any longer
    //get utf tools
    global $phpbb_root_path, $phpEx;
    $phpbb_root_path = PATH . $script_path . '/';
    $phpEx = 'php';
    define('IN_PHPBB', true);
    include_once PATH . $script_path . '/includes/utf/utf_tools.' . $phpEx;
    $row_leve = 'user_type';
    $admin_level = 3;
    $query2 = array('SELECT' => '*', 'FROM' => "`{$forum_prefix}users`");
    $query2['WHERE'] = $hashed ? "user_id=" . intval($name) . "  AND user_password='******' " : "username_clean='" . $SQLBB->escape(utf8_clean_string($name)) . "'";
    if ($return_name) {
        $query2['SELECT'] = "username";
        $query2['WHERE'] = "user_id=" . intval($name);
    }
    $query = '';
    if (!$hashed) {
        $result2 = $SQLBB->build($query2);
        while ($row = $SQLBB->fetch($result2)) {
            $SQLBB->free($result2);
            if ($return_name) {
                return $row['username'];
            } else {
                if (phpbb_check_hash($pass, $row['user_password'])) {
                    $query = $query2;
                }
            }
        }
    } else {
        $query = $query2;
    }
    if (empty($query)) {
        $SQLBB->close();
        return false;
    }
    ($hook = $plugin->run_hook('qr_select_usrdata_phpbb_usr_class')) ? eval($hook) : null;
    //run hook
    $result = $SQLBB->build($query);
    if ($SQLBB->num($result) != 0) {
        while ($row = $SQLBB->fetch($result)) {
            if ($SQLBB->num($SQLBB->query("SELECT ban_userid FROM `{$forum_prefix}banlist` WHERE ban_userid=" . intval($row['user_id']))) == 0) {
                if (!$loginadm) {
                    define('USER_ID', $row['user_id']);
                    define('GROUP_ID', $row[$row_leve] == $admin_level ? '1' : '3');
                    define('USER_NAME', $row['username']);
                    define('USER_MAIL', $row['user_email']);
                    if ($row[$row_leve] == $admin_level) {
                        define('USER_ADMIN', true);
                    }
                }
                $userinfo = $row;
                $userinfo['group_id'] = $row[$row_leve] == $admin_level ? '1' : '3';
                $user_y = kleeja_base64_encode(serialize(array('id' => $row['user_id'], 'name' => $row['username'], 'mail' => $row['user_email'], 'last_visit' => time())));
                if (!$hashed && !$loginadm) {
                    $usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt($row['user_id'] . '|' . $row['user_password'] . '|' . $expire . '|' . sha1(md5($config['h_key'] . $row['user_password']) . $expire) . '|' . ($row[$row_leve] == $admin_level ? '1' : '3') . '|' . $user_y), $expire);
                }
                ($hook = $plugin->run_hook('qr_while_usrdata_phpbb_usr_class')) ? eval($hook) : null;
                //run hook
            } else {
                //he is banned from phpBB
                $SQLBB->free($result);
                unset($pass);
                $SQLBB->close();
                return false;
            }
        }
        $SQLBB->free($result);
        unset($pass);
        $SQLBB->close();
        return true;
    } else {
        $SQLBB->free($result);
        $SQLBB->close();
        return false;
    }
    //dont know why they come here !
    return false;
}
 if (empty($_POST['sitename']) || empty($_POST['siteurl']) || empty($_POST['sitemail']) || empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email'])) {
     echo $lang['EMPTY_FIELDS'];
     echo $footer_inst;
     exit;
 }
 if (strpos($_POST['email'], '@') === false) {
     echo $lang['WRONG_EMAIL'];
     echo $footer_inst;
     exit;
 }
 //connect .. for check
 $SQL = new SSQL($dbserver, $dbuser, $dbpass, $dbname);
 include_once '../includes/usr.php';
 include_once '../includes/functions_alternative.php';
 $usrcp = new usrcp();
 $user_salt = substr(kleeja_base64_encode(pack("H*", sha1(mt_rand()))), 0, 7);
 $user_pass = $usrcp->kleeja_hash_password($_POST['password'] . $user_salt);
 $user_name = $SQL->escape($_POST['username']);
 $user_mail = $SQL->escape($_POST['email']);
 $config_sitename = $SQL->escape($_POST['sitename']);
 $config_siteurl = $SQL->escape($_POST['siteurl']);
 $config_sitemail = $SQL->escape($_POST['sitemail']);
 $config_style = $SQL->escape($_POST['style']);
 $config_urls_type = in_array($_POST['urls_type'], array('id', 'filename', 'direct')) ? $_POST['urls_type'] : 'id';
 $clean_name = $usrcp->cleanusername($SQL->escape($user_name));
 /// ok .. we will get sqls now ..
 include 'includes/install_sqls.php';
 include 'includes/default_values.php';
 $err = $dots = 0;
 $errors = '';
 //do important alter before
Example #4
0
File: vb.php Project: Saleh7/Kleeja
function kleeja_auth_login($name, $pass, $hashed = false, $expire, $loginadm = false, $return_name = false)
{
    global $lang, $config, $usrcp, $userinfo;
    global $script_path, $script_cp1256, $script_srv, $script_db, $script_user, $script_pass, $script_prefix, $script_db_charset;
    if (isset($script_path)) {
        //check for last slash
        if (isset($script_path[strlen($script_path)]) && $script_path[strlen($script_path)] == '/') {
            $script_path = substr($script_path, 0, strlen($script_path));
        }
        //get some useful data from vb config file
        if (file_exists(PATH . $script_path . SCRIPT_CONFIG_PATH)) {
            require_once PATH . $script_path . SCRIPT_CONFIG_PATH;
            //
            //get config from config file
            //
            $forum_srv = $config['MasterServer']['servername'];
            $forum_db = $config['Database']['dbname'];
            $forum_user = $config['MasterServer']['username'];
            $forum_pass = $config['MasterServer']['password'];
            $forum_prefix = $config['Database']['tableprefix'];
            if ($config['MasterServer']['port'] != 3306) {
                $forum_srv .= ':' . $config['MasterServer']['port'];
            }
            //some people change their db charset
            if (isset($config['Mysqli']['charset'])) {
                $forum_db_charset = $config['Mysqli']['charset'];
            }
        } else {
            big_error('Forum path is not correct', sprintf($lang['SCRIPT_AUTH_PATH_WRONG'], 'Vbulletin'));
        }
    } else {
        //
        //custom config data
        //
        $forum_srv = $script_srv;
        $forum_db = $script_db;
        $forum_user = $script_user;
        $forum_pass = $script_pass;
        $forum_prefix = $script_prefix;
        //some people change their db charset
        if (isset($script_db_charset)) {
            $forum_db_charset = $script_db_charset;
        }
    }
    if (empty($forum_srv) || empty($forum_user) || empty($forum_db)) {
        return;
    }
    $SQLVB = new SSQL($forum_srv, $forum_user, $forum_pass, $forum_db, true);
    if (isset($forum_db_charset)) {
        //config
        $SQLVB->set_names($forum_db_charset);
    } else {
        $SQLVB->set_names('latin1');
    }
    unset($forum_pass);
    // We do not need this any longer
    $pass = empty($script_cp1256) || !$script_cp1256 ? $pass : $usrcp->kleeja_utf8($pass, false);
    $name = empty($script_cp1256) || !$script_cp1256 || $hashed ? $name : $usrcp->kleeja_utf8($name, false);
    $query_salt = array('SELECT' => $hashed ? '*' : 'salt', 'FROM' => "`{$forum_prefix}user`");
    $query_salt['WHERE'] = $hashed ? "userid=" . intval($name) . " AND password='******' AND usergroupid != '8'" : "username='******' AND usergroupid != '8'";
    //if return only name let's ignore the obove
    if ($return_name) {
        $query_salt['SELECT'] = "username";
        $query_salt['WHERE'] = "userid=" . intval($name);
    }
    ($hook = kleeja_run_hook('qr_select_usrdata_vb_usr_class')) ? eval($hook) : null;
    //run hook
    $result_salt = $SQLVB->build($query_salt);
    if ($SQLVB->num_rows($result_salt) > 0) {
        while ($row1 = $SQLVB->fetch_array($result_salt)) {
            if ($return_name) {
                return empty($script_cp1256) || !$script_cp1256 ? $row1['username'] : $usrcp->kleeja_utf8($row1['username']);
            }
            if (!$hashed) {
                $pass = md5(md5($pass) . $row1['salt']);
                // without normal md5
                $query = array('SELECT' => '*', 'FROM' => "`{$forum_prefix}user`", 'WHERE' => "username='******' AND password='******' AND usergroupid != '8'");
                $result = $SQLVB->build($query);
                if ($SQLVB->num_rows($result) != 0) {
                    while ($row = $SQLVB->fetch_array($result)) {
                        if (!$loginadm) {
                            define('USER_ID', $row['userid']);
                            define('GROUP_ID', $row['usergroupid'] == 6 ? 1 : 3);
                            define('USER_NAME', empty($script_cp1256) || !$script_cp1256 ? $row['username'] : $usrcp->kleeja_utf8($row['username']));
                            define('USER_MAIL', $row['email']);
                            define('USER_ADMIN', $row['usergroupid'] == 6 ? 1 : 0);
                        }
                        //define('LAST_VISIT',$row['last_visit']);
                        $userinfo = $row;
                        $userinfo['group_id'] = $row['usergroupid'] == 6 ? 1 : 3;
                        $user_y = kleeja_base64_encode(serialize(array('id' => $row['userid'], 'name' => USER_NAME, 'mail' => $row['email'], 'last_visit' => time())));
                        $hash_key_expire = sha1(md5($config['h_key'] . $row['password']) . $expire);
                        if (!$loginadm) {
                            $usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt($row['userid'] . '|' . $row['password'] . '|' . $expire . '|' . $hash_key_expire . '|' . ($row['usergroupid'] == 6 ? 1 : 3) . '|' . $user_y), $expire);
                        }
                        ($hook = kleeja_run_hook('qr_while_usrdata_vb_usr_class')) ? eval($hook) : null;
                        //run hook
                    }
                    $SQLVB->freeresult($result);
                } else {
                    $SQLVB->close();
                    return false;
                }
            } else {
                if (!$loginadm) {
                    define('USER_ID', $row1['userid']);
                    define('USER_NAME', empty($script_cp1256) || !$script_cp1256 ? $row1['username'] : $usrcp->kleeja_utf8($row1['username']));
                    define('USER_MAIL', $row1['email']);
                    define('USER_ADMIN', $row1['usergroupid'] == 6 ? 1 : 0);
                    define('GROUP_ID', $row1['usergroupid'] == 6 ? 1 : 3);
                    $userinfo = $row1;
                    $userinfo['group_id'] = $row1['usergroupid'] == 6 ? 1 : 3;
                }
            }
        }
        #whil1
        $SQLVB->freeresult($result_salt);
        unset($pass);
        $SQLVB->close();
        return true;
    } else {
        $SQLVB->close();
        return false;
    }
}
Example #5
0
File: api.php Project: omtim/kleeja
function kleeja_auth_login($name, $pass, $hashed = false, $expire, $loginadm = false, $return_username = false)
{
    global $lang, $config, $usrcp, $userinfo;
    global $script_path, $script_api_key, $script_cp1256;
    //URL must be begin with http://
    if (empty($script_path) || $script_path[0] != 'h') {
        big_error('Forum URL must be begin with http://', sprintf($lang['SCRIPT_AUTH_PATH_WRONG'], 'API'));
    }
    //api key is the key to make the query between the remote script and kleeja more secure !
    //this must be changed in the real use
    if (empty($script_api_key)) {
        big_error('api key', 'To connect to the remote script you have to write the API key ...');
    }
    $pass = empty($script_cp1256) || !$script_cp1256 ? $pass : $usrcp->kleeja_utf8($pass, false);
    $name = empty($script_cp1256) || !$script_cp1256 || $hashed ? $name : $usrcp->kleeja_utf8($name, false);
    /*
    	@see file : docs/kleeja_(vb,mysmartbb,phpbb)_api.txt
    */
    $api_http_query = 'api_key=' . kleeja_base64_encode($script_api_key) . '&' . ($hashed ? 'userid' : 'username') . '=' . urlencode($name) . '&pass='******'&return_username=1' : '';
    //get it
    $remote_data = fetch_remote_file($script_path . '?' . $api_http_query);
    //no responde
    //empty or can not connect
    if ($remote_data == false || empty($remote_data)) {
        return false;
    }
    //see kleeja_api.php file
    //split the data , the first one is always 0 or 1
    //0 : error
    //1: ok
    $user_info = explode('%|%', kleeja_base64_decode($remote_data));
    //omg, it's 0 , 0 : error, lets die here
    if ((int) $user_info[0] == 0) {
        return false;
    }
    //
    //if we want username only we have to return it quickly and die here
    //
    if ($return_username) {
        return empty($script_cp1256) || !$script_cp1256 ? $user_info[1] : $usrcp->kleeja_utf8($user_info[1]);
    }
    //
    //when loggin to admin, we just want a check, no data setup ..
    //
    if (!$loginadm) {
        define('USER_ID', $user_info[1]);
        define('GROUP_ID', 3);
        define('USER_NAME', empty($script_cp1256) || !$script_cp1256 ? $user_info[2] : $usrcp->kleeja_utf8($user_info[2]));
        define('USER_MAIL', $user_info[3]);
        define('USER_ADMIN', (int) $user_info[5] == 1 ? 1 : 0);
    }
    //user ifo
    //and this must be filled with user data comming from url
    $userinfo = array();
    $userinfo['group_id'] = GROUP_ID;
    $user_y = kleeja_base64_encode(serialize(array('id' => USER_ID, 'name' => USER_NAME, 'mail' => USER_MAIL, 'last_visit' => time())));
    //add cookies
    if (!$loginadm) {
        $usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt($user_info[1] . '|' . $user_info[4] . '|' . $expire . '|' . sha1(md5($config['h_key'] . $user_info[4]) . $expire) . '|' . GROUP_ID . '|' . $user_y), $expire);
    }
    //no need after now
    unset($pass);
    //yes ! he is a real user
    return true;
}
 function en_de_crypt($data, $type = 1)
 {
     global $config;
     static $txt = array();
     if (empty($txt)) {
         if (empty($config['h_key'])) {
             $config['h_key'] = sha1('2^#@qr39)]k%$_-(');
             //default !
         }
         $chars = str_split($config['h_key']);
         foreach (range('a', 'z') as $k => $v) {
             if (!isset($chars[$k])) {
                 break;
             }
             $txt[$v] = $chars[$k] . $k . '-';
         }
     }
     switch ($type) {
         case 1:
             $data = str_replace('=', '_', kleeja_base64_encode($data));
             $data = strtr($data, $txt);
             break;
         case 2:
             $txtx = array_flip($txt);
             $txtx = array_reverse($txtx, true);
             $data = strtr($data, $txtx);
             $data = kleeja_base64_decode(str_replace('_', '=', $data));
             break;
     }
     return $data;
 }
 $num = 0;
 #if Kleeja integtared we dont want make alot of queries
 $ids_and_names = array();
 while ($row = $SQL->fetch_array($result)) {
     $userfile = $config['siteurl'] . ($config['mod_writer'] ? 'fileuser-' . $row['user'] . '.html' : 'ucp.php?go=fileuser&amp;id=' . $row['user']);
     #for username in integrated user system
     if ($row['user'] != '-1' and (int) $config['user_system'] != 1) {
         if (!in_array($row['user'], $ids_and_names)) {
             $row['username'] = $usrcp->usernamebyid($row['user']);
             $ids_and_names[$row['user']] = $row['username'];
         } else {
             $row['username'] = $ids_and_names[$row['user']];
         }
     }
     //make new lovely arrays !!
     $arr[] = array('id' => $row['id'], 'name' => "<a title=\" " . ($row['real_filename'] == '' ? $row['name'] : $row['real_filename']) . "\" href=\"./" . PATH . $row['folder'] . "/" . $row['name'] . "\" target=\"blank\">" . ($row['real_filename'] == '' ? strlen($row['name']) > 20 ? substr($row['name'], 0, 20) . '...' : $row['name'] : (strlen($row['real_filename']) > 20 ? substr($row['real_filename'], 0, 20) . '...' : $row['real_filename'])) . "</a>", 'size' => Customfile_size($row['size']), 'ups' => $row['uploads'], 'time' => date('d-m-Y H:i a', $row['time']), 'type' => $row['type'], 'folder' => $row['folder'], 'report' => $row['report'] > 4 ? "<span style=\"color:red;font-weight:bold\">" . $row['report'] . "</span>" : $row['report'], 'user' => $row['user'] == '-1' ? $lang['GUST'] : '<a href="' . $userfile . '" target="_blank">' . $row['username'] . '</a>', 'ip' => '<a href="http://www.ripe.net/whois?form_type=simple&amp;full_query_string=&amp;searchtext=' . $row['user_ip'] . '&amp;do_search=Search" target="_new">' . $row['user_ip'] . '</a>', 'showfilesbyip' => basename(ADMIN_PATH) . '?cp=' . basename(__FILE__, '.php') . '&search=' . kleeja_base64_encode(serialize(array('user_ip' => $row['user_ip']))));
     $del[$row['id']] = isset($_POST['del_' . $row['id']]) ? $_POST['del_' . $row['id']] : '';
     //when submit
     if (isset($_POST['submit'])) {
         if ($del[$row['id']]) {
             //delete from folder ..
             @kleeja_unlink(PATH . $row['folder'] . '/' . $row['name']);
             //delete thumb
             if (is_file($row['folder'] . '/thumbs/' . $row['name'])) {
                 @kleeja_unlink(PATH . $row['folder'] . '/thumbs/' . $row['name']);
             }
             $ids[] = $row['id'];
             $num++;
             $sizes += $row['size'];
         }
     }
 /**
  * delete any content from any template , this will used in plugins
  * used in unistall tag at plugin xml file
  *
  * todo : use file handler, require ftp info at uninstalling
  */
 function delete_ch_tpl($template_name, $delete_txt = array())
 {
     global $dbprefix, $lang, $config, $STYLE_PATH_ADMIN, $STYLE_PATH, $THIS_STYLE_PATH;
     if (is_array($template_name)) {
         foreach ($template_name as $tn) {
             $this->delete_ch_tpl($tn, $delete_txt);
         }
         return;
     }
     $style_path = substr($template_name, 0, 6) == 'admin_' ? $STYLE_PATH_ADMIN : $THIS_STYLE_PATH;
     $is_admin_template = substr($template_name, 0, 6) == 'admin_' ? true : false;
     //if template not found and default style is there and not admin tpl
     $template_path = $style_path . $template_name . '.html';
     if (!file_exists($template_path)) {
         if ($config['style'] != 'default' && !$is_admin_template) {
             $template_path_alternative = str_replace('/' . $config['style'] . '/', '/default/', $template_path);
             if (file_exists($template_path_alternative)) {
                 $template_path = $template_path_alternative;
             }
         }
     }
     if (file_exists($template_path)) {
         $d_contents = file_get_contents($template_path);
     } else {
         $d_contents = '';
     }
     include_once "s_strings.php";
     $finder = new sa_srch();
     $finder->find_word = $delete_txt;
     $finder->another_word = '<!-- deleted ' . md5(implode(null, $delete_txt)) . ' -->';
     $finder->text = trim($d_contents);
     $finder->do_search(2);
     $cached_instructions = array();
     if ($d_contents != '' && md5($finder->text) != md5($d_contents) && is_writable($style_path)) {
         //update
         $this->f->_write($style_path . $template_name . '.html', $finder->text);
         //delete cache ..
         delete_cache('tpl_' . $template_name);
     } else {
         $cached_instructions[$template_name] = array('action' => 'replace_with', 'find' => $finder->find_word[0] . '(.*?)' . $finder->find_word[1], 'action_text' => $finder->another_word);
     }
     //add cached instuctions to cache if there
     if (sizeof($cached_instructions) > 0) {
         //fix
         if (file_exists(PATH . 'cache/styles_cached.php')) {
             $cached_content = file_get_contents(PATH . 'cache/styles_cached.php');
             $cached_content = kleeja_base64_decode($cached_content);
             $cached_content = unserialize($cached_content);
             $cached_instructions += $cached_content;
         }
         $filename = @fopen(PATH . 'cache/styles_cached.php', 'w');
         fwrite($filename, kleeja_base64_encode(serialize($cached_instructions)));
         fclose($filename);
     }
     if ($this->f_method === 'zfile') {
         if ($this->f->check()) {
             $this->zipped_files = $this->f->push($plugin_name);
         }
     }
     return true;
 }
Example #9
0
function kleeja_auth_login($name, $pass, $hashed = false, $expire, $loginadm = false, $return_name = false)
{
    global $lang, $config, $usrcp, $userinfo;
    global $script_path, $script_encoding, $script_srv, $script_db, $script_user, $script_pass, $script_prefix;
    if (isset($script_path)) {
        //check for last slash /
        if (isset($script_path[strlen($script_path)]) && $script_path[strlen($script_path)] == '/') {
            $script_path = substr($script_path, 0, strlen($script_path));
        }
        //get database data from mysmartbb config file
        if (file_exists(PATH . $script_path . SCRIPT_CONFIG_PATH)) {
            require_once PATH . $script_path . SCRIPT_CONFIG_PATH;
            $forum_srv = $config['db']['server'];
            $forum_db = $config['db']['name'];
            $forum_user = $config['db']['username'];
            $forum_pass = $config['db']['password'];
            $forum_prefix = $config['db']['prefix'];
        } else {
            big_error('Forum path is not correct', sprintf($lang['SCRIPT_AUTH_PATH_WRONG'], 'MySmartBB'));
        }
    } else {
        $forum_srv = $script_srv;
        $forum_db = $script_db;
        $forum_user = $script_user;
        $forum_pass = $script_pass;
        $forum_prefix = $script_prefix;
    }
    if (empty($forum_srv) || empty($forum_user) || empty($forum_db)) {
        return;
    }
    $SQLMS = new SSQL($forum_srv, $forum_user, $forum_pass, $forum_db, true);
    $SQLVB->set_names('latin1');
    $pass = $usrcp->kleeja_utf8($pass, false);
    $name = $usrcp->kleeja_utf8($name, false);
    $query = array('SELECT' => '*', 'FROM' => "`{$forum_prefix}member`");
    $query['WHERE'] = $hashed ? "id=" . intval($name) . " AND password='******'" : "username='******' AND password='******'";
    //if return only name let's ignore the obove
    if ($return_name) {
        $query_salt['SELECT'] = "username";
        $query_salt['WHERE'] = "id=" . intval($name);
    }
    ($hook = kleeja_run_hook('qr_select_usrdata_mysbb_usr_class')) ? eval($hook) : null;
    //run hook
    $result = $SQLMS->build($query);
    if ($SQLMS->num_rows($result) != 0) {
        while ($row = $SQLMS->fetch_array($result)) {
            if ($return_name) {
                return $row['username'];
            }
            if (!$loginadm) {
                define('USER_ID', $row['id']);
                define('GROUP_ID', $row['usergroup'] == 1 ? 1 : 3);
                define('USER_NAME', $usrcp->kleeja_utf8($row['username']));
                define('USER_MAIL', $row['email']);
                define('USER_ADMIN', $row['usergroup'] == 1 ? 1 : 0);
            }
            $userinfo = $row;
            $userinfo['group_id'] = GROUP_ID;
            $user_y = kleeja_base64_encode(serialize(array('id' => $row['id'], 'name' => $usrcp->kleeja_utf8($row['username']), 'mail' => $row['email'], 'last_visit' => time())));
            $hash_key_expire = sha1(md5($config['h_key'] . $row['password']) . $expire);
            if (!$hashed && !$loginadm) {
                $usrcp->kleeja_set_cookie('ulogu', $usrcp->en_de_crypt($row['id'] . '|' . $row['password'] . '|' . $expire . '|' . $hash_key_expire . '|' . GROUP_ID . '|' . $user_y), $expire);
            }
            ($hook = kleeja_run_hook('qr_while_usrdata_mysbb_usr_class')) ? eval($hook) : null;
            //run hook
        }
        $SQLMS->freeresult($result);
        unset($pass);
        $SQLMS->close();
        return true;
    } else {
        $SQLMS->close();
        return false;
    }
}
Example #10
0
/**
* send email
*/
function _sm_mk_utf8($text)
{
    return "=?UTF-8?B?" . kleeja_base64_encode($text) . "?=";
}
         $queryhooks = $SQL->build(array('SELECT' => '*', 'FROM' => "{$dbprefix}hooks", 'WHERE' => "plg_id=" . $plg_id));
         if ($SQL->num_rows($queryhooks) > 0) {
             echo "\t" . '<hooks>' . "\n";
             while ($hook = $SQL->fetch_array($queryhooks)) {
                 echo "\t\t" . '<hook name="' . $hook['hook_name'] . '"><![CDATA[' . clean_xml_cdata($hook['hook_content']) . ']]></hook>' . "\n";
             }
             echo "\t" . '</hooks>' . "\n";
         }
         if (!empty($row['plg_files'])) {
             $nfiles = unserialize(kleeja_base64_decode($row['plg_files']));
             echo "\t" . '<files>' . "\n";
             foreach ($nfiles as $f) {
                 if ($f[0] == '/') {
                     $f = substr($f, 1);
                 }
                 echo "\t\t" . '<file path="' . $f . '"><![CDATA[' . kleeja_base64_encode(@file_get_contents(PATH . $f)) . ']]></file>' . "\n";
             }
             echo "\t" . '</files>' . "\n";
         }
         echo '</kleeja>';
         exit;
     } else {
         kleeja_admin_err($lang['ERROR']);
     }
     break;
     //downaloding zipped changes ..
 //downaloding zipped changes ..
 case 6:
     if (!isset($_GET['fn'])) {
         kleeja_admin_err($lang['ERROR']);
     }