Avatar billede frezzer81 Nybegynder
23. februar 2005 - 16:35 Der er 12 kommentarer og
2 løsninger

problemer med ae oe aa

Hejsa Eksperter

Jeg har hentet et news script på nettet og smidt ind på vores side, men har nogle problemer med æøå på siden.

Siden kan ses her:
http://www.bookselv.dk/vtr

Som det kan ses er det kun i "seneste news" ude til højre at æøå ik virker, alt det andet er skrevet i html.

Herunder poster jeg lige koderne for de forskellige filer, ved ikke hvor eller om problemet ligger i en af dem, det skal lige siges jeg absolut ikke kender ret meget til php.
Avatar billede frezzer81 Nybegynder
23. februar 2005 - 16:35 #1
easynews.php
--------------
<?php
/*

    .: EasyNews by Pierino :.
|===============================|
| http://www.code4fun.org      |
| mail01: info@code4fun.org    |
| mail02: sanculamo@hotmail.com |
|===============================|


*/

/************************ SETTING UP SOME VARIABLES ***************************/

// include configuration variables
  include 'config.php';

// images path
  $imgpath=$enPath."images/";

// extra margin to fit text near image
  $margin=round($tableWidth*2/3);

// inizializzo/azzero la variabile $image all'inizio del ciclo
  $image="";

// check start variable
if ( !isset($_GET['start']) || $_GET['start']<1 ) $start = 1;
else $start = $_GET['start'];


/*********************** ESTABILISH DBMS CONNECTION ***************************/

// connection
$conn = @mysql_connect($db_host, $db_user, $db_pw) or die ("Error during DBMS connection:<br />" . mysql_error() );

// db selection
@mysql_select_db($db_name,$conn) or die ("Error during db selection:<br /> " . mysql_error() );

// get num rows
$query = "SELECT * FROM $table_name";
$result = @mysql_query($query,$conn) or die ("Error reading news from database, check config.php file and run setup.php first:<br />" . mysql_error() );
$num_rows = @mysql_num_rows($result);

// calculate how many pages
$pages = intval($num_rows/$newscount);
if ($num_rows%$newscount) $pages++;

// check if someone insert manually a wrong page
if ($start > $pages) $start = 1;

// select query
$recordStart=($start*$newscount)-$newscount;
$query = "SELECT newstime,newstext,newsimg,align,link,newstitle FROM $table_name ORDER BY newstime DESC LIMIT $recordStart,$newscount";
$result = @mysql_query($query,$conn) or die ("Error reading news from database, check config.php file and run setup.php first:<br />" . mysql_error() );
$num_rows = @mysql_num_rows($result);


        // there are news to show...
        if ($num_rows) {
       

/****************************** PRINT NEWS ************************************/


            // table header
            echo "<table style=\"width: $tableWidth"."px; border: $tableBorder"."px solid $borderColor; padding: $topPadding"."px $rightPadding"."px $bottomPadding"."px $leftPadding"."px; text-align:$textAlign;\">\n";

            while ($riga = @mysql_fetch_row($result)) {

              /****************************************************************
              /*  DATE,TITLE AND TEXT HANDLING
              ****************************************************************/

              // date
              $date="<span style=\"font-family:Verdana,Arial; font-size: $dateSize"."px; color: $dateColor; font-weight: $dateBoldness;\">[".date('', $riga[0])."]</span>";
                     
              // if title exist push back to the date
              if (isset($riga[5]) && $riga[5]!="")  $date.=""."<span style=\"font-family:Verdana,Arial; font-size: $titleSize"."px; color: $titleColor; font-weight: $titleBoldness;\">".$riga[5]."</span>";

              // text
              $text=$riga[1];

              /****************************************************************
              /*  IMAGE HANDLING
              ****************************************************************/

              if ($riga[2]!="") {

                  // user submitted link
                  if ($riga[4]!="") $image="<a href=\"$riga[4]\">";
                  // image link to it self
                  else $image="<a href=\"".$imgpath."".$riga[2]."\" target=\"_blank\">";
                 
                  // image alignment
                  if ($riga[3]=='left') $padding="2px 5px 0px 0px";
                  else $padding="2px 0px 0px 0px";
                  $image.="<img style=\"padding: ".$padding."\" align=\"".$riga[3]."\" src=\"".$imgpath.$riga[2]."\" alt=\"news image\" border=\"0\" ".imgSize($imgpath.$riga[2] , $tableWidth, $margin)." /></a>";

              }
              else $image="";

              /****************************************************************
              /*  PRINT SINGLE NEWS
              ****************************************************************/
             
              echo "<tr><td style=\"padding: 0px 2px 2px 2px; background-color: $dateBgColor;\">$date</td></tr>\n
            <tr><td style=\"background-color: $textBgColor; font-family:Arial,Verdana; font-size: $textSize"."px; color: $textColor; font-weight: $textBoldness; \">".$image."$text</td></tr>\n
            <tr><td style=\"height:$spHeight"."px; background-color: transparent;\"></td></tr>\n
                    <tr><td style=\"height:$hrHeight"."px; background-color:$hrColor;\"></td></tr>\n";
       
            } // end while loop

            // html table footer and paginator
            print "<tr><td style=\"text-align: center; font-family:Verdana; font-size: $textSize"."px; color: $textColor; padding: 5px 2px 0px 2px;\">";
              if ($start>1) print "<a style=\"text-decoration:none;\" href=\"".$_SERVER['SCRIPT_NAME']."?start=".($start-1)."\">&lt;</a> ";
            print " page ".$start."/".$pages." ";
            if ($start<$pages) print " <a style=\"text-decoration:none;\" href=\"".$_SERVER['SCRIPT_NAME']."?start=".($start+1)."\">&gt;</a>";
            print "</td></tr>\n";
                 
        } // end if ($num_row)

        // nessuna news è presente nel db
        else print "<div style=\"padding: 4px 4px 4px 4px; text-align: center; font-family:Arial,Verdana; font-size: 12px; color: #000000;\">No News In Database</div>";


// close connection
@mysql_close($conn);




/*******************************************************************************
**            Img Size According $maxWidth and $margin                      **
*******************************************************************************/
function imgSize($img, $maxWidth, $margin) {


        // dati dell'immagine reale
        if (!$size = @getimagesize($img)) {
        //
        $newWidth = $maxWidth-$margin;
        return "width=\"$newWidth\"";
    }
    $width=$size[0];
    $height=$size[1];
        // rapporto lunghezza/altezza dell'immagine reale
        $ratio = $height/$width;
        // calcolo dei nuovi valori lunghezza e altezza in accordo col parametro
        // $maxWidth e $margin
        if ($width>$maxWidth-$margin) {
                $newWidth = $maxWidth-$margin;
                $newHeight= round($newWidth*$ratio);
        }
        else { $newWidth=$width; $newHeight=$height; }
        return "width=\"$newWidth\" height=\"$newHeight\"";


}







?>
Avatar billede frezzer81 Nybegynder
23. februar 2005 - 16:35 #2
main.php
---------
<html>
<head>
<title>Main</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
{  background-color: #FFFFFF; background-image: url(images/main-bg.gif); background-repeat: no-repeat }
-->
{  }
{  }
{  }
{  }
{  }
{  }
{  }
{  }
{  }
{  }
{  }
{  }
{  }
{  }
{  }
</style></head>

<body bgcolor="#FFFFFF" topmargin="0" leftmargin="0" link="#C0C0C0" vlink="#C0C0C0" alink="#C0C0C0">
<table border="0" cellspacing="1" cellpadding="3" style="border-collapse: collapse" bordercolor="#111111" width="650">
  <tr valign="top">
    <td width="35">&nbsp;</td>
    <td width="350">
      <p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Velkommen
        til <b><br>
        </b></font> <b><font face="Verdana, Arial, Helvetica, sans-serif">Varde Turist- &amp; Rejsebureau</font></b></p>
      <p align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">Der
        er nogen, der siger, at det er bedre at være lille og vågen, end stor
        og d....! <br>
        <br>
        Det tror vi er helt rigtigt! Hos os kan du planlægge, bestille og betale
        din ferie. Du får alle dine rejsepapirer udleveret her hos os, og vi sørger
        for, at du får svar på alle dine spørgsmål. Før sender vi dig ikke af
        sted! <br>
        <br>
        Vores personale har rejst rigtig meget i hele verden, vi har mange års
        erfaring i rejsebranchen, og vi samarbejder kun med de allerbedste. Det
        kommer vores kunder til gode! <br>
        <br>
        Så velkommen til! Vi glæder os til at hjælpe dig ud i den store verden.
        </font><br>
        <br>
      </p>
      <p align="center"> <img src="images/logo.gif" width="247" height="68"> </p>
      </td>
    <td width="35">
      &nbsp;</td>
    <td width="158"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
<?php include("easynews.php");?>
    &nbsp;</p>
        </font>
    </td>
    <td width="36">&nbsp;</td>
  </tr>
</table>
<p>&nbsp; </p>
</body>
</html>
Avatar billede frezzer81 Nybegynder
23. februar 2005 - 16:36 #3
setup.php
-------------
<?php
/*

  .: EasyNews 1.5 by Pierino :.
|===============================|
| http://www.code4fun.org      |
| mail01: info@code4fun.org    |
| mail02: sanculamo@hotmail.com |
|===============================|

*/

//----------------------------
/* START OR REPLACE SESSION */
session_start();

//-----------------------------------------
/* INCLUDE AND SETTING UP SOME VARIABLES */
include 'config.php';

// 1:visualizza il form per l'inserimento delle news
$visualizzaFormInserimento=0;
// 1:visualizza il form per editare le news
$visualizzaFormEdit=0;
// 1:visualizza lista news presenti nel db
$visualizzaNewsList=1;
// messaggio "variabile" mostrato nell'header
$msg="";
// emoticons path
$emopath=$enPath."emoticons/";

// emoticons array
$emoticons = array ( "char" => array ( ":)" , ":D" , ":(" , ":-S" , ":-P" , "8o|" , ":-O" , ";)" ),
                    "icon" => array ( "<img src=\"".$emopath."smile001.gif\" alt=\"smilie for :)\"  title=\":)\"  width=\"21\" height=\"21\" border=\"0\" />",
                                      "<img src=\"".$emopath."smile002.gif\" alt=\"smilie for :D\"  title=\":D\"  width=\"21\" height=\"21\" border=\"0\" />",
                                      "<img src=\"".$emopath."smile003.gif\" alt=\"smilie for :(\"  title=\":(\"  width=\"21\" height=\"21\" border=\"0\" />",
                                      "<img src=\"".$emopath."smile005.gif\" alt=\"smilie for :-S\" title=\":-S\" width=\"21\" height=\"21\" border=\"0\" />",
                                      "<img src=\"".$emopath."smile007.gif\" alt=\"smilie for :-P\" title=\":-P\" width=\"21\" height=\"21\" border=\"0\" />",
                                      "<img src=\"".$emopath."smile011.gif\" alt=\"smilie for 8o|\" title=\"8o|\" width=\"21\" height=\"21\" border=\"0\" />",
                                      "<img src=\"".$emopath."smile008.gif\" alt=\"smilie for :-O\" title=\":-O\" width=\"21\" height=\"21\" border=\"0\" />",
                                      "<img src=\"".$emopath."smile009.gif\" alt=\"smilie for ;)\"  title=\";)\"  width=\"21\" height=\"21\" border=\"0\" />"
                                    ),
                    "meaning" => array ( "happy" , "very happy" , "sad" , "confused" , "tongue sticking out" , "angry grin" , "surprised" , "wink" ) );



//------------------------------
/* ADMIN RESTRICTED AREA TEST */
//------------------------------------------------------------------------------
// update session variables with "user name" and "password"
if ( isset($_POST['id']) && isset($_POST['pw']) ) {
    $_SESSION['userid']=$_POST['id']; $_SESSION['password']=$_POST['pw'];
}

// check "user name" and "password"
if ($_SESSION['userid']==$id && $_SESSION['password']==$pw ) {

//------------------------------------------------------------------------------
//********************** START WHILE LOOP (DUMMY) ******************************
//------------------------------------------------------------------------------

do {

//------------------------------------------------------------------------------
/************** CONNESSIONE E OPERAZIONI PRELIMINARI DATABASE *****************/
//------------------------------------------------------------------------------

if (!$conn = connect($db_host,$db_user,$db_pw,$db_name,$table_name)) break;

//------------------------------------------------------------------------------
/********************** ESECUZIONE VARIE OPZIONI ******************************/
//------------------------------------------------------------------------------


/*******************************************************************************
***                        delete single news                              ***
*******************************************************************************/
if ($_GET['action']=='delete') {

    $newsid = $_GET['newsid'];

    $query="DELETE FROM $table_name WHERE newstime='$newsid'";

    if ($result = mysql_query($query,$conn)) {

          // news deleted from database
          $msg=".:. News removed.";

          // delete image from file system
          deleteImg($newsid.".jpg");

    }
    // error during delete query
    else $msg=".:. Delete failure:<br />" . mysql_error();

break; }


/*******************************************************************************
***                          delete all news                                ***
*******************************************************************************/
if ($_GET['action']=='deleteall') {

    if ($_GET['confirm']) {

        $query="DELETE FROM $table_name WHERE 1";

        if ($result = mysql_query($query,$conn)) {
            // alla news deleted from database
            $msg=".:. All news deleted successfully.";
            // empty images dir
            purge("images/");
        }
        else $msg=".:. Delete fail:<br />" .mysql_error();
    }
    else { $msg="You're about to delete all news in database:<a href=\"".$_SERVER['SCRIPT_NAME']."?action=deleteall&amp;confirm=true\"> go on</a>.";
          $visualizzaNewsList=0;
    }

break; }


/*******************************************************************************
***                            submit news                                  ***
*******************************************************************************/
if ($_GET['action']=='insert')  {

          // validate submitted fields
          if ( isset($_POST['text']) && $_POST['text']!="" ) {

              //********                RACCOLTA DATI                *********

              // news ID (timestamp)
              $newsid = $_POST['time'];
             
              // title
              $newstitle = trim($_POST['title']);
              $newstitle = nl2br(htmlspecialchars($newstitle));
                $newstitle = str_replace('<', '&lt;', $newstitle);
              $newstitle = str_replace('>', '&gt;', $newstitle);
             

              // text
              $text = trim($_POST['text']);
              // bbcode
              bb2html( $text );
              // emoticons
              $text = doReplace($text , $emoticons['char'], $emoticons['icon'] );

              // image position
              $align=$_POST['imgposition'];

              //image link
              if (isset($_POST['url']) && $_POST['url']!="http://") $linkImg=$_POST['url']; else $linkImg="";

              //*******      INSERIMENTO DATABASE E UPLOAD FILE      *********

              // insertion query
              if (!insertText($conn, $table_name, $newsid, $text, $newstitle )) break;

              // file upoload routine
              if (!uploadFile($conn, $newsid, $table_name,$linkImg,$align)) break;

          }
          else {
                  $msg = ".:. Submit news, image must be ".$maxSize."K max jpg file.";
                  // show submitting form
                  $visualizzaFormInserimento=1;
                  // hide news list
                  $visualizzaNewsList=0;
          }
break; }


/*******************************************************************************
***                        edit news (update)                              ***
*******************************************************************************/
if ($_GET['action']=='edit') {


    if (isset($_POST['newsid']) && isset($_POST['text']) && $_POST['text']!=""){

        //********          INSERIMENTO DATI EDITATI            ****************
        //********                RACCOLTA DATI                ****************
        // news id
        $newsid = $_POST['newsid'];

        // title
        $newstitle = trim($_POST['title']);
        $newstitle = nl2br(htmlspecialchars($newstitle));
        $newstitle = str_replace('<', '&lt;', $newstitle);
        $newstitle = str_replace('>', '&gt;', $newstitle);

        // text
        $text = trim($_POST['text']);
        bb2html( $text );
        $text = doReplace($text, $emoticons['char'], $emoticons['icon'] );

        // image position
        $align=$_POST['imgposition'];

        // image link
        $linkImg=$_POST['url'];

        //*******      INSERIMENTO DATABASE E UPLOAD FILE      ****************
        // update text row
        if (!updateText($conn, $table_name, $newsid, $text, $newstitle )) break;

            // delete image
            if ($_POST['deleteimage']=="delete") {

                    // aggiorna il database cancellando il record dell'immagine
                    updateImg($conn, $newsid, $table_name , "del" , "del");
                    // delete image from file system
                    deleteImg($newsid.".jpg");
                    break;
            }
            if ($_POST['delink']=="on") $linkImg="del";
            // upload image
            uploadFile($conn, $newsid, $table_name, $linkImg, $align);



    }
    else {

        //**********              PRINT EDIT FORM                ***************
 
        if (isset($_GET['newsid']) && $_GET['newsid']!="" && is_numeric($_GET['newsid']) ) {

                $newsid = $_GET['newsid'];
                $msg="Edit text and/or upload image [max ".$maxSize."K, jpg file].";
                $visualizzaFormEdit=1; $visualizzaNewsList=0;
        }
        else if (isset($_POST['newsid']) && $_POST['newsid']!="" && is_numeric($_POST['newsid']) ) {

                $newsid = $_POST['newsid'];
                $msg="Edit text and/or upload image [max ".$maxSize."K, jpg file].";
                $visualizzaFormEdit=1; $visualizzaNewsList=0;
        }
        else {

                $msg="General fault, retry.";
                $visualizzaFormEdit=0; $visualizzaNewsList=1;
        }
    }

break; }


/*******************************************************************************
***                            show help                                    ***
*******************************************************************************/
if ($_GET['action']=='help') {

    $msg=":: List : Show all news.<br />
          :: Add News : Submit a news.<br />
          :: Delete All : Delete all the news.<br />
          :: Preview : Show news look.<br />
          :: Help : Show this page.<br />";

    $visualizzaNewsList=0;


break; }



/*******************************************************************************
***                            show help                                    ***
*******************************************************************************/
if ($_GET['action']=='about') {

    $msg="EasyNews is freeware and open source.<br /><br />
          Visit mY hoMe paGe: <a href=\"www.code4fun.org</a><br" target="_blank">http://www.code4fun.org\">www.code4fun.org</a><br /><br />
          ConTact mE : <a href=\"mailto:info@code4fun.org\">info@code4fun.org</a><br />";

    $visualizzaNewsList=0;

// inutile....
break; }


/*** CHIUSURA WHILE DUMMY ***/
} while(0);

//------------------------------------------------------------------------------
/*********************** END WHILE LOOP (DUMMY) *******************************/
//------------------------------------------------------------------------------




//------------------------------------------------------------------------------
/***********************      XHTML OUTPUT      ******************************/
//------------------------------------------------------------------------------

// print header xhtml
top();

// print menu
print_header($msg);

// print news submit form
if ($visualizzaFormInserimento) printFormNews();

// print edit form
if ($visualizzaFormEdit) { printFormEdit($conn, $table_name, $newsid); }

// se la connessione al db è riuscita e non ci sono stati errori
// durante le query successive visualizza le news presenti nel db
// e chiudi la connessione
if ($conn && $visualizzaNewsList) {

        // stampa l'elenco delle news se presenti
        print_news(0, $conn, $table_name);

        // chiusura della connessione
        mysql_close($conn);
}

// print footer
foot();

} // end if check restricted area

//-------------------------------------------------------------------
/* if check user name and password fail print restricted area form */
else {restictedArea();}












/**************************  F U N C T I O N S  *******************************/


/*******************************************************************************
**            Visualizza Form per accesso alla Restricted Area              **
*******************************************************************************/
function connect($db_host,$db_user,$db_pw,$db_name,$table_name) {


        global $msg;

// connessione al DBMS
if (!$conn = @mysql_connect($db_host, $db_user, $db_pw)) {

    $msg="Error during connection, check connection parameters in 'config.php' file: " . mysql_error();
    return $conn;
}

// crea il db se non esiste
$query="CREATE DATABASE IF NOT EXISTS `".$db_name."`";
if (!$result = @mysql_query($query,$conn)) {

    $msg="Error during database creation: " . mysql_error();
    $conn=0;
    return $conn;
}

// selezione del db
if (!$result= @mysql_select_db($db_name,$conn)) {

    $msg="Error during database selection: " . mysql_error();
    $conn=0;
    return $conn;
}

// se la tabella non esiste la crea
if(!@mysql_num_rows(mysql_query("SHOW TABLES LIKE '".$table_name."'"))==1) {

          // Crea la tabella $table_name
          $query = "CREATE TABLE `$table_name` (
                    `newstime` INT DEFAULT '0' NOT NULL ,
                    `newstext` TEXT NOT NULL ,
                    `newsimg` VARCHAR(50) DEFAULT '',
                    `align` ENUM( 'left', 'right' ) DEFAULT 'left' NOT NULL ,
                    `link` VARCHAR(150) DEFAULT '',
                    `newstitle` VARCHAR(100) DEFAULT '',
                    PRIMARY KEY ( `newstime` )
                    );";

          if (!$result = @mysql_query($query,$conn)) {

              $msg="Table creation fail: " . mysql_error();
              $conn=0;
              return $conn;
          }

}

return $conn;
}


/*******************************************************************************
**                        STAMPA INTESTAZIONE E MENU                          **
*******************************************************************************/

function print_header($msg) {

                // Nome del file corrente
                $currentFile= array_pop(explode("/", $_SERVER["SCRIPT_NAME"]));

                echo "
                <table border='1' cellpadding='10' cellspacing='0' width='500'>

                <!-- logo -->
                <tr><td class=\"logo\"><a href='http://www.code4fun.org' target='_blank'>EasyNews</a><br />
                    <div class=\"mini-text\"> [ v.1.5 ] </div></td></tr>

                <!-- Menu -->
                <tr><td class=\"menu\"><strong>.: menu:&nbsp;&nbsp;
                    <a href='$currentFile'>list</a>&nbsp;|&nbsp;
                    <a href='$currentFile?action=insert'>add news</a>&nbsp;|&nbsp;
                    <a href='$currentFile?action=deleteall'>delete all</a>&nbsp;|&nbsp;
                    <a href='demo.php' target='_blank'>preview</a>&nbsp;|&nbsp;
                    <a href='$currentFile?action=help'>help</a>&nbsp;|&nbsp;
                    <a href='$currentFile?action=about'>?</a></strong>
                </td></tr>";
                if (isset($msg) && $msg!="") print "<tr><td><span class='titolo'>$msg</span</td></tr>";
                print "</table>";


}



/*******************************************************************************
**                          VISUALIZZA NEWS                                  **
********************************************************************************
** $newscount: numero di news da visualizzare (0: tutte le news presenti)
** $conn: handle di connessione al db restituito da una chiamata mysql_connect()
** $table_name: tabella in cui sono memorizzate le news
*******************************************************************************/

function print_news($newscount, $conn, $table_name) {

        $query="SELECT newstime,newstext,newsimg,newstitle FROM $table_name ORDER BY newstime DESC";
        $result = @mysql_query($query,$conn) or die(mysql_error());
        $num_rows = @mysql_num_rows($result);

        if ($num_rows) {
                  // tabella che contiene le news...
                  echo "<p></p>
                        <table class=\"tablenews\">
                        <tr><td class=\"title\" colspan=\"5\">News list:</td></tr>
                        <tr><td width=\"80\" class=\"keyc\">Date</td>
                            <td class=\"keyc\">Text</td>
                            <td class=\"keyc\" width=\"40\">Edit</td>
                            <td class=\"keyc\" width=\"40\">Img</td>
                            <td class=\"keyc\" width=\"50\">Delete</td>
                        </tr>";

                  // estraggo le news...
                  if ( $newscount>$num_rows || $newscount==0 ) $newscount=$num_rows;
                  for ($i=0; $i<$newscount; $i++) {

                  $riga=mysql_fetch_row($result);

                    // le varie righe
                    $data=date('d M y' , $riga[0]);
            $text = $riga[1];
            if ($riga[2]==NULL) $imgField="&nbsp;"; else $imgField="<a href=\"java script:CaricaFoto('images/".$riga[2]."')\"><img src=\"icons/preview.gif\" border=0></a>";
                    if (isset($riga[3]) && $riga[3]!="") $title = "<strong>".$riga[3]."</strong><br />"; else $title="";

                    if ( $i&1 ) { $bgcolor='#F5F5F5'; } // righe dispari
                    else $bgcolor='#DCE0E3';

                  echo "<tr><td bgcolor='$bgcolor' class=\"testo\">$data</td>
                            <td bgcolor='$bgcolor' class=\"testo\" style=\"text-align:left\">$title $text</td>
                            <td bgcolor='$bgcolor' class=\"testo\"><a href='".$_SERVER['SCRIPT_NAME']."?action=edit&amp;newsid=$riga[0]'><img src=\"icons/edit.gif\" border=0></a></td>
                            <td bgcolor='$bgcolor' class=\"testo\" style=\"text-align:center\">$imgField</td>
                            <td bgcolor='$bgcolor' class=\"testo\"><a href='".$_SERVER['SCRIPT_NAME']."?action=delete&amp;newsid=$riga[0]'><img src=\"icons/delete.gif\" border=0></a></td>
                        </tr>";
                  // chiusura tabella
                  if ($i==$newscount-1) print "</table><br />";
                  }
        }
        else echo "<p></p>
                    <table border='1' width='500' cellspacing='0' cellpadding='4'>
                    <tr><td class=\"titolo\" style=\"text-align:center\">..: News table is empty :..</td></tr>
                    </table>";

}



/*******************************************************************************
**                  VISUALIZZA FORM PER INSERIMENTO NEWS                    **
*******************************************************************************/

function printFormNews() {

        global $emoticons,$maxSize;

        $currentFile= array_pop(explode("/", $_SERVER["SCRIPT_NAME"]));
        $currenttime=time();
        $data = date('d M y' , $currenttime);


        /* TEXT SECTION ******************************************************/
        echo "<p></p>
              <form enctype=\"multipart/form-data\" name=\"news\" action=\"$currentFile?action=insert\" method=\"post\">
              <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"".($maxSize*1000)."\" />
              <input type=\"hidden\" name=\"time\" value=\"$currenttime\" />

              <table class=\"tablenews\">
              <tr><td class=\"title\" colspan=\"2\">Text setup</td></tr>
              <tr><td class=\"key\" colspan=\"2\">Date : ".$data."</td></tr>

              <tr><td class=\"key\">
              Title: <input type=\"text\" name=\"title\" size=\"58\" maxlength=\"100\" value=\"\" /><br /><br />
              Text:<br /><textarea cols=\"48\" rows=\"6\" wrap=\"ON\" name=\"text\">Here the text...</textarea><br />
        ";

        /* BBCODE SHORTCUT ***************************************************/
        printBBcodeShort();
            echo "</td><td width=\"60\" class=\"emo\">eMo<br /><br />";

        /* EMOTICONS *********************************************************/
        printEmoticons($emoticons);

        /* FILE UPLOAD SECTION ***********************************************/
        printFormUpload(0, $img=null);

        echo "<tr><td colspan=\"2\" class=\"keyc\"><input type=\"submit\" value=\"&gt;&gt; POST &lt;&lt;\" /></td></tr>
              </table></form>";

}

/*******************************************************************************
**                  Visualizza Form per editare una news                      **
*******************************************************************************/
function printFormEdit($conn, $table_name, $id) {

        global $emoticons;

        $query = "SELECT newstext,newsimg,align,link,newstitle FROM $table_name WHERE newstime='$id'";
        $result = @mysql_query($query,$conn) or die(mysql_error());
        $row = mysql_fetch_row($result);
        $data = date('d M y' , $id);

        // text
        $text = $row[0];
        // emoticons
        $text = doReplace($text, $emoticons['icon'], $emoticons['char'] );
        // text bbcode reverse
        html2bb($text);
        // image
        $currentImage=$row[1];
        // image align
        $align=$row[2];
        // image link
        $hyperlink=$row[3];
        // title
        $title=$row[4];
        $title = str_replace('&lt;', '<', $title);
        $title = str_replace('&gt;', '>', $title);
       

        echo "<p></p>
              <form enctype=\"multipart/form-data\" name=\"news\" action=\"".$_SERVER['SCRIPT_NAME']."?action=edit\" method=\"post\">
              <input name=\"newsid\" type=\"hidden\" value=\"$id\">
              <table class=\"tablenews\">
              <tr><td class=\"title\" colspan=\"2\">Text setup</td></tr>
              <tr><td class=\"key\" colspan=\"2\">Date : ".$data."</td></tr>
              <tr><td class=\"key\">
              Title: <input type=\"text\" name=\"title\" size=\"58\" maxlength=\"100\" value=\"$title\" /><br /><br />
              Text:<br /><textarea cols=\"48\" rows=\"6\" wrap=\"ON\" name=\"text\">$text</textarea><br />
        ";

        /* BBCODE SHORTCUT ***************************************************/
        printBBcodeShort();

        echo "</td><td width=\"60\" class=\"emo\">eMo<br /><br />\n";

        /* EMOTICONS *********************************************************/
        printEmoticons($emoticons);

        /* FILE UPLOAD SECTION ***********************************************/
        printFormUpload( 1 , $currentImage, $hyperlink, $align );

        echo "<tr><td colspan=\"2\" class=\"keyc\">
              <input type=\"submit\" value=\"&gt;&gt; UPDATE &lt;&lt;\">
              </td></tr>
              </table></form>";
             
        @mysql_close($conn);

}


/*******************************************************************************
**            VISUALIZZA LA LISTA DELLE EMOTICONS DISPONIBILI                **
*******************************************************************************/

function printEmoticons(&$matrice) {

        for ($i=0; $i<count($matrice['char']); $i++ ) {

        echo "<a href=\"java script:SetEm_o('".$matrice['char'][$i]."')\">".$matrice['icon'][$i]."</a>&nbsp;";
        if ( $i&1 ) print "<br />";
        }

}

/*******************************************************************************
**            VISUALIZZA LA LISTA DELLE SHORTCUT BBCODE                      **
*******************************************************************************/
function printBBcodeShort() {

        echo "<a href=\"java script:SetEm_o('')\"><img src=\"icons/bold.gif\" alt=\"bold\" width=\"21\" height=\"20\" border=\"0\" /></a>
              <a href=\"java script:SetEm_o('')\"><img src=\"icons/italic.gif\" alt=\"italic\" width=\"21\" height=\"20\" border=\"0\" /></a>
              <a href=\"java script:SetEm_o('')\"><img src=\"icons/underline.gif\" alt=\"underline\" width=\"21\" height=\"20\" border=\"0\" /></a>
              <a href=\"java script:SetEm_o('link')\"><img src=\"icons/createlink.gif\" width=\"21\" height=\"20\" alt=\"create link\" border=\"0\" /></a>
              <a href=\"java script:SetEm_o('[br]')\"><img src=\"icons/break.gif\" alt=\"break line\" width=\"21\" height=\"20\" border=\"0\" /></a>
            ";


}

/*******************************************************************************
**                    VISUALIZZA FORM UPLOAD IMMAGINE                        **
*******************************************************************************/

function printFormUpload($flag, $img , $hyperlink="" , $align="left") {

        if ($hyperlink=="") $unlinkButton="&nbsp;";
        else $unlinkButton="<input name=\"delink\" type=\"checkbox\" value=\"on\">Unlink";

        if ($img=="") $img = "&nbsp;No image submitted for this news.";
        else $img = "<a href=\"java script:CaricaFoto('images/".$img."')\">&nbsp;<img style=\"padding: 0px 0px 15px 0px\" border=\"0\" align=\"left\" src=\"images/".$img."\" width=\"100\" /></a>
                      <br />&nbsp;<input name=\"deleteimage\" type=\"checkbox\" value=\"delete\">Delete current image<br />";

        echo "<tr><td class=\"title2\" colspan=\"2\"><br />Image setup</td></tr>";

        if ($flag) echo "<tr><td class=\"key\" colspan=\"2\">".$img."</td></tr>";

        echo "<tr><td style=\"background-color:#E1EAEE; font-size: 12px; font-family:Verdana,Arial; font-weight:normal;\"; colspan=\"2\"><br />
                    <!-- Name of input element determines name in $_FILES array -->
                    &nbsp;.: image file :&nbsp;<input name=\"userfile\" type=\"file\" size=\"25\" />
                    &nbsp;.: align :&nbsp;<select size=\"1\" name=\"imgposition\">";

        if ($align=="left") echo "<option value=\"left\">Left</option><option value=\"right\">Right</option>";
        else                echo "<option value=\"right\">Right</option><option value=\"left\">Left</option>";

        echo "</select><br />";

        // link immagine
        if ($flag && $hyperlink!="") $size=38;
        else $size=50;
        echo "<br />&nbsp;.: current image link : <input name=\"url\" type=\"text\" size=\"$size\" value=\"$hyperlink\">&nbsp;&nbsp;".$unlinkButton."
              <br /><br /></td></tr>";



}

/*******************************************************************************
**                            html -> bbcode                                    **
*******************************************************************************/

function html2bb(&$html2bbtxt) {

        // let's remove all the linefeeds, unix
        $html2bbtxt = str_replace(chr(10), '', $html2bbtxt); //                "\n"

        // and Mac (windoze uses both)
        $html2bbtxt = str_replace(chr(13), '', $html2bbtxt); //                "\r"

        // 'ordinary' transformations
        $html2bbtxt = str_replace('<br />', '[br]', $html2bbtxt);
        $html2bbtxt = str_replace('<strong>', '', $html2bbtxt);
        $html2bbtxt = str_replace('</strong>', '
', $html2bbtxt);
        $html2bbtxt = str_replace('<em>', '', $html2bbtxt);
        $html2bbtxt = str_replace('</em>', '
', $html2bbtxt);
        $html2bbtxt = str_replace('<span style="border-bottom: 1px dotted">', '', $html2bbtxt);
        $html2bbtxt = str_replace('</span>', '
', $html2bbtxt);

        // more stuff
        $html2bbtxt = str_replace('<a href="','[url=', $html2bbtxt);
        $html2bbtxt = str_replace('</a>', '[/url]', $html2bbtxt);
        $html2bbtxt = str_replace('" >', ']', $html2bbtxt);

        // the hypertext entities.. (ditto)
        $html2bbtxt = str_replace('<', '&lt;', $html2bbtxt);
        $html2bbtxt = str_replace('>', '&gt;', $html2bbtxt);

        $html2bbtxt = preg_replace("/<\?(.*)\?>/i", "<b>script-kiddie prank: \\1</b>", $html2bbtxt);

        // you know what happens to the inventor of the database on Judgement Day?
        if (get_magic_quotes_gpc()) stripslashes($html2bbtxt);


}


/*******************************************************************************
**                            bbcode -> html                                  **
*******************************************************************************/

function bb2html(&$string){

$string = nl2br(htmlspecialchars($string));

$patterns = array(
                                    '`\[b\](.+?)\[/b\]`is',
                                    '`\[i\](.+?)\[/i\]`is',
                                    '`\[u\](.+?)\[/u\]`is',
                                    '`\[url=([a-z0-9]+://)([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*?)?)\](.*?)\[/url\]`si'
                  );

$replaces =  array(
                                    '<strong>\\1</strong>',
                                    '<em>\\1</em>',
                                    '<span style="border-bottom: 1px dotted">\\1</span>',
                                    '<a href="\1\2" >\6</a>'
                  );


$string = str_replace("[br]", "<br />", $string);

$string = preg_replace($patterns, $replaces , $string);


}



/*******************************************************************************
**      sostituisce gli elementi con stesso indice fra 2 array              **
*******************************************************************************/
// sostituisce in $text tutte le occorrenze degli elementi dell'array $s con le
// analoghe (di pari indice) dell'array $d,
function doReplace( &$text, &$s, &$d ) {

        $textMod="";
        for ($i=0; $i<count($s); $i++) {
                if (!$i) $textMod = str_replace($s[$i], $d[$i], $text);
                else    $textMod = str_replace($s[$i], $d[$i], $textMod);

        }

        return $textMod;

}




/*******************************************************************************
**                            Upload image file                              **
*******************************************************************************/
function uploadFile($conn,$newsid,$table_name,$linkImg,$align) {

        global $msg,$maxSize;


        if  ( $_FILES['userfile']['size']!=0 && $_FILES['userfile']['size']<($maxSize*1000)
            && ($_FILES['userfile']['type'] == 'image/jpg'
            || $_FILES['userfile']['type'] == 'image/jpeg'
            || $_FILES['userfile']['type'] == 'image/pjpeg') ) {

            $uploaddir = 'images/';
            $uploadfile = $uploaddir . $newsid . ".jpg";


                      if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {

                          // upload riuscito
                          $msg.= " Image successfully uploaded.";
                          // update image file name in database
                          if (updateImg($conn, $newsid, $table_name, $newsid.".jpg" , $linkImg , $align )) return true;
                          else return false;

                      }
                      else {
                            $msg.= " Error: possible file upload attack!";
                            return false;
                      }
        }
        else {
                // image not submitted
                if ($_FILES['userfile']['size']==0 && $_FILES['userfile']['name']=="") {
                        $msg .= " Image not submitted.";
                        // update (in case) link and align
                        if (updateImg($conn, $newsid, $table_name, "" , $linkImg , $align )) return true;
                        else return false;
                }
                else $msg .= " Image upload failure, wrong file.";
        }
}



/*******************************************************************************
**              Aggiorna il campo newsimg,link e align                      **
*******************************************************************************/

function updateImg($connId, $newsId, $table_name, $fileName , $linkImg , $align="left" ) {

global $msg;

// aggiorno i campi selettivamente

$query="UPDATE $table_name SET align='$align' ";

if ($linkImg=="del") { $query.=", link='' "; $msg.=" Link deleted.";}
else if ($linkImg!="") { validateUrl($linkImg); $query.=", link='$linkImg' "; }

if ($fileName=="del") $query.=", newsimg='' ";
else if ($fileName!="") $query.=", newsimg='$fileName' ";

$query.=" WHERE newstime='$newsId'";

if ($result = @mysql_query($query,$connId)) return true;
else { $msg.=" Error during UPDATE: ".mysql_error(); return false; }



}

/*******************************************************************************
**                    Valida URL sprovvisti di http://                      **
*******************************************************************************/
function validateUrl(&$url) {

        $str1="www.";
        if (!strncmp($str1, $url, 4)) $url="http://".$url;
        else return true;
}



/*******************************************************************************
**                    Inserisce newstime e newstext                          **
*******************************************************************************/
function insertText($connId, $table_name, $newstime, $text, $title) {

        global $msg;

        // insertion query
        $query="INSERT INTO $table_name (newstime,newstext,newstitle) VALUES ('$newstime','$text','$title')";
        if ($result = mysql_query($query,$connId)) { $msg=".:. News added successfully."; return true; }
        else { $msg=".:. Insertion failure:<br />".mysql_error(); return false; }

}

/*******************************************************************************
**                    Aggiorna newstime e newstext                          **
*******************************************************************************/
function updateText($connId, $table_name, $newsId, $text, $title ) {

        global $msg;

        // update text field
        $query = "UPDATE $table_name SET newstitle='$title' , newstext='$text' WHERE newstime='$newsId'";
        if ($result = mysql_query($query,$connId)) { $msg=".:. News updated."; return true; }
        else { $msg=".:. News update failure:<br />".mysql_error(); return false; }

}


/*******************************************************************************
**                        Delete Image from dir                              **
*******************************************************************************/
function deleteImg($fileName) {

        global $msg;

        if (file_exists("images/".$fileName)) {

            if (unlink("images/".$fileName)) $msg.=" Image removed.";
            else $msg.=" Image not removed.";

        }
        else $msg.=" Image not present.";


}


/*******************************************************************************
**                        Svuota una directory                                **
*******************************************************************************/

function purge($dir) {

  $handle = opendir($dir);
  while (false !== ($file = readdir($handle))) {

    if ($file != "." && $file != "..")  {

      if (is_dir($dir.$file)) {

        purge ($dir.$file."/");
        rmdir($dir.$file);

      }
      else { unlink($dir.$file); }

    }
  }
  closedir($handle);

}


/*******************************************************************************
**            Visualizza Form per accesso alla Restricted Area              **
*******************************************************************************/
function restictedArea() {

        echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
              <html xmlns=\"http://www.w3.org/1999/xhtml\">
                <head>
                <title>EasyNews Restricted Area</title>
                <meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\" />
                <style type=\"text/css\">
                <!--
                body {
                      background-color: #FFFFFF;
                      margin-top: 30px;
                      margin-right: 0px;
                      margin-bottom: 0px;
                      margin-left: 0px;
                      font-family: Verdana, Arial, Courier, Serif;



                }

                .container { margin:0px auto; text-align: center; width: 200px;}

                .box {

                        background-color: #CCCCCC;
                        width: 200px;
                        text-align: center;
                        border-color: #000000;
                        border-style: solid;
                        border-width: 2px 2px 2px 2px;
                        padding: 10px 4px 4px 4px;
                        margin: 0px 0px 0px 0px;
                        font-family: Verdana, Arial, sans-serif;
                        font-size: 13px;
                }
                -->
                </style>
                </head>
                <body>
                      <div align=\"center\">
                      <div class=\"container\">
                      <div class=\"box\">
                      <p><strong>EasyNews</strong><br />Restricted Area</p>
                      <form name=\"restricted\" action=\"$currentFile\" method=\"post\">
                      User Name: <input name=\"id\" type=\"text\" value=\"\" /><br />
                      Password: <input name=\"pw\" type=\"password\" value=\"\" />
                      <p><input type=\"submit\" value=\"submit\" /></p>
                      </form>
                      </div>
                      </div>
                      </div>
                </body>
                </html>
        ";
}

/*******************************************************************************
*****                          HEADER XHTML                              *****
*******************************************************************************/
function top() {

echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
      <html xmlns=\"http://www.w3.org/1999/xhtml\">
      <head>
        <title>EasyNews - www.code4fun.org</title>
        <meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\" />
        <style type=\"text/css\">
        <!--
        body {margin-top: 30px; font-family: Arial, Verdana; color: #000000; font-size: 12px;  padding:0px;}
        .container { margin:0px auto; width: 500px;}
        A:LINK {text-decoration:none; color: #336699;}
        A:VISITED {text-decoration:none; color: #336699;}
        A:HOVER {text-decoration:none; color: #33CCFF;}
        table.tablenews { width: 500px; border: 2px solid #999999;}
        td.title {border-style: solid; border-width: 0px 0px 2px 0px; background-color: #ffffff; font-size: 13px; font-family:Verdana,Arial; font-weight:bold; text-align:left;}
        td.title2 {border-style: solid; border-width: 1px 0px 2px 0px; background-color: #ffffff; font-size: 13px; font-family:Verdana,Arial; font-weight:bold; text-align:left;}
        td.key {background-color:#F0F0F0; font-size: 12px; font-family:Verdana,Arial; font-weight:normal; text-align:left; padding: 4px 4px 4px 6px; }
        td.keyc {background-color:#F0F0F0; font-size: 12px; font-family:Verdana,Arial; font-weight:bold; text-align:center; padding: 4px 0px 4px 0px; }
        td.emo {background-color:#E1EAEE; font-size: 12px; font-family:Verdana,Arial; font-weight:normal; text-align:center; padding: 4px 3px 4px 3px; }
        .logo { font-size: 26px; font-style: normal; background:#F0F0F0; text-align:center; }
        .titolo { font-size: 12px; font-family:Verdana,Arial; font-weight:bold; text-align:left; }
        .menu {font-size: 12px; font-family:Verdana,Arial; font-weight: lighter; text-align:left; }
        .testo { font-size: 12px; font-family:Arial,Verdana; padding:5px 5px 5px 5px; text-align:center;}
        .mini-text {font-size: 10px; font-family:Arial,Verdana; font-weight: bold; }
        -->
        </style>
        <SCRIPT type=\"text/javascript\">
        <!--
        function SetEm_o(emo){document.news.text.value+=''+emo; document.news.text.focus();}
        function CaricaFoto(img){
                foto1= new Image();
                foto1.src=(img);
                Controlla(img);
        }
        function Controlla(img){
                if((foto1.width!=0)&&(foto1.height!=0)){
                viewFoto(img);
                }
                else{
                funzione=\"Controlla('\"+img+\"')\";
                intervallo=setTimeout(funzione,20);
                }
        }
        function viewFoto(img){
                largh=foto1.width+20;
                altez=foto1.height+20;
                stringa=\"width=\"+largh+\",height=\"+altez;
                finestra=window.open(img,\"\",stringa);
        }
        //-->
        </SCRIPT>
      </head>
        <body>
        <div class=\"container\">
        ";


}


/*******************************************************************************
*****                          FOOTER XHTML                              *****
*******************************************************************************/
function foot() { echo "</div></body></html>"; }


?>
Avatar billede frezzer81 Nybegynder
23. februar 2005 - 16:36 #4
config.php
-------------
<?
/*
    .: EasyNews by Pierino :.
|===============================|
| http://www.code4fun.org      |
| mail01: info@code4fun.org    |
| mail02: sanculamo@hotmail.com |
|===============================|

*/



/* Database Account                                                          */
$db_host = "xxx";
$db_name = "xxx";
$table_name = "xxx";
$db_user = "xxx";
$db_pw = "xxx";

/* Control Panel (restricted area) User Id & Password                        */
$id='xxx';
$pw='xxx';

/* EasyNews folder path. Example: http://www.yourdomain.org/easynews/        */
$enPath="http://www.bookselv.dk/easynews/";

/* Number of news to show each page                                          */
$newscount=5;

/* Max upload file size (in Kb)                                              */
$maxSize=200;



/************************* custom look ****************************************/

/* table */
$tableBorder=0;              // table border, 0 = no border
$borderColor='#999999';      // table border color
$tableWidth=150;            // table width
$topPadding=0;              // padding-top in pixel
$rightPadding=0;            // padding-right in pixel
$bottomPadding=0;            // padding-bootom in pixel
$leftPadding=0;              // padding-left in pixel
$textAlign='left';          // text alignment (date & text fields)


/* date & title field */
$dateSize=1;                // date field font size (in pixel)
$dateColor='#ffffff';        // date field font color
$dateBoldness='lighter';      // date field boldness: normal,bold,bolder or lighter
$titleSize=10;              // title field font size (in pixel)
$titleColor='#000000';      // title field font color
$titleBoldness='bold';      // title field boldness: normal,bold,bolder or lighter
$dateBgColor='#ffffff';      // date & title fields background color


/* text field */
$textSize=10;                // text field font size (in pixel)
$textColor='#000000';        // text field font color
$textBgColor='#ffffff';      // text field background color
$textBoldness='normal';      // text field boldness: normal,bold,bolder or lighter


/* space at the end of text in pixel (increase readability) */
$spHeight='4';

/* horizonthal rule divisor */
$hrColor='#CCCC99';          // horizontal rule color
$hrHeight='1';              // horizontal rule height


?>
Avatar billede detox Nybegynder
23. februar 2005 - 16:42 #5
Du havde nu ikke behøvet poste så meget. Problemet er at data i højre side er gemt i utf-8 format, så de skal decodes med: utf8_decode()
http://dk2.php.net/manual/en/function.utf8-decode.php
Avatar billede frezzer81 Nybegynder
23. februar 2005 - 16:48 #6
Sorry :)

Kunne du sige i hvilken fil og hvor utf8_decode() skal stå? som sagt ved faktisk intet om php :( eller er det noget som skal stå en mill steder :)
Avatar billede detox Nybegynder
23. februar 2005 - 17:29 #7
Hvert fald her i easynews.php:

$text=$riga[1]; rettes til:

$text=utf8_decode($riga[1]);
Avatar billede detox Nybegynder
23. februar 2005 - 17:30 #8
Evt. osse her (samme fil):

              if (isset($riga[5]) && $riga[5]!="")  $date.=""."<span style=\"font-family:Verdana,Arial; font-size: $titleSize"."px; color: $titleColor; font-weight: $titleBoldness;\">".$riga[5]."</span>";

til:

              if (isset($riga[5]) && $riga[5]!="")  $date.=""."<span style=\"font-family:Verdana,Arial; font-size: $titleSize"."px; color: $titleColor; font-weight: $titleBoldness;\">".utf8_decode($riga[5])."</span>";
Avatar billede detox Nybegynder
23. februar 2005 - 17:45 #9
Men der må være rettet i koden ift. det du poster her. Jeg kan ikke finde dette link i koden:

<a href="http://www.bookselv.dk/vtr/nyhed.html" >Læs mere...</a>
Avatar billede avminarm Juniormester
23. februar 2005 - 21:28 #10
det skal rettes begge steder ;o)

både ved riga[1] of riga[5] filen hvor det er rettet til kan copy/pastes herunder:

---------------------------
<?php
/*    file: easynews.php
    .: EasyNews by Pierino :.
|===============================|
| http://www.code4fun.org      |
| mail01: info@code4fun.org    |
| mail02: sanculamo@hotmail.com |
|===============================|


*/

/************************ SETTING UP SOME VARIABLES ***************************/

// include configuration variables
  include 'config.php';

// images path
  $imgpath=$enPath."images/";

// extra margin to fit text near image
  $margin=round($tableWidth*2/3);

// inizializzo/azzero la variabile $image all'inizio del ciclo
  $image="";

// check start variable
if ( !isset($_GET['start']) || $_GET['start']<1 ) $start = 1;
else $start = $_GET['start'];


/*********************** ESTABILISH DBMS CONNECTION ***************************/

// connection
$conn = @mysql_connect($db_host, $db_user, $db_pw) or die ("Error during DBMS connection:<br />" . mysql_error() );

// db selection
@mysql_select_db($db_name,$conn) or die ("Error during db selection:<br /> " . mysql_error() );

// get num rows
$query = "SELECT * FROM $table_name";
$result = @mysql_query($query,$conn) or die ("Error reading news from database, check config.php file and run setup.php first:<br />" . mysql_error() );
$num_rows = @mysql_num_rows($result);

// calculate how many pages
$pages = intval($num_rows/$newscount);
if ($num_rows%$newscount) $pages++;

// check if someone insert manually a wrong page
if ($start > $pages) $start = 1;

// select query
$recordStart=($start*$newscount)-$newscount;
$query = "SELECT newstime,newstext,newsimg,align,link,newstitle FROM $table_name ORDER BY newstime DESC LIMIT $recordStart,$newscount";
$result = @mysql_query($query,$conn) or die ("Error reading news from database, check config.php file and run setup.php first:<br />" . mysql_error() );
$num_rows = @mysql_num_rows($result);

        // there are news to show...
        if ($num_rows) {
       

/****************************** PRINT NEWS ************************************/


            // table header
            echo "<table style=\"width: $tableWidth"."px; border: $tableBorder"."px solid $borderColor; padding: $topPadding"."px $rightPadding"."px $bottomPadding"."px $leftPadding"."px; text-align:$textAlign;\">\n";

            while ($riga = @mysql_fetch_row($result)) {

              /****************************************************************
              /*  DATE,TITLE AND TEXT HANDLING
              ****************************************************************/

              // date
              $date="<span style=\"font-family:Verdana,Arial; font-size: $dateSize"."px; color: $dateColor; font-weight: $dateBoldness;\">[".date('d M y' , $riga[0])."]</span> :";
                     
              // if title exist push back to the date
              if (isset($riga[5]) && $riga[5]!="")  $date.=": "."<span style=\"font-family:Verdana,Arial; font-size: $titleSize"."px; color: $titleColor; font-weight: $titleBoldness;\">".utf8_decode($riga[5])."</span>";

              // text
              $text=utf8_decode($riga[1]);

              /****************************************************************
              /*  IMAGE HANDLING
              ****************************************************************/

              if ($riga[2]!="") {

                  // user submitted link
                  if ($riga[4]!="") $image="<a href=\"$riga[4]\">";
                  // image link to it self
                  else $image="<a href=\"".$imgpath."".$riga[2]."\" target=\"_blank\">";
                 
                  // image alignment
                  if ($riga[3]=='left') $padding="2px 5px 0px 0px";
                  else $padding="2px 0px 0px 0px";
                  $image.="<img style=\"padding: ".$padding."\" align=\"".$riga[3]."\" src=\"".$imgpath.$riga[2]."\" alt=\"news image\" border=\"0\" ".imgSize($imgpath.$riga[2] , $tableWidth, $margin)." /></a>";

              }
              else $image="";

              /****************************************************************
              /*  PRINT SINGLE NEWS
              ****************************************************************/
             
              echo "<tr><td style=\"padding: 0px 2px 2px 2px; background-color: $dateBgColor;\">$date</td></tr>\n
                    <tr><td style=\"background-color: $textBgColor; font-family:Arial,Verdana; font-size: $textSize"."px; color: $textColor; font-weight: $textBoldness; \">".$image."$text</td></tr>\n
                    <tr><td style=\"height:$spHeight"."px; background-color: transparent;\"></td></tr>\n
                    <tr><td style=\"height:$hrHeight"."px; background-color:$hrColor;\"></td></tr>\n";

            } // end while loop

            // html table footer and paginator
            print "<tr><td style=\"text-align: center; font-family:Verdana; font-size: $textSize"."px; color: $textColor; padding: 5px 2px 0px 2px;\">";
              if ($start>1) print "<a style=\"text-decoration:none;\" href=\"".$_SERVER['SCRIPT_NAME']."?start=".($start-1)."\">&lt;</a> ";
            print " page ".$start."/".$pages." ";
            if ($start<$pages) print " <a style=\"text-decoration:none;\" href=\"".$_SERVER['SCRIPT_NAME']."?start=".($start+1)."\">&gt;</a>";
            print "</td></tr>\n";

              /* PLEASE DON'T REMOVE LINK UNDER THIS LINE , SUPPORT FREE SOFTWARE ! */
            print "<tr><td style=\"padding: 5px 0px 0px 0px; background-color: $textBgColor; text-align: right; font-family:Arial,Verdana; font-size: 10px; color: $textColor; font-weight: $textBoldness; \">powered by <a href=\"http://www.code4fun.org\">EasyNews</a></td></tr>\n</table>\n";

        } // end if ($num_row)

        // nessuna news è presente nel db
        else print "<div style=\"padding: 4px 4px 4px 4px; text-align: center; font-family:Arial,Verdana; font-size: 12px; color: #000000;\">No News In Database</div>";


// close connection
@mysql_close($conn);




/*******************************************************************************
**            Img Size According $maxWidth and $margin                      **
*******************************************************************************/
function imgSize($img, $maxWidth, $margin) {


        // dati dell'immagine reale
        if (!$size = @getimagesize($img)) {
        //
        $newWidth = $maxWidth-$margin;
        return "width=\"$newWidth\"";
    }
    $width=$size[0];
    $height=$size[1];
        // rapporto lunghezza/altezza dell'immagine reale
        $ratio = $height/$width;
        // calcolo dei nuovi valori lunghezza e altezza in accordo col parametro
        // $maxWidth e $margin
        if ($width>$maxWidth-$margin) {
                $newWidth = $maxWidth-$margin;
                $newHeight= round($newWidth*$ratio);
        }
        else { $newWidth=$width; $newHeight=$height; }
        return "width=\"$newWidth\" height=\"$newHeight\"";


}
?>
Avatar billede frezzer81 Nybegynder
25. februar 2005 - 09:20 #11
avminarm > vil du være venlig og smide et svar, giver 50 points til jer begge. og 1000 tak for hjælpen :)
Avatar billede avminarm Juniormester
25. februar 2005 - 12:57 #12
ja da ;o)
Avatar billede frezzer81 Nybegynder
25. februar 2005 - 13:00 #13
hehe tror du ramte kommentar istedet ;)
Avatar billede avminarm Juniormester
25. februar 2005 - 13:31 #14
ups - det gik for stærkt
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
Vi tilbyder markedets bedste kurser inden for webudvikling

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