public static function SetAppNotices($notices) { try { $safeNotices = ensureArray($notices, 0, 50); } catch (Exception $e) { throw new Exception('设置公告:' . implode(';', $notices) . '时出错。'); return false; } $cacheKey = 'app_cache'; setCache($cacheKey, $safeNotices); $sql = 'delete from wa_app where name = `notice` ; '; foreach ($notices as $safeNotice) { $sql .= 'insert into wa_app (`name`, `value`) values (`notice`, `' . $safeNotice . '`) ; '; } $result = runSql($sql); if (!$result) { throw new Exception('设置公告:' . implode(';', $notices) . '时出错。'); } return $result; }
$langv=$_POST["langv"]; $code=$_POST["code"]; $password=$_POST['password']; $delete=$_POST['delete']; $length = strlen($code); $table_change = array('"'=>'&double_quoteee','\''=>'&single_quoteee'); $code = strtr($code,$table_change); //die($code); if ($length<=30) die("<h1>代码过短!需要大于30B</h1>"); if ($id<=0){ $sql_con = getSqlCon(); $sql = "INSERT INTO `codepaste`(`title`, `code`, `language`, `author`, `password`, `length`) VALUES (\"$title\",\"$code\",\"$langv\",\"$author\",\"$password\",$length)"; runSql($sql); header("Location: List.php"); }else{ $sql_con = getSqlCon(); if (getSingleVal('codepaste','id',$id,'password')!=$password && $password!='CodePaste_Root') die ("<h1>Access Denied!(Wrong Password)</h1>"); if ($delete != "Delete"){ $sql = 'UPDATE `codepaste` SET `title`="'.$title.'",`code`="'.$code.'",`language`="'.$langv.'",`author`="'.$author.'",`length`='.$length.' WHERE `id` = '.$id; runSql($sql); header("Location: Code.php?ID=".$id); }else{ $sql = "DELETE FROM `codepaste` WHERE `id` = $id"; runSql($sql); header("Location: index.php"); } } ?>
public static function DeleteMsg($id, $user) { try { $safeId = ensureInt($id, 10); } catch (Exception $e) { throw new Exception('删除消息时出错:' . $e->getMessage()); return false; } $msgInfo = self::GetMsgInfo($safeId); if (!$msgInfo) { return false; } if ($msgInfo['msg_sender'] == $user) { $me = 'sender'; $opposite = 'receiver'; } else { if ($msgInfo['msg_receiver'] == $user) { $me = 'receiver'; $opposite = 'sender'; } else { throw new Exception('非消息相关用户。'); return false; } } self::SetMsgRead($msgInfo['msg_id']); $cacheKey = "usermsg_"; $cacheKey .= $msgInfo['msg_' . $me] . '_' . $msgInfo['msg_' . $opposite]; $cache = getCache($cacheKey); if ($cache) { while (list($key, $value) = each($cache)) { if ($value['msg_id'] = $safeId) { unset($cache[$key]); break; } } setCache($cacheKey, $cache); } $cacheKey = 'msginfo_' . $safeId; if ($msgInfo[$opposite . '_deleted']) { setCache($cacheKey, null); $sql = "delete from wa_msg where `msg_id` = {$safeId} limit 1;"; $ret = runSql($sql); } else { $cache = getCache($cacheKey); if ($cache) { $cache[$me . '_deleted'] = true; setCache($cacheKey, $cache); } $sql = "update wa_msg set `{$me}_deleted` = 1 where `msg_id` = {$safeId} limit 1"; $ret = runSql($sql); } return $ret; }
public static function DeleteWall($id) { try { $safeId = ensureInt($id, 10); } catch (Exception $e) { throw new Exception('删除墙时出错:' . $e->getMessage()); return false; } $wallInfo = self::GetWallInfo($safeId); if (!$wallInfo) { throw new Exception('删除墙时出错。'); return false; } $cacheKey = 'creatorwall_' . $wallInfo['wall_creator']; $cache = getCache($cacheKey); if ($cache) { while (list($key, $value) = each($cache)) { if ($value['wall_id'] == $safeId) { unset($cache[$key]); setCache($cacheKey, $cache); break; } } } $cacheKey = 'accesswall_' . $wallInfo['wall_access']; $cache = getCache($cacheKey); if ($cache) { while (list($key, $value) = each($cache)) { if ($value['wall_id'] == $safeId) { unset($cache[$key]); setCache($cacheKey, $cache); break; } } } $cacheKey = 'typewall_' . $wallInfo['wall_type']; $cache = getCache($cacheKey); if ($cache) { while (list($key, $value) = each($cache)) { if ($value['wall_id'] == $safeId) { unset($cache[$key]); setCache($cacheKey, $cache); break; } } } $users = self::FindUserIdsByWall($safeId); if ($users) { while (list($key, $value) = each($users)) { $cacheKey = 'userwall_' . $value['user_id']; $cache = getCache($cacheKey); if ($cache) { while (list($userKey, $userValue) = each($cache)) { if ($userValue['wall_id'] == $safeId) { unset($cache[$userKey]); setCache($cacheKey, $cache); break; } } } } } $cacheKey = 'walluser_' . $safeId; setCache($cacheKey, null); $cacheKey = 'wallinfo_' . $safeId; setCache($cacheKey, null); $wallSql = "delete from wa_wall where `wall_id` = {$safeId} limit 1;"; $wallUserSql = "delete from wa_walluser where `wall_id` = {$safeId};"; if (runSql($wallSql) && runSql($wallUserSql)) { return true; } else { throw new Exception('删除墙时出错。'); } }
public static function DeleteComment($id) { try { $safeId = ensureInt($id); } catch (Exception $e) { throw new Exception('删除评论时出错:' . $e->getMessage()); return null; } $commentInfo = self::GetCommentInfo($id); $cacheKey = 'postcomment_' . $commentPost['comment_post`']; $cache = getCache($cacheKey); if ($commentInfo && $cache) { while (list($key, $value) = each($cache)) { if ($value['comment_id'] == $safeId) { unset($cache[$key]); break; } } setCache($cacheKey, $cache); } $cacheKey = 'commentinfo_' . $safeId; setCache($cacheKey, null); $sql = "delete from wa_comment where comment_id = {$safeId} limit 1"; $ret = runSql($sql); if (!$ret) { throw new Exception('删除评论时出错。'); return null; } return $ret; }
public static function DeletePost($id) { try { $safeId = ensureInt($id, 10); } catch (Exception $e) { throw new Exception('删除墙贴时出错:' . $e->getMessage()); return false; } $postInfo = self::GetPostInfo($safeId); $cacheKey = 'wallpost_' . $postInfo['post_wall']; $cache = getCache($cacheKey); if ($postInfo && $cache) { while (list($key, $value) = each($cache)) { if ($value['post_id'] = $safeId) { unset($cache[$key]); break; } } setCache($cacheKey, $cache); } $cacheKey = 'postinfo_' . $safeId; setCache($cacheKey, null); $sql = "delete from wa_post where `post_id` = {$safeId} limit 1"; $ret = runSql($sql); if (!$ret) { throw new Exception('删除墙贴时出错。'); return null; } return $ret; }
function delRow(){ $sql_con = getSqlCon(); $sql = "DELETE FROM `appmanager_content` WHERE `id` = {$_POST['ID']}"; runSql($sql_con,$sql); }
public static function DeleteUser($id) { try { $safeId = ensureInt($id, 10); } catch (Exception $e) { throw new Exception('删除用户时出错。'); return null; } $cacheInfoKey = 'userinfo_' . $safeId; $cacheDataKey = 'userdata_' . $safeId; $cacheProfileKey = 'userprofile_' . $safeId; setCache($cacheInfoKey, null); setCache($cacheDataKey, null); setCache($cacheProfileKey, null); $sqlInfo = "delete from wa_user where user_id= {$safeId} limit 1;"; $sqlData = "delete from wa_userdata where user_id= {$safeId} limit 1;"; $sqlProfile = "delete from wa_userprofile where user_id= {$safeId} limit 1;"; $ret = runSql($sqlInfo) & runSql($sqlData) & runSql($sqlProfile); $userCache = getCache('users'); if ($userCache) { while (list($key, $value) = each($userCache)) { if ($value['user_id'] == $safeId) { unset($userCache[$key]); break; } } setCache('users', $userCache); } return $ret; }