Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-29-2010, 06:02 PM
wolfe wolfe is offline
 
Join Date: Jan 2002
Posts: 900
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default ajax help pease

i need help with this code if theres any Ajax coders on here this is my grabbing script with grabs the content without a page refresh. it was working a charm on vB3 but since i updated to vB4 its not working something to do with it not working on XHTML can anyone help me out PLEASE need to get it back up urgent

Template Code:

HTML Code:
<script type="text/javascript">

    function ax()
    {
        if(document.getElementById('btnS').value=="Fill")
        {
            document.getElementById('txtTitle').value        =    "";
            document.getElementById('image').value        =    "";
            document.getElementById('infolink').value        =    "";
            document.getElementById('summary').value        =    "";
            
            axtitle();
            aximg();
                        axlink();
            axdesc();            
        }
    }

    function axtitle()
    {
        var uri    =    document.getElementById('url').value;

        var xt = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        if (xt)
        {
            xt.onreadystatechange = function()
            {
                if (xt.readyState == 4 && xt.status == 200)
                {
                    document.getElementById('txtTitle').value= xt.responseText;
                    document.getElementById('btnS').value="Fill"
                }
            }
            document.getElementById('btnS').value="Filling...";
            xt.open("POST", "getinfo.php?purl="+uri+"&preq=title", true);
            xt.send("purl="+uri+"&preq=title");
        }
    }
    
    function aximg()
    {
        var uri    =    document.getElementById('url').value;

        var xi = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        if (xi)
        {
            xi.onreadystatechange = function()
            {
                if (xi.readyState == 4 && xi.status == 200)
                {
                    document.getElementById('image').value= xi.responseText;
                    document.getElementById('btnS').value="Fill"
                }
            }
            document.getElementById('btnS').value="Filling...";
            xi.open("POST", "getinfo.php?purl="+uri+"&preq=img", true);
            xi.send("purl="+uri+"&preq=img");
        }
    }

    function axlink()
    {
        var uri    =    document.getElementById('url').value;

        var xi = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        if (xi)
        {
            xi.onreadystatechange = function()
            {
                if (xi.readyState == 4 && xi.status == 200)
                {
                    document.getElementById('infolink').value= xi.responseText;
                    document.getElementById('btnS').value="Fill"
                }
            }
            document.getElementById('btnS').value="Filling...";
            xi.open("POST", "getinfo.php?purl="+uri+"&preq=link", true);
            xi.send("purl="+uri+"&preq=link");
        }
    }
    
    function axdesc()
    {
        var uri    =    document.getElementById('url').value;

        var xd = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        if (xd)
        {
            xd.onreadystatechange = function()
            {
                if (xd.readyState == 4 && xd.status == 200)
                {
                    document.getElementById('summary').value    = xd.responseText;
                    document.getElementById('btnS').value="Fill"
                }
            }
            document.getElementById('btnS').value="Filling...";
            xd.open("POST", "getinfo.php?purl="+uri+"&preq=desc", true);
            xd.send("purl="+uri+"&preq=desc");
        }
    }

</script>

<form>
<table border="0" cellpadding="1" cellspacing="1">
<tr>
    <td>
    <b>Quick Fill:</b><br />  
    <input class="url" type='text' size='40' name='url' id='url' value="" /> <input type='button' id="btnS" value='Fill' onclick="ax(this);" />  
    </td>
</tr>
</table> 

            <div><input class="title" type="text" size="40" id="txtTitle" name="name" value="" /></div>

            <div><input class="url" type="text" maxlength="1000" size="40" name="info" id="info" value="" /></div>

            <div><input class="img" type="text" maxlength="1000" size="40" name="image" id="image" value="" /></div>
</form>
PHP File Code:
PHP Code:
<?php

function get_page($url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    $content = curl_exec($ch);
    return $content;
}

$purl        = "";
$preq        = "title";
$title    = "";
$desc        = "";
$imgl        = "";

extract($_REQUEST);

if($purl!="") {

    $content = get_page($purl);
      // ###############  GAMESTOP INFO    
 if(preg_match("~gamestop.com~", $purl))
    {
        preg_match("~<td width=\"510\" align=\"left\" class=\"prodtitle\" valign=\"top\">.+?(.+?)&nbsp;.+?</td>~s", $content, $res);
        $replacements = "/\'/";
        $titles = trim($res[1]);
        $title = strip_tags(preg_replace($replacements,'',$titles));
                
        preg_match("~<img src=\"(/common/images/lbox[^\"]+)~s", $content, $resimg);
        $img1 = strip_tags("http://www.gamestop.com".$resimg[1]."");
        preg_match("~<td width=\"620\" class=\"stdcopy\">(.+?)</td>~s", $content, $resdesc);
        $replacements = "/\'/";
        $desc = strip_tags(preg_replace($replacements,'',$resdesc[1]));
        $desc = trim($desc);
        if (empty($desc)) { $desc = "No Description Available"; }        
    }


}
 
//$img = cacheFetch($img1,"");

if($preq=="title")
    print($title);
else if($preq=="desc")
    print($desc);
else if($preq=="img")
    print($img1);    
else if($preq=="link")
    print($purl);    
?>
--------------- Added [DATE]1264870365[/DATE] at [TIME]1264870365[/TIME] ---------------

* BUMP * can anyone help me with this code please.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:28 PM.


Powered by vBulletin® Version 3.9.0
Copyright ©2000 - 2017, vBulletin Solutions Inc.