Ver Mensaje Individual
  #3 (permalink)  
Antiguo 25/09/2008, 02:36
lobo negro
 
Fecha de Ingreso: abril-2006
Mensajes: 34
Antigüedad: 18 años, 8 meses
Puntos: 0
Respuesta: Ayuda con modificación para PHPnews

3ª parte del codigo:

Código:
      /* Set Variables */
      $time = strftime($Settings['timeformat'], $news['time']);
      $subject = stripslashes($news['subject']);
      $titletext = stripslashes($news['titletext']);
      $maintext = stripslashes($news['maintext']);

      /* Find out who made the post (keeps track of usernames) */
      $username = $news['username'];

      /* Print Comments if enabled */
      if ($Settings['enablecomments'] == 1)
      {
        $query = mysql_query('SELECT count(*) as total FROM ' . $db_prefix . 'comments WHERE mid = ' . $news['id'] . '');
        $var = mysql_fetch_assoc($query);
        $comments = '<a href="' . $_SERVER['PHP_SELF'] . '?action=fullnews&amp;showcomments=1&amp;id=' . $news['id'] . '">' . $language['CONTENT_NEWSCOMMENTS'] . ' (' . $var['total'] . ')</a>';
      }

      $category = '<a href="' . $_SERVER['PHP_SELF'] . '?action=showcat&amp;catid=' . $news['catid'] . '">' . $news['catname'] . '</a>';

      if ($news['caticon'] != '')
      {
        $caticon = '<img src="' . $news['caticon'] . '" border="0" alt="' . $news['catname'] . '" />';
      }
      else
      {
        $caticon = '';
      }
      
      if (!$username)
      {
        $username = $news['postername'];
      }

      if ($Settings['enableavatars'] == 1)
      {
        if($news['avatar'] != '')
        {
          $avatar = '<img src="' . $news['avatar'] . '" border="0" alt="' . $username . '\'s avatar" />';
        }
        else
        {
          $avatar = '';
        }
      }

      if ($row['email'] != '')
      {
        $username = '<a href="mailto:' . $news['email'] . '">' . $username . '</a>';
      }
      else
      {
        $username = $username;
      }

      /* Display link to show comments & news if enabled */
      if ($maintext != '' && $Settings['showcominnews'] == 1 && $Settings['enablecomments'] == 1)
      {
        $maintext = '<a href="' . $_SERVER['PHP_SELF'] . '?action=fullnews&amp;showcomments=1&amp;id=' . $news['id'] . '">' . $language['CONTENT_NEWSFULLSTORY'] . '</a>';
      }
      else if ($maintext != '')
      {
        $maintext = '<a href="' . $_SERVER['PHP_SELF'] . '?action=fullnews&amp;id=' . $news['id'] . '">' . $language['CONTENT_NEWSFULLSTORY'] . '</a>';
      }
      else
      {
        $maintext = '';
      }

      if ($Settings['enablestf'] == 1)
      {
        $sendtofriend = '<a href="javascript:sendtof(\'' . $Settings['phpnewsurl'] . 'sendtofriend.php?mid=' . $news['id'] . '\')">' . $language['CONTENT_NEWSSTFLINK'] . '</a>';
      }

      /* Parse the code */
      $maintext = parseCode($maintext);
      $titletext = parseCode($titletext);

      include($path . 'templates/news_temp.php');
      echo "\n";
    }

    /* If previous/next links are enabled */
    if ($Settings['enableprevnext'] == 1 && $include == 1)
    {
      echo '<br />' , "\n";
      $catid = $_GET['catid'];

      /* Show Previous Page link? */
      if($_GET['prevnext'] != NULL && $_GET['prevnext'] != 0)
      {
        echo '<span style="margin-right:5px;"><a href="' , $_SERVER['PHP_SELF'] , '?prevnext=' , $previouspage , '">' , $language['CONTENT_PREVIOUS'] , '</a></span>';
        echo "\n";
      }

      /* Show Next Page Link? */
      if($nextpage != 0)
      {
        echo '<span style="margin-left:5px;"><a href="' , $_SERVER['PHP_SELF'] , '?prevnext=' , $nextpage , '">' , $language['CONTENT_NEXT'] , '</a></span>';
        echo "\n";
      }
    }
  }
}

function post()
{
  global $_SERVER, $language, $Settings, $db_prefix;

  /* Clean up */
  $_POST['name'] = str_replace(array('&', '"', '<', '>', '|'), array('&amp;', '&quot;', '&lt;', '&gt;', '|'), trim($_POST['name']));
  $_POST['message'] = str_replace(array('&', '"', '<', '>', '|'), array('&amp;', '&quot;', '&lt;', '&gt;', '|'), trim($_POST['message']));

  $_POST['email'] = trim($_POST['email']);
  $_POST['email'] = strip_tags($_POST['email']);

  $_POST['website'] = trim($_POST['website']);
  $_POST['website'] = strip_tags($_POST['website']);

  $_POST['message'] = replace($_POST['message'], 1);

  /* Make sure set amount of time has passed since last post by this person */
  $query = mysql_query('SELECT time FROM ' . $db_prefix . 'comments WHERE ip = \'' . $_SERVER['REMOTE_ADDR'] . '\' ORDER by id DESC LIMIT 1');
  $result = mysql_fetch_assoc($query);

  /* Make sure there are no problems with the Post */
  if ($Settings['enablecomments'] != 1)
  {
    echo '<b>' , $language['CONTENT_ERROR'] , '</b>: ' , $language['CONTENT_DISABLED'];
  }
  else if (!$_POST['mid'])
  {
    echo '<b>' , $language['CONTENT_ERROR'] , '</b>: ' , $language['CONTENT_GENERALERROR'];
  }
  else if (time()-$result['time'] < $Settings['floodprotection'])
  {
    echo '<b>' , $language['CONTENT_ERROR'] , '</b>: ' , $language['CONTENT_ERRORWAIT'];
  }
  /* Check if it's a valid email */
  else if ($_POST['email'] != '' && !eregi('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$', $_POST['email']))
  {
    echo '<b>' , $language['CONTENT_ERROR'] , '</b>: ' , $language['CONTENT_ERROREMAIL'];
  }
  else if (!$_POST['message'])
  {
    echo '<b>' , $language['CONTENT_ERROR'] , '</b>: ' , $language['CONTENT_SENDTOFRIENDMSG'];
  }
  /* Everything is okay! */
  else
  {
    /* Set final defaults */
    if($_POST['website'] == 'http://')
    {
      $_POST['website'] = '';
    }
  
    if (!$_POST['name'])
    {
      $_POST['name'] = 'Guest';
    }
    
    $time = time();
    mysql_query('INSERT INTO ' . $db_prefix . 'comments (ip,mid,time,name,message,email,website) VALUES (\'' . $_SERVER['REMOTE_ADDR'] . '\', \'' . $_POST['mid'] . '\', \'' . $time . '\', \'' . $_POST['name'] . '\', \'' . $_POST['message'] . '\', \'' . $_POST['email'] . '\', \'' . $_POST['website'] . '\')');

    /* Display the comments */
    $_GET['showcomments'] = 1;
    $_GET['id'] = $_POST['mid'];
    fullNews();
  }
}