Exemple #1
0
<?php

include_once 'connect.php';
switch ($_GET["table"] || $_POST["table"]) {
    case "score":
        updateScore($_GET);
        break;
    case "personne":
        updatePersonne($_GET);
        break;
    case "document":
        updateDocument($_GET);
        break;
    case "personnesw2ui":
        updatePersonnesForW2UIGrid();
        break;
    default:
        break;
}
function updateScore($data)
{
    global $conn;
    $sql = "update scores set distance=" . $data["distance"] . ", maj = NOW() where id_scores =" . $data["id_score"];
    //echo $sql;
    if ($conn->query($sql) === TRUE) {
        echo "score updated successfully";
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }
}
function updatePersonne($data)
Exemple #2
0
function grabAnchors($hrefLinks, $main_site)
{
    // grab the last id for this main site
    $query = 'SELECT max(link_id),link_id FROM scrapper WHERE main_site_id = ' . $hrefLinks['main_site_id'];
    $result = fetch_record($query);
    $id = intval($result['link_id']);
    // cURL the link and dump into the array the result
    $array = curlHREF($hrefLinks['ref_link']);
    sort($array);
    // $array is returned as sorted array. get the fist and last
    // index of the a-html-tag and start the loop from there
    // anything else can be ignored
    // get begin index
    $startpos = getStart($array);
    // get last index
    $endpos = getLast($array, $startpos);
    // if startpos = endpos, it would mean that the a-html-tag is not found properly
    // update the document and exit
    if ($startpos == $endpos) {
        updateDocument($hrefLinks);
        return;
    }
    // start parsing the a-html-tag
    for ($i = $startpos; $i <= $endpos; $i++) {
        // extract the href from the a-html-tag
        $href_a = getHREF($array[$i]);
        // check if link if to be excluded
        if (excludLink($href_a, $main_site) === false) {
            if (checkduplicate($href_a) === true) {
                $id = $id + 1;
                $query = "INSERT INTO scrapper (main_site_id, ref_link, link_id) VALUES ('" . $hrefLinks['main_site_id'] . "','" . $href_a . "','" . $id . "')";
                // add the links
                run_mysql_query($query);
            }
        }
    }
    // update the document after the parsing of the a-html-tag
    updateDocument($hrefLinks);
    return;
}