[xoops-cvslog 132] CVS update: xoops2jp/html/modules/system/admin/smilies

Back to archive index

onokazu onoka****@users*****
2005年 6月 11日 (土) 11:32:53 JST


Index: xoops2jp/html/modules/system/admin/smilies/main.php
diff -u xoops2jp/html/modules/system/admin/smilies/main.php:1.2 xoops2jp/html/modules/system/admin/smilies/main.php:1.3
--- xoops2jp/html/modules/system/admin/smilies/main.php:1.2	Fri Mar 18 21:52:38 2005
+++ xoops2jp/html/modules/system/admin/smilies/main.php	Sat Jun 11 11:32:52 2005
@@ -1,5 +1,5 @@
 <?php
-// $Id: main.php,v 1.2 2005/03/18 12:52:38 onokazu Exp $
+// $Id: main.php,v 1.3 2005/06/11 02:32:52 onokazu Exp $
 //  ------------------------------------------------------------------------ //
 //                XOOPS - PHP Content Management System                      //
 //                    Copyright (c) 2000 XOOPS.org                           //
@@ -30,46 +30,153 @@
 // ------------------------------------------------------------------------- //
 
 if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
-	exit("Access Denied");
+    exit("Access Denied");
 }
+
 include_once XOOPS_ROOT_PATH."/modules/system/admin/smilies/smilies.php";
 $op ='SmilesAdmin';
-$ok = 0;
-foreach ($_POST as $k => $v) {
-	${$k} = $v;
-}
 
-if (isset($_GET['op']) && ($_GET['op'] == 'SmilesEdit' || $_GET['op'] == 'SmilesDel')) {
-	$op = $_GET['op'];
-	$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
+if (!empty($_GET['op'])) {
+    $op = $_GET['op'];
+} elseif (!empty($_POST['op'])) {
+    $op = $_POST['op'];
 }
 
 switch($op) {
-case "update":
-	$count = count($smile_id);
-	for ($i = 0; $i < $count; $i++) {
-		$smile_display[$i] = empty($smile_display[$i]) ? 0 : 1;
-		if ($old_display[$i] != $smile_display[$i]) {
-			$xoopsDB->query('UPDATE '.$xoopsDB->prefix('smiles').' SET display='.$smile_display[$i].' WHERE id ='.intval($smile_id[$i]));
-		}
-	}
-	redirect_header('admin.php?fct=smilies',2,_AM_DBUPDATED);
-	break;
+
+case "SmilesUpdate":
+    if (!XoopsMultiTokenHandler::quickValidate('smilies_SmilesUpdate')) {
+        redirect_header('admin.php?fct=smilies',3,"Ticket Error");
+    }
+    $count = (!empty($_POST['smile_id']) && is_array($_POST['smile_id'])) ? count($_POST['smile_id']) : 0;
+    $db =& Database::getInstance();
+    for ($i = 0; $i < $count; $i++) {
+        $smile_id = intval($_POST['smile_id'][$i]);
+        if (empty($smile_id)) {
+            continue;
+        }
+        $smile_display = empty($_POST['smile_display'][$i]) ? 0 : 1;
+        if (isset($_POST['old_display'][$i]) && $_POST['old_display'][$i] != $smile_display[$i]) {
+            $db->query('UPDATE '.$db->prefix('smiles').' SET display='.$smile_display.' WHERE id ='.$smile_id);
+        }
+    }
+    redirect_header('admin.php?fct=smilies',2,_AM_DBUPDATED);
+    break;
+
 case "SmilesAdd":
-	SmilesAdd($smile_code, $smile_url, $smile_desc, $smile_display);
-	break;
+    if (!XoopsMultiTokenHandler::quickValidate('smilies_SmilesAdd')) {
+        redirect_header('admin.php?fct=smilies',3,"Ticket Error");
+    }
+    $db =& Database::getInstance();
+    $myts =& MyTextSanitizer::getInstance();
+    include_once XOOPS_ROOT_PATH.'/class/uploader.php';
+    $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'), 100000, 120, 120);
+    $uploader->setAllowedExtensions(array('gif', 'jpeg', 'jpg', 'png'));
+    $uploader->setPrefix('smil');
+    if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
+        if (!$uploader->upload()) {
+            $err = $uploader->getErrors();
+        } else {
+            $smile_url = $uploader->getSavedFileName();
+            $smile_code = $myts->stripSlashesGPC($_POST['smile_code']);
+            $smile_desc = $myts->stripSlashesGPC($_POST['smile_desc']);
+            $smile_display = intval($_POST['smile_display']) > 0 ? 1 : 0;
+            $newid = $db->genId($db->prefix('smilies')."_id_seq");
+            $sql = sprintf("INSERT INTO %s (id, code, smile_url, emotion, display) VALUES (%d, %s, %s, %s, %d)", $db->prefix('smiles'), $newid, $db->quoteString($smile_code), $db->quoteString($smile_url), $db->quoteString($smile_desc), $smile_display);
+            if (!$db->query($sql)) {
+                $err = 'Failed storing smiley data into the database';
+            }
+        }
+    } else {
+        $err = $uploader->getErrors();
+    }
+    if (!isset($err)) {
+        redirect_header('admin.php?fct=smilies&amp;op=SmilesAdmin',2,_AM_DBUPDATED);
+    } else {
+        xoops_cp_header();
+        xoops_error($err);
+        xoops_cp_footer();
+    }
+    break;
+
 case "SmilesEdit":
-	SmilesEdit($id);
-	break;
+    $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
+    if ($id > 0) {
+        SmilesEdit($id);
+    }
+    break;
+
 case "SmilesSave":
-	SmilesSave($id, $smile_code, $smile_url, $smile_desc, $smile_display, $old_smile);
-	break;
+    $id = isset($_POST['id']) ? intval($_POST['id']) : 0;
+    if ($id <= 0 || !XoopsMultiTokenHandler::quickValidate('smilies_SmilesSave')) {
+        redirect_header('admin.php?fct=smilies',3,"Ticket Error");
+    }
+    $myts =& MyTextSanitizer::getInstance();
+    $smile_code = $myts->stripSlashesGPC($_POST['smile_code']);
+    $smile_desc = $myts->stripSlashesGPC($_POST['smile_desc']);
+    $smile_display = intval($_POST['smile_display']) > 0 ? 1 : 0;
+    $db =& Database::getInstance();
+    if (!empty($_POST['smile_url'])) {
+        include_once XOOPS_ROOT_PATH.'/class/uploader.php';
+        $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'), 100000, 120, 120);
+        $uploader->setAllowedExtensions(array('gif', 'jpeg', 'jpg', 'png'));
+        $uploader->setPrefix('smil');
+        if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
+            if (!$uploader->upload()) {
+                $err = $uploader->getErrors();
+            } else {
+                $smile_url = $uploader->getSavedFileName();
+                if (!$db->query(sprintf("UPDATE %s SET code = %s, smile_url = %s, emotion = %s, display = %d WHERE id = %d", $db->prefix('smiles'), $db->quoteString($smile_code), $db->quoteString($smile_url), $db->quoteString($smile_desc), $smile_display, $id))) {
+                    $err = 'Failed storing smiley data into the database';
+                } else {
+                    $oldsmile_path = str_replace("\\", "/", realpath(XOOPS_UPLOAD_PATH.'/'.trim($_POST['old_smile'])));
+                    if (0 === strpos($oldsmile_path, XOOPS_UPLOAD_PATH) && is_file($oldsmile_path)) {
+                        unlink($oldsmile_path);
+                    }
+                }
+            }
+        } else {
+            $err = $uploader->getErrors();
+        }
+    } else {
+        $sql = sprintf("UPDATE %s SET code = %s, emotion = %s, display = %d WHERE id = %d", $db->prefix('smiles'), $db->quoteString($smile_code), $db->quoteString($smile_desc), $smile_display, $id);
+        if (!$db->query($sql)) {
+            $err = 'Failed storing smiley data into the database';
+        }
+    }
+    if (!isset($err)) {
+        redirect_header('admin.php?fct=smilies&amp;op=SmilesAdmin',2,_AM_DBUPDATED);
+    } else {
+        xoops_cp_header();
+        xoops_error($err);
+        xoops_cp_footer();
+        exit();
+    }
+    break;
+
 case "SmilesDel":
-	SmilesDel($id, $ok);
-	break;
+    $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
+    if ($id > 0 ) {
+        xoops_cp_header();
+        xoops_token_confirm(array('fct' => 'smilies', 'op' => 'SmilesDelOk', 'id' => $id), 'admin.php', _AM_WAYSYWTDTS);
+        xoops_cp_footer();
+    }
+    break;
+
+case "SmilesDelOk":
+    $id = isset($_POST['id']) ? intval($_POST['id']) : 0;
+    if ($id <= 0 || !xoops_confirm_validate()) {
+        redirect_header('admin.php?fct=smilies',3,"Ticket Error");
+    }
+    $db =& Database::getInstance();
+    $sql = sprintf("DELETE FROM %s WHERE id = %u", $db->prefix('smiles'), $id);
+    $db->query($sql);
+    redirect_header("admin.php?fct=smilies&amp;op=SmilesAdmin",2,_AM_DBUPDATED);
+    break;
+
 case "SmilesAdmin":
 default:
-	SmilesAdmin();
-	break;
+    SmilesAdmin();
+    break;
 }
 ?>
\ No newline at end of file
Index: xoops2jp/html/modules/system/admin/smilies/smileform.php
diff -u xoops2jp/html/modules/system/admin/smilies/smileform.php:1.2 xoops2jp/html/modules/system/admin/smilies/smileform.php:1.3
--- xoops2jp/html/modules/system/admin/smilies/smileform.php:1.2	Fri Mar 18 21:52:38 2005
+++ xoops2jp/html/modules/system/admin/smilies/smileform.php	Sat Jun 11 11:32:52 2005
@@ -1,5 +1,5 @@
 <?php
-// $Id: smileform.php,v 1.2 2005/03/18 12:52:38 onokazu Exp $
+// $Id: smileform.php,v 1.3 2005/06/11 02:32:52 onokazu Exp $
 //  ------------------------------------------------------------------------ //
 //                XOOPS - PHP Content Management System                      //
 //                    Copyright (c) 2000 XOOPS.org                           //
@@ -32,6 +32,7 @@
 include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
 $smile_form = new XoopsThemeForm($smiles['smile_form'], 'smileform', 'admin.php');
 $smile_form->setExtra('enctype="multipart/form-data"');
+$smile_form->addElement(new XoopsFormToken(XoopsMultiTokenHandler::quickCreate('smilies_'.$smiles['op'])));
 $smile_form->addElement(new XoopsFormText(_AM_SMILECODE, 'smile_code', 26, 25, $smiles['smile_code']), true);
 $smile_form->addElement(new XoopsFormText(_AM_SMILEEMOTION, 'smile_desc', 26, 25, $smiles['smile_desc']), true);
 $smile_select = new XoopsFormFile('', 'smile_url', 5000000);
Index: xoops2jp/html/modules/system/admin/smilies/smilies.php
diff -u xoops2jp/html/modules/system/admin/smilies/smilies.php:1.2 xoops2jp/html/modules/system/admin/smilies/smilies.php:1.3
--- xoops2jp/html/modules/system/admin/smilies/smilies.php:1.2	Fri Mar 18 21:52:38 2005
+++ xoops2jp/html/modules/system/admin/smilies/smilies.php	Sat Jun 11 11:32:52 2005
@@ -1,5 +1,5 @@
 <?php
-// $Id: smilies.php,v 1.2 2005/03/18 12:52:38 onokazu Exp $
+// $Id: smilies.php,v 1.3 2005/06/11 02:32:52 onokazu Exp $
 //  ------------------------------------------------------------------------ //
 //                XOOPS - PHP Content Management System                      //
 //                    Copyright (c) 2000 XOOPS.org                           //
@@ -30,186 +30,97 @@
 // ------------------------------------------------------------------------- //
 
 if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
-	exit("Access Denied");
+    exit("Access Denied");
 }
-
 function SmilesAdmin()
 {
-	$db =& Database::getInstance();
-	$url_smiles = XOOPS_UPLOAD_URL;
-	$myts =& MyTextSanitizer::getInstance();
-	xoops_cp_header();
-	echo "<h4 style='text-align:left;'>"._AM_SMILESCONTROL."</h4>";
-
-	if ($getsmiles = $db->query("SELECT * FROM ".$db->prefix("smiles"))) {
-		if (($numsmiles = $db->getRowsNum($getsmiles)) == "0") {
-			//EMPTY
-		} else {
-			echo '<form action="admin.php" method="post"><table width="100%" class="outer" cellpadding="4" cellspacing="1">';
-			echo "<tr align='center'><th align='left'>" ._AM_CODE."</th>";
-			echo "<th>" ._AM_SMILIE."</th>";
-			echo "<th>"._AM_SMILEEMOTION."</th>";
-			echo "<th>" ._AM_DISPLAYF."</th>";
-			echo "<th>"._AM_ACTION."</th>";
-			echo "</tr>\n";
-			$i = 0;
-			while ($smiles = $db->fetchArray($getsmiles)) {
-				if ($i % 2 == 0) {
-					$class = 'even';
-				} else {
-					$class= 'odd';
-				}
-				$smiles['code'] = $myts->makeTboxData4Show($smiles['code']);
-				$smiles['smile_url'] = $myts->makeTboxData4Edit($smiles['smile_url']);
-				$smiles['smile_emotion'] = $myts->makeTboxData4Edit($smiles['emotion']);
-				echo "<tr align='center' class='$class'>";
-				echo "<td align='left'>".$smiles['code']."</td>";
-				echo "<td><img src='".$url_smiles."/".$smiles['smile_url']."' alt='' /></td>";
-				echo '<td>'.$smiles['smile_emotion'].'</td>';
-				echo '<td><input type="hidden" name="smile_id['.$i.']" value="'.$smiles['id'].'" /><input type="hidden" name="old_display['.$i.']" value="'.$smiles['display'].'" /><input type="checkbox" value="1" name="smile_display['.$i.']"';
-				if ($smiles['display'] == 1) {
-					echo ' checked="checked"';
-				}
-				echo "</td><td><a href='admin.php?fct=smilies&amp;op=SmilesEdit&amp;id=".$smiles['id']."'>" ._AM_EDIT."</a>&nbsp;";
-				echo "<a href='admin.php?fct=smilies&amp;op=SmilesDel&amp;id=".$smiles['id']."'>" ._AM_DEL."</a></td>";
-				echo "</tr>\n";
-				$i++;
-			}
-			echo '<tr><td class="foot" colspan="5" align="center"><input type="hidden" name="op" value="update" /><input type="hidden" name="fct" value="smilies" /><input type="submit" value="'._SUBMIT.'" /></tr></table></form>';
-		}
-	} else {
-		echo _AM_CNRFTSD;
-	}
-	$smiles['smile_code'] = '';
-	$smiles['smile_url'] = 'blank.gif';
-	$smiles['smile_desc'] = '';
-	$smiles['smile_display'] = 1;
-	$smiles['smile_form'] = _AM_ADDSMILE;
-	$smiles['op'] = 'SmilesAdd';
-	$smiles['id'] = '';
-	include XOOPS_ROOT_PATH.'/modules/system/admin/smilies/smileform.php';
-	$smile_form->display();
-	xoops_cp_footer();
+    $db =& Database::getInstance();
+    $url_smiles = XOOPS_UPLOAD_URL;
+    $myts =& MyTextSanitizer::getInstance();
+    xoops_cp_header();
+    echo "<h4 style='text-align:left;'>"._AM_SMILESCONTROL."</h4>";
+
+    if ($getsmiles = $db->query("SELECT * FROM ".$db->prefix("smiles"))) {
+        if (($numsmiles = $db->getRowsNum($getsmiles)) == "0") {
+            //EMPTY
+        } else {
+            $token=&XoopsMultiTokenHandler::quickCreate('smilies_SmilesUpdate');
+            echo '<form action="admin.php" method="post"><table width="100%" class="outer" cellpadding="4" cellspacing="1">';
+            echo $token->getHtml();
+            echo "<tr align='center'><th align='left'>" ._AM_CODE."</th>";
+            echo "<th>" ._AM_SMILIE."</th>";
+            echo "<th>"._AM_SMILEEMOTION."</th>";
+            echo "<th>" ._AM_DISPLAYF."</th>";
+            echo "<th>"._AM_ACTION."</th>";
+            echo "</tr>\n";
+            $i = 0;
+            while ($smiles = $db->fetchArray($getsmiles)) {
+                if ($i % 2 == 0) {
+                    $class = 'even';
+                } else {
+                    $class= 'odd';
+                }
+                $smiles['code'] = $myts->makeTboxData4Show($smiles['code']);
+                $smiles['smile_url'] = $myts->makeTboxData4Edit($smiles['smile_url']);
+                $smiles['smile_emotion'] = $myts->makeTboxData4Edit($smiles['emotion']);
+                echo "<tr align='center' class='$class'>";
+                echo "<td align='left'>".$smiles['code']."</td>";
+                echo "<td><img src='".$url_smiles."/".$smiles['smile_url']."' alt='' /></td>";
+                echo '<td>'.$smiles['smile_emotion'].'</td>';
+                echo '<td><input type="hidden" name="smile_id['.$i.']" value="'.$smiles['id'].'" /><input type="hidden" name="old_display['.$i.']" value="'.$smiles['display'].'" /><input type="checkbox" value="1" name="smile_display['.$i.']"';
+                if ($smiles['display'] == 1) {
+                    echo ' checked="checked"';
+                }
+                echo " /></td><td><a href='admin.php?fct=smilies&amp;op=SmilesEdit&amp;id=".$smiles['id']."'>" ._AM_EDIT."</a>&nbsp;";
+                echo "<a href='admin.php?fct=smilies&amp;op=SmilesDel&amp;id=".$smiles['id']."'>" ._AM_DEL."</a></td>";
+                echo "</tr>\n";
+                $i++;
+            }
+            echo '<tr><td class="foot" colspan="5" align="center"><input type="hidden" name="op" value="SmilesUpdate" /><input type="hidden" name="fct" value="smilies" />';
+            //echo xoops_token_gethtml();
+            echo '<input type="submit" value="'._SUBMIT.'" /></tr></table></form>';
+        }
+    } else {
+        echo _AM_CNRFTSD;
+    }
+    $smiles['smile_code'] = '';
+    $smiles['smile_url'] = 'blank.gif';
+    $smiles['smile_desc'] = '';
+    $smiles['smile_display'] = 1;
+    $smiles['smile_form'] = _AM_ADDSMILE;
+    $smiles['op'] = 'SmilesAdd';
+    $smiles['id'] = '';
+    include XOOPS_ROOT_PATH.'/modules/system/admin/smilies/smileform.php';
+    $smile_form->display();
+    xoops_cp_footer();
 }
 
 function SmilesEdit($id)
 {
-	$db =& Database::getInstance();
-	$myts =& MyTextSanitizer::getInstance();
-	xoops_cp_header();
-	echo '<a href="admin.php?fct=smilies">'._AM_SMILESCONTROL .'</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;'._AM_EDITSMILE.'<br /><br />';
-	if ($getsmiles = $db->query("SELECT * FROM ".$db->prefix("smiles")." WHERE id = $id")) {
-		$numsmiles = $db->getRowsNum($getsmiles);
-		if ( $numsmiles == 0 ) {
-			//EMPTY
-		} else {
-			if ($smiles = $db->fetchArray($getsmiles)) {
-				$smiles['smile_code'] = $myts->makeTboxData4Edit($smiles['code']);
-				$smiles['smile_url'] = $myts->makeTboxData4Edit($smiles['smile_url']);
-				$smiles['smile_desc'] = $myts->makeTboxData4Edit($smiles['emotion']);
-				$smiles['smile_display'] = $smiles['display'];
-				$smiles['smile_form'] = _AM_EDITSMILE;
-				$smiles['op'] = 'SmilesSave';
-				include XOOPS_ROOT_PATH.'/modules/system/admin/smilies/smileform.php';
-				$smile_form->addElement(new XoopsFormHidden('old_smile', $smiles['smile_url']));
-				$smile_form->display();
-			}
-		}
-	} else {
-		echo _AM_CNRFTSD;
-	}
-	xoops_cp_footer();
-}
-
-function SmilesAdd($smile_code, $smile_url, $smile_desc, $smile_display)
-{
-	$db =& Database::getInstance();
-	$myts =& MyTextSanitizer::getInstance();
-
-	include_once XOOPS_ROOT_PATH.'/class/uploader.php';
-	$uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'), 100000, 120, 120);
-	$uploader->setPrefix('smil');
-	if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
-		if (!$uploader->upload()) {
-			$err = $uploader->getErrors();
-		} else {
-			$smile_url = $myts->makeTboxData4Save($uploader->getSavedFileName());
-			$smile_code = $myts->makeTboxData4Save($smile_code);
-			$smile_desc = $myts->makeTboxData4Save($smile_desc);
-			$smile_display = intval($smile_display) > 0 ? 1 : 0;
-			$newid = $db->genId($db->prefix('smilies')."_id_seq");
-			if (!$db->query("INSERT INTO ".$db->prefix('smiles')." (id, code, smile_url, emotion, display) VALUES ($newid, '$smile_code','$smile_url','$smile_desc', $smile_display)")) {
-				$err = 'Failed storing smiley data into the database';
-			}
-		}
-	} else {
-		$err = $uploader->getErrors();
-	}
-	if (!isset($err)) {
-		redirect_header('admin.php?fct=smilies&amp;op=SmilesAdmin',2,_AM_DBUPDATED);
-	} else {
-		xoops_cp_header();
-		xoops_error($err);
-		xoops_cp_footer();
-		exit();
-	}
-}
-
-function SmilesSave($id, $smile_code, $smile_url, $smile_desc, $smile_display, $old_smile)
-{
-	$db =& Database::getInstance();
-	$myts =& MyTextSanitizer::getInstance();
-	if (isset($smile_url) && trim($smile_url) != '') {
-		include_once XOOPS_ROOT_PATH.'/class/uploader.php';
-		$uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'), 100000, 120, 120);
-		$uploader->setPrefix('smil');
-		if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
-			if (!$uploader->upload()) {
-				$err = $uploader->getErrors();
-			} else {
-				$smile_url = $myts->makeTboxData4Save($uploader->getSavedFileName());
-				$smile_code = $myts->makeTboxData4Save($smile_code);
-				$smile_desc = $myts->makeTboxData4Save($smile_desc);
-				$smile_display = intval($smile_display) > 0 ? 1 : 0;
-				if (!$db->query("UPDATE ".$db->prefix('smiles')." SET code = '$smile_code', smile_url = '$smile_url', emotion = '$smile_desc', display=$smile_display WHERE id =".intval($id))) {
-					$err = 'Failed storing smiley data into the database';
-				} else {
-					@unlink(XOOPS_UPLOAD_PATH.'/'.$old_smile);
-				}
-			}
-		} else {
-			$err = $uploader->getErrors();
-		}
-	} else {
-		$smile_code = $myts->makeTboxData4Save($smile_code);
-		$smile_desc = $myts->makeTboxData4Save($smile_desc);
-		$smile_display = intval($smile_display) > 0 ? 1 : 0;
-		if (!$db->query("UPDATE ".$db->prefix('smiles')." SET code = '$smile_code', emotion = '$smile_desc', display=$smile_display WHERE id =".intval($id))) {
-			$err = 'Failed storing smiley data into the database';
-		}
-	}
-	if (!isset($err)) {
-		redirect_header('admin.php?fct=smilies&amp;op=SmilesAdmin',2,_AM_DBUPDATED);
-	} else {
-		xoops_cp_header();
-		xoops_error($err);
-		xoops_cp_footer();
-		exit();
-	}
-}
-
-function SmilesDel($id, $ok=0)
-{
-	$db =& Database::getInstance();
-	if ($ok == 1) {
-		$sql = sprintf("DELETE FROM %s WHERE id = %u", $db->prefix('smiles'), intval($id));
-		$db->query($sql);
-		redirect_header("admin.php?fct=smilies&amp;op=SmilesAdmin",2,_AM_DBUPDATED);
-		exit();
+    $db =& Database::getInstance();
+    $myts =& MyTextSanitizer::getInstance();
+    xoops_cp_header();
+    echo '<a href="admin.php?fct=smilies">'._AM_SMILESCONTROL .'</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;'._AM_EDITSMILE.'<br /><br />';
+    if ($getsmiles = $db->query("SELECT * FROM ".$db->prefix("smiles")." WHERE id = $id")) {
+        $numsmiles = $db->getRowsNum($getsmiles);
+        if ( $numsmiles == 0 ) {
+            //EMPTY
+        } else {
+            if ($smiles = $db->fetchArray($getsmiles)) {
+                $smiles['smile_code'] = $myts->makeTboxData4Edit($smiles['code']);
+                $smiles['smile_url'] = $myts->makeTboxData4Edit($smiles['smile_url']);
+                $smiles['smile_desc'] = $myts->makeTboxData4Edit($smiles['emotion']);
+                $smiles['smile_display'] = $smiles['display'];
+                $smiles['smile_form'] = _AM_EDITSMILE;
+                $smiles['op'] = 'SmilesSave';
+                include XOOPS_ROOT_PATH.'/modules/system/admin/smilies/smileform.php';
+                //$smile_form->addElement(new XoopsFormHidden('old_smile', $smiles['smile_url']));
+                $smile_form->display();
+            }
+        }
     } else {
-		xoops_cp_header();
-		xoops_confirm(array('fct' => 'smilies', 'op' => 'SmilesDel', 'ok' => 1, 'id' => $id), 'admin.php', _AM_WAYSYWTDTS);
-		xoops_cp_footer();
-	}
+        echo _AM_CNRFTSD;
+    }
+    xoops_cp_footer();
 }
 ?>
\ No newline at end of file


xoops-cvslog メーリングリストの案内
Back to archive index