⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acp_icons.php

📁 这些都是我以前学习是用到的源码
💻 PHP
📖 第 1 页 / 共 2 页
字号:
						$sql = "SELECT $field_sql							FROM $table";						$result = $db->sql_query($sql);						while ($row = $db->sql_fetchrow($result))						{							++$order;							$cur_img[$row[$field_sql]] = 1;						}						$db->sql_freeresult($result);					}					if (!($pak_ary = @file($phpbb_root_path . $img_path . '/' . $pak)))					{						trigger_error($user->lang['PAK_FILE_NOT_READABLE'] . adm_back_link($this->u_action), E_USER_WARNING);					}					foreach ($pak_ary as $pak_entry)					{						$data = array();						if (preg_match_all("#'(.*?)', #", $pak_entry, $data))						{							if ((sizeof($data[1]) != 4 && $mode == 'icons') || 								(sizeof($data[1]) != 6 && $mode == 'smilies'))							{								trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING);							}							// Stripslash here because it got addslashed before... (on export)							$img = stripslashes($data[1][0]);							$width = stripslashes($data[1][1]);							$height = stripslashes($data[1][2]);							$display_on_posting = stripslashes($data[1][3]);							if (isset($data[1][4]) && isset($data[1][5]))							{								$emotion = stripslashes($data[1][4]);								$code = stripslashes($data[1][5]);							}							if ($current == 'replace' && 								(($mode == 'smilies' && !empty($cur_img[$code])) || 								($mode == 'icons' && !empty($cur_img[$img]))))							{								$replace_sql = ($mode == 'smilies') ? $code : $img;								$sql = array(									$fields . '_url'		=> $img,									$fields . '_height'		=> (int) $height,									$fields . '_width'		=> (int) $width,									'display_on_posting'	=> (int) $display_on_posting,								);								if ($mode == 'smilies')								{									$sql = array_merge($sql, array(										'emotion'				=> $emotion,									));								}								$sql = "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql) . " 									WHERE $field_sql = '" . $db->sql_escape($replace_sql) . "'";								$db->sql_query($sql);							}							else							{								++$order;								$sql = array(									$fields . '_url'	=> $img,									$fields . '_height'	=> (int) $height,									$fields . '_width'	=> (int) $width,									$fields . '_order'	=> (int) $order,									'display_on_posting'=> (int) $display_on_posting,								);								if ($mode == 'smilies')								{									$sql = array_merge($sql, array(										'code'				=> $code,										'emotion'			=> $emotion,									));								}								$db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql));							}						}					}					$cache->destroy('icons');					$cache->destroy('sql', $table);					trigger_error($user->lang[$lang . '_IMPORT_SUCCESS'] . adm_back_link($this->u_action));				}				else				{					$pak_options = '';					foreach ($_paks as $pak)					{						$pak_options .= '<option value="' . $pak . '">' . htmlspecialchars($pak) . '</option>';					}					$template->assign_vars(array(						'S_CHOOSE_PAK'		=> true,						'S_PAK_OPTIONS'		=> $pak_options,						'L_TITLE'			=> $user->lang['ACP_' . $lang],						'L_EXPLAIN'			=> $user->lang['ACP_' . $lang . '_EXPLAIN'],						'L_NO_PAK_OPTIONS'	=> $user->lang['NO_' . $lang . '_PAK'],						'L_CURRENT'			=> $user->lang['CURRENT_' . $lang],						'L_CURRENT_EXPLAIN'	=> $user->lang['CURRENT_' . $lang . '_EXPLAIN'],						'L_IMPORT_SUBMIT'	=> $user->lang['IMPORT_' . $lang],						'U_BACK'		=> $this->u_action,						'U_ACTION'		=> $this->u_action . '&amp;action=import',						)					);				}			break;			case 'export':				$this->page_title = 'EXPORT_' . $lang;				$this->tpl_name = 'message_body';				$template->assign_vars(array(					'MESSAGE_TITLE'		=> $user->lang['EXPORT_' . $lang],					'MESSAGE_TEXT'		=> sprintf($user->lang['EXPORT_' . $lang . '_EXPLAIN'], '<a href="' . $this->u_action . '&amp;action=send">', '</a>'))				);				return;			break;			case 'send':				$sql = "SELECT * 					FROM $table					ORDER BY {$fields}_order";				$result = $db->sql_query($sql);				$pak = '';				while ($row = $db->sql_fetchrow($result))				{					$pak .= "'" . addslashes($row[$fields . '_url']) . "', ";					$pak .= "'" . addslashes($row[$fields . '_width']) . "', ";					$pak .= "'" . addslashes($row[$fields . '_height']) . "', ";					$pak .= "'" . addslashes($row['display_on_posting']) . "', ";					if ($mode == 'smilies')					{						$pak .= "'" . addslashes($row['emotion']) . "', ";						$pak .= "'" . addslashes($row['code']) . "', ";					}					$pak .= "\n";				}				$db->sql_freeresult($result);				if ($pak != '')				{					garbage_collection();					header('Pragma: public');					// Send out the Headers					header('Content-Type: text/x-delimtext; name="' . $fields . '.pak"');					header('Content-Disposition: inline; filename="' . $fields . '.pak"');					echo $pak;					flush();					exit;				}				else				{					trigger_error($user->lang['NO_' . strtoupper($fields) . '_EXPORT'] . adm_back_link($this->u_action), E_USER_WARNING);				}			break;			case 'delete':				$sql = "DELETE FROM $table					WHERE {$fields}_id = $icon_id";				$db->sql_query($sql);				switch ($mode)				{					case 'smilies':					break;					case 'icons':						// Reset appropriate icon_ids						$db->sql_query('UPDATE ' . TOPICS_TABLE . " 							SET icon_id = 0 							WHERE icon_id = $icon_id");						$db->sql_query('UPDATE ' . POSTS_TABLE . " 							SET icon_id = 0 							WHERE icon_id = $icon_id");					break;				}				$notice = $user->lang[$lang . '_DELETED'];				$cache->destroy('icons');				$cache->destroy('sql', $table);			break;			case 'move_up':			case 'move_down':				// Get current order id...				$sql = "SELECT {$fields}_order as current_order					FROM $table					WHERE {$fields}_id = $icon_id";				$result = $db->sql_query($sql);				$current_order = (int) $db->sql_fetchfield('current_order');				$db->sql_freeresult($result);				if ($current_order == 0 && $action == 'move_up')				{					break;				}				// on move_down, switch position with next order_id...				// on move_up, switch position with previous order_id...				$switch_order_id = ($action == 'move_down') ? $current_order + 1 : $current_order - 1;				// 				$sql = "UPDATE $table					SET {$fields}_order = $current_order					WHERE {$fields}_order = $switch_order_id						AND {$fields}_id <> $icon_id";				$db->sql_query($sql);				// Only update the other entry too if the previous entry got updated				if ($db->sql_affectedrows())				{					$sql = "UPDATE $table						SET {$fields}_order = $switch_order_id						WHERE {$fields}_order = $current_order							AND {$fields}_id = $icon_id";					$db->sql_query($sql);				}				$cache->destroy('icons');				$cache->destroy('sql', $table);			break;		}		// By default, check that image_order is valid and fix it if necessary		$sql = "SELECT {$fields}_id AS order_id, {$fields}_order AS fields_order			FROM $table			ORDER BY display_on_posting DESC, {$fields}_order";		$result = $db->sql_query($sql);		if ($row = $db->sql_fetchrow($result))		{			$order = 0;			do			{				++$order;				if ($row['fields_order'] != $order)				{					$db->sql_query("UPDATE $table						SET {$fields}_order = $order						WHERE {$fields}_id = " . $row['order_id']);				}			}			while ($row = $db->sql_fetchrow($result));		}		$db->sql_freeresult($result);		$template->assign_vars(array(			'L_TITLE'			=> $user->lang['ACP_' . $lang],			'L_EXPLAIN'			=> $user->lang['ACP_' . $lang . '_EXPLAIN'],			'L_IMPORT'			=> $user->lang['IMPORT_' . $lang],			'L_EXPORT'			=> $user->lang['EXPORT_' . $lang],			'L_NOT_DISPLAYED'	=> $user->lang[$lang . '_NOT_DISPLAYED'],			'L_ICON_ADD'		=> $user->lang['ADD_' . $lang],			'L_ICON_EDIT'		=> $user->lang['EDIT_' . $lang],			'NOTICE'			=> $notice,			'COLSPAN'			=> ($mode == 'smilies') ? 5 : 3,			'S_SMILIES'			=> ($mode == 'smilies') ? true : false,			'U_ACTION'			=> $this->u_action,			'U_IMPORT'			=> $this->u_action . '&amp;action=import',			'U_EXPORT'			=> $this->u_action . '&amp;action=export',			)		);		$spacer = false;		$sql = "SELECT * 			FROM $table			ORDER BY {$fields}_order ASC";		$result = $db->sql_query($sql);		while ($row = $db->sql_fetchrow($result))		{			$alt_text = ($mode == 'smilies') ? $row['code'] : '';			$template->assign_block_vars('items', array(				'S_SPACER'		=> (!$spacer && !$row['display_on_posting']) ? true : false,				'ALT_TEXT'		=> $alt_text,				'IMG_SRC'		=> $phpbb_root_path . $img_path . '/' . $row[$fields . '_url'],				'WIDTH'			=> $row[$fields . '_width'],				'HEIGHT'		=> $row[$fields . '_height'],				'CODE'			=> (isset($row['code'])) ? $row['code'] : '',				'EMOTION'		=> (isset($row['emotion'])) ? $row['emotion'] : '',				'U_EDIT'		=> $this->u_action . '&amp;action=edit&amp;id=' . $row[$fields . '_id'],				'U_DELETE'		=> $this->u_action . '&amp;action=delete&amp;id=' . $row[$fields . '_id'],				'U_MOVE_UP'		=> $this->u_action . '&amp;action=move_up&amp;id=' . $row[$fields . '_id'],				'U_MOVE_DOWN'	=> $this->u_action . '&amp;action=move_down&amp;id=' . $row[$fields . '_id'])			);			if (!$spacer && !$row['display_on_posting'])			{				$spacer = true;			}		}		$db->sql_freeresult($result);	}}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -