Esempio n. 1
0
/**
 * @package tikiwiki
 */
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
require 'tiki-setup.php';
if (!isset($_POST['page'], $_POST['content'], $_POST['index'], $_POST['type'], $_SERVER['HTTP_REFERER'])) {
    die('Missing parameters');
}
$page = $_POST['page'];
$plugin = strtolower(basename($_POST['type']));
$type = TikiLib::strtoupper($plugin);
if (empty($parserlib)) {
    $parserlib = TikiLib::lib('parser');
}
if (!($meta = $parserlib->plugin_info($plugin))) {
    exit;
}
if (!isset($_POST['message'])) {
    $_POST['message'] = (isset($meta['name']) ? tra($meta['name']) : $plugin) . ' ' . tra('Plugin modified by editor.');
}
$info = $tikilib->get_page_info($page);
$tikilib->get_perm_object($page, 'wiki page', $info, true);
if ($tiki_p_edit != 'y') {
    header("Location: {$_SERVER['HTTP_REFERER']}");
    exit;
}
Esempio n. 2
0
function wikiplugin_dbreport_parse(&$code)
{
    global $debug, $wikiplugin_dbreport_fields_allowed;
    // code properties
    $len = strlen($code);
    $pos = 0;
    // FSM state
    $parse_state = 0;
    $parse_link_return = 0;
    $parse_line_return = 0;
    $parse_cell_return = 0;
    $parse_object;
    $parse_text;
    $parse_line;
    $parse_cell;
    $span_mode;
    unset($parse_report);
    $parse_report = new WikipluginDBReport();
    // parse the code
    while (true) {
        // get the next token
        $token = wikiplugin_dbreport_next_token($code, $len, $pos);
        $pos = $token->after;
        // repeat while we have an unconsumed token
        while (isset($token)) {
            $next_token = $token;
            switch ($parse_state) {
                case 0:
                    // next keyword
                    switch ($token->type) {
                        case 'eof':
                            if (!isset($parse_report->sql)) {
                                return wikiplugin_dbreport_parse_error($token, "Unexpected End.");
                            }
                            return $parse_report;
                            break;
                        case 'key':
                            switch (TikiLib::strtoupper($token->content)) {
                                case 'SQL':
                                    $parse_state = 1;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    $wikiplugin_dbreport_fields_allowed = false;
                                    // no fields in sql
                                    break;
                                case 'PARAM':
                                    // create the parameter object
                                    unset($parse_object);
                                    $parse_object = new WikipluginDBReportParameter($token);
                                    $parse_report->params[] =& $parse_object;
                                    $parse_state = 2;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    $wikiplugin_dbreport_fields_allowed = false;
                                    // no fields in sql params
                                    break;
                                case 'GROUP':
                                    // create the group object
                                    unset($parse_object);
                                    $parse_object = new WikipluginDBReportGroup();
                                    $parse_report->groups[] =& $parse_object;
                                    $parse_state = 3;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    $wikiplugin_dbreport_fields_allowed = true;
                                    // we can now parse fields
                                    break;
                                case 'TABLE':
                                    // create the table object
                                    unset($parse_object);
                                    $parse_object = new WikipluginDBReportTable();
                                    $parse_report->table =& $parse_object;
                                    $parse_state = 4;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    $wikiplugin_dbreport_fields_allowed = true;
                                    // we can now parse fields
                                    break;
                                case 'FAIL':
                                    // create the fail object
                                    unset($parse_object);
                                    $parse_object = new WikipluginDBReportFail();
                                    $parse_report->fail =& $parse_object;
                                    $parse_state = 10;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    $wikiplugin_dbreport_fields_allowed = false;
                                    // no fields in fail message
                                    break;
                                default:
                                    return wikiplugin_dbreport_parse_error($token, "Invalid keyword '{$token->content}'");
                            }
                            break;
                        default:
                            return wikiplugin_dbreport_parse_error($token, "Unexpected " . $token->type . " '" . $token->content . "' at " . $token->start);
                    }
                    break;
                case 1:
                    // SQL content
                    switch ($token->type) {
                        case 'eof':
                            $parse_state = 0;
                            // switch state and reparse the token
                            break;
                        case 'bra':
                            $parse_report->sql .= $token->content;
                            unset($next_token);
                            // consume the token
                            break;
                        case 'txt':
                            $parse_report->sql .= stripcslashes($token->content);
                            unset($next_token);
                            // consume the token
                            break;
                        case 'key':
                            $parse_state = 0;
                            // switch state and reparse the token
                            break;
                        default:
                            return wikiplugin_dbreport_parse_error($token, "Unexpected " . $token->type_name() . " '{$token->content}' after 'SQL'. String expected.");
                    }
                    break;
                case 2:
                    // PARAM content
                    switch ($token->type) {
                        case 'eof':
                            $parse_state = 0;
                            // switch parse state
                            break;
                            /* case 'sty':
                            			$parse_object->name = $token->content;
                            			unset($next_token);	// consume the token
                            			break; */
                        /* case 'sty':
                        			$parse_object->name = $token->content;
                        			unset($next_token);	// consume the token
                        			break; */
                        case 'fld':
                            $parse_object->append_field($token->content);
                            unset($next_token);
                            // consume the token
                            break;
                        case 'var':
                            $parse_object->append_variable($token->content);
                            unset($next_token);
                            // consume the token
                            break;
                        case 'txt':
                            unset($parse_object->elements);
                            $parse_object->elements[] = new WikipluginDBReportText($token);
                            unset($next_token);
                            // consume the token
                            break;
                        case 'key':
                            unset($parse_object);
                            $parse_state = 0;
                            // switch state and reparse the token
                            break;
                        default:
                            return wikiplugin_dbreport_parse_error($token, "Unexpected " . $token->type_name() . " '{$token->content}' after 'PARAM'. Name, Field, String or Variable expected.");
                    }
                    break;
                case 3:
                    // GROUP content
                    switch ($token->type) {
                        case 'eof':
                            $parse_state = 0;
                            // switch state and reparse the token
                            break;
                        case 'fld':
                            unset($parse_object->fields);
                            $parse_object->fields[] = new WikipluginDBReportField($token->content);
                            $parse_object->field_count++;
                            unset($next_token);
                            // consume the token
                            break;
                        case 'txt':
                        case 'var':
                            unset($parse_text);
                            $parse_text = new WikipluginDBReportText($token);
                            $parse_object->contents[] =& $parse_text;
                            $parse_text_return = $parse_state;
                            // return to this state
                            $parse_state = 9;
                            // switch state
                            unset($next_token);
                            // consume the token
                            break;
                        case 'sty':
                            unset($parse_object->style);
                            $parse_object->style = new WikipluginDBReportStyle($token);
                            unset($next_token);
                            // consume the token
                            break;
                        case 'key':
                            switch (TikiLib::strtoupper($token->content)) {
                                case '<':
                                    unset($parse_link);
                                    $parse_link = new WikipluginDBReportLink($token);
                                    // create the link object
                                    $parse_object->link =& $parse_link;
                                    $parse_link_return = $parse_state;
                                    // return to this state
                                    $parse_state = 5;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    break;
                                default:
                                    unset($parse_object);
                                    // we are finished parsing the group
                                    $wikiplugin_dbreport_fields_allowed = false;
                                    // we cannot parse fields anymore
                                    $parse_state = 0;
                                    // switch state and reparse the token
                                    break;
                            }
                            break;
                        default:
                            return wikiplugin_dbreport_parse_error($token, "Unexpected " . $token->type_name() . " '{$token->content}' after '<'. Field, String or Style expected.");
                    }
                    break;
                case 4:
                    // TABLE content
                    switch ($token->type) {
                        case 'eof':
                            $parse_state = 0;
                            // switch state and reparse the token
                            break;
                        case 'sty':
                            unset($parse_object->style);
                            $parse_object->style = new WikipluginDBReportStyle($token);
                            unset($next_token);
                            // consume the token
                            break;
                        case 'key':
                            switch (TikiLib::strtoupper($token->content)) {
                                case 'HEADER':
                                    unset($parse_line);
                                    $parse_line = new WikipluginDBReportLine();
                                    $parse_object->headers[] =& $parse_line;
                                    $parse_line_return = $parse_state;
                                    // return to this state
                                    $parse_state = 6;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    break;
                                case 'FOOTER':
                                    unset($parse_line);
                                    $parse_line = new WikipluginDBReportLine();
                                    $parse_object->footers[] =& $parse_line;
                                    $parse_line_return = $parse_state;
                                    // return to this state
                                    $parse_state = 6;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    break;
                                case 'ROW':
                                case 'ROWS':
                                    unset($parse_line);
                                    $parse_line = new WikipluginDBReportLine();
                                    $parse_object->rows[] =& $parse_line;
                                    $parse_line_return = $parse_state;
                                    // return to this state
                                    $parse_state = 6;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    break;
                                default:
                                    unset($parse_object);
                                    // we are finished parsing the table
                                    $wikiplugin_dbreport_fields_allowed = false;
                                    // we cannot parse fields anymore
                                    $parse_state = 0;
                                    // switch state and reparse the token
                            }
                            break;
                        default:
                            return wikiplugin_dbreport_parse_error($token, "Unexpected " . $token->type_name() . " '{$token->content}' after 'TABLE'. HEADER, FOOTER, ROWS, <, or Style expected.");
                    }
                    break;
                case 5:
                    // Link content
                    switch ($token->type) {
                        case 'eof':
                            return wikiplugin_dbreport_parse_error($token, "Unexpected EOF in WikipluginDBReportLink. '>' expected.");
                            break;
                        case 'var':
                        case 'fld':
                            unset($parse_link->contents);
                            $parse_link->contents[] = new WikipluginDBReportField($token->content);
                            unset($next_token);
                            // consume the token
                            break;
                        case 'txt':
                            unset($parse_link->contents);
                            $parse_link->contents[] = new WikipluginDBReportContent($token);
                            unset($next_token);
                            // consume the token
                            break;
                            /*
                            case 'txt':
                            	$parse_link->append($token->content);
                            	unset($next_token);		// consume the token
                            	break;
                            case 'var':
                            	$parse_link->append_variable($token->content);
                            	unset($next_token);		// consume the token
                            	break;
                            case 'fld':
                            	$parse_link->append_field($token->content);
                            	unset($next_token);		// consume the token
                            	break;
                            */
                        /*
                        case 'txt':
                        	$parse_link->append($token->content);
                        	unset($next_token);		// consume the token
                        	break;
                        case 'var':
                        	$parse_link->append_variable($token->content);
                        	unset($next_token);		// consume the token
                        	break;
                        case 'fld':
                        	$parse_link->append_field($token->content);
                        	unset($next_token);		// consume the token
                        	break;
                        */
                        case 'sty':
                            unset($parse_link->style);
                            $parse_link->style = new WikipluginDBReportStyle($token);
                            unset($next_token);
                            // consume the token
                            break;
                        case 'key':
                            switch (TikiLib::strtoupper($token->content)) {
                                case '<':
                                    return wikiplugin_dbreport_parse_error($token, "Unexpected '<' in Link. '>' expected.");
                                case '>':
                                    unset($next_token);
                                    // consume the token
                                    $parse_state = $parse_link_return;
                                    // return to previous state
                                    break;
                                default:
                                    return wikiplugin_dbreport_parse_error($token, "Unexpected Keyword '{$token->content}' in Link. '>' expected.");
                            }
                        default:
                            $parse_state = $parse_link_return;
                            // switch state and reparse the token
                    }
                    break;
                case 6:
                    // HEADER, FOOTER, ROW content
                    switch ($token->type) {
                        case 'eof':
                            $parse_state = $parse_line_return;
                            // switch state and reparse the token
                            break;
                        case 'sty':
                            unset($parse_link->styles);
                            $parse_line->styles[] = new WikipluginDBReportStyle($token);
                            unset($next_token);
                            // consume the token
                            break;
                        case 'key':
                            switch (TikiLib::strtoupper($token->content)) {
                                case 'CELL':
                                    unset($parse_cell);
                                    $parse_cell = new WikipluginDBReportCell();
                                    $parse_line->cells[] =& $parse_cell;
                                    $parse_cell_return = $parse_state;
                                    // return to this state
                                    $parse_state = 7;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    break;
                                case '<':
                                    unset($parse_link);
                                    $parse_link = new WikipluginDBReportLink($token);
                                    // create the link object
                                    $parse_line->link =& $parse_link;
                                    $parse_link_return = $parse_state;
                                    // return to this state
                                    $parse_state = 5;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    break;
                                case 'HEADER':
                                case 'ROW':
                                case 'FOOTER':
                                case 'FAIL':
                                    $parse_state = $parse_line_return;
                                    break;
                                default:
                                    return wikiplugin_dbreport_parse_error($token, "Invalid keyword '{$token->content}' after row. CELL or Link expected.");
                            }
                            break;
                        default:
                            return wikiplugin_dbreport_parse_error($token, "Unexpected " . $token->type_name() . " '{$token->content}' in row.");
                    }
                    break;
                case 7:
                    // CELL content
                    switch ($token->type) {
                        case 'eof':
                            $parse_state = $parse_cell_return;
                            // switch state and reparse the token
                            break;
                        case 'fld':
                        case 'var':
                        case 'txt':
                            unset($parse_text);
                            $parse_text = new WikipluginDBReportText($token);
                            $parse_cell->contents[] =& $parse_text;
                            $parse_text_return = $parse_state;
                            // return to this state
                            $parse_state = 9;
                            // switch state
                            unset($next_token);
                            // consume the token
                            break;
                        case 'sty':
                            unset($parse_cell->style);
                            $parse_cell->style = new WikipluginDBReportStyle($token);
                            unset($next_token);
                            // consume the token
                            break;
                        case 'key':
                            switch (TikiLib::strtoupper($token->content)) {
                                case '<':
                                    unset($parse_link);
                                    $parse_link = new WikipluginDBReportLink($token);
                                    // create the link object
                                    $parse_cell->link =& $parse_link;
                                    $parse_link_return = $parse_state;
                                    // return to this state
                                    $parse_state = 5;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    break;
                                case 'SPAN':
                                    $span_mode = 'COL';
                                    $parse_state = 8;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    break;
                                case 'COLSPAN':
                                    $span_mode = 'COL';
                                    $parse_state = 8;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    break;
                                case 'ROWSPAN':
                                    $span_mode = 'ROW';
                                    $parse_state = 8;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    break;
                                case 'CELL':
                                case 'HEADER':
                                case 'ROW':
                                case 'COLUMN':
                                case 'FOOTER':
                                case 'FAIL':
                                    $parse_state = $parse_cell_return;
                                    // switch state and reparse the token
                                    break;
                                default:
                                    return wikiplugin_dbreport_parse_error($token, "Invalid keyword '{$token->content}' in 'CELL'. Field, String, Style or Link expected.");
                            }
                            break;
                        default:
                            return wikiplugin_dbreport_parse_error($token, "Unexpected " . $token->type_name() . " '{$token->content}' after 'CELL'.");
                    }
                    break;
                case 8:
                    // SPAN content
                    switch ($token->type) {
                        case 'key':
                            // try to parse the keyword as as number
                            $span = (int) $token->content;
                            if ((string) $span == $token->content) {
                                if ($span_mode == 'ROW') {
                                    $parse_cell->rowspan = $span;
                                } else {
                                    $parse_cell->colspan = $span;
                                }
                                unset($next_token);
                                // consume the token
                            }
                            $parse_state = 7;
                            // switch state (and possibly reparse the token)
                            break;
                        default:
                            $parse_state = 7;
                            // switch state and reparse the token
                    }
                    break;
                case 9:
                    // Text content
                    switch ($token->type) {
                        case 'sty':
                            unset($parse_text->style);
                            $parse_text->style = new WikipluginDBReportStyle($token);
                            unset($next_token);
                            // consume the token
                            break;
                        case 'key':
                            switch (TikiLib::strtoupper($token->content)) {
                                case '<':
                                    unset($parse_link);
                                    $parse_link = new WikipluginDBReportLink($token);
                                    // create the link object
                                    $parse_text->link =& $parse_link;
                                    $parse_link_return = $parse_state;
                                    // return to this state
                                    $parse_state = 5;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    break;
                                default:
                                    $parse_state = $parse_text_return;
                                    // return to the previous state
                                    break;
                            }
                            break;
                        default:
                            $parse_state = $parse_text_return;
                            // return to the previous state
                            break;
                    }
                    break;
                case 10:
                    // Fail content
                    switch ($token->type) {
                        case 'eof':
                            $parse_state = 0;
                            // switch state and reparse the token
                            break;
                        case 'var':
                        case 'txt':
                            unset($parse_text);
                            $parse_text = new WikipluginDBReportText($token);
                            $parse_object->contents[] =& $parse_text;
                            $parse_text_return = $parse_state;
                            // return to this state
                            $parse_state = 9;
                            // switch state
                            unset($next_token);
                            // consume the token
                            break;
                        case 'sty':
                            unset($parse_object->style);
                            $parse_object->style = new WikipluginDBReportStyle($token);
                            unset($next_token);
                            // consume the token
                            break;
                        case 'key':
                            switch (TikiLib::strtoupper($token->content)) {
                                case '<':
                                    unset($parse_link);
                                    $parse_link = new WikipluginDBReportLink($token);
                                    // create the link object
                                    $parse_object->link =& $parse_link;
                                    $parse_link_return = $parse_state;
                                    // return to this state
                                    $parse_state = 5;
                                    // switch state
                                    unset($next_token);
                                    // consume the token
                                    break;
                                default:
                                    unset($parse_object);
                                    // we are finished parsing the fail
                                    $parse_state = 0;
                                    // switch state and reparse the token
                                    break;
                            }
                            break;
                        default:
                            return wikiplugin_dbreport_parse_error($token, "Unexpected " . $token->type_name() . " '{$token->content}' after 'FAIL'.");
                    }
                    break;
                default:
                    $parse_state = 0;
            }
            $token = $next_token;
        }
    }
}
Esempio n. 3
0
	/**
	 * Convert rgb() color definiton to hex color definiton
	 * 
	 * @param unknown_type $col
	 * @return The hex representation
	 */
	function parseColor(&$col)
	{
		
		if (preg_match("/^rgb\( *(\d+) *, *(\d+) *, *(\d+) *\)$/", $col, $parts) ) {
			$hex = str_pad(dechex($parts[1]), 2, '0', STR_PAD_LEFT)
			     . str_pad(dechex($parts[2]), 2, '0', STR_PAD_LEFT)
				 . str_pad(dechex($parts[3]), 2, '0', STR_PAD_LEFT);
			$hex = '#' . TikiLib::strtoupper($hex);
		} else {
			$hex = $col;
		}
		
		return $hex;
	}
Esempio n. 4
0
	function validate_user_tiki($user, $pass, $challenge, $response, $validate_phase = false)
	{
		global $prefs;

		// first verify that the user exists
		$query = 'select * from `users_users` where binary `login` = ?';
		$result = $this->query($query, array($user));

		if (!$result->numRows()) {
			$query = 'select * from `users_users` where upper(`login`) = ?';
			$result = $this->query($query, array(TikiLib::strtoupper($user)));

			switch ($result->numRows()) {
				case 0:
					return array(USER_NOT_FOUND, $user);

				case 1:
								break;

				default:
					return array(USER_AMBIGOUS, $user);
			}
		}


		$res = $result->fetchRow();
		$user = $res['login'];

		// next verify the password with every hashes methods
		if ($prefs['feature_challenge'] == 'n' || empty($response)) {
			if (!empty($res['valid']) && $pass == $res['valid']) // used for validation of user account before activation
				return array(USER_VALID, $user);

			if ($res['waiting'] == 'u')
				return array(ACCOUNT_WAITING_USER, $user);
			if ($res['waiting'] == 'a')
				return array(ACCOUNT_DISABLED, $user);

			if ($res['hash'] == md5($user.$pass.trim($res['email']))) // very old method md5(user.pass.email), for compatibility
				return array(USER_VALID, $user);

			if ($res['hash'] == md5($user.$pass)) // old method md5(user.pass), for compatibility
				return array(USER_VALID, $user);

			if ($res['hash'] == md5($pass)) // normal method md5(pass)
				return array(USER_VALID, $user);

			if ($this->hash_pass($pass, $res['hash']) == $res['hash']) // new method (crypt-md5) and tikihash method (md5(pass))
				return array(USER_VALID, $user);

			return array(PASSWORD_INCORRECT, $user);
		} else {
			// Use challenge-reponse method
			// Compare pass against md5(user,challenge,hash)
			$hash = $this->getOne('select `hash` from `users_users` where binary `login`=?', array($user));

			if (!isset($_SESSION["challenge"]))
				return array(false, $user);

			//print("pass: $pass user: $user hash: $hash <br />");
			//print("challenge: ".$_SESSION["challenge"]." challenge: $challenge<br />");
			//print("response : $response<br />");
			if ($response == md5($user . $hash . $_SESSION["challenge"])) {
				$this->update_lastlogin($user);
				return array(USER_VALID, $user);
			} else {
				return array(false, $user);
			}
		}

		return array(PASSWORD_INCORRECT, $user);
	}
Esempio n. 5
0
 static function cmpcatname($a, $b)
 {
     $a = TikiLib::strtoupper(TikiLib::take_away_accent($a));
     $b = TikiLib::strtoupper(TikiLib::take_away_accent($b));
     return strcmp($a, $b);
 }
Esempio n. 6
0
 private function convert_plugin_for_ckeditor($name, $args, $plugin_result, $data, $info = array())
 {
     $ck_editor_plugin = '{' . (empty($data) ? $name : TikiLib::strtoupper($name) . '(') . ' ';
     $arg_str = '';
     // not using http_build_query() as it converts spaces into +
     if (!empty($args)) {
         foreach ($args as $argKey => $argValue) {
             if (is_array($argValue)) {
                 if (isset($info['params'][$argKey]['separator'])) {
                     $sep = $info['params'][$argKey]['separator'];
                 } else {
                     $sep = ',';
                 }
                 $ck_editor_plugin .= $argKey . '="' . implode($sep, $argValue) . '" ';
                 // process array
                 $arg_str .= $argKey . '=' . implode($sep, $argValue) . '&';
             } else {
                 $ck_editor_plugin .= $argKey . '="' . $argValue . '" ';
                 $arg_str .= $argKey . '=' . $argValue . '&';
             }
         }
     }
     if (substr($ck_editor_plugin, -1) === ' ') {
         $ck_editor_plugin = substr($ck_editor_plugin, 0, -1);
     }
     if (!empty($data)) {
         $ck_editor_plugin .= ')}' . $data . '{' . TikiLib::strtoupper($name) . '}';
     } else {
         $ck_editor_plugin .= '}';
     }
     // work out if I'm a nested plugin and return empty if so
     $stack = debug_backtrace();
     $plugin_nest_level = 0;
     foreach ($stack as $st) {
         if ($st['function'] === 'parse_first') {
             $plugin_nest_level++;
             if ($plugin_nest_level > 1) {
                 return '';
             }
         }
     }
     $arg_str = rtrim($arg_str, '&');
     $icon = isset($info['icon']) ? $info['icon'] : 'img/icons/wiki_plugin_edit.png';
     // some plugins are just too flakey to do wysiwyg, so show the "source" for them ;(
     if (in_array($name, array('trackerlist', 'kaltura', 'toc', 'freetagged', 'draw', 'googlemap'))) {
         $plugin_result = '&nbsp;&nbsp;&nbsp;&nbsp;' . $ck_editor_plugin;
     } else {
         // Tiki 7+ adds ~np~ to plugin output so remove them
         $plugin_result = preg_replace('/~[\\/]?np~/ms', '', $plugin_result);
         $plugin_result = $this->parse_data($plugin_result, array('is_html' => false, 'suppress_icons' => true, 'ck_editor' => true, 'noparseplugins' => true));
         // remove hrefs and onclicks
         $plugin_result = preg_replace('/\\shref\\=/i', ' tiki_href=', $plugin_result);
         $plugin_result = preg_replace('/\\sonclick\\=/i', ' tiki_onclick=', $plugin_result);
         $plugin_result = preg_replace('/<script.*?<\\/script>/mi', '', $plugin_result);
     }
     if (!in_array($name, array('html'))) {
         // remove <p> and <br>s from non-html
         $data = str_replace(array('<p>', '</p>', "\t"), '', $data);
         $data = str_replace('<br />', "\n", $data);
     }
     if ($this->contains_html_block($plugin_result)) {
         $elem = 'div';
     } else {
         $elem = 'span';
     }
     $elem_style = 'position:relative;';
     if (in_array($name, array('img', 'div')) && preg_match('/<' . $name . '[^>]*style="(.*?)"/i', $plugin_result, $m)) {
         if (count($m)) {
             $elem_style .= $m[1];
         }
     }
     $ret = '~np~<' . $elem . ' class="tiki_plugin" plugin="' . $name . '" style="' . $elem_style . '"' . ' syntax="' . htmlentities($ck_editor_plugin, ENT_QUOTES, 'UTF-8') . '"' . ' args="' . htmlentities($arg_str, ENT_QUOTES, 'UTF-8') . '"' . ' body="' . htmlentities($data, ENT_QUOTES, 'UTF-8') . '">' . '<img src="' . $icon . '" width="16" height="16" style="float:left;position:relative;z-index:10001" />' . $plugin_result . '<!-- end tiki_plugin --></' . $elem . '>~/np~';
     return $ret;
 }
Esempio n. 7
0
 private function convert_plugin_for_ckeditor($name, $args, $plugin_result, $data, $info = array())
 {
     $ck_editor_plugin = '{' . (empty($data) ? $name : TikiLib::strtoupper($name) . '(') . ' ';
     $arg_str = '';
     // not using http_build_query() as it converts spaces into +
     if (!empty($args)) {
         foreach ($args as $argKey => $argValue) {
             if (is_array($argValue)) {
                 if (isset($info['params'][$argKey]['separator'])) {
                     $sep = $info['params'][$argKey]['separator'];
                 } else {
                     $sep = ',';
                 }
                 $ck_editor_plugin .= $argKey . '="' . implode($sep, $argValue) . '" ';
                 // process array
                 $arg_str .= $argKey . '=' . implode($sep, $argValue) . '&';
             } else {
                 // even though args are now decoded we still need to escape double quotes
                 $argValue = addslashes($argValue);
                 $ck_editor_plugin .= $argKey . '="' . $argValue . '" ';
                 $arg_str .= $argKey . '=' . $argValue . '&';
             }
         }
     }
     if (substr($ck_editor_plugin, -1) === ' ') {
         $ck_editor_plugin = substr($ck_editor_plugin, 0, -1);
     }
     if (!empty($data)) {
         $ck_editor_plugin .= ')}' . $data . '{' . TikiLib::strtoupper($name) . '}';
     } else {
         $ck_editor_plugin .= '}';
     }
     // work out if I'm a nested plugin and return empty if so
     $stack = debug_backtrace();
     $plugin_nest_level = 0;
     foreach ($stack as $st) {
         if ($st['function'] === 'parse_first') {
             $plugin_nest_level++;
             if ($plugin_nest_level > 1) {
                 return '';
             }
         }
     }
     $arg_str = rtrim($arg_str, '&');
     $icon = isset($info['icon']) ? $info['icon'] : 'img/icons/wiki_plugin_edit.png';
     // some plugins are just too fragile to do wysiwyg, so show the "source" for them ;(
     $excluded = array('tracker', 'trackerlist', 'trackerfilter', 'kaltura', 'toc', 'freetagged', 'draw', 'googlemap', 'include', 'module', 'list', 'custom_search', 'iframe', 'map', 'calendar', 'file', 'files', 'mouseover', 'sort', 'slideshow', 'convene', 'redirect', 'galleriffic');
     $ignore = null;
     $enabled = $this->plugin_enabled($name, $ignore);
     if (in_array($name, $excluded) || !$enabled) {
         $plugin_result = '&nbsp;&nbsp;&nbsp;&nbsp;' . $ck_editor_plugin;
     } else {
         if (!isset($info['format']) || $info['format'] !== 'html') {
             $oldOptions = $this->option;
             $plugin_result = $this->parse_data($plugin_result, array('is_html' => false, 'suppress_icons' => true, 'ck_editor' => true, 'noparseplugins' => true));
             $this->setOptions($oldOptions);
             // reset the noparseplugins option, to allow for proper display in CkEditor
             $this->option['noparseplugins'] = false;
         } else {
             $plugin_result = preg_replace('/~[\\/]?np~/ms', '', $plugin_result);
             // remove no parse tags otherwise they get nested later (bad)
         }
         if (!getCookie('wysiwyg_inline_edit', 'preview', false)) {
             // remove hrefs and onclicks
             $plugin_result = preg_replace('/\\shref\\=/i', ' tiki_href=', $plugin_result);
             $plugin_result = preg_replace('/\\sonclick\\=/i', ' tiki_onclick=', $plugin_result);
             $plugin_result = preg_replace('/<script.*?<\\/script>/mi', '', $plugin_result);
             // remove hidden inputs
             $plugin_result = preg_replace('/<input.*?type=[\'"]?hidden[\'"]?.*>/mi', '', $plugin_result);
         }
     }
     if (!in_array($name, array('html'))) {
         // remove <p> and <br>s from non-html
         $data = str_replace(array('<p>', '</p>', "\t"), '', $data);
         $data = str_replace('<br />', "\n", $data);
     }
     if ($this->contains_html_block($plugin_result)) {
         $elem = 'div';
     } else {
         $elem = 'span';
     }
     $elem_style = 'position:relative;';
     if (!$enabled) {
         $elem_style .= 'opacity:0.3;';
     }
     if (in_array($name, array('img', 'div')) && preg_match('/<' . $name . '[^>]*style="(.*?)"/i', $plugin_result, $m)) {
         if (count($m)) {
             $elem_style .= $m[1];
         }
     }
     $ret = '~np~<' . $elem . ' contenteditable="false" unselectable="on" class="tiki_plugin" data-plugin="' . $name . '" style="' . $elem_style . '"' . ' data-syntax="' . htmlentities($ck_editor_plugin, ENT_QUOTES, 'UTF-8') . '"' . ' data-args="' . htmlentities($arg_str, ENT_QUOTES, 'UTF-8') . '"' . ' data-body="' . htmlentities($data, ENT_QUOTES, 'UTF-8') . '">' . '<img src="' . $icon . '" width="16" height="16" class="plugin_icon" />' . $plugin_result . '<!-- end tiki_plugin --></' . $elem . '>~/np~';
     return $ret;
 }
Esempio n. 8
0
 public function get_plugin_description($name, &$enabled, $area_id = 'editwiki')
 {
     $tikilib = TikiLib::lib('tiki');
     $parserlib = TikiLib::lib('parser');
     if (!($info = $parserlib->plugin_info($name)) && $parserlib->plugin_exists($name, true)) {
         $enabled = true;
         $func_name = "wikiplugin_{$name}_help";
         if (!function_exists($func_name)) {
             return false;
         }
         $ret = $func_name();
         return $tikilib->parse_data($ret);
     } else {
         $smarty = TikiLib::lib('smarty');
         $enabled = true;
         $ret = $info;
         if (isset($ret['prefs'])) {
             global $prefs;
             // If the plugin defines required preferences, they should all be to 'y'
             foreach ($ret['prefs'] as $pref) {
                 if (!isset($prefs[$pref]) || $prefs[$pref] != 'y') {
                     $enabled = false;
                     return;
                 }
             }
         }
         if (isset($ret['documentation']) && ctype_alnum($ret['documentation'])) {
             $ret['documentation'] = "http://doc.tiki.org/{$ret['documentation']}";
         }
         $smarty->assign('area_id', $area_id);
         $smarty->assign('plugin', $ret);
         $smarty->assign('plugin_name', TikiLib::strtoupper($name));
         return $smarty->fetch('tiki-plugin_help.tpl');
     }
 }
Esempio n. 9
0
 function other_user_has_email($user, $email)
 {
     $query = 'select `login` from `users_users` where upper(`email`)=? and `login`!=?';
     $pass = $this->getOne($query, array(TikiLib::strtoupper($email), $user));
     return $pass;
 }