Avatar billede human900 Nybegynder
30. november 2005 - 19:21 Der er 2 kommentarer og
1 løsning

et script i PHP til ASP

Hejsa
Jeg har en hjemmeside, med et forum. Jeg vil gerne have sidste nyt fra forum ind på hjemmesiden, og så har jeg fået en PHP fil men min webside kan kun tage ASP og JAVA.
Hjemmeside : www.oks.dk
Forum kommer du ind i fra linket på siden.

Her er php script:

<head>
<meta http-equiv="Content-Language" content="da">
<link rel="StyleSheet" href="pages/style.css" type="text/css">
</head>
<table border="0" width="30%" id="table1">
    <tr>
        <td bgcolor="#FF0000">
        <p align="center"><b><font color="#FFFFFF" face="Verdana">Seneste Emner</font></b></td>
    </tr>
</table>


<table class="but" border="2" width="30%" id="table2" height="47">
    <tr>
        <td><?
/**
* Mod Title:  Latest posts/topics
* Mod Version: phpBB 2.0
* Author:      Pegas (pegas@ami.cz) (originally made by ?, previous version by LiLCoolboy (M@urice Cheung))
* Description: Shows latest posts or topics on any page, 2 optional parameters
* Release:    v3.0, 27.01.2003
***
* DeMo:                http://kocky-online.cz (Czech language)
* Installation Level:  Easy
* Installation Time:  5 minutes
* Files To Edit:      0
* Included Files:      (if necessary)
***
* Installation Notes:
* Put this code into new file, set $serverPath and $urlPath,
* upload this file onto server and include into your page and you are done!
*  -- OR --
* Put this code into your page, set $serverPath and $urlPath,
* and you are done!
***
* Parameters:
* There are 2 optional parameters when calling this code as standalone file via include!
* type - whether to show topics or posts
*  type=posts  - posts [default when missing]
*  type=topics - topics
* count - how much posts/topics show
*  count=# [default is 3]
***
* Examples (assume that your file with this code is hilites.php):
* hilites.php?type=topics&count=5
*  - shows latest 5 topics
* hilites.php?type=topics
*  - shows latest 3 topics
* hilites.php
*  - shows latest 3 posts
***
* Revision:
* v1.0
*  author: ?
* v2.0
*  author: LiLCoolboy (M@urice Cheung)
*  - not working without significant changes, mistypes
* v3.0
*  author: Petr Gasparik
*  + added parameters when called as standalone file
*  + posts/topics selection corrected
*  + corrected mistypes
*/
$urlPath = "/forum";    //example: if your forum URL looks like http://kocky-online.cz/forum, this should be "/forum"
$serverPath = "forum/config.php";            //example: when this file is in URL path /forum/mod, this should be ../config.php
if(empty($count))
    $count = "10";                                    //default value of how many posts/topics to show
if(empty($type))
    $type = "posts";        //default value of whether to show 'posts' or 'topics'
$titleLimit = 30;            //this is max.length of 'title' of topic/post
$moreLimit = 20;            //this is max.length of 'more' (used in posts)

//-----------------[ DO NOT EDIT BELOW HERE ]-------------------------
include_once("$serverPath");
$db = @mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("here we die at connection");
@mysql_select_db("$dbname",$db) or die("here we die");

if($type == "topics")
{
    $prefix = 'p';
  $sql = "SELECT x.post_subject as title, p.post_id as id, f.forum_id, t.topic_title as more "
          ."FROM ${table_prefix}topics t, ${table_prefix}forums f, ${table_prefix}posts p, ${table_prefix}posts_text x "
          ."WHERE t.topic_id = p.topic_id AND f.forum_id = t.forum_id AND p.post_id = x.post_id "
          ."ORDER BY p.post_id DESC "
          ."LIMIT $count";
}
else
{
    $prefix = 't';
  $sql = "SELECT t.topic_title as title, t.topic_id as id, f.forum_id, '' as more "
          ."FROM ${table_prefix}topics t, ${table_prefix}forums f "
          ."WHERE f.forum_id = t.forum_id "
          ."ORDER BY topic_time DESC "
          ."LIMIT $count";
}

//echo $sql;

if($r = mysql_query($sql, $db)) {
    while($m = mysql_fetch_array($r)) {
        $j = stripslashes($m[title]);
        $k = substr($j, 0, $titleLimit) . "...";
        if(!empty($m[more]))
            $m[more] = '('.substr($m[more], 0, $moreLimit) . '...)';
        if ($type == 'posts') {
            $anchor = '#'.$m[id];
        }
        //-------------------[ THIS IS ONLY LINE YOU COULD CHANGE ]--------------------------
        echo "<a title=\"$m[title]\" href=\"$urlPath/viewtopic.php?${prefix}=$m[id]&sid=$m[forum_id]${anchor}\">$k</a> $m[more]<br />";
    }
}
?></td>
    </tr>
</table>
Avatar billede eagleeye Praktikant
30. november 2005 - 23:09 #1
Her er da et forsøg oversat til VBscript.

Du har en fil som hedder config.php den skal laves om til en .asp fil. $ fjernes foran variablenavne og ; fjernes fra slutningen af linien.

Hvilken database bruger du?

<head>
<meta http-equiv="Content-Language" content="da">
<link rel="StyleSheet" href="pages/style.css" type="text/css">
</head>
<table border="0" width="30%" id="table1">
    <tr>
        <td bgcolor="#FF0000">
        <p align="center"><b><font color="#FFFFFF" face="Verdana">Seneste Emner</font></b></td>
    </tr>
</table>


<table class="but" border="2" width="30%" id="table2" height="47">
    <tr>
        <td><%
'
'* Mod Title:  Latest posts/topics
'* Mod Version: phpBB 2.0
'* Author:      Pegas (pegas@ami.cz) (originally made by ?, previous version by LiLCoolboy (M@urice Cheung))
'* Description: Shows latest posts or topics on any page, 2 optional parameters
'* Release:    v3.0, 27.01.2003
'***
'* DeMo:                http://kocky-online.cz (Czech language)
'* Installation Level:  Easy
'* Installation Time:  5 minutes
'* Files To Edit:      0
'* Included Files:      (if necessary)
'***
'* Installation Notes:
'* Put this code into new file, set $serverPath and $urlPath,
'* upload this file onto server and include into your page and you are done!
'*  -- OR --
'* Put this code into your page, set $serverPath and $urlPath,
'* and you are done!
'***
'* Parameters:
'* There are 2 optional parameters when calling this code as standalone file via include!
'* type - whether to show topics or posts
'*  type=posts  - posts [default when missing]
'*  type=topics - topics
'* count - how much posts/topics show
'*  count=# [default is 3]
'***
'* Examples (assume that your file with this code is hilites.php):
'* hilites.php?type=topics&count=5
'*  - shows latest 5 topics
'* hilites.php?type=topics
'*  - shows latest 3 topics
'* hilites.php
'*  - shows latest 3 posts
'***
'* Revision:
'* v1.0
'*  author: ?
'* v2.0
'*  author: LiLCoolboy (M@urice Cheung)
'*  - not working without significant changes, mistypes
'* v3.0
'*  author: Petr Gasparik
'*  + added parameters when called as standalone file
'*  + posts/topics selection corrected
'*  + corrected mistypes
'*/
urlPath = "/forum"    'example: if your forum URL looks like http://kocky-online.cz/forum, this should be "/forum"
serverPath = "forum/config.php" 'example: when this file is in URL path /forum/mod, this should be ../config.php
if (count = "") then
    count = "10"  'default value of how many posts/topics to show
end if
if (type = "") then
    type = "posts" 'default value of whether to show 'posts' or 'topics'
end if
titleLimit = 30 'this is max.length of 'title' of topic/post
moreLimit = 20  'this is max.length of 'more' (used in posts)

'//-----------------[ DO NOT EDIT BELOW HERE ]-------------------------
' config.php filen skal laves om til config.asp, og $ fjernes foran variablenavne og ; fjernes i slutningen af linien.
%> <!-- #include file="forum/config.asp"--> <%

Set conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")

conString = "DRIVER={MySQL};SERVER=" & dbhost & ";DATABASE=" & dbname &";UID=" & dbuser & ";PWD=" & dbpasswd & ";"
Conn.Open conString

if (type = "topics") then
  prefix = "p"
  sql = "SELECT x.post_subject as title, p.post_id as id, f.forum_id, t.topic_title as more " & _
          "FROM " & table_prefix & "topics t, " & table_prefix & "forums f, " & table_prefix & "posts p, " & table_prefix & "posts_text x " &_
          "WHERE t.topic_id = p.topic_id AND f.forum_id = t.forum_id AND p.post_id = x.post_id " &_
          "ORDER BY p.post_id DESC " &_
          "LIMIT " & count
else
  prefix = "t"
  sql = "SELECT t.topic_title as title, t.topic_id as id, f.forum_id, '' as more " &_
          "FROM " & table_prefix & "topics t, " & table_prefix & "forums f " &_
          "WHERE f.forum_id = t.forum_id " &_
          "ORDER BY topic_time DESC " &_
          "LIMIT " & count
end if

'response.write sql

Set rs = Conn.Execute (sql)
if (not rs.EOF) then
    do while (not rs.EOF)
        j = rs("title")
        k = mid(j, 1, titleLimit) & "..."
        if (not isnull(rs("more")) then
            mmore = "("& mid(rs("more"), 1, moreLimit) & "...)"
        else
            mmore = ""
        end if
        if (type = "posts") then
            anchor = "#"&rs("id")
        end if
        '//-------------------[ THIS IS ONLY LINE YOU COULD CHANGE ]--------------------------
        Response.Write "<a title=""" & rs("title") & """ href=""" & urlPath & "/viewtopic.php?"& prefix&"="&rs("id")&"&sid="&rs("forum_id")&anchor&""">"&k&"</a>"& mmore&"<br />"
       
        rs.MoveNext
    loop
end if
%></td>
    </tr>
</table>
Avatar billede human900 Nybegynder
01. december 2005 - 09:53 #2
tak, jeg prøver at arbejde med den...
Avatar billede human900 Nybegynder
03. april 2006 - 17:39 #3
hmmm, er for svært ... så jeg lukker lige; kunne ikke få det til at virke ..Men tak alligevel.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester