Status
Not open for further replies.

pankaj

Active Member
1,817
2009
149
0
This is the code. I can see output for a site's alexa like GOOGLE.
But not for variable $linkdetail.URL but when I use $linkdetail.URL it gives me the link.

OUTFILE HERE - http://www.warez-core.com/details/link-1

Any help in correcting this part in the code ?
<td><strong>Alexa Rank of {$linkdetail.TITLE} </strong></td>
<
td> {php}echo alexaRank($linkdetail.URL);{/php}</td>



PHP:
{* Calculate title from path *}
{capture name="title"}
{/capture}
{strip}

{include file="header.tpl"}

{include file="top_bar.tpl"}
<div id="main">
{foreach from=$linkdetail item=linkdetail}


{php}
$domain = $linkdetail.URL;
function alexaRank($domain){
    $remote_url = 'http://data.alexa.com/data?cli=10&dat=snbamz&url='.trim($domain);
    $search_for = '<POPULARITY URL';
    if ($handle = @fopen($remote_url, "r")) {
        while (!feof($handle)) {
            $part .= fread($handle, 100);
            $pos = strpos($part, $search_for);
            if ($pos === false)
            continue;
            else
            break;
        }
        $part .= fread($handle, 100);
        fclose($handle);
    }
    $str = explode($search_for, $part);
    $str = array_shift(explode('"/>', $str[1]));
    $str = explode('TEXT="', $str);

    return $str[1];
}
echo alexaRank($domain);
{/php}


<table border="0">
    <tr><td colspan="2"><h2>{$linkdetail.TITLE}</h2></td></tr>
    <tr>
        <td rowspan="4">
            <img src="http://msnsearch.srv.girafa.com/srv/i?s=MSNSEARCH&r={$linkdetail.URL}" align="absmiddle" border="1" width="160" alt="{$linkdetail.TITLE}" />
        </td>
        <td><strong>Title: </strong></td>
        <td><a href={$linkdetail.URL}>{$linkdetail.TITLE}</a></td>
    </tr>
    <tr>
            <td><strong>URL: </strong></td>
            <td>{$linkdetail.URL}</td>
    </tr>
    <tr>
            <td><strong>Description: </strong></td>
            <td>{$linkdetail.DESCRIPTION}</td>
    </tr>
    <tr>
            <td><strong>Page Rank: </strong></td>
            <td>{$linkdetail.PAGERANK}</td>
    </tr>
     

   <tr>
            <td><strong>Google's Alexa Rank: </strong></td>
            <td> {php}echo alexaRank("google.com");{/php}</td>
    </tr>
<tr>
            <td><strong>Alexa Rank of {$linkdetail.TITLE} </strong></td>
<td> {php}echo alexaRank($linkdetail.URL);{/php}</td>
            
    </tr>

</table>
{/foreach}
</div>
{include file="footer.tpl"}
{/strip}
 
10 comments
Oh now I see that this is a cheap copy of ddlrank.com haha :D , nice going by taking litewarez's ideas for ddlrank ;)

Ontopic: Could you be more specific, was looking for a "bold" part in your code but couldn"t find it.
 
It's not copy to ddlrank, I had plan in my mind from many months of making a warez directory as probably there are none.

And it's completely different from ddlrank. In DDLRank they rank big DDL sites and forums. Its for people who are looking for big sites.

But mine one is a directory. It will list all small and big warez sites be it a blog, forum or anything.
________
Volcano digital review
 
Last edited:
for starters you creating functions in a loop... wft lol

foreach(....){
function xxx(){}
}

this means that the function is being created multiple times!

i see your using smarty, why not create a smarty plugin with that function and then use like

{$linkdetail.URL|alexaRank}
 
This is the code. I can see output for a site's alexa like GOOGLE.
But not for variable $linkdetail.URL but when I use $linkdetail.URL it gives me the link.

OUTFILE HERE - http://www.warez-core.com/details/link-1

Any help in correcting this part in the code ?
<td><strong>Alexa Rank of {$linkdetail.TITLE} </strong></td>
<
td> {php}echo alexaRank($linkdetail.URL);{/php}</td>



PHP:
{* Calculate title from path *}
{capture name="title"}
{/capture}
{strip}

{include file="header.tpl"}

{include file="top_bar.tpl"}
<div id="main">
{foreach from=$linkdetail item=linkdetail}


{php}
$domain = $linkdetail.URL;
function alexaRank($domain){
    $remote_url = 'http://data.alexa.com/data?cli=10&dat=snbamz&url='.trim($domain);
    $search_for = '<POPULARITY URL';
    if ($handle = @fopen($remote_url, "r")) {
        while (!feof($handle)) {
            $part .= fread($handle, 100);
            $pos = strpos($part, $search_for);
            if ($pos === false)
            continue;
            else
            break;
        }
        $part .= fread($handle, 100);
        fclose($handle);
    }
    $str = explode($search_for, $part);
    $str = array_shift(explode('"/>', $str[1]));
    $str = explode('TEXT="', $str);

    return $str[1];
}
echo alexaRank($domain);
{/php}


<table border="0">
    <tr><td colspan="2"><h2>{$linkdetail.TITLE}</h2></td></tr>
    <tr>
        <td rowspan="4">
            <img src="http://msnsearch.srv.girafa.com/srv/i?s=MSNSEARCH&r={$linkdetail.URL}" align="absmiddle" border="1" width="160" alt="{$linkdetail.TITLE}" />
        </td>
        <td><strong>Title: </strong></td>
        <td><a href={$linkdetail.URL}>{$linkdetail.TITLE}</a></td>
    </tr>
    <tr>
            <td><strong>URL: </strong></td>
            <td>{$linkdetail.URL}</td>
    </tr>
    <tr>
            <td><strong>Description: </strong></td>
            <td>{$linkdetail.DESCRIPTION}</td>
    </tr>
    <tr>
            <td><strong>Page Rank: </strong></td>
            <td>{$linkdetail.PAGERANK}</td>
    </tr>
     

   <tr>
            <td><strong>Google's Alexa Rank: </strong></td>
            <td> {php}echo alexaRank("google.com");{/php}</td>
    </tr>
<tr>
            <td><strong>Alexa Rank of {$linkdetail.TITLE} </strong></td>
<td> {php}echo alexaRank($linkdetail.URL);{/php}</td>
            
    </tr>

</table>
{/foreach}
</div>
{include file="footer.tpl"}
{/strip}
Edit nevermind it should work lmao
 
for starters you creating functions in a loop... wft lol

foreach(....){
function xxx(){}
}

this means that the function is being created multiple times!

i see your using smarty, why not create a smarty plugin with that function and then use like

{$linkdetail.URL|alexaRank}

lol @ you. Can't you see that its to extract alexa rank from a given page ? Therefore a loop in needed.

I will try creating smarty plugin. I didn't think of it before.

Edit nevermind it should work lmao

You simply quoted my code and saying it should work. ROFLMAO
 
if you understood functions/methods/classes and how there stored in scope then you would realise that what your doing is wrong!

PHP:
{php}
function alexaRank($domain){
    $remote_url = 'http://data.alexa.com/data?cli=10&dat=snbamz&url='.trim($domain);
    $search_for = '<POPULARITY URL';
    if ($handle = @fopen($remote_url, "r")) {
        while (!feof($handle)) {
            $part .= fread($handle, 100);
            $pos = strpos($part, $search_for);
            if ($pos === false)
            continue;
            else
            break;
        }
        $part .= fread($handle, 100);
        fclose($handle);
    }
    $str = explode($search_for, $part);
    $str = array_shift(explode('"/>', $str[1]));
    $str = explode('TEXT="', $str);

    return $str[1];
} // CREATE THE FUNCTION INSTANCE OUT OF THE LOOP
{/php}
{foreach from=$linkdetail item=linkdetail}
{php}
echo alexaRank($linkdetail.URL); //not sure if you can pull smarty vars into php blocks
{/php}

<table border="0">
    <tr><td colspan="2"><h2>{$linkdetail.TITLE}</h2></td></tr>
    <tr>
        <td rowspan="4">
            <img src="http://msnsearch.srv.girafa.com/srv/i?s=MSNSEARCH&r={$linkdetail.URL}" align="absmiddle" border="1" width="160" alt="{$linkdetail.TITLE}" />
        </td>
        <td><strong>Title: </strong></td>
        <td><a href={$linkdetail.URL}>{$linkdetail.TITLE}</a></td>
    </tr>
    <tr>
            <td><strong>URL: </strong></td>
            <td>{$linkdetail.URL}</td>
    </tr>
    <tr>
            <td><strong>Description: </strong></td>
            <td>{$linkdetail.DESCRIPTION}</td>
    </tr>
    <tr>
            <td><strong>Page Rank: </strong></td>
            <td>{$linkdetail.PAGERANK}</td>
    </tr>
     

   <tr>
            <td><strong>Googles Alexa Rank: </strong></td>
            <td> {php}echo alexaRank("google.com");{/php}</td>
    </tr>
<tr>
            <td><strong>Alexa Rank of {$linkdetail.TITLE} </strong></td>
<td> {php}echo alexaRank($linkdetail.URL);{/php}</td>
            
    </tr>

</table>
{/foreach}
 
Status
Not open for further replies.
Back
Top