% If Request.QueryString("action")="logoff" then session("authenticated")="0" session("username")="" session("password")="" Response.Redirect("/notic") End If %>
| ||||||||||||||||||||||||
|
|
<% If Session("username")<>"" then %>
Gestão de notícias - Utilizador <%=Session("username")%>
<% End if %> <% ' Set NewsDate Session Variable if Session("NewsDate")="" Then Session("NewsDate")=Date if (request.form("date")<>"")and(request.form("update")="")then session("NewsDate")=request.form("date") ' delete news if request.querystring("action")="delete" then SQLOpen("select username from news where id=" & request.querystring("id")) If not SQLEof Then if (Session("username")="admin")or(SQLField("username")=Session("username"))Then SQLClose MyRs.Open "select * from news where id=" & Request.QueryString("id"), MyDSN, adOpenKeySet, adLockPessimistic, adCmdText MyRs.Delete MyRs.Close response.write("Notícia apagada. ") else SQLClose response.write("Não autorizado. ") end if else SQLClose Response.Write "A Notícias já se encontrava apagada. " End If end if ' update news, from form if request.form("update")="1" then SQLOpen("select username,valid from news where id=" & request.form("id")) if (Session("username")="admin")or((SQLField("username")=Session("username"))and(SQLField("valid")="0"))Then SQLClose MyRs.Open "select * from news where id=" & Request.Form("id"), MyDSN, adOpenKeySet, adLockPessimistic, adCmdText MyRs("date")=request.form("date") MyRs("title")=request.form("title") MyRs("texto")=request.form("texto") MyRs("category")=request.form("categoria") if request.form("partner")<>"" then MyRs("partner")=request.form("partner") MyRs("url_redirect")=request.form("url_redirect") MyRs.Update MyRs.Close response.write("Notícia actualizada. ") else SQLClose response.write("Não autorizado. ") end if end If ' create news, from form if request.form("create")="1" then SQLOpen("select valid_news from users where name='" & Session("username") & "'") ValidNews=SQLField("valid_news") SQLClose MyRs.Open "news", MyDSN, adOpenKeySet, adLockPessimistic, adCmdTable MyRs.AddNew MyRs("date")=now MyRs("title")=request.form("title") MyRs("texto")=request.form("texto") MyRs("category")=request.form("categoria") if request.form("partner")<>"" then MyRs("partner")=request.form("partner") MyRs("url_redirect")=request.form("url_redirect") MyRs("valid")=ValidNews MyRs("username")=Session("username") MyRs.Update MyRs.Close response.write("Notícia criada. ") end If ' update/create news - show form if(request.querystring("action")="update")or(request.querystring("action")="create")then Response.Write "" else ' show news ' Response.Write " " %> <% SQLNew SQLOpen("select * from news where date<=#" & Session("NewsDate") & "# order by date desc") Response.Write " " Response.Write "
|
|