Esempio n. 1
0
 function save_f_method($method)
 {
     global $dbprefix, $SQL, $config;
     if (!get_config('upg_f_method')) {
         return add_config('upg_f_method', $method);
     } else {
         return update_config('upg_f_method', $method);
     }
 }
Esempio n. 2
0
function add_config($name, $value = '', $order = 0, $field = '', $type = '0', $dynamic = false)
{
    global $plugin;
    #if bulk adding
    if (is_array($name)) {
        foreach ($name as $n => $v) {
            add_config($n, $v['order'], $v['field'], $v['type'], $v['dynamic']);
        }
        return;
    }
    global $dbprefix, $SQL, $config, $d_groups;
    if (get_config($name)) {
        return true;
    }
    if ($field != '' && $type == '0') {
        $type = 'other';
    }
    if ($type == 'groups') {
        #add this option to all groups
        $group_ids = array_keys($d_groups);
        foreach ($group_ids as $g_id) {
            $insert_query = array('INSERT' => '`name`, `value`, `group_id`', 'INTO' => "{$dbprefix}groups_data", 'VALUES' => "'" . $SQL->escape($name) . "','" . $SQL->escape($value) . "', " . $g_id);
            ($hook = $plugin->run_hook('insert_sql_add_config_func_groups_data')) ? eval($hook) : null;
            //run hook
            $SQL->build($insert_query);
        }
    }
    $insert_query = array('INSERT' => '`name` ,`value` ,`option` ,`display_order`, `type`, `dynamic`', 'INTO' => "{$dbprefix}config", 'VALUES' => "'" . $SQL->escape($name) . "','" . $SQL->escape($value) . "', '" . $SQL->escape($field) . "', " . intval($order) . ",'" . $SQL->escape($type) . "','" . ($dynamic ? '1' : '0') . "'");
    ($hook = $plugin->run_hook('insert_sql_add_config_func')) ? eval($hook) : null;
    //run hook
    $SQL->build($insert_query);
    if ($SQL->affected()) {
        delete_cache('data_config');
        $config[$name] = $value;
        return true;
    }
    return false;
}
	include_once($config["base_path"]."/include/top_header.php");
	if(isset($_REQUEST['show']) && $_REQUEST['show']=='all')
	{
		addmap_picker(true);
	}
	else
	{
		addmap_picker(false);
	}
	include_once($config["base_path"]."/include/bottom_footer.php");
	break;

case 'addmap':
	if(isset($_REQUEST['file']))
	{
		add_config($_REQUEST['file']);
		header("Location: weathermap-cacti-plugin-mgmt.php");
	}
	else
	{
		print "No such file.";
	}

	break;

case 'editor':
	// chdir(dirname(__FILE__));
	// include_once('./weathermap-cacti-plugin-editor.php');
	break;

case 'rebuildnow':
Esempio n. 4
0
         $xresult = $SQL->build($xquery);
         $xexts = '';
         while ($row = $SQL->fetch($xresult)) {
             if ($row['gust_allow']) {
                 $xexts .= ($xexts == '' ? '' : ',') . "('" . $SQL->escape($row['ext']) . "', 2, " . $row['gust_size'] . ")";
             }
             if ($row['user_allow']) {
                 $xexts .= ($xexts == '' ? '' : ',') . "('" . $SQL->escape($row['ext']) . "', 3, " . $row['user_size'] . ")";
             }
         }
         $SQL->free($result);
         #delete prev exts before adding
         $query_del = array('DELETE' => "{$dbprefix}groups_exts", 'WHERE' => 'group_id=2 OR group_id=3');
         $SQL->build($query_del);
         $SQL->query("INSERT INTO {$dbprefix}groups_exts (ext, group_id, size) VALUES " . $xexts . ";");
         add_config('exts_upraded1_5', 'done');
     }
 }
 #delete ext?
 $DELETED_EXT = $GE_INFO = false;
 if (isset($_GET['del'])) {
     //check _GET Csrf token
     if (!kleeja_check_form_key_get('adm_users')) {
         kleeja_admin_err($lang['INVALID_GET_KEY'], true, $lang['ERROR'], true, $action, 2);
     }
     $req_ext = isset($_GET['del']) ? intval($_GET['del']) : 0;
     if (!$req_ext) {
         kleeja_admin_err('ERROR-NO-EXT-ID', true, '', true, $action, 2);
     }
     $query_del = array('DELETE' => "{$dbprefix}groups_exts", 'WHERE' => 'ext_id=' . $req_ext);
     $SQL->build($query_del);
Esempio n. 5
0
    if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) > 2) {
        $config['language'] = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
        if (!file_exists(PATH . 'lang/' . $config['language'] . '/common.php')) {
            $config['language'] = 'en';
        }
    }
}
//check style
if (!$config['style'] || empty($config['style'])) {
    $config['style'] = 'default';
}
//check h_kay, important for kleeja
if (empty($config['h_key'])) {
    $h_k = sha1(microtime() . rand(0, 100));
    if (!update_config('h_key', $h_k)) {
        add_config('h_key', $h_k);
    }
}
//Global vars for Kleeja
$STYLE_PATH = $config['siteurl'] . 'styles/' . (trim($config['style_depend_on']) == '' ? $config['style'] : $config['style_depend_on']) . '/';
$THIS_STYLE_PATH = $config['siteurl'] . 'styles/' . $config['style'] . '/';
$THIS_STYLE_PATH_ABS = PATH . 'styles/' . $config['style'] . '/';
$STYLE_PATH_ADMIN = $config['siteurl'] . 'admin/' . (is_browser('mobile') || defined('IN_MOBILE') ? 'toffee/' : 'toffee/');
$STYLE_PATH_ADMIN_ABS = PATH . 'admin/' . (is_browser('mobile') || defined('IN_MOBILE') ? 'toffee/' : 'toffee/');
$DEFAULT_PATH_ADMIN_ABS = PATH . 'admin/toffee/';
$DEFAULT_PATH_ADMIN = $config['siteurl'] . 'admin/toffee/';
//get languge of common
get_lang('common');
//ban system
get_ban();
/** Enable this if you want it !
Esempio n. 6
0
                $text = $lang['U_LAST_VER_KLJ'];
            } else {
                if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '>')) {
                    $text = sprintf($lang['UPDATE_NOW_S'], KLEEJA_VERSION, strtolower($version_data)) . '<br /><br />' . $lang['UPDATE_KLJ_NOW'];
                }
            }
        }
        #lets decode it
        $v = @unserialize($config['new_version']);
        #To prevent expected error [ infinit loop ]
        if (isset($_GET['show_msg'])) {
            $query_get = array('SELECT' => '*', 'FROM' => "{$dbprefix}config", 'WHERE' => "name = 'new_version'");
            $result_get = $SQL->build($query_get);
            if (!$SQL->num($result_get)) {
                //add new config value
                add_config('new_version', '');
            }
        }
        $data = array('version_number' => $version_data, 'last_check' => time(), 'msg_appeared' => isset($_GET['show_msg']) ? true : false, 'copyrights' => !empty($b_data[1]) && strpos($b_data[1], 'yes') !== false ? true : false);
        $data = serialize($data);
        update_config('new_version', $SQL->escape($data), false);
        delete_cache('data_config');
    }
    //then go back  to start
    if (isset($_GET['show_msg'])) {
        redirect(ADMIN_PATH . '?update_done=1');
        $SQL->close();
        exit;
    }
    #end current_smt == general
}
 function add_plugin($contents)
 {
     global $dbprefix, $SQL, $lang, $config, $STYLE_PATH_ADMIN, $STYLE_PATH, $THIS_STYLE_PATH, $olang;
     //initiate file handler
     if (empty($this->f) && $this->f_method != '') {
         $this->f = new $this->f_method();
     }
     //parse xml content
     $XML = new kxml();
     $gtree = $XML->xml_to_array($contents);
     //sekelton of Kleeja plugin file
     $tree = empty($gtree['kleeja']) ? null : $gtree['kleeja'];
     $plg_info = empty($tree['info']) ? null : $tree['info'];
     $plg_install = empty($tree['install']) ? null : $tree['install'];
     $plg_uninstall = empty($tree['uninstall']) ? null : $tree['uninstall'];
     $plg_tpl = empty($tree['templates']) ? null : $tree['templates'];
     $plg_hooks = empty($tree['hooks']) ? null : $tree['hooks'];
     $plg_langs = empty($tree['langs']) ? null : $tree['langs'];
     $plg_updates = empty($tree['updates']) ? null : $tree['updates'];
     $plg_instructions = empty($tree['instructions']) ? null : $tree['instructions'];
     $plg_phrases = empty($tree['phrases']) ? null : $tree['phrases'];
     $plg_options = empty($tree['options']) ? null : $tree['options'];
     $plg_files = empty($tree['files']) ? null : $tree['files'];
     //important tags not exists
     if (empty($plg_info)) {
         big_error('Error', $lang['ERR_XML_NO_G_TAGS'] . (defined('DEV_STAGE') ? __FILE__ . ':' . __LINE__ : ''));
     }
     if (!empty($plg_info['plugin_kleeja_version']['value']) && version_compare(strtolower($plg_info['plugin_kleeja_version']['value']), strtolower(KLEEJA_VERSION), '>=') == false) {
         big_error('Error', $lang['PLUGIN_N_CMPT_KLJ']);
     }
     $plg_errors = array();
     $plg_new = true;
     $plugin_name = preg_replace("/[^a-z0-9-_]/", "-", strtolower($plg_info['plugin_name']['value']));
     //is this plugin exists before !
     $is_query = array('SELECT' => 'plg_id, plg_name, plg_ver', 'FROM' => "{$dbprefix}plugins", 'WHERE' => 'plg_name="' . $plugin_name . '"');
     $res = $SQL->build($is_query);
     if ($SQL->num_rows($res)) {
         //it's not new one ! , let's see if it same version
         $plg_new = false;
         $cur_ver = $SQL->fetch_array($res);
         $this->plg_id = $cur_ver['plg_id'];
         $cur_ver = $cur_ver['plg_ver'];
         $new_ver = $SQL->escape($plg_info['plugin_version']['value']);
         if (version_compare(strtolower($cur_ver), strtolower($new_ver), '>=')) {
             return 'xyz';
         } else {
             if (!empty($plg_updates)) {
                 if (is_array($plg_updates['update'])) {
                     if (array_key_exists("attributes", $plg_updates['update'])) {
                         $plg_updates['update'] = array($plg_updates['update']);
                     }
                 }
                 foreach ($plg_updates['update'] as $up) {
                     if (version_compare(strtolower($cur_ver), strtolower($up['attributes']['to']), '<')) {
                         eval($up['value']);
                     }
                 }
             }
         }
     }
     $there_is_intruct = false;
     if (isset($plg_instructions)) {
         if (is_array($plg_instructions['instruction']) && array_key_exists("attributes", $plg_instructions['instruction'])) {
             $plg_instructions['instruction'] = array($plg_instructions['instruction']);
         }
         $instarr = array();
         foreach ($plg_instructions['instruction'] as $in) {
             if (empty($in['attributes']['lang']) || !isset($in['attributes']['lang'])) {
                 big_error('Error', $lang['ERR_XML_NO_G_TAGS'] . (defined('DEV_STAGE') ? __FILE__ . ':' . __LINE__ : ''));
             }
             $instarr[$in['attributes']['lang']] = $in['value'];
         }
         $there_is_intruct = isset($instarr) && !empty($instarr) ? true : false;
     }
     $there_is_files = false;
     if (isset($plg_files)) {
         if (is_array($plg_files['file']) && array_key_exists("attributes", $plg_files['file'])) {
             $plg_files['file'] = array($plg_files['file']);
         }
         $newfiles = array();
         foreach ($plg_files['file'] as $in) {
             if (empty($in['attributes']['path']) || !isset($in['attributes']['path'])) {
                 big_error('Error', $lang['ERR_XML_NO_G_TAGS'] . (defined('DEV_STAGE') ? __FILE__ . ':' . __LINE__ : ''));
             }
             $newfiles[$in['attributes']['path']] = $in['value'];
         }
         $there_is_files = isset($newfiles) && !empty($newfiles) ? true : false;
     }
     if (isset($plg_info['plugin_description'])) {
         if (is_array($plg_info['plugin_description']['description']) && array_key_exists("attributes", $plg_info['plugin_description']['description'])) {
             $plg_info['plugin_description']['description'] = array($plg_info['plugin_description']['description']);
         }
         $p_desc = array();
         foreach ($plg_info['plugin_description']['description'] as $in) {
             if (empty($in['attributes']['lang']) || !isset($in['attributes']['lang'])) {
                 big_error('Error', $lang['ERR_XML_NO_G_TAGS'] . (defined('DEV_STAGE') ? __FILE__ . ':' . __LINE__ : ''));
             }
             $p_desc[$in['attributes']['lang']] = $in['value'];
         }
     }
     //store important tags (for now only "install" and "templates" tags)
     $store = '';
     //storing unreached elements
     if (isset($plg_install) && trim($plg_install['value']) != '') {
         $store .= '<install><![CDATA[' . $plg_install['value'] . ']]></install>' . "\n\n";
     }
     if (isset($plg_updates)) {
         $updates = explode("<updates>", $contents);
         $updates = explode("</updates>", $updates[1]);
         $store .= '<updates>' . $updates[0] . '</updates>' . "\n\n";
     }
     if (isset($plg_tpl)) {
         $templates = explode("<templates>", $contents);
         $templates = explode("</templates>", $templates[1]);
         $store .= '<templates>' . $templates[0] . '</templates>' . "\n\n";
     }
     //eval install code
     if (isset($plg_install) && trim($plg_install['value']) != '' && $plg_new) {
         eval($plg_install['value']);
     }
     //if there is an icon with the plugin
     $plugin_icon = false;
     if (!empty($plg_info['plugin_icon']['value'])) {
         $plugin_icon = $SQL->escape($plg_info['plugin_version']['value']);
     }
     //if the plugin was new
     if ($plg_new) {
         //insert in plugin table
         $insert_query = array('INSERT' => 'plg_name, plg_ver, plg_author, plg_dsc, plg_icon, plg_uninstall, plg_instructions, plg_store, plg_files', 'INTO' => "{$dbprefix}plugins", 'VALUES' => "'" . $SQL->escape($plugin_name) . "','" . $SQL->escape($plg_info['plugin_version']['value']) . "','" . $SQL->escape($plg_info['plugin_author']['value']) . "','" . $SQL->escape(kleeja_base64_encode(serialize($p_desc))) . "','" . ($plugin_icon ? $plugin_icon . "','" : '') . $SQL->real_escape($plg_uninstall['value']) . "','" . ($there_is_intruct ? $SQL->escape(kleeja_base64_encode(serialize($instarr))) : '') . "','" . $SQL->real_escape($store) . "','" . ($there_is_files ? $SQL->escape(kleeja_base64_encode(serialize(array_keys($newfiles)))) : '') . "'");
         $SQL->build($insert_query);
         $this->plg_id = $SQL->insert_id();
     } else {
         //update language
         delete_olang('', '', $this->plg_id);
         $update_query = array('UPDATE' => "{$dbprefix}plugins", 'SET' => "plg_ver='" . $new_ver . "', plg_author='" . $SQL->escape($plg_info['plugin_author']['value']) . "', plg_dsc='" . $SQL->escape($plg_info['plugin_description']['value']) . "', plg_uninstall='" . $SQL->real_escape($plg_uninstall['value']) . ($plugin_icon ? "', plg_icon='" . $plugin_icon : '') . "', plg_instructions='" . ($there_is_intruct ? $SQL->escape(kleeja_base64_encode(serialize($instarr))) : '') . "', plg_files='" . ($there_is_files ? $SQL->escape(kleeja_base64_encode(serialize(array_keys($newfiles)))) : '') . "', plg_store='" . $SQL->escape($store) . "'", 'WHERE' => "plg_id=" . $this->plg_id);
         $SQL->build($update_query);
     }
     if (isset($plg_phrases)) {
         if (is_array($plg_phrases['lang']) && array_key_exists("attributes", $plg_phrases['lang'])) {
             $plg_phrases['lang'] = array($plg_phrases['lang']);
         }
         $phrases = array();
         foreach ($plg_phrases['lang'] as $in) {
             if (empty($in['attributes']['name']) || !isset($in['attributes']['name'])) {
                 big_error('Error', $lang['ERR_XML_NO_G_TAGS']);
             }
             //first we create a new array that can carry language phrases
             $phrases[$in['attributes']['name']] = array();
             if (is_array($in['phrase']) && array_key_exists("attributes", $in['phrase'])) {
                 $in['phrase'] = array($in['phrase']);
             }
             //get phrases value
             foreach ($in['phrase'] as $phrase) {
                 $phrases[$in['attributes']['name']][$phrase['attributes']['name']] = $phrase['value'];
             }
             //finally we add it to the database
             add_olang($phrases[$in['attributes']['name']], $in['attributes']['name'], $this->plg_id);
         }
     }
     if (isset($plg_options)) {
         if (is_array($plg_options['option']) && array_key_exists("attributes", $plg_options['option'])) {
             $plg_options['option'] = array($plg_options['option']);
         }
         foreach ($plg_options['option'] as $in) {
             add_config($in['attributes']['name'], $in['attributes']['value'], $in['attributes']['order'], $in['value'], $in['attributes']['menu'], $this->plg_id);
         }
         //delete_cache('data_config');
     }
     //add new files
     if ($there_is_files) {
         foreach ($newfiles as $path => $content) {
             $this->f->_write($this->_fixpath_newfile($path), kleeja_base64_decode($content));
         }
         unset($newfiles);
     }
     //cache important instruction
     $cached_instructions = array();
     //some actions with tpls
     if (isset($plg_tpl)) {
         //edit template
         if (isset($plg_tpl['edit'])) {
             include_once "s_strings.php";
             $finder = new sa_srch();
             if (is_array($plg_tpl['edit']['template']) && array_key_exists("attributes", $plg_tpl['edit']['template'])) {
                 $plg_tpl['edit']['template'] = array($plg_tpl['edit']['template']);
             }
             foreach ($plg_tpl['edit']['template'] as $temp) {
                 $template_name = $SQL->real_escape($temp['attributes']['name']);
                 if (isset($temp['find']['value']) && isset($temp['findend']['value'])) {
                     $finder->find_word = array(1 => $temp['find']['value'], 2 => $temp['findend']['value']);
                 } else {
                     $finder->find_word = $temp['find']['value'];
                 }
                 $finder->another_word = $temp['action']['value'];
                 switch ($temp['action']['attributes']['type']) {
                     case 'add_after':
                         $action_type = 3;
                         break;
                     case 'add_after_same_line':
                         $action_type = 4;
                         break;
                     case 'add_before':
                         $action_type = 5;
                         break;
                     case 'add_before_same_line':
                         $action_type = 6;
                         break;
                     case 'replace_with':
                         $action_type = 1;
                         break;
                 }
                 $style_path = substr($template_name, 0, 6) == 'admin_' ? $STYLE_PATH_ADMIN : $THIS_STYLE_PATH;
                 //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 (trim($config['style_depend_on']) != '') {
                         $depend_on = $config['style_depend_on'];
                         $template_path_alternative = str_replace('/' . $config['style'] . '/', '/' . trim($depend_on) . '/', $template_path);
                         if (file_exists($template_path_alternative)) {
                             $template_path = $template_path_alternative;
                         }
                     } else {
                         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;
                             }
                         }
                     }
                 }
                 $d_contents = file_exists($template_path) ? file_get_contents($template_path) : '';
                 $finder->text = trim($d_contents);
                 $finder->do_search($action_type);
                 if ($d_contents != '' && $finder->text != $d_contents) {
                     //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' => $temp['action']['attributes']['type'], 'find' => $temp['find']['value'], 'action_text' => $temp['action']['value']);
                 }
             }
         }
         #end edit
         //new templates
         if (isset($plg_tpl['new'])) {
             if (is_array($plg_tpl['new']['template'])) {
                 if (array_key_exists("attributes", $plg_tpl['new']['template'])) {
                     $plg_tpl['new']['template'] = array($plg_tpl['new']['template']);
                 }
             }
             foreach ($plg_tpl['new']['template'] as $temp) {
                 $style_path = substr($template_name, 0, 6) == 'admin_' ? $STYLE_PATH_ADMIN : $THIS_STYLE_PATH;
                 $template_name = $temp['attributes']['name'];
                 $template_content = trim($temp['value']);
                 $this->f->_write($style_path . $template_name . '.html', $template_content);
                 /**
                 						$cached_instructions[$template_name] = array(
                 																		'action'		=> 'new', 
                 																		'find'			=> '',
                 																		'action_text'	=> $template_content,
                 																	);
                 					**/
             }
         }
         #end new
     }
     #ens tpl
     //hooks
     if (isset($plg_hooks['hook'])) {
         $plugin_author = strip_tags($plg_info['plugin_author']['value'], '<a><span>');
         $plugin_author = $SQL->real_escape($plugin_author);
         //if the plugin is not new then replace the old hooks with the new hooks
         if (!$plg_new) {
             //delete old hooks !
             $query_del = array('DELETE' => "{$dbprefix}hooks", 'WHERE' => "plg_id=" . $this->plg_id);
             $SQL->build($query_del);
         }
         //then
         if (is_array($plg_hooks['hook'])) {
             if (array_key_exists("attributes", $plg_hooks['hook'])) {
                 $plg_hooks['hook'] = array($plg_hooks['hook']);
             }
         }
         foreach ($plg_hooks['hook'] as $hk) {
             $hook_for = $SQL->real_escape($hk['attributes']['name']);
             $hk_value = $SQL->real_escape($hk['value']);
             $insert_query = array('INSERT' => 'plg_id, hook_name, hook_content', 'INTO' => "{$dbprefix}hooks", 'VALUES' => "'" . $this->plg_id . "','" . $hook_for . "', '" . $hk_value . "'");
             $SQL->build($insert_query);
         }
         //delete cache ..
         //delete_cache('data_hooks');
     }
     //done !
     if (sizeof($plg_errors) < 1) {
         //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 $there_is_intruct ? 'zipped/inst' : 'zipped';
             }
         }
         return $plg_new ? $there_is_intruct ? 'inst' : 'done' : 'upd';
     } else {
         return $plg_errors;
     }
     return false;
 }
Esempio n. 8
0
function add_config_r($configs)
{
    if (!is_array($configs)) {
        return false;
    }
    //array(name=>array(value=>,order=>,html=>),...);
    foreach ($configs as $n => $m) {
        add_config($n, $m['value'], $m['order'], $m['html'], $m['type'], $m['plg_id'], $m['dynamic']);
    }
    return;
}