Jump to content

Sorry you guys :(


marklarah

Recommended Posts

This is a long one. Buuut...

i have a couple of problems. Im running a link system (that links to stuff), and I have a function which removes the "http://www." and so yeah. It doesn't seem to work. Also the search thingy i made doesn't work either. Also, this could be quite hard to read, but I can't really tab my braces, because im coding it on a web editor (cpanel x)

<?php
$title = 'BLUElinks';
require_once 'header.inc.php';
navigator($title, 1, 0, 0);
$link = @$_GET['link'];
$action = @$_GET['action'];

//
// My function below for the removing of the beginning of links
//

function ht($qer){
$qer = str_replace('http://','', $qer);
$qer = str_replace('www.','', $qer);
$qer = substr($qer, 0, strpos($qer, "/"));
return $qer;
}
?>
<style type="text/css">
.lik A:link {text-decoration: none}
.lik A:visited {text-decoration: none; color: blue;}
.lik A:active {text-decoration: none; color: blue;}
.lik A:hover {text-decoration: underline;}
</style>

<?
If (!isset($_SESSION['blue'])){
if ((isset($_POST['user'])) && (isset($_POST['pass']))){
$result = mysql_query("SELECT * FROM `users` WHERE `userid` = '$useridm'");
$row = mysql_fetch_array($result);
$ba = $row['ba'];

  if ($ba == "1"){

$us = $_POST['user'];
$ps = md5($_POST['pass']);
$result = mysql_query("SELECT * FROM `users` WHERE `username` = '$us' AND `bwd` = '$ps'");
$num = mysql_num_rows($result);
if ($num == "1"){
$_SESSION['blue'] = "gtfo my session variable";
echo '<table width="65%" align="center" border="0"><tr><td><br><table border="1" width="100%"><tr><td align="center" class="b"><h2>BLUElinks Login</h2></td></tr><tr><td align="center" class="shade"><br><b>Login Successful</b> - <a href="blue">Proceed</a><br><br></td></tr></table><br></td></tr></table>';
}else{

echo '<table width="65%" align="center" border="0"><tr><td><br><table border="1" width="100%"><tr><td align="center" class="b"><h2>BLUElinks Login</h2></td></tr><tr><td align="center" class="shade"><br>Oops! Something went wrong - try again. Maybe the wrong password or whatever.<br><br></td></tr></table><br></td></tr></table>';

}
}else{


echo '<table width="65%" align="center" border="0"><tr><td><br><table border="1" width="100%"><tr><td align="center" class="b"><h2>BLUElinks Login</h2></td></tr><tr><td align="center" class="shade"><br>You need to be invited. Away.<br><br></td></tr></table><br></td></tr></table>';



}
}else{

?>
<table width="65%" align="center" border="0"><tr><td><br><table border="1" width="100%"><tr><td align="center" class="b">


<form method="POST" action="blue"><h2>BLUElinks Login</h2></td></tr><tr><td align="center" class="shade"><br>


<b>Username: </b><input type="text" name="user" value="<?=$username?>"><br><b>Password: </b><input type="password" name="pass"><br><input type="submit" value="Login"></form><br>



<br></td></tr></table><br></td></tr></table>
<?php
}
}else{






  
?>







<table width="100%">
<tr align="center">
<td>
<?
if (isset($link)){
$result = mysql_query("SELECT * FROM `blue` WHERE `ID` = '$link'");
$row = mysql_fetch_array($result);
$url = $row['link'];
if (!isset($url)){
echo '<h2>Invalid Link</h2> - <a href="blue">Back</a>';
}else{
?>
<h3 align="left"><a href="blue">Back</a></h3>
<table>
<tr>
<td>
<form method="post" action=""><b>Rate:</b> <select><option value ="1">1</option><option value ="2">2</option><option value ="3">3</option><option value ="4">4</option><option value ="5" selected="yes">5</option><option value ="6">6</option><option value ="7">7</option><option value ="8">8</option><option value ="9">9</option><option value ="10">10</option></select>/10</td></tr></table>

<br>
<span class="lik"><a href="view.php?id=<?=$link?>">
<img src="http://www.iwebtool2.com/img/?r=http://boards.ammostar.net&domain=<?= $url ?>"><br><small>
<?= $url ?></small>
</a>
<br>
<p><?= $row['description'] ?></p>
<hr>
<b>Submitted by:</b> <?= user($row['userid']) ?> | <b>Rating:</b> 
<?
$result = mysql_query("SELECT * FROM `late` WHERE `lid` = '$link'");
$num = mysql_num_rows($result);
if($num == 0){
echo 'No ratings yet';
}else{
$result2 = mysql_query("SELECT SUM(rating) FROM `late` WHERE `lid` = '$link'");

$row = mysql_fetch_array($result2);

echo ($row['SUM(rating)'] / $num);
echo "/10";
}
}
?>
<hr>
</td>
</tr>
</table>

<?
}else{
?>
<table width="100%">
<form action="?action=search" method="POST">
<tr width="100%" align="left">
    <td colspan="3" width="100%"><h3>Welcome to BLUElinks!</h3><hr><b>Control: </b> <a href="?action=submit">Submit Link</a> | Search: <input type="text" name="se" maxlength="25"> <input type="submit" value="Search"><hr><br><br></td>
</tr>
</form>
<?
if (isset($_GET['view'])){
$view = $_GET['view'];
if ($view == "rate"){
$h = "Most Popular Links";
}else if ($view == "viewed"){
$h = "Most Viewed Links";

}else{
$view = "latest";
$h = "Latest Links";

}


}else{
$view = "latest";
$h = "Latest Links";
}




if (((!isset($action))) || ($action != "upload") || ($action != "search")){

?>
<tr width="100%" align="left">
    <td colspan="3" width="100%" class="shade"><b>View By:</b> <a href="?view=rate">Most Popular</a> | <a href="blue">Latest</a> | <a href="?view=viewed">Most Viewed</a></td>
</tr>
<tr width="100%" align="center">
    <td colspan="3" width="100%" class="a"><?=$h?></td>
</tr>

<tr align="center">
    <td width="50%" class="b">Link</td>
    <td width="7%" class="b">NSFW?</td>
    <td width="43%" class="b">Info</td>
</tr>
<?
if ($view == "rate"){
//
// The below query is not mine, somebody helped me - thanks for it
//
$result = mysql_query("SELECT
  blue.*,
  (
    SELECT 
      SUM(l.rating)
      FROM late
        AS l
      WHERE l.lid = blue.id
  ) AS rating 
  FROM blue
  ORDER BY rating DESC
  LIMIT 10");
}else if($view == "viewed"){
$result = mysql_query("SELECT * FROM `blue` ORDER BY `views`DESC LIMIT 10");
}else{
$result = mysql_query("SELECT * FROM `blue` ORDER BY `date` DESC LIMIT 10");
}
  $i = 0;
while ($row = mysql_fetch_array($result)){

$to = $row['link'];
    $class = $i&1 ? ' class="shade"' : '';

?>
      <tr><td <?= $class ?>><span class="lik"><a href="?link=<?= $row['ID'] ?>"><?
//
//
//
//
// The function call is below (ht)
//
//
//
//
//
ht($to);

$bob = $row['ID'];

$result3 = mysql_query("SELECT * FROM `late` WHERE `lid` = '$bob'");
$num2 = mysql_num_rows($result3);


$result2 = mysql_query("SELECT SUM(rating) FROM `late` WHERE `lid` = '$bob'");

$row2 = mysql_fetch_array($result2);
if ($num2 > 0){
$r = ($row2['SUM(rating)'] / $num2).'/10';
}else{
$r = "No ratings yet";
}


if ($row['ns'] == "1"){
$f = '<font color="red">NSFW</font>';
}else{
$f = '<font color="Green">OKFW</font>';
}
?>



<br /><small><?= $row['description'] ?></small></a></span></td><td <?= $class ?> align="center">
<?=$f?>
</td>
      <td <?= $class ?>>Submitted by: <a href="whois.php?user=<?= $row['userid'] ?>"><?= user($row['userid']) ?></a> | Rating: <?=$r?> | Views: (<?= $row['views'] ?>)</td>
</tr>
   <?
$i++;
}
}else{
?>
<tr width="100%" align="center">
    <td colspan="1" width="100%" class="a">Upload</td>
</tr>

<tr align="left">
    <td width="100%" class="shade">
<h3>Upload Link</h3><br>



<?
if (!isset($_POST['se'])){
if ((isset($_POST['link'])) && (isset($_POST['desc']))){
$lin = htmlentities($_POST['link']);
$pos = htmlentities($_POST['desc']);
if (isset($_POST['nsfw'])) {
$nsfw = "1";
}else{
$nsfw = "0";
}
mysql_query("INSERT INTO blue (`ID`, link, description, views, `date`, userid, ns) VALUES(NULL, '$lin', '$pos', '0', NOW(), '$useridm', '$nsfw' ) ") or die(mysql_error());  
echo '<h3>Link inserted into database</h3> - <a href="blue">Continue</a>';
}else{
?>
<form method="POST" action="?action=upload">
<b>Link</b>: <input type="text" name="link" maxlength="100" size="100"><br><br><b>Short Description</b>: <input type="text" maxlength="70" size="100" name="desc"><br><br><b>NSFW</b>: <input type="checkbox" name="nsfw"> - If its naked boobies or whatever, click this. But don't just spam endless galleries.<br><br><input type="submit">
</form>
<?
}

}else if ($action=="search"){
$q = htmlentities($_POST['se']);
$q = '%'.$q.'%';





$sql = "SELECT * FROM `blue` WHERE `description` LIKE '$q' OR `link` LIKE '$q' ORDER BY `link` ASC";
$query = mysql_query($sql) or die(mysql_error());
$total = mysql_num_rows($query);




?>

<tr width="100%" align="center">
    <td colspan="1" width="100%" class="a">Upload</td>
</tr>

<tr align="left">
    <td width="100%" class="shade">
<h3>Search Results</h3><br>
<?
if($total>0) {
?>
<small>Search results found for <i><?=$q?></i> - <?=$total?></small><br><br>
<?
$i = 1;
while ($row = mysql_fetch_array($query)){
//
//
//
//
// and again here below i would think, but i dont know weather it works - this search doesn't work.
//
//
//
//

echo '<b>'.$i.'</b>) '.ht($row['link']).' - '.$row['description'].'<hr width="80%">';

$i++;
}
}else{
echo 'Sorry, no search results found for'.$q.' ';
}


}
// here
// }




?>


</td>
   
</tr>
<?


}



?>
</table>
<?

}


?>




<?php
}


?>
<?
require 'footer.inc.php';
?>

 

 

Thanks  :o:)

 

Link to comment
https://forums.phpfreaks.com/topic/100771-sorry-you-guys/
Share on other sites

Hm... your http://www thing:

<?php
   $link = 'http://www.citrosaft.com';
   if (substr($link,0,strlen('http://'))) $link = substr($link,strlen('http://'));
   if (substr($link,0,strlen('www.')))  $link = substr($link,strlen('www.'));

   echo $link;
?>

 

I don't really want to read your code... I don't have that much time. Sorry

Link to comment
https://forums.phpfreaks.com/topic/100771-sorry-you-guys/#findComment-515405
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.