Printable Version of Topic

Click here to view this topic in its original format

Nexus Forums _ Nexus Atlas Official Forum _ Item Search

Posted by: oogabooga Dec 15 2009, 12:35 AM

Nexustk.net used to have an item search where when you searched for the item it showed in descending order who had the most to the least of that particular item. Possible to add that to nexusatlas?

Posted by: Sarphendon Dec 15 2009, 07:42 AM


Posted by: oogabooga Dec 15 2009, 09:38 AM

I heard that reading a whole sentence is actually beneficial before replying.

Posted by: AllyGator Dec 15 2009, 12:49 PM

QUOTE (oogabooga @ Dec 14 2009, 11:35 PM) *
Nexustk.net used to have an item search where when you searched for the item it showed in descending order who had the most to the least of that particular item. Possible to add that to nexusatlas?


We don't have that, code it for us?

Posted by: oogabooga Dec 15 2009, 04:47 PM

QUOTE (AllyGator @ Dec 15 2009, 12:49 PM) *
We don't have that, code it for us?


I have no idea where to start but I figured I should just suggest it. tongue.gif

Posted by: Sarphendon Dec 15 2009, 08:14 PM

QUOTE (AllyGator @ Dec 15 2009, 01:49 PM) *
We don't have that, code it for us?


Well since stataddict uses alot of that stuff for its main function, maybe...just maybe...we can cohearce aceostar to add something like that to stataddict, or make the code for us? *puppy dog eyes*

Posted by: AllyGator Dec 16 2009, 11:47 AM

also *puppy dog eyes*

Posted by: Interstate Dec 19 2009, 03:38 AM

QUOTE (oogabooga @ Dec 15 2009, 04:47 PM) *
I have no idea where to start but I figured I should just suggest it. tongue.gif



Start here:

CODE
<?php

require_once("config.php");
set_time_limit(0);

$letters_int = 0;
$letters_char;

while($letters_int < 26)
{
    switch($letters_int)
    {
        case 0: $letters_char="a"; break;
        case 1: $letters_char="b"; break;
        case 2: $letters_char="c"; break;
        case 3: $letters_char="d"; break;
        case 4: $letters_char="e"; break;
        case 5: $letters_char="f"; break;
        case 6: $letters_char="g"; break;
        case 7: $letters_char="h"; break;
        case 8: $letters_char="i"; break;
        case 9: $letters_char="j"; break;
        case 10: $letters_char="k"; break;
        case 11: $letters_char="l"; break;
        case 12: $letters_char="m"; break;
        case 13: $letters_char="n"; break;
        case 14: $letters_char="o"; break;
        case 15: $letters_char="p"; break;
        case 16: $letters_char="q"; break;
        case 17: $letters_char="r"; break;
        case 18: $letters_char="s"; break;
        case 19: $letters_char="t"; break;
        case 20: $letters_char="u"; break;
        case 21: $letters_char="v"; break;
        case 22: $letters_char="w"; break;
        case 23: $letters_char="x"; break;
        case 24: $letters_char="y"; break;
        case 25: $letters_char="z"; break;
    }

    $url = "http://users.nexustk.com/userfiles/".$letters_char.".html";
    $contents  = file_get_contents($url);

    $string_start ='<a href="http://users.nexustk.com/?name=';
    $string_end ='">';
        
    $name_start  = strpos($contents, $string_start);
        while($name_start !== false)
    {
        $name_start  = $name_start+40;
        $name_end    = strpos($contents, $string_end, $name_start);
        $name_length = $name_end-$name_start;

        $name = substr($contents, $name_start, $name_length);
    
        $name_start  = strpos($contents, $string_start, $name_end);

        $query = "SELECT COUNT(*) FROM nexususers WHERE name='$name'";
        $usr = mysql_query($query);
        if(!$usr) exit("Error - ".mysql_error());
        $total = mysql_result($usr, 0);
        if($total < 1)
        {
            $query= "INSERT INTO nexususers VALUES(
                NULL,
                '$name',
                CURDATE(),
                NULL)";

            if(mysql_query($query))
            {
                echo $name."<br>";
            }
            else exit("Errior adding data - " . mysql_error());
        }
    }    

    //increase letter page loop
        $letters_int = $letters_int+1;

                            
}

?>


That'll get you all unique names listed on the user pages. Next step:

- open user pages based on names collected the same way you opened user list in above code
- find unique string_start and string_end values for item names and counts
- parse out item information and insert in new database just like done in above code with names
- display items however you want with whatever sorting/organizing functions you care to use

Example for how to display items, may want to order by count in your case though:

CODE
<?php

require_once("config.php");

$results = mysql_query("SELECT * FROM nexusitems ORDER BY name")
or die(mysql_error());

echo "<table border='1'>";
echo "<tr><th>Id</th> <th>Name</th> <th>Price</th> <th>User</th> <th>Date</th </tr>";

while($row=mysql_fetch_array($results))
{
    echo "<tr><td>";
    echo $row['id'];
    echo "</td><td>";
        echo $row['name'];
    echo "</td><td>";
        echo $row['price'];
    echo "</td><td>";
        echo $row['user'];
    echo "</td><td>";
        echo $row['date'];
    echo "</td></tr>";
}
echo "</table>";
?>


Now you know where to start =)

Aceostar or Berig shouldn't have any problem with this, it is pretty basic web programming.
The above code should also make it very easy for someone who hasn't done it before but has basic web scripting knowledge to do this and other similar things.

Posted by: AllyGator Dec 19 2009, 03:53 PM


http://www.nexusatlas.com/search1.html
http://www.nexusatlas.com/search2.html

I never know where to start!

Posted by: Interstate Dec 19 2009, 06:47 PM


You need to design and add database tables that make logical sense first, like so:

CODE
<?php

require_once("config.php");

mysql_query("CREATE TABLE nexusitems(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
name TEXT,
gif  TEXT,
price TEXT,
user TEXT,
date TEXT
)")
or die(mysql_error());

echo "Table Created!";

?>




Also, the config.php file that is required in these is what I usually do to include mysql connection configuration, like so:

CODE
<?

$dblocation = "127.0.0.1";
$dbname = "skynet";
$dbuser = "root";
$dbpasswd = "";
$dbcnx = mysql_connect($dblocation, $dbuser, $dbpasswd);

if (!dbcnx)
{
    exit ("MySQL server is not available: ".mysql_error());
}

if(!@mysql_select_db($dbname, $dbcnx))
{
    exit ("Database is not available: ".mysqlerror());
}

?>

Posted by: AllyGator Dec 20 2009, 10:40 AM

I don't want to make a database that pulls from the user pages. neener!

Didn't nexus wiki have that? Maybe you can ask them to put it up again.

Posted by: Excaliber Aug 19 2010, 04:45 PM

This is the website I use to do item searches. Not sure if it'll be helpful to anyone or not.

http://users.nexustk.com/search/

It searches the user pages for both items and names of players. Sometimes it's helpful, others not. Remember to use " " in order to refine searches.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)