GetDb(); $error = array(); $userplugin_id = ""; if (isset($_POST["userplugin_id"])) $userplugin_id = (int)$_POST["userplugin_id"]; else if (isset($_GET["userplugin_id"])) $userplugin_id = (int)$_GET["userplugin_id"]; $plugin_name= ""; if (isset($_POST["plugin_name"])) $plugin_name = $_POST["plugin_name"]; $orig_plugin_name = ""; if (isset($_POST["origpluginname"])) $orig_plugin_name = $_POST["origpluginname"]; $code= ""; if (isset($_POST["code"])) $code = $_POST["code"]; $description= ""; if (isset($_POST["description"])) $description = $_POST["description"]; if (isset($_POST["cancel"])) { redirect("listusertags.php".$urlext); return; } $userid = get_userid(); $access = check_permission($userid, 'Modify User-defined Tags'); $ajax = false; if (isset($_POST['ajax']) && $_POST['ajax']) $ajax = true; if ($access) { if (isset($_POST["editplugin"])) { $CMS_EXCLUDE_FROM_RECENT = 1; $validinfo = true; if ($plugin_name == "") { $error[] = lang('nofieldgiven', array(lang('editusertag'))); $validinfo = false; } elseif(preg_match('<^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$>', $plugin_name) == 0) { $error[] = lang('error_udt_name_chars'); $validinfo = false; } else { if( $plugin_name != $orig_plugin_name && UserTagOperations::get_instance()->UserTagExists($plugin_name) ) { $error[] = lang('usertagexists'); $validinfo = false; } } // Make sure no spaces are put into plugin name. $without_spaces = str_replace(' ', '', $plugin_name); if ($plugin_name != $without_spaces) { $error[] = lang('error_udt_name_whitespace'); $validinfo = false; } if ($code == "") { $error[] = lang('nofieldgiven', array(lang('code'))); $validinfo = false; } else if (strrpos($code, '{') !== FALSE) { $lastopenbrace = strrpos($code, '{'); $lastclosebrace = strrpos($code, '}'); if ($lastopenbrace > $lastclosebrace) { $error[] = lang('invalidcode'); $error[] = lang('invalidcode_brace_missing'); $validinfo = false; } } if ($validinfo) { srand(); ob_start(); if (eval('function testfunction'.rand().'() {'.$code."\n}") === FALSE) { $error[] = lang('invalidcode'); //catch the error //eval('function testfunction'.rand().'() {'.$code.'}'); $buffer = ob_get_clean(); //add error $error[] = preg_replace('/
/', '', $buffer ); $validinfo = false; } else { ob_get_clean(); } } if ($validinfo) { // Send event EditUserDefinedTagPre Events::SendEvent('Core', 'EditUserDefinedTagPre', array('id' => $userplugin_id, 'name' => &$plugin_name, 'code' => &$code)); // Update database $query = "UPDATE ".cms_db_prefix()."userplugins SET userplugin_name = ".$db->qstr($plugin_name).", code = ".$db->qstr($code).", description = ".$db->qstr($description).", modified_date = ".$db->DBTimeStamp(time())." WHERE userplugin_id = ". (int)$userplugin_id; $result = $db->Execute($query); if ($result) { // Send event EditUserDefinedTagPost & put mention to Admin Log Events::SendEvent('Core', 'EditUserDefinedTagPost', array('id' => $userplugin_id, 'name' => &$plugin_name, 'code' => &$code)); // put mention into the admin log audit($userplugin_id, 'User Defined Tag: '.$plugin_name, 'Edited'); if( !isset( $_POST['apply'] ) ) { redirect("listusertags.php".$urlext."&message=usertagupdated"); return; } } else { $error[] = lang('errorupdatingusertag'); } } // Check if we need ajax output if ($ajax) { header('Content-Type: text/xml'); print ''; print ''; if (sizeof($error)) { print 'Error'; print '
' . join('
  • ', $error) . '
  • '; print ']]>
    '; } else { print 'Success'; print '
    '; } print '
    '; exit; } } else if ($userplugin_id != -1) { $row = UserTagOperations::get_instance()->GetUserTag($userplugin_id); $plugin_name = $row["userplugin_name"]; $orig_plugin_name = $plugin_name; $code = $row['code']; $description = $row['description']; } } if (strlen($plugin_name)>0) { $CMS_ADMIN_SUBTITLE = $plugin_name; } $addlScriptSubmit = ''; $syntaxmodule = get_preference(get_userid(FALSE),'syntaxhighlighter'); if( $syntaxmodule && ($module = ModuleOperations::get_instance()->get_module_instance($syntaxmodule)) ) { if( $module->IsSyntaxHighlighter() && $module->SyntaxActive() ) { $addlScriptSubmit .= $module->SyntaxPageFormSubmit(); } } $closestr = cms_html_entity_decode(lang('close')); $headtext = << //

    ' + details + '<\/p><\/div>'; jQuery('input[name=cancel]').fadeOut(); jQuery('input[name=cancel]').attr('value','{$closestr}'); jQuery('input[name=cancel]').fadeIn(); } else { htmlShow = '

    '; echo '

    « '.lang('back').'

    '; include_once("footer.php"); # vim:ts=4 sw=4 noet ?>