Forum Moderators: coopster

Message Too Old, No Replies

Modify php script

         

Doood

3:43 pm on Jul 7, 2003 (gmt 0)

10+ Year Member



I've been searching for almost a year for a script that lets users add their link to list and allows visitors to rate/vote on each link so to let everyone else know if the link is work clicking on. A custom built script is way out of my price range.

Well I finally found one that is similar to what I want, it's a topsite toplist type script but those featurs can be turned off to make it a free for all link list. The only problem is that newest links are on bottom instead of on top. The creatures of the scripts want to much $ for modifing it so the newest links are on top. Can I do this myself without any knowledge of php programming?

It has the ability to order the list by votes, hits, hits out, rank, but I just want it to order the list by date. Anyone know how to do this?

waldemar

3:47 pm on Jul 7, 2003 (gmt 0)

10+ Year Member



Search your script for SQL SELECT queries; usually you will find an "ORDER BY" attribute there, you just have to "ORDER BY [dateVariable] DESC".
(The real name of [dateVariable] you have to figure out from the code.)

wruk999

3:49 pm on Jul 7, 2003 (gmt 0)

10+ Year Member



Hi Doood,

If you can paste just the SQL line out of the code page where the links are listed, then there should be something like

SELECT * FROM links ORDER BY date ASC

You need to revers the ASC bit at the end. Depending on what it is, ie: ASC changes to DESC, or DESC changes to ASc.

Though this depends on the way the dbase is set up.

Will you be able to find the swl line?

dmorison

3:53 pm on Jul 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Somebody (vince3 I think) posted a free for all links PHP script on here a few days ago but I can't put my finger on it... anybody?

We went on to discuss security and the ways and means of protecting your database from user input etc...

[edited by: dmorison at 3:57 pm (utc) on July 7, 2003]

dmorison

3:55 pm on Jul 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The script might just be sorting on an auto-incremented ID field with no date information..

ORDER BY table_id DESC

might be what's needed on the end of the query that pulls the links out of the database, and where table_id is the name of the ID field of the links table.

Doood

4:30 pm on Jul 7, 2003 (gmt 0)

10+ Year Member



I really don't even know where to look because the script came with about 30-40 php pages.

I searched the index.php and mysql.php pages for sql select, order by, order, select, asc, and didn't find anything relevant I don't think.

Am I looking in the right place?

Doood

4:32 pm on Jul 7, 2003 (gmt 0)

10+ Year Member



I found this, is this it? or is that for language files

<td width='20%' bgcolor='#FAFAF2' valign='middle' rowspan='5' align='center'>
<b>{$mtl->lang['in']}</b><br />
<select name='asc' class='select'>
<option value='asc'>{$mtl->lang['ascending']}</option>
<option value='desc' selected='selected'>{$mtl->lang['descending']}</option>
</select>
</td>

or maybe it's in this on the ssi.php page?

$order_array = array ('votes','out','hits','rating');

foreach($order_array as $v)
{if($v == $mtl->input['order'])
{$order = $v;
$past = "{$order}_past";}
}

if(!isset($order))
{if(((is_numeric($mtl->input['sum_v']) OR is_numeric($mtl->input['sum_vo']) OR is_numeric($mtl->input['sum_r'])) AND $op = 'input') OR (preg_match("/sum/", $mtl->config['list_order']) AND $op = 'config'))
{if($op == "input")
{$v = "sum({$mtl->input['sum_v']},{$mtl->input['sum_o']},{$mtl->input['sum_h']},{$mtl->input['sum_r']})";
$this->search_url .= "&order={$v}";
}
else
{$v = $mtl->config['list_order'];}

$v = preg_replace("/sum\((.*?)\)/", "\\1", $v);
$sum = explode(",", $v);
$order = "((votes*0.$sum[0])+(out*0.$sum[1])+(hits*0.$sum[2])+((rating/GREATEST(rating_total, 1))*0.$sum[3])) ";
$past = " ((votes_past*0.$sum[0])+(out_past*0.$sum[1])+(hits_past*0.$sum[2])+((rating_past/GREATEST(rating_total, 1))*0.$sum[3])) ";
}
else
{$order = $mtl->config['list_order'];
$past = "{$order}_past";}
}

$DB->query("SELECT id,site_name FROM mtl_sites WHERE a_mail='1' AND a_admin='1' AND a_ban!='1' AND a_hide!='1' $cats ORDER BY $order DESC LIMIT {$mtl->input['no']}");

waldemar

5:51 pm on Jul 7, 2003 (gmt 0)

10+ Year Member



That looks good, although the filename is a little weird; see the last line with that SELECT statement? Like dmorison suggested, replace "ORDER BY $order" with "ORDER BY id DESC" and see what happens.

If this doesn't help, check the table "mtl_sites" for any fields that might contain a date and insert them behind the "ORDER BY"...

Doood

6:53 pm on Jul 7, 2003 (gmt 0)

10+ Year Member



waldemar, nothing at all happened that I noticed. I'm not sure about the mtl_sites table because I don't know how to read any of it.

Maybe I'll just request a refund for this script and continue my quest to find a free for all type script that allows voting for each link and places newest links on top. Most people have never even heard of such a beast.

waldemar

6:55 am on Jul 8, 2003 (gmt 0)

10+ Year Member



Oh there's plenty of places out there with (free) scripts you can try out. It's just very time-consuming to check them one after the other :-)
Personally for scripts like this I look into [simplythebest.net...] or [hotscripts.com...] or Google.

Maybe don't give up yet. Keep on searching for the right SQL SELECT-query - if you find it (and there's almost no doubt it exists ;-) ), it's just a matter of a couple of minutes to adjust everything. Plus, you learn a lot this way ;-)