/** Returns the number of visits in the specified time range $range_start : start of range in unix time. see comment at the start of the file $range_end : end of range in unix time. see comment at the start of the file site_id : see comment at the start of the file url: see comment at the start of the file */ function fs_api_get_visits_range($range_start, $range_end, $site_id = true, $url = null) { require_once dirname(__FILE__) . '/db-sql.php'; $url_id = null; if ($url) { $url_id = fs_get_url_id($url); if ($url_id === null) { return 0; } } return fs_get_unique_hit_count_range($site_id, true, $range_start, $range_end, $url_id); }
function fs_replace_url_metadata($url, $type, $value = null) { $url_id = fs_get_url_id($url); if (empty($url_id)) { return "URL Not found: <b>{$url}</b>"; } return fs_replace_url_metadata_by_id($url_id, $type, $value); }
function fs_update_post_titles() { $path = fs_get_firestats_path(); if (!$path) { return "FS_PATH not defined"; } require_once $path . '/php/db-sql.php'; global $wpdb; require_once ABSPATH . "wp-includes/pluggable.php"; $posts = $wpdb->get_results("SELECT ID,post_title FROM {$wpdb->posts} WHERE post_type = 'post'"); if ($posts === false) { return $wpdb->last_error; } $site_id = get_option('firestats_site_id'); foreach ($posts as $post) { $id = $post->ID; $title = $post->post_title; $link = get_permalink($id); if (empty($link)) { continue; } // make sure the url exists in the urls table.; $url_id = fs_get_url_id($link); if ($url_id == null) { $res = fs_insert_url($link, $site_id); if ($res !== true) { return "Error inserting url: {$res}"; } $url_id = fs_get_url_id($link); } // replace title with current one $res = fs_set_url_title($link, $title); if ($res !== true) { return "Error handling post ({$post->post_title}) : {$res}"; } // mark url as a post $res = fs_set_url_type($link, FS_URL_TYPE_POST); if ($res !== true) { return $res; } } return true; }