[geeklog-cvs] geeklog-1.3/public_html/admin/plugins/staticpages index.php,1.15,1.16

dhaun at geeklog.net dhaun at geeklog.net
Mon Mar 10 05:50:02 EST 2003


Update of /usr/cvs/geeklog/geeklog-1.3/public_html/admin/plugins/staticpages
In directory internal.geeklog.net:/tmp/cvs-serv25664/public_html/admin/plugins/staticpages

Modified Files:
	index.php 
Log Message:
You can now edit the ID of a static page (to create more readable URLs).


Index: index.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/admin/plugins/staticpages/index.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** index.php	9 Mar 2003 11:47:22 -0000	1.15
--- index.php	10 Mar 2003 10:50:00 -0000	1.16
***************
*** 6,11 ****
  // +---------------------------------------------------------------------------+
  // | index.php                                                                 |
- // | Administration page.                                                      |
  // |                                                                           |
  // +---------------------------------------------------------------------------+
  // | Copyright (C) 2000-2003 by the following authors:                         |
--- 6,11 ----
  // +---------------------------------------------------------------------------+
  // | index.php                                                                 |
  // |                                                                           |
+ // | Administration page.                                                      |
  // +---------------------------------------------------------------------------+
  // | Copyright (C) 2000-2003 by the following authors:                         |
***************
*** 55,59 ****
  *
  */ 
! function form($A, $error=false) 
  {
  	global $_TABLES, $PHP_SELF, $_CONF, $HTTP_POST_VARS, $_USER, $LANG_STATIC,$_SP_CONF, $LANG_ACCESS, $mode, $sp_id;
--- 55,59 ----
  *
  */ 
! function form ($A, $error = false) 
  {
  	global $_TABLES, $PHP_SELF, $_CONF, $HTTP_POST_VARS, $_USER, $LANG_STATIC,$_SP_CONF, $LANG_ACCESS, $mode, $sp_id;
***************
*** 89,95 ****
          $sp_template->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
      	$sp_template->set_var('lang_owner', $LANG_ACCESS['owner']);
! 		$sp_template->set_var('owner_username', DB_getItem($_TABLES['users'],'username',"uid = {$A['owner_id']}"));
! 		$sp_template->set_var('owner_id', $A['owner_id']);
!    		$sp_template->set_var('lang_group', $LANG_ACCESS['group']);
      	$usergroups = SEC_getUserGroups();
      	if ($access == 3) {
--- 89,95 ----
          $sp_template->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
      	$sp_template->set_var('lang_owner', $LANG_ACCESS['owner']);
!         $sp_template->set_var('owner_username', DB_getItem($_TABLES['users'],'username',"uid = {$A['owner_id']}"));
!         $sp_template->set_var('owner_id', $A['owner_id']);
!         $sp_template->set_var('lang_group', $LANG_ACCESS['group']);
      	$usergroups = SEC_getUserGroups();
      	if ($access == 3) {
***************
*** 127,131 ****
--- 127,138 ----
          $sp_template->set_var('lang_writtenby', $LANG_STATIC['writtenby']);
          $sp_template->set_var('username', DB_getItem($_TABLES['users'],'username',"uid = {$A["sp_uid"]}"));
+         $sp_template->set_var ('lang_url', $LANG_STATIC['url']);
+         $sp_template->set_var ('lang_id', $LANG_STATIC['id']);
          $sp_template->set_var('sp_uid', $A['sp_uid']);
+         $sp_template->set_var('sp_id', $A['sp_id']);
+         $sp_template->set_var('sp_old_id', $A['sp_old_id']);
+         $sp_template->set_var ('example_url', COM_buildURL ($_CONF['site_url']
+                                . '/staticpages/index.php?page=' . $A['sp_id']));
+ 
          if (SEC_hasRights ('staticpages.PHP')) {
              if ($A['sp_php'] == 1) {
***************
*** 139,143 ****
              $sp_template->set_var('php_msg',$LANG_STATIC['php_msg']);
          } else {
!   	    $sp_template->set_var('php_type','hidden');
              $sp_template->set_var('php_warn','');
              $sp_template->set_var('php_msg','');
--- 146,150 ----
              $sp_template->set_var('php_msg',$LANG_STATIC['php_msg']);
          } else {
!   	        $sp_template->set_var('php_type','hidden');
              $sp_template->set_var('php_warn','');
              $sp_template->set_var('php_msg','');
***************
*** 200,204 ****
              $sp_template->set_var('lang_allowedhtml', $LANG_STATIC['all_html_allowed']);
          }
-         $sp_template->set_var('sp_id', $A['sp_id']);
          $sp_template->set_var('lang_hits', $LANG_STATIC['hits']);
          if (empty($A['sp_hits'])) {
--- 207,210 ----
***************
*** 221,241 ****
  *
  */
! function staticpageeditor($sp_id, $mode = '') 
  {
  	global $HTTP_POST_VARS, $_USER, $_CONF, $_TABLES;
  
! 	if (!empty($sp_id) && $mode == 'edit') {
! 		$result = DB_query("SELECT *,UNIX_TIMESTAMP(sp_date) AS unixdate FROM {$_TABLES['staticpage']} WHERE sp_id = '$sp_id' AND " . SP_getPerms('','3'));
! 		$A = DB_fetchArray($result);
! 	} elseif ($mode == 'edit') {
! 		$A['sp_id'] = COM_makesid();
! 		$A['sp_uid'] = $_USER["uid"];
! 		$A['unixdate'] = time();
! 	} else {
! 		$A = $HTTP_POST_VARS;
! 		$A['sp_content'] = COM_checkHTML(COM_checkWords($A['sp_content']));
! 		$A['sp_title'] = strip_tags($A['sp_title']);
! 	}
! 	return form($A);
  }
  
--- 227,251 ----
  *
  */
! function staticpageeditor ($sp_id, $mode = '') 
  {
  	global $HTTP_POST_VARS, $_USER, $_CONF, $_TABLES;
  
!     if (!empty ($sp_id) && $mode == 'edit') {
!         $result = DB_query ("SELECT *,UNIX_TIMESTAMP(sp_date) AS unixdate FROM {$_TABLES['staticpage']} WHERE sp_id = '$sp_id' AND " . SP_getPerms ('', '3'));
!         $A = DB_fetchArray ($result);
!         $A['sp_old_id'] = $A['sp_id'];
!     } elseif ($mode == 'edit') {
!         $A['sp_id'] = COM_makesid ();
!         $A['sp_uid'] = $_USER['uid'];
!         $A['unixdate'] = time ();
!         $A['sp_old_id'] = '';
!     } else {
!         $A = $HTTP_POST_VARS;
!         $A['sp_content'] = COM_checkHTML (COM_checkWords ($A['sp_content']));
!         $A['sp_title'] = strip_tags ($A['sp_title']);
!         $A['sp_old_id'] = $HTTP_POST_VARS['sp_old_id'];
!     }
! 
!     return form ($A);
  }
  
***************
*** 243,247 ****
  # Displays a list of static pages 
  
! function liststaticpages($page = 1) 
  {
  	global $_TABLES, $LANG_STATIC, $_CONF;
--- 253,257 ----
  # Displays a list of static pages 
  
! function liststaticpages ($page = 1) 
  {
  	global $_TABLES, $LANG_STATIC, $_CONF;
***************
*** 327,340 ****
  * @sp_php       int         Flag to indicate PHP usage
  * @sp_nf        int         Flag to indicate type of not found message
  *
  */
! function submitstaticpage($sp_id,$sp_uid,$sp_title,$sp_content,$unixdate,$sp_hits,$sp_format, $sp_onmenu, $sp_label, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon, $sp_php, $sp_nf)
  {
  	global $_CONF, $LANG12, $LANG_STATIC, $_SP_CONF, $_TABLES;
  
! 	if (!empty($sp_title) && !empty($sp_content)) {
! 		$date = date("Y-m-d H:i:s",$unixdate);
  
! 		if (empty($sp_hits)) $sp_hits = 0;
  
          if ($sp_onmenu== 'on') {
--- 337,374 ----
  * @sp_php       int         Flag to indicate PHP usage
  * @sp_nf        int         Flag to indicate type of not found message
+ * @sp_old_id    string      original ID of this static page
  *
  */
! function submitstaticpage ($sp_id, $sp_uid, $sp_title, $sp_content, $unixdate, $sp_hits, $sp_format, $sp_onmenu, $sp_label, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon, $sp_php, $sp_nf, $sp_old_id)
  {
  	global $_CONF, $LANG12, $LANG_STATIC, $_SP_CONF, $_TABLES;
  
!     $sp_id = str_replace (' ', '', $sp_id);
!     $sp_id = str_replace (array ('_', '/', '\\', ':'), '-', $sp_id);
!     if (empty ($sp_id)) {
!         $sp_id = COM_makesid ();
!     }
  
!     // Check for unique page ID
!     $duplicate_id = false;
!     $delete_old_page = false;
!     if (DB_count ($_TABLES['staticpage'], 'sp_id', $sp_id) > 0) {
!         if ($sp_id != $sp_old_id) {
!             $duplicate_id = true;
!         }
!     } else {
!         $delete_old_page = true;
!     }
! 
!     if ($duplicate_id) {
!         $retval .= COM_siteHeader ();
!         $retval .= COM_errorLog ($LANG_STATIC['duplicate_id'], 2);
!         $retval .= staticpageeditor ($sp_id);
!         $retval .= COM_siteFooter ();
!         echo $retval;
!     } elseif (!empty ($sp_title) && !empty ($sp_content)) {
! 		$date = date ("Y-m-d H:i:s", $unixdate);
! 
! 		if (empty ($sp_hits)) $sp_hits = 0;
  
          if ($sp_onmenu== 'on') {
***************
*** 346,384 ****
  		// Clean up the text
          if ($_SP_CONF['censor'] == 1) {
!             $sp_content = COM_checkWords($sp_content); 
!             $sp_title = COM_checkWords($sp_title);
!             $sp_label = COM_checkWords($sp_label);
          }
          if ($_SP_CONF['filter_html'] == 1) {
!             $sp_content = COM_checkHTML($sp_content);
!             $sp_title = COM_checkHTML($sp_title);
!             $sp_label = COM_checkHTML($sp_label);
          }
!         $sp_content = addslashes($sp_content);
!         $sp_title = addslashes($sp_title);
!         $sp_label = addslashes($sp_label);
! 
! 		//$sp_content= addslashes(COM_checkHTML(COM_checkWords($sp_content)));
! 		//$sp_title = addslashes(htmlspecialchars(strip_tags(COM_checkWords($sp_title))));
! 		//$sp_label = addslashes(htmlspecialchars(strip_tags(COM_checkWords($sp_label))));
  
!         //If user does not have php edit perms, then set php flag to 0.
!         if (!SEC_hasRights('staticpages.PHP')) {
! 	        $sp_php='0';
          }
!         list($perm_owner,$perm_group,$perm_members,$perm_anon) = SEC_getPermissionValues($perm_owner,$perm_group,$perm_members,$perm_anon);		
! 		DB_save($_TABLES['staticpage'],'sp_id,sp_uid,sp_title,sp_content,sp_date,sp_hits,sp_format,sp_onmenu,sp_label,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,sp_php,sp_nf',"'$sp_id',$sp_uid,'$sp_title','$sp_content','$date',$sp_hits,'$sp_format',$sp_onmenu,'$sp_label',$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon,'$sp_php','$sp_nf'",$_CONF['site_admin_url'] . '/plugins/staticpages/index.php');
! 
  	} else {
!         $retval .= COM_siteHeader();
! 		$retval .= COM_errorLog($LANG_STATIC['no_title_or_content'],2);
! 		$retval .= staticpageeditor($sp_id);
!         $retval .= COM_siteFooter();
          echo $retval;
  	}
  }
  
- // MAIN
  
  
  if (empty($mode) OR empty($sp_id)) {
--- 380,418 ----
  		// Clean up the text
          if ($_SP_CONF['censor'] == 1) {
!             $sp_content = COM_checkWords ($sp_content); 
!             $sp_title = COM_checkWords ($sp_title);
!             $sp_label = COM_checkWords ($sp_label);
          }
          if ($_SP_CONF['filter_html'] == 1) {
!             $sp_content = COM_checkHTML ($sp_content);
!             $sp_title = COM_checkHTML ($sp_title);
!             $sp_label = COM_checkHTML ($sp_label);
          }
!         $sp_content = addslashes ($sp_content);
!         $sp_title = addslashes ($sp_title);
!         $sp_label = addslashes ($sp_label);
  
!         // If user does not have php edit perms, then set php flag to 0.
!         if (!SEC_hasRights ('staticpages.PHP')) {
! 	        $sp_php = 0;
          }
!         list($perm_owner,$perm_group,$perm_members,$perm_anon) = SEC_getPermissionValues($perm_owner,$perm_group,$perm_members,$perm_anon);
! 		DB_save ($_TABLES['staticpage'], 'sp_id,sp_uid,sp_title,sp_content,sp_date,sp_hits,sp_format,sp_onmenu,sp_label,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,sp_php,sp_nf', "'$sp_id',$sp_uid,'$sp_title','$sp_content','$date',$sp_hits,'$sp_format',$sp_onmenu,'$sp_label',$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon,'$sp_php','$sp_nf'");
!         if ($delete_old_page) {
!             DB_delete ($_TABLES['staticpage'], 'sp_id', $sp_old_id);
!         }
!         echo COM_refresh ($_CONF['site_admin_url']
!                           . '/plugins/staticpages/index.php');
  	} else {
!         $retval .= COM_siteHeader ();
!         $retval .= COM_errorLog ($LANG_STATIC['no_title_or_content'], 2);
!         $retval .= staticpageeditor ($sp_id);
!         $retval .= COM_siteFooter ();
          echo $retval;
  	}
  }
  
  
+ // MAIN
  
  if (empty($mode) OR empty($sp_id)) {
***************
*** 399,408 ****
      $display .= COM_siteFooter();
  } else if (($mode == $LANG_STATIC['save']) && !empty ($LANG_STATIC['save'])) {
!     submitstaticpage($sp_id,$sp_uid,$sp_title,$sp_content,$unixdate,$sp_hits,$sp_format,$sp_onmenu,$sp_label, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon, $sp_php, $sp_nf);
!     COM_errorlog("Saved Static Page " . $sp_id,1);
  } else {
!     $display .= COM_siteHeader('menu');
!     $display .= liststaticpages($sp_id);
!     $display .= COM_siteFooter();
  }
  
--- 433,444 ----
      $display .= COM_siteFooter();
  } else if (($mode == $LANG_STATIC['save']) && !empty ($LANG_STATIC['save'])) {
!     submitstaticpage ($sp_id, $sp_uid, $sp_title, $sp_content, $unixdate,
!             $sp_hits, $sp_format, $sp_onmenu, $sp_label, $owner_id, $group_id,
!             $perm_owner, $perm_group, $perm_members, $perm_anon, $sp_php,
!             $sp_nf, $sp_old_id);
  } else {
!     $display .= COM_siteHeader ('menu');
!     $display .= liststaticpages ($page);
!     $display .= COM_siteFooter ();
  }
  





More information about the geeklog-cvs mailing list