Ejemplo n.º 1
0
 NOTE: I'm bothered by something here... while one gets the top
 1000, there could be drastic differences (not likely between any two
 days, but possible)....It doesn't really affect this code, but could
 affect users of the output files.
 */
$Output = fopen("{$out_file}", 'w') or die("Can' open: {$php_errormsg}\n");
echo "Extracting the top {$HowMany_projects} projects from:\n{$in_file}\n";
echo "\nWriting the top {$HowMany_projects} projects to: {$out_file}\n";
// need a valid doc, write the header 1st, and open tag
write_hdr($Output);
while (false != ($line = fgets($F1, 1024))) {
    #  echo "Line is:\n$line\n";
    if (preg_match('/<project>/', $line)) {
        $proj_mark = ftell($F1);
    } elseif (preg_match('/<popularity_rank>[0-9].*</', $line)) {
        $pos = strpos($line, '>');
        $rank_pos = $pos + 1;
        $rank_end = strpos($line, '</', $rank_pos);
        $rank_len = $rank_end - $rank_pos;
        $rank = substr($line, $rank_pos, $rank_len);
        if ((int) $rank <= $HowMany_projects) {
            //pdbg("Processing rank:$rank");
            write_entry($F1, $proj_mark, $Output);
        }
    }
}
// write the end tag and close up shop
close_tag($Output);
fclose($F1);
fclose($Output);
echo "Done\n";
Ejemplo n.º 2
0
if ($contact_service->update(1, $entry)) {
    echo 'Update worked';
}
echo '</p>';
echo '<p>';
/***********************************************/
/* Retrieve entry with id = 1 (Note: this must */
/* have been previously created in the         */
/* database.                                   */
/***********************************************/
echo '<p>';
echo '<b>Testing Retrieve<br/></b>';
echo 'Retrieving the entry with id = 1. Note the changed field.<br/>';
$entry = $contact_service->retrieve(1);
echo '<pre>';
write_entry($entry);
echo '</pre>';
echo '</p>';
echo '<p>';
/***********************************************/
/* Delete the entry we created earlier.        */
/***********************************************/
echo '<p>';
echo '<b>Testing Delete<br/></b>';
echo 'Deleting entry with id = ' . $id . '<br/>';
if ($contact_service->delete($id)) {
    echo 'Delete worked';
}
echo '</p>';
echo '<p>';
function write_entry($entry)