Esempio n. 1
0
function getReviews($d, $sku)
{
    //echo "getReviews: " . $sku . "\n";
    global $r, $revs;
    $reviews = $d->find('#product-reviews-list > li.review');
    if (count($reviews) > 0) {
        $revs[$sku] += count($reviews);
        foreach ($reviews as $rev) {
            $data = array($sku, trim($rev->find('span[property=name]', 0)->innertext), round($rev->find('meta[property=ratingValue]', 0)->content / 20, 1), trim($rev->find('span[property=author]', 0)->innertext), "", trim($rev->find('meta[property=datePublished]', 0)->content, "on "), trim($rev->find('div.review-text', 0)->innertext));
            fputcsv($r, $data);
        }
    }
    if (!is_null($d->find('a.i-next', 0))) {
        $newurl = $d->find('a.i-next', 0)->href;
        //echo "Another page of reviews found: " . $newurl . "\n";
        $d->load(scraperwiki::scrape($newurl));
        getReviews($d, $sku);
    } else {
        echo "Saved " . $revs[$sku] . " reviews for sku: " . $sku . ".\n";
    }
}
Esempio n. 2
0
function assignCommonListlinksVar(&$savant, &$links, &$pathWay, &$pageNav)
{
    global $task, $Itemid, $my, $cat_id, $mtconf;
    $database =& JFactory::getDBO();
    require_once $mtconf->getjconf('absolute_path') . '/administrator/components/com_mtree/mfields.class.php';
    # Load custom fields' caption
    if ($task == 'advsearch') {
        $database->setQuery("SELECT CONCAT( 'cust_', cf_id ) AS name, caption AS value, field_type FROM #__mt_customfields WHERE published = 1 AND advanced_search = 1");
        $custom_fields = $database->loadObjectList("name");
    } else {
        $database->setQuery("SELECT CONCAT( 'cust_', cf_id ) AS name, caption AS value, field_type FROM #__mt_customfields");
        $custom_fields = $database->loadObjectList("name");
    }
    $fields = array();
    $arrayLinkId = array();
    if (count($links) > 0) {
        foreach ($links as $link) {
            $arrayLinkId[] = intval($link->link_id);
        }
    }
    $tmp_fields = array();
    $tmp_core_fields = array();
    if (count($arrayLinkId) > 0) {
        $sql = "SELECT cf.*, cfv.link_id, cfv.value, cfv.attachment, cfv.counter, ft.ft_class FROM #__mt_customfields AS cf " . "\nLEFT JOIN #__mt_cfvalues AS cfv ON cf.cf_id=cfv.cf_id " . "\nLEFT JOIN #__mt_fieldtypes AS ft ON ft.field_type=cf.field_type" . "\nWHERE cf.published = '1' AND cf.summary_view = '1' " . "\nAND cfv.link_id IN (" . implode(',', $arrayLinkId) . ") " . "\nORDER BY cf.ordering ASC, link_id DESC";
        $database->setQuery($sql);
        $tmp_fields = $database->loadObjectList();
        $sql_core = "SELECT cf. * , NULL AS link_id, '' AS value, NULL AS attachment, ft.ft_class " . "\nFROM #__mt_customfields AS cf " . "\nLEFT JOIN #__mt_fieldtypes AS ft ON ft.field_type=cf.field_type " . "\nWHERE cf.published = '1' " . "\nAND cf.summary_view = '1' " . "\nAND cf.iscore = '1' " . "\nORDER BY cf.ordering ASC";
        $database->setQuery($sql_core);
        $tmp_core_fields = $database->loadObjectList();
    }
    if (count($arrayLinkId) > 0 && (count($tmp_core_fields) > 0 || count($tmp_fields) > 0)) {
        $tmp_fields = array_merge($tmp_fields, $tmp_core_fields);
    }
    // Custom fields that do not require value, appear only once with a NULL value to link_id.
    // This loop clone the custom fields for each link
    foreach ($tmp_fields as $key => $value) {
        if (is_null($value->link_id)) {
            foreach ($arrayLinkId as $linkId) {
                $tmp_value = $value;
                $tmp_value = PHP_VERSION < 5 ? $value : clone $value;
                $tmp_value->link_id = $linkId;
                $tmp_fields[] = $tmp_value;
                unset($tmp_value);
            }
        }
    }
    usort($tmp_fields, "customFieldsSort");
    if (count($links) > 0) {
        foreach ($links as $link) {
            $tmp_link_id = $link->link_id;
            $fields[$link->link_id] = new mFields();
            $data = null;
            $i = 0;
            foreach ($tmp_fields as $key => $value) {
                if ($value->link_id == $tmp_link_id) {
                    $data[$key * 28] = $value;
                    unset($tmp_fields[$key]);
                }
                $i++;
            }
            $fields[$link->link_id]->setCoresValue($link->link_name, $link->link_desc, $link->address, $link->city, $link->state, $link->country, $link->postcode, $link->telephone, $link->fax, $link->email, $link->website, $link->price, $link->link_hits, $link->link_votes, $link->link_rating, $link->link_featured, $link->link_created, $link->link_modified, $link->link_visited, $link->publish_up, $link->publish_down, $link->metakey, $link->metadesc, $link->user_id, $link->username);
            $fields[$link->link_id]->loadFields($data);
        }
    }
    # Mambots
    if ($mtconf->get('cat_parse_plugin')) {
        applyMambots($links);
    }
    assignCommonVar($savant);
    $savant->assignRef('pathway', $pathWay);
    $savant->assign('pageNav', $pageNav);
    $savant->assignRef('links', $links);
    $savant->assignRef('fields', $fields);
    $savant->assign('reviews', getReviews($links));
    $savant->assign('min_votes_to_show_rating', $mtconf->get('min_votes_to_show_rating'));
    $savant->assign('custom_fields', $custom_fields);
    $savant->assign('listing_image_dir', $mtconf->getjconf('live_site') . $mtconf->get('listing_image_dir'));
    $savant->assign('cat_id', $cat_id);
    return true;
}
    purchaseOrder();
}
if ($function == "add_coupon") {
    addCoupon();
}
if ($function == "get_order") {
    getOrder();
}
if ($function == "get_orders") {
    getOrders();
}
if ($function == "add_review") {
    addReview();
}
if ($function == "get_reviews") {
    getReviews();
}
if ($function == "check_employee") {
    checkEmployee();
}
if ($function == "register_employee") {
    registerEmployee();
}
if ($function == "get_managed_employees") {
    getManagedEmployees();
}
if ($function == "get_employee_username") {
    getEmployeeUsername();
}
if ($function == "get_warehouses") {
    getWarehouses();
        if ($i == $gutachtennr) {
            print " selected";
        }
        print ">{$i}</option>\n";
    }
    print "</select>" . "<p><input type=\"submit\" name=\"submitButtonName\" value=\"Gutachten zeigen\"></p>\n" . "</form>";
} else {
    echo "<p>Es liegen noch keine Gutachten vor!</p>";
}
if (!ereg("^[0-9]*\$", $autor)) {
    print "<p>Bitte die Matrikelnr. des Autors angeben!</p>";
}
if ($gutachtennr > 0) {
    if (0 < $nr && $nr <= $gutachtennr) {
        $query = "SELECT dokument, anmerkung, punkte, validiert, zusatzpunkte FROM dokumente WHERE autor = '{$autor}' AND aufgabenr='{$nr}'";
        getReviews($query);
    } else {
        echo "<p>Finger weg vom Formular!</p>";
    }
}
function getReviews($query)
{
    global $con;
    global $nr;
    global $autor;
    $rs = mysql_query($query);
    if (!$rs) {
        print "<p>Datenbank-Fehler. Bitte erneut versuchen</p>";
    } elseif (mysql_num_rows($rs) > 0) {
        $rs_array = mysql_fetch_row($rs);
        $dokument = $rs_array[0];
Esempio n. 5
0
include "connection.php";
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
//determine the which query to form
$query_func = $_REQUEST['q'];
switch ($query_func) {
    case 'post_review':
        $reviewer = $_COOKIE['userID'];
        $driver = $_REQUEST['driver'];
        $content = $_REQUEST['content'];
        $rating = $_REQUEST['rating'];
        echo postReview($driver, $reviewer, $content, $rating);
        break;
    case 'get_reviews':
        $driver = $_REQUEST['driver'];
        echo getReviews($driver);
        break;
    case 'get_user_recent_trips':
        $userID = $_COOKIE['userID'];
        $trips = getUserRecentTrips($userID);
        echo $trips;
        break;
    case 'search':
        $words = $_REQUEST['words'];
        echo searchALL($words);
        break;
    case 'start_following':
        $sessionUser = $_COOKIE['userID'];
        $profileUser = $_REQUEST['profileUser'];
        startFollowing($profileUser, $sessionUser);
        break;