Beispiel #1
0
function CheckFilter()
{
    global $UserID;
    if ($UserID > 0) {
        if (isset($_POST['L']) && isset($_POST['V'])) {
            if (is_numeric($_POST['L']) && is_numeric($_POST['V'])) {
                list($QR, $DR, $T) = QuerySingle("SELECT UL.UserLocationID FROM 1100_User_Locations UL WHERE UL.UserID = " . $UserID . " AND UL.LocationID = " . (int) $_POST['L'] . ";");
                if ($QR > 0) {
                    if (isset($_POST['C'])) {
                        SetFilter($DR['UserLocationID'], FilterCategory, (int) $_POST['C'], (int) $_POST['V'], 100, true);
                    } elseif (isset($_POST['T'])) {
                        SetFilter($DR['UserLocationID'], FilterType, (int) $_POST['T'], (int) $_POST['V'], 1, false);
                    } elseif (isset($_POST['D'])) {
                        SetFilter($DR['UserLocationID'], FilterDeal, (int) $_POST['D'], (int) $_POST['V'], -1, true);
                    }
                }
            }
        }
    }
    exit;
}
Beispiel #2
0
function GetDetails()
{
    global $LanguageID;
    global $Response;
    global $UserID;
    $Strings = GSA('1000,1329,1330,1331,1332,1334,1339,1350,1367,1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,1660,1661,1662,1663,1664,1665,1666,1667,1669,1670,1671,1672,1673', $LanguageID, false, true);
    if (isset($_POST['DID'])) {
        if (is_numeric($_POST['DID'])) {
            list($QR, $DR, $T) = QuerySingle("SELECT COALESCE(LSDa.StringText, LSDb.StringText) AS DText, D.DealPrice AS DPrice, D.DealQR AS QR, DC.MPrice, COALESCE(DC.DCount, 1) AS DCount,\n                COALESCE(UR.RAvg, 0) AS RAvg, COALESCE(UR.RCount, 0) AS RCount, COALESCE(DCT.CCount, 0) AS CCount, COALESCE(URx.Score, 0) AS MyScore,\n                S.StoreID, S.StoreName AS SName, S.StoreWebsite AS SWeb, L.LocationAddress AS Adr, DS.DealSourceName AS DSName, DS.DealSourceFileName AS FName,\n                UNIX_TIMESTAMP(D.DateExpiry) AS ExpDate, COUNT(L.LocationID) AS LCount, UF.FavoriteID AS FavID, L.LocationLatitude AS Lat, L.LocationLongitude AS Lng, DSU.URLID\n               FROM 4000_Deals D\n              INNER JOIN 4100_Deal_Sources DS ON DS.DealSourceID = D.DealSourceID\n              INNER JOIN 2000_Stores S ON D.StoreID = S.StoreID\n               LEFT JOIN (SELECT StoreID, AVG(Score) AS RAvg, COUNT(ReviewID) AS RCount FROM 1300_User_Reviews WHERE Status = 1 GROUP BY StoreID) UR ON UR.StoreID = S.StoreID\n               LEFT JOIN (SELECT StoreID, UserID, Score FROM 1300_User_Reviews) URx ON URx.UserID = " . $UserID . " AND URx.StoreID = S.StoreID\n               LEFT JOIN 2200_Store_Locations SL ON SL.StoreID = S.StoreID\n               LEFT JOIN 3000_Locations L ON SL.LocationID = L.LocationID AND L.LocationLatitude != -1\n               LEFT JOIN 0200_Language_Strings LSDa ON D.StringID = LSDa.StringID AND LSDa.LanguageID = " . $LanguageID . "\n               LEFT JOIN 0200_Language_Strings LSDb ON D.StringID = LSDb.StringID AND LSDb.LanguageID = 1\n               LEFT JOIN (SELECT StoreID, COUNT(DealID) AS DCount, MIN(DealPrice) AS MPrice FROM 4000_Deals GROUP BY StoreID) DC ON DC.StoreID = S.StoreID\n               LEFT JOIN (SELECT DealID, COUNT(ClickID) AS CCount FROM 4200_Deal_Clickthroughs WHERE DealID = " . (int) $_POST['DID'] . " GROUP BY DealID) DCT ON DCT.DealID = D.DealID\n               LEFT JOIN 1200_User_Favorites UF ON UF.DealID = D.DealID AND UF.UserID = " . $UserID . "\n               LEFT JOIN (SELECT URLID, Latitude, Longitude FROM 4110_Deal_Source_URLs GROUP BY Latitude, Longitude) DSU ON DSU.Latitude = L.LocationLatitude AND DSU.Longitude = L.LocationLongitude\n              WHERE D.DealID = " . (int) $_POST['DID'] . "\n              GROUP BY D.DealID;");
            if ($QR < 0) {
                SysLogIt('Error finding deal with ID of ' . (int) $_POST['DID'] . '.', StatusError, ActionSelect);
            } elseif ($QR > 0) {
                $Response->S = true;
                $Response->C = (int) $_POST['DID'];
                $Response->R = array();
                $Response->R[2] = 0;
                $Response->R[3] = 0;
                //Do header
                //-------------------
                $Response->R[0] = '';
                if (!isset($_POST['SM'])) {
                    $Response->R[0] = ' <DIV CLASS="cls z3" onClick="HPanR();">' . Pacify($Strings[1000]) . '</DIV>';
                }
                $Response->R[0] .= '<DIV CLASS="b sz18 padr w100p nowr flwh">' . $DR['SName'] . '</DIV>
                            <DIV CLASS="sz13">';
                if (!(is_null($DR['SWeb']) || trim($DR['SWeb']) == '')) {
                    $Response->R[0] .= '<DIV><A HREF="' . $DR['SWeb'] . '" TARGET="_blank">' . $Strings[1650] . '</A></DIV><DIV>';
                }
                if ($DR['LCount'] > 0) {
                    $Response->R[0] .= '   <DIV>' . ($DR['LCount'] == 1 ? $DR['Adr'] : str_replace('%a', $DR['LCount'], $Strings[1665]));
                }
                $Response->R[0] .= '</DIV><HR>';
                //Do buttons
                //-------------------
                $Response->R[0] .= '<DIV CLASS="sz14 w100p nowr flwh h30" ID="DetB">
                             <DIV CLASS="din butt dtb tibu mgrrxs" onClick="Buy(' . (int) $_POST['DID'] . ')" onMouseOver="DoHlp(this,1305);" onMouseOut="KlHlp();"><DIV CLASS="padlm">' . $Strings[1330] . '</DIV></DIV>';
                if (!isset($_POST['SM'])) {
                    //if (($UserID > 0) && (is_null($DR['FavID']))) $Response->R[0] .= ' <DIV CLASS="din butt dtb tisv mgrrxs" onClick="TogSav(1,'.(int)$_POST['DID'].'); RstDet('.(int)$_POST['DID'].');" onMouseOver="DoHlp(this,1306);" onMouseOut="KlHlp();"><DIV CLASS="padlm">'.$Strings[1331].'</DIV></DIV>';
                    if ($UserID > 0) {
                        if (is_null($DR['FavID'])) {
                            $Response->R[0] .= ' <DIV CLASS="din butt dtb tisv mgrrxs" onClick="TogSav(1,' . (int) $_POST['DID'] . ',1);" onMouseOver="DoHlp(this,1306);" onMouseOut="KlHlp();"><DIV CLASS="padlm">' . $Strings[1331] . '</DIV></DIV>';
                        } else {
                            $Response->R[0] .= ' <DIV CLASS="din dbutt dtb tisvd mgrrxs"><DIV CLASS="padlm">' . $Strings[1367] . '</DIV></DIV>';
                        }
                    } else {
                        $Response->R[0] .= ' <DIV CLASS="din dbutt dtb tidsv mgrrxs" onMouseOver="DoHlp(this,1334,1);" onMouseOut="KlHlp();"><DIV CLASS="padlm">' . $Strings[1331] . '</DIV></DIV>';
                    }
                    if (is_null($DR['FavID'])) {
                        $Response->R[0] .= '  <DIV CLASS="din butt dtb tihi mgrrxs" onClick="KlD(' . (int) $_POST['DID'] . '); HPanR();" onMouseOver="DoHlp(this,1307);" onMouseOut="KlHlp();"><DIV CLASS="padlm">' . $Strings[1332] . '</DIV></DIV>';
                    } else {
                        $Response->R[0] .= '  <DIV CLASS="din butt dtb tihi mgrrxs" onClick="TogSav(0,' . (int) $_POST['DID'] . ',1);" onMouseOver="DoHlp(this,1352);" onMouseOut="KlHlp();"><DIV CLASS="padlm">' . $Strings[1339] . '</DIV></DIV>';
                    }
                }
                $Response->R[0] .= '   <DIV CLASS="din butt dtb tish mgrrxs" onClick="Share(' . (int) $_POST['DID'] . ')" onMouseOver="DoHlp(this,1351);" onMouseOut="KlHlp();"><DIV CLASS="padlm">' . $Strings[1350] . '</DIV></DIV>
                               </DIV>';
                $Response->R[0] .= '</DIV>';
                //Do content
                //-------------------
                $Response->D .= '<DIV CLASS="sz13 dkbl" ID="DetC">
                             <DIV CLASS="sech"><IMG SRC="/IF/H-Des.png" WIDTH=20 HEIGHT=20 ALT="" CLASS="valgm padrxs"><B>' . $Strings[1651] . '</B></DIV>
                             <DIV CLASS="padls">' . $DR['DText'] . '</DIV>
                             <DIV CLASS="padls">
                               <UL>';
                if ($DR['ExpDate'] > 0 && date('Y', $DR['ExpDate']) > 1969) {
                    if ($DR['ExpDate'] < time()) {
                        $DLeft = $Strings[1329];
                    } else {
                        $DLeft = round(($DR['ExpDate'] - time()) / 60 / 60 / 24);
                        if ($DLeft < 180) {
                            $DLeft = '<span class="red">' . $DLeft . '</span>';
                        }
                        $DLeft = $DLeft . ' ' . $Strings[1653];
                    }
                    $Response->D .= '<LI>' . $Strings[1652] . ' ' . date('Y-m-d', $DR['ExpDate']) . ' (' . $DLeft . ')</LI>';
                }
                $Response->D .= '     <LI>' . $Strings[1667] . ' <SPAN CLASS="fklnk" onClick="Buy(' . (int) $_POST['DID'] . ')" onMouseOver="DoHlp(this,1305);" onMouseOut="KlHlp();">' . $DR['DSName'] . '</SPAN>.</LI>
                              </UL>
                            </DIV>
                             <DIV CLASS="sech padts"><IMG SRC="/IF/H-Stat.png" WIDTH=20 HEIGHT=20 ALT="" CLASS="valgm padrxs"><B>' . $Strings[1654] . '</B></DIV>
                             <DIV CLASS="padls">
                               <UL>
                                 <LI>' . str_replace('%a', $DR['DCount'] > 1 ? '<DIV CLASS="nbutt" onClick="DHist(' . (int) $_POST['DID'] . ');" onMouseOver="DoHlp(this,1144);" onMouseOut="KlHlp();">' . $DR['DCount'] . ' ' . $Strings[1672] . '</DIV>' : '<B>' . $DR['DCount'] . '</B> ' . $Strings[1673], $Strings[1655]) . '</LI>
                                 <LI>';
                $Response->D .= is_null($DR['MPrice']) || $DR['DPrice'] <= $DR['MPrice'] ? $Strings[1656] : $Strings[1657];
                $Response->D .= '     </LI>';
                if ($DR['CCount'] > 0) {
                    $Response->D .= '<LI>' . str_replace('%a', $DR['CCount'], $Strings[1658]) . '</LI>';
                }
                $Response->D .= '   </UL>
                            </DIV>
                             <DIV CLASS="sech"><IMG SRC="/IF/H-Rev.png" WIDTH=20 HEIGHT=20 ALT="" CLASS="valgm padrxs"><B>' . $Strings[1659] . '</B></DIV>
                             <DIV CLASS="padls"><SPAN CLASS="fll sz24 mgrrxs dkgray fra algc"><B>' . ($DR['RAvg'] == 0 ? '--' : number_format($DR['RAvg'], 1)) . '</B></SPAN>' . str_replace('%a', $DR['RCount'], $Strings[1660]) . '<BR />';
                if ($DR['RCount'] > 0) {
                    $Response->D .= '<DIV CLASS="nbutt" onClick="GetRvw(' . (int) $_POST['DID'] . ',0)">' . $Strings[1661] . '</DIV> &bull; ';
                }
                if ($UserID > 0) {
                    $Response->D .= (int) $DR['MyScore'] == 0 ? '<DIV CLASS="nbutt" onClick="AddRvw(' . (int) $_POST['DID'] . ');">' . $Strings[1662] . '</DIV>' : '<SPAN>' . str_replace('%a', (int) $DR['MyScore'], $Strings[1663]) . '</SPAN>';
                } else {
                    $Response->D .= '<SPAN CLASS="fklnk" onClick="NewAcct();">' . $Strings[1664] . '</SPAN>';
                }
                $Response->D .= '   <DIV CLASS="clr"></DIV>
                           </DIV>';
                if ($DR['LCount'] > 1) {
                    $Response->D .= '<DIV CLASS="sech padts"><IMG SRC="/IF/H-Adr.png" WIDTH=20 HEIGHT=20 ALT="" CLASS="valgm padrxs"><B>' . $Strings[1666] . '</B></DIV><DIV CLASS="padls"><UL>';
                    list($SQR, $SRS, $T) = QuerySet('SELECT LD.LocationID, LD.LocationAddress AS Adr
                 FROM 2200_Store_Locations SL
                INNER JOIN 3000_Locations LD ON LD.LocationID = SL.LocationID
                WHERE SL.StoreID = ' . $DR['StoreID'] . ';');
                    if ($SQR > 0) {
                        while ($SDR = mysql_fetch_array($SRS)) {
                            $Response->D .= '<LI>' . $SDR['Adr'] . '</LI>';
                        }
                    } elseif ($SQR < 0) {
                        SysLogIt('Error searching for saved deal\'s store locations.', StatusError, ActionSelect);
                        $Response->S = false;
                        $Response->Send();
                    }
                    $Response->D .= '</UL>
                           </DIV>';
                } elseif (is_null($DR['URLID'])) {
                    if ($DR['LCount'] > 0) {
                        $Response->D .= '<DIV CLASS="sech padt"><IMG SRC="/IF/H-Eye.png" WIDTH=20 HEIGHT=20 ALT="" CLASS="valgm padrxs"><B>' . $Strings[1669] . '</B></DIV>
                               <DIV ID="GSVDIV" CLASS="mrgls gsv"></DIV>';
                        $Response->R[2] = $DR['Lat'];
                        $Response->R[3] = $DR['Lng'];
                    }
                }
                if (!is_null($DR['QR'])) {
                    $Response->D .= '<DIV CLASS="sech padt"><IMG SRC="/IF/H-Pho.png" WIDTH=20 HEIGHT=20 ALT="" CLASS="valgm padrxs"><B>' . $Strings[1670] . '</B></DIV>
                             <DIV CLASS="mrgl padbxs">' . $Strings['1671'] . '</DIV>
                             <DIV CLASS="mrgls algc"><IMG SRC="/QR/' . $DR['QR'] . '" CLASS="rbrds fra padaxs" WIDTH=150 HEIGHT=150 ALT=""></DIV>';
                }
                $Response->D .= '</DIV>';
                if (isset($_POST['ULID'])) {
                    if (is_numeric($_POST['ULID'])) {
                        if ((int) $_POST['ULID'] > 0) {
                            SetFilter((int) $_POST['ULID'], FilterDeal, (int) $_POST['DID'], 0, -1, false);
                        }
                    }
                }
                $Response->Send();
            }
        }
    }
    $Response->S = false;
    $Response->Send();
}