| [ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (wishy@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.sf.net 5 # 6 #This program is free software; you can redistribute it and/or modify 7 #it under the terms of the GNU General Public License as published by 8 #the Free Software Foundation; either version 2 of the License, or 9 #(at your option) any later version. 10 # 11 #This program is distributed in the hope that it will be useful, 12 #but WITHOUT ANY WARRANTY; without even the implied warranty of 13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 #GNU General Public License for more details. 15 #You should have received a copy of the GNU General Public License 16 #along with this program; if not, write to the Free Software 17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 # 19 #$Id: adduserplugin.php 3784 2007-02-09 23:20:35Z elijahlofgren $ 20 21 $CMS_ADMIN_PAGE=1; 22 23 require_once ("../include.php"); 24 25 check_login(); 26 27 $error = array(); 28 29 $plugin_name= ""; 30 if (isset($_POST["plugin_name"])) $plugin_name = $_POST["plugin_name"]; 31 32 $code= ""; 33 if (isset($_POST["code"])) $code = $_POST["code"]; 34 35 if (isset($_POST["cancel"])) { 36 redirect("listusertags.php"); 37 return; 38 } 39 40 $userid = get_userid(); 41 $access = check_permission($userid, 'Modify User-defined Tags'); 42 43 $use_javasyntax = false; 44 if (get_preference($userid, 'use_javasyntax') == "1") $use_javasyntax = true; 45 46 $smarty = new Smarty_CMS($gCms->config); 47 load_plugins($smarty); 48 49 global $gCms; 50 $db =& $gCms->GetDb(); 51 52 if ($access) { 53 if (isset($_POST["addplugin"])) { 54 55 $validinfo = true; 56 if ($plugin_name == "") { 57 $error[] = lang('nofieldgiven',array(lang('name'))); 58 $validinfo = false; 59 } 60 else 61 { 62 if (in_array($plugin_name, $gCms->cmsplugins)) 63 { 64 $error[] = lang('usertagexists'); 65 $validinfo = false; 66 } 67 } 68 // Make sure no spaces are put into plugin name. 69 $without_spaces = str_replace(' ', '', $plugin_name); 70 if ($plugin_name != $without_spaces) 71 { 72 $error[] = lang('error_udt_name_whitespace'); 73 $validinfo = false; 74 } 75 if ($code == "") { 76 $error[] = lang('nofieldgiven',array(lang('code'))); 77 $validinfo = false; 78 } 79 else if (strrpos($code, '{') !== FALSE) 80 { 81 $lastopenbrace = strrpos($code, '{'); 82 $lastclosebrace = strrpos($code, '}'); 83 if ($lastopenbrace > $lastclosebrace) 84 { 85 $error[] = lang('invalidcode'); 86 $validinfo = false; 87 } 88 } 89 90 if ($validinfo) 91 { 92 srand(); 93 ob_start(); 94 if (eval('function testfunction'.rand().'() {'.$code.'}') === FALSE) 95 { 96 $error[] = lang('invalidcode'); 97 //catch the error 98 //eval('function testfunction'.rand().'() {'.$code.'}'); 99 $buffer = ob_get_clean(); 100 //add error 101 $error[] = preg_replace('/<br \/>/', '', $buffer ); 102 $validinfo = false; 103 } 104 else 105 { 106 ob_end_clean(); 107 } 108 } 109 110 if ($validinfo) { 111 $new_usertag_id = $db->GenID(cms_db_prefix()."userplugins_seq"); 112 Events::SendEvent('Core', 'AddUserDefinedTagPre', array('id' => $new_usertag_id, 'name' => &$plugin_name, 'code' => &$code)); 113 $query = "INSERT INTO ".cms_db_prefix()."userplugins (userplugin_id, userplugin_name, code, create_date, modified_date) VALUES ($new_usertag_id, ".$db->qstr($plugin_name).", ".$db->qstr($code).", ".$db->DBTimeStamp(time()).", ".$db->DBTimeStamp(time()).")"; 114 $result = $db->Execute($query); 115 if ($result) { 116 Events::SendEvent('Core', 'AddUserDefinedTagPost', array('id' => $new_usertag_id, 'name' => &$plugin_name, 'code' => &$code)); 117 audit($new_usertag_id, $plugin_name, 'Added User Defined Tag'); 118 redirect("listusertags.php?message=usertagadded"); 119 return; 120 } 121 else { 122 $error .= lang('errorinsertingtag'); 123 } 124 } 125 } 126 } 127 128 include_once ("header.php"); 129 130 if (!$access) { 131 echo '<div class=\"pageerrorcontainer\"><p class="pageerror">'.lang('noaccessto', array(lang('addusertag'))).'</p></div>'; 132 } 133 else { 134 if (FALSE == empty($error)) { 135 echo $themeObject->ShowErrors($error); 136 } 137 ?> 138 139 <div class="pagecontainer"> 140 <?php echo $themeObject->ShowHeader('addusertag'); ?> 141 <form enctype="multipart/form-data" action="adduserplugin.php" method="post"> 142 <div class="pageoverflow"> 143 <p class="pagetext">*<?php echo lang('name')?>:</p> 144 <p class="pageinput"> 145 <input type="text" name="plugin_name" maxlength="255" value="<?php echo $plugin_name?>" /> 146 </p> 147 </div> 148 <div class="pageoverflow"> 149 <p class="pagetext">*<?php echo lang('code')?></p> 150 <p class="pageinput"><textarea class="pagetextarea" name="code" rows="" cols=""><?php echo $code ?></textarea></p> 151 </div> 152 <div class="pageoverflow"> 153 <p class="pagetext"> </p> 154 <p class="pageinput"> 155 <input type="hidden" name="addplugin" value="true" /> 156 <input type="submit" value="<?php echo lang('submit')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" /> 157 <input type="submit" name="cancel" value="<?php echo lang('cancel')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" /> 158 </p> 159 </div> 160 </form> 161 </div> 162 163 <?php 164 } 165 echo '<p class="pageback"><a class="pageback" href="'.$themeObject->BackUrl().'">« '.lang('back').'</a></p>'; 166 include_once ("footer.php"); 167 168 # vim:ts=4 sw=4 noet 169 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |