GetDb(); if ($access) { if (isset($_POST["addplugin"])) { $validinfo = true; if ($plugin_name == "") { $error[] = lang('nofieldgiven',array(lang('name'))); $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( UserTagOperations::get_instance()->SmartyTagExists($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'); $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_end_clean(); } } if ($validinfo) { $new_usertag_id = $db->GenID(cms_db_prefix()."userplugins_seq"); Events::SendEvent('Core', 'AddUserDefinedTagPre', array('id' => $new_usertag_id, 'name' => &$plugin_name, 'code' => &$code)); $query = "INSERT INTO ".cms_db_prefix()."userplugins (userplugin_id, userplugin_name, code, description, create_date, modified_date) VALUES ($new_usertag_id, ".$db->qstr($plugin_name).", ".$db->qstr($code).", ".$db->qstr($description).", ".$db->DBTimeStamp(time()).", ".$db->DBTimeStamp(time()).")"; $result = $db->Execute($query); if ($result) { Events::SendEvent('Core', 'AddUserDefinedTagPost', array('id' => $new_usertag_id, 'name' => &$plugin_name, 'code' => &$code)); // put mention into the admin log audit($new_usertag_id, 'User Defined Tag: '.$plugin_name, 'Added'); redirect("listusertags.php".$urlext."&message=usertagadded"); return; } else { $error[] = lang('errorinsertingtag').' '.$db->ErrorMsg(); } } } } include_once("header.php"); if (!$access) { echo '

'.lang('noaccessto', array(lang('addusertag'))).'

'; } else { if (FALSE == empty($error)) { echo $themeObject->ShowErrors($error); } ?>
ShowHeader('addusertag'); ?>

*:

*

 

« '.lang('back').'

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