//ADDING FOR SEARCH
if ($tagsMode == 'Search Tags') {
    global $mod_strings;
    if (!empty($search_tag_name)) {
        $search_tag_name = $GLOBALS['db']->quote($search_tag_name[0]);
        $query = "select id,tag_name from kbtags where tag_name='{$search_tag_name}' and deleted = 0";
        $result = $GLOBALS['db']->query($query);
        //$searched_tagIds  =  $GLOBALS['db']->fetchByAssoc($result);
        $searched_and_related_Ids = array();
        $searched_ids = array();
        //for each search tag id find all the way to the root and save the nodes enroute
        //in the sequence.
        $found = 0;
        while (($searchIds = $GLOBALS['db']->fetchByAssoc($result)) != null) {
            $found = 1;
            $searched_and_related_Ids[$searchIds['id']] = getRootNode($searchIds['id'], $searchIds['tag_name']);
        }
        if ($found == 1) {
            $root_node = get_searched_tags_nodes($searched_and_related_Ids);
            $tagstree = new KBTree('tagstree');
            $tagstree->set_param('module', 'KBTags');
            $tagstree->set_param('moduleview', 'modal');
            $tagstree->add_node($root_node);
            //			    $response = generate_nodes_array_custom($tagstree);
            $response = $tagstree->generate_nodes_array($tagstree);
        } else {
            $not_found_msg = $mod_strings['LBL_NO_MATHING_TAG_FOUND'];
            $response = "<script>alert('{$not_found_msg}')</script>";
        }
        echo $response;
        sugar_cleanup();
예제 #2
0
function Login($user, $pass)
{
    global $T8;
    if (!extension_loaded('bcmath')) {
        html_error('This plugin needs BCMath extension for login.');
    }
    $password_aes = prepare_key(str_to_a32($pass));
    $T8['user_handle'] = stringhash($user, $password_aes);
    $res = apiReq(array('a' => 'us', 'user' => $user, 'uh' => $T8['user_handle']));
    if (is_numeric($res[0])) {
        check_errors($res[0], 'Cannot login');
    }
    $T8['master_key'] = decrypt_key(base64_to_a32($res[0]['k']), $password_aes);
    $privk = a32_to_str(decrypt_key(base64_to_a32($res[0]['privk']), $T8['master_key']));
    $rsa_priv_key = array(0, 0, 0, 0);
    for ($i = 0; $i < 4; $i++) {
        $l = (ord($privk[0]) * 256 + ord($privk[1]) + 7) / 8 + 2;
        $rsa_priv_key[$i] = mpi2bc(substr($privk, 0, $l));
        $privk = substr($privk, $l);
    }
    $T8['sid'] = rsa_decrypt(mpi2bc(base64url_decode($res[0]['csid'])), $rsa_priv_key[0], $rsa_priv_key[1], $rsa_priv_key[2]);
    $T8['sid'] = base64url_encode(substr(strrev($T8['sid']), 0, 43));
    getRootNode();
    t8ArrToCookieArr($rsa_priv_key);
    SaveCookies($user, $pass);
    // Update cookies file.
    $cookie = '';
}