{
    if (!($file = fopen($pages_file_path, 'w'))) {
        print_r('Unable to open file to create pages CSV.');
    }
    $i = 0;
    while ($i < $pages) {
        $i++;
        $output = array();
        $output[] = $i;
        fputcsv($file, $output);
    }
    fclose($file);
}
// The number of users to be represented in your graph.
$users = 10;
// The number of pages your users could visit. On a Drupal site, each page is represented intenally as 'www.blah.com/node/int_value'.
// I follow this convention here. Drupal just happens to call them 'nodes'. :-)
$pages = 100;
// Maximum unique page views per user.
// We don't count hitting the same page multiple times.
$max_views_per_user = 5;
// We will use this as a property value.
$base_url = 'sheldonkreger.com';
// This is where outpt CSV files will go. Edit to fit your filesystem.
$connections_file_path = '/home/sheldon/connections.csv';
$pages_file_path = '/home/sheldon/pages.csv';
$users_file_path = '/home/sheldon/users.csv';
// Invoke the functions.
generate_pages($pages, $pages_file_path);
generate_users($users, $users_file_path);
generate_connections($users, $pages, $max_views_per_user, $connections_file_path);
Example #2
0
/**
 * The screen you'll see after submitting an entry. It stores the entry, updates the indices (pivot's
 * content indices, and the search index), rebuilds the frontpage and XML & Atom feeds, and then it
 * displays a list of the latest entries.
 *
 */
function entrysubmit_screen()
{
    global $db, $config_array, $Pivot_Vars, $entry, $Cfg, $Users, $Paths, $Weblogs, $filtered_words;
    // check against unauthorised direct access.
    check_csrf();
    $db = new db();
    $entry = get_entry_from_post();
    if (!$entry['title'] == "" || !$entry['introduction'] == "" || !$entry['user'] == "") {
        // in this part, we remove the entry from the categories in which
        // the current user is not allowed to post entries
        foreach ($entry['category'] as $my_cat) {
            $allowed = explode("|", $Cfg['cat-' . $my_cat]);
            if (in_array($Pivot_Vars['user'], $allowed)) {
                $allowed_cats[] = $my_cat;
            } else {
                $message .= '<br />';
                $message .= sprintf(lang('entries', 'entry_catnopost'), $m_cat);
                debug("not in category: " . $my_cat);
            }
        }
        $entry['category'] = $allowed_cats;
        $db->set_entry($entry);
        if ($db->save_entry(TRUE)) {
            $message = sprintf(lang('entries', 'entry_saved_ok') . $message, '<i>' . trimtext($entry['title'], 25) . '</i>');
        } else {
            $message = sprintf(lang('entries', 'entry_saved_ok'), '<i>' . trimtext($entry['title'], 25) . '</i>');
        }
        // only trigger the ping if it's a new entry..
        if ($entry['code'] == ">" && $entry['status'] == "publish") {
            $ping = TRUE;
        } else {
            $ping = FALSE;
        }
        // only notify if entry is published, and is either new or status changed to publish.
        if ($entry['status'] == "publish") {
            if ($entry['code'] == ">" || $entry['oldstatus'] != "publish") {
                $notified = notify_new('entry', $db->entry);
                $notified = "<br /><br />" . $notified;
            }
        }
        // if the global index as they are made var is set - can continue
        if ('1' == $Cfg['search_index']) {
            /*
            			2004/10/16 =*=*= JM
            			an entry should only be indexed if both are true:
            			 - 'publish'==$entry['status']
            			 - current date is at least equal to $entry['publish_date']
            			I lie, there is another case...
            			it is conceivable that this is a timed publish AND the time has come
            			I will leave this to timed publish routines - if I can find them...
            			-> pvLib ... it's flagged
            and of course, providing that there is at least one
            			category where it would be indexed...
            something else that can't be tested... if the user changes a normal
            			publish to a timed-publish, or puts on hold when it was previously
            			normal. user should reindex in this case
            */
            // check status and date
            if ('publish' == $entry['status'] || 'timed' == $entry['status'] && $entry['publish_date'] <= date('Y-m-d-H-i')) {
                // categories...
                if (can_search_cats(cfg_cat_nosearchindex(), $entry['category'])) {
                    include_once 'modules/module_search.php';
                    update_index($db->entry);
                    debug('update search index: ' . $db->entry['code']);
                }
            }
        }
        // perhaps send a trackback ping.
        if ($Pivot_Vars['tb_url'] != "" && $entry['status'] == "publish") {
            debug("tburl: " . $Pivot_Vars['tb_url']);
            require_once 'includes/send_trackback.php';
            $weblogs = find_weblogs_with_cat($db->entry['category']);
            if (isset($Weblogs[$weblogs[0]])) {
                $my_url = $Paths['host'] . make_filelink($db->entry['code'], $weblogs[0], '');
                $weblog_title = $Weblogs[$weblogs[0]]['name'];
                debug("TRACKBACK ping: {$my_url}");
                $message .= '<br />';
                $message .= sprintf(lang('entries', 'entry_ping_sent'), $Pivot_Vars['tb_url']);
                $tb_urls = explode("\n", $Pivot_Vars['tb_url']);
                // make the contents of what to send with the trackback..
                $tb_contents = parse_step4($entry['introduction']);
                if ($Pivot_Vars['convert_lb'] == 2) {
                    $tb_contents = pivot_textile($tb_contents);
                } else {
                    if ($Pivot_Vars['convert_lb'] == 3 || $Pivot_Vars['convert_lb'] == 4) {
                        $tb_contents = pivot_markdown($tb_contents, $Pivot_Vars['convert_lb']);
                    }
                }
                $tb_contents = trimtext(strip_tags($tb_contents), 255);
                foreach ($tb_urls as $tb_url) {
                    $tb_url = trim($tb_url);
                    if (isurl($tb_url)) {
                        trackback_send($Pivot_Vars['tb_url'], $my_url, $entry['title'], $weblog_title, $tb_contents);
                    }
                }
            }
        }
        // Update the tags for this entry if it's published and remove the old tags if not
        if ($db->entry['status'] == 'publish') {
            writeTags($db->entry['keywords'], $_POST['f_keywords_old'], $db->entry['code']);
        } else {
            deleteTags($_POST['f_keywords_old'], $db->entry['code']);
        }
    }
    generate_pages($db->entry['code'], TRUE, TRUE, TRUE, $ping);
    entries_screen($message . $notified);
}
Example #3
0
/**
 * Deletes a post.
 *
 * @param string $postid
 * @return void
 */
function pivot_delete_post($postid)
{
    global $db;
    $entry = $db->read_entry($postid);
    $db->delete_entry();
    $overview_arr = $db->getlist(-4, 0, "", "", FALSE);
    foreach ($overview_arr as $entry) {
        generate_pages($entry['code'], TRUE, TRUE, TRUE, FALSE);
    }
}
Example #4
0
                debug("comment from '" . $Pivot_Vars['piv_name'] . "' added.");
            } else {
                generate_moderation_queue($my_comment);
                debug("comment from '" . $Pivot_Vars['piv_name'] . "' added to moderation queue.");
            }
        }
        // remove it from cache, to make sure the latest one is used.
        $db->unread_entry($entry['code']);
        // first get the filename..
        $filelink = make_filelink($Pivot_Vars['piv_code'], $Pivot_Vars['piv_weblog'], '', $message, TRUE);
        // send mail..
        if (!isset($Pivot_Vars['vote'])) {
            send_mail_comm();
        }
        // regenerate entry, frontpage and archive..
        generate_pages($Pivot_Vars['piv_code'], TRUE, TRUE, TRUE, FALSE, FALSE);
        redirect($filelink);
    }
    if (isset($Pivot_Vars['preview'])) {
        $db->set_entry($entry);
        define('__SILENT__', TRUE);
        define('LIVEPAGE', TRUE);
        // only set the message if not done yet (otherwise the 'no_name' notice would be overwritten)
        if (!isset($Pivot_Vars['message'])) {
            $Pivot_Vars['message'] = lang('comment', 'preview');
        }
        $output = parse_entry($Pivot_Vars['piv_code'], $Current_weblog);
        $comm_js = fill_comment_form_submit($Pivot_Vars['piv_name'], $Pivot_Vars['piv_email'], $Pivot_Vars['piv_url'], $Pivot_Vars['piv_rememberinfo'], $Pivot_Vars['piv_comment'], $Pivot_Vars['piv_notify'], $Pivot_Vars['piv_discreet']);
        echo str_replace("</body>", "{$comm_js}\n</body>", $output);
    }
} else {
Example #5
0
/**
 * Screen that's shown when rebuilding all pages.
 */
function regen()
{
    global $Cfg, $db, $Weblogs, $Pivot_Vars, $VerboseGenerate, $Allow_RSS, $totalfiles, $done_archives, $archive_array_next, $archive_array_prev, $Archive_array;
    PageHeader(lang('adminbar', 'regen_title'), 1);
    PageAnkeiler(lang('userbar', 'admin') . ' &raquo; ' . lang('adminbar', 'regen_title'));
    // initialise the threshold..
    if (isset($Cfg['rebuild_threshold']) && $Cfg['rebuild_threshold'] > 4) {
        $threshold = $Cfg['rebuild_threshold'];
    } else {
        $threshold = 28;
    }
    $db = new db();
    // also force the archive index file to be updated
    @unlink('db/ser-archives.php');
    // Make a new archive array.
    $Archive_array = make_archive_array();
    // ugly hack, to get a big slice of mem back..
    $entries_arr = $db->getcodes_range("0000-00-00-00-00", "2010-01-01-00-00", "", "", FALSE);
    $totalfiles = 0;
    $count = 0;
    if (isset($Pivot_Vars['count'])) {
        $count = $Pivot_Vars['count'];
        $totalfiles = $Pivot_Vars['totalfiles'];
        reset($entries_arr);
        do {
            next($entries_arr);
            $key = key($entries_arr);
            //echo "(k $key)";
        } while ($key < $Pivot_Vars['count']);
    }
    do {
        $key = key($entries_arr);
        $loopentry = current($entries_arr);
        // Generate only archive pages and static entry pages, not
        // frontpage or RSS.
        generate_pages($loopentry, TRUE, FALSE, TRUE, FALSE, FALSE);
        $count++;
        if ($count % 10 == 0) {
            printf("%1.2f sec: Processed %d entries.." . "<br />\n", timetaken('int'), $count);
            flush();
        }
        // server friendly generate all..
        if (timetaken("int") > $threshold) {
            $myurl = sprintf("index.php?session=%s&menu=admin&func=admin&do=regen&count=%s&totalfiles=%s", $Pivot_Vars['session'], $count, $totalfiles);
            printf('<script> self.location = "%s"; </script>', $myurl);
            die;
        }
    } while (next($entries_arr));
    printf("<br />A total of <b>%s</b> entries have been processed, and <b>%s</b> files have been created" . "<br />\n", $count, $totalfiles);
    // Generate frontpages and feeds.
    echo "<p>" . lang('adminbar', 'buildfrontpage_title') . "</p>";
    $VerboseGenerate = true;
    $Allow_RSS = true;
    foreach ($Weblogs as $name => $weblog) {
        generate_frontpage($name);
    }
    echo "<p>" . lang('general', 'done') . "</p>";
    PageFooter();
}
Example #6
0
/**
 * Process a comment for moderation. Action 1 = allow,
 * action 2 = delete.
 *
 * When allowed, the comment is changed in the entry, so it is displayed, and it
 * is added to the last_comments. Whene deleted it'll be deleted from the entry
 *
 * @param array $comm
 * @param integer $action
 */
function moderate_process($comm, $action)
{
    global $db, $Paths, $Current_weblog, $Cfg;
    if (!isset($db)) {
        $db = new db();
    }
    if ($action == 1) {
        // Allow comment.
        // First, get the entry..
        $entry = $db->read_entry($comm['code'], true);
        $send_notifaction = false;
        foreach ($entry['comments'] as $key => $loopcomm) {
            if ($loopcomm['name'] == $comm['name'] && $loopcomm['date'] == $comm['date']) {
                // fix the entry..
                $entry['comments'][$key]['moderate'] = 0;
                // Store the comment that's approved. We need it a bit later on to send the notifications
                $modcomment = $entry['comments'][$key];
                // Save it..
                $db->set_entry($entry);
                $db->save_entry();
                // Add it to the 'last comments'..
                if (file_exists("db/ser_lastcomm.php")) {
                    $lastcomm = load_serialize("db/ser_lastcomm.php", true, true);
                } else {
                    $lastcomm = array();
                }
                $lastcomm[] = $comm;
                if (count($lastcomm) > $Cfg['lastcomm_amount_max']) {
                    array_shift($lastcomm);
                }
                save_serialize("db/ser_lastcomm.php", $lastcomm);
                $send_notifaction = true;
            }
        }
        // Regenerate the entry page (if it's static) and the corresponding archive page.
        generate_pages($comm['code'], TRUE, FALSE, TRUE, FALSE, FALSE);
        if ($send_notifaction) {
            // We need to determine the current weblog..
            $weblogs = find_weblogs_with_cat($entry['category']);
            $Current_weblog = current($weblogs);
            // Handle the users that want to be notified via email..
            notify_new('comment', array($entry, $modcomment));
        }
    } else {
        if ($action == 2) {
            // Delete comment.
            // First, get the entry..
            $entry = $db->read_entry($comm['code'], true);
            foreach ($entry['comments'] as $key => $loopcomm) {
                if ($loopcomm['name'] == $comm['name'] && $loopcomm['date'] == $comm['date']) {
                    // fix the entry..
                    unset($entry['comments'][$key]);
                    // Save it..
                    $db->set_entry($entry);
                    $db->save_entry();
                }
            }
        }
    }
}
Example #7
0
    if ($error) {
        echo "<b>Not posted: For some reason</b><br />";
    } else {
        if ($Users[$entry['user']]['pass'] == md5($entry['pass'])) {
            // if so, save the new entry and generate files (if necesary)
            $db = new db();
            $entry['code'] = ">";
            $entry['date'] = date('Y-m-d-H-i');
            //fix the category
            $entry['category'] = array($entry['category']);
            $entry = $db->set_entry($entry);
            $db->save_entry();
            // remove it from cache, to make sure the latest one is used.
            $db->unread_entry($entry['code']);
            // regenerate entry, frontpage and archive..
            generate_pages($entry['code'], TRUE, TRUE, TRUE);
            echo "<b>Your entry has been posted!</b><br />";
        } else {
            echo "<b>Not posted: Wrong User and/or Password</b><br />";
            // add one to the failed login attempts.
            if (strlen($entry['user']) > 0) {
                $Cfg['fl_' . $_SERVER['REMOTE_ADDR']]++;
                SaveSettings();
            }
            debug("Wrong password/username ({$entry['user']})");
        }
    }
}
?>
<form name="form1" method="post" action="minilog.php">
<p>Username:<br />
Example #8
0
    $low_trackback = strtolower(trackback_format($my_trackback['excerpt']));
    if (substr_count($low_trackback, "href=") > 2) {
        $message = lang('trackback', 'too_many_hrefs');
        unset($Pivot_Vars['post']);
    }
}
if (isset($Pivot_Vars['post'])) {
    $db->set_entry($entry);
    // send mail..
    send_mail_tb();
    // switch to weblog's language (it might be changed in the meantime)
    LoadWeblogLanguage($Weblogs[$Current_weblog]['language']);
    debug("trackback from '" . $Pivot_Vars['piv_name'] . "' added.");
    $db->save_entry(FALSE);
    // do not update the index.
    //update the 'last trackbacks' file
    if (isset($my_trackback)) {
        generate_last_trackbacks($my_trackback);
    }
    // remove it from cache, to make sure the latest one is used.
    $db->unread_entry($entry['code']);
    // regenerate entry, frontpage and archive..
    generate_pages($Pivot_Vars['tb_id'], TRUE, TRUE, TRUE, FALSE, FALSE);
    add_hook("trackback", "post");
    execute_hook("trackback", "post", $Pivot_Vars, $entry);
    respondExit();
} else {
    add_hook("trackback", "post");
    execute_hook("trackback", "post", $Pivot_Vars, "");
    respondExit($message, 1);
}