コード例 #1
0
ファイル: blog.module.php プロジェクト: scott-t/ssc
/**
 * Comment submission
 */
function blog_guest_comment_submit()
{
    global $ssc_database, $ssc_site_url;
    $details['n'] = $_POST['n'];
    $details['s'] = $_POST['s'];
    $details['e'] = $_POST['e'];
    ssc_cookie('comment_details', serialize($details), 15552000);
    // Load antispam
    if (ssc_load_library('sscAkismet')) {
        $spam = new sscAkismet($ssc_site_url, ssc_var_get('wordpress_api', ''));
        if (!$spam) {
            // No API key - submit but mark for moderation
            $is_spam = SSC_BLOG_COMMENT_SPAM;
        } else {
            $spam->setContent($_POST['c'], 'comment');
            $spam->setAuthor($_POST['n'], $_POST['e'], $_POST['s']);
            $spam->setRemote($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT']);
            $spam->setBlog($_POST['perma']);
            $is_spam = $spam->isSpam() ? SSC_BLOG_COMMENT_SPAM | SSC_BLOG_COMMENT_CAN_SPAM : SSC_BLOG_COMMENT_CAN_SPAM;
            // Increment caught count
            if ($is_spam & SSC_BLOG_COMMENT_SPAM) {
                ssc_var_set('akismet_count', (int) ssc_var_get('akismet_count', 1) + 1);
            }
        }
    } else {
        // No Akismet library - submit but mark for moderation
        $is_spam = SSC_BLOG_COMMENT_SPAM;
    }
    if ($is_spam & SSC_BLOG_COMMENT_SPAM && ssc_var_get('blog.discard_spam', false)) {
        ssc_add_message(SSC_MSG_WARN, t('Your post was marked as spam and permanently discarded - please try to reduce it\'s "spammyness" and try again'));
        $_POST['spammed'] = true;
    } else {
        $_POST['spammed'] = false;
        $result = $ssc_database->query("INSERT INTO #__blog_comment (post_id, author, email, site, created, status, body, ip)\n\t\t\tVALUES (%d, '%s', '%s', '%s', %d, %d, '%s', '%s')", $_POST['i'], $_POST['n'], $_POST['e'], $_POST['s'], time(), $is_spam, $_POST['c'], $_SERVER['REMOTE_ADDR']);
        // Result tree
        if ($result) {
            // Submission successful
            if ($is_spam & SSC_BLOG_COMMENT_SPAM) {
                // Comment was marked as spam
                if ($is_spam & SSC_BLOG_COMMENT_CAN_SPAM) {
                    // ... by Akismet
                    ssc_add_message(SSC_MSG_WARN, t('Your comment has been submitted but marked as spam and queued for moderation.  Do not resubmit your comment.'));
                } else {
                    // Akisment unavailable - manual moderation
                    ssc_add_message(SSC_MSG_INFO, t('Your comment has been submitted and queued for moderation.  Do not resubmit as it should be checked soon.'));
                }
            } else {
                ssc_add_message(SSC_MSG_INFO, t('Your comment was successfully added'));
            }
        } else {
            ssc_add_message(SSC_MSG_CRIT, t('There was a server error encountered while submitting your comment'));
        }
    }
}
コード例 #2
0
ファイル: crond.php プロジェクト: scott-t/ssc
 */
define("_VALID_SSC", 1);
define("SSC_CRON_MIN_TIME", 60 * 59);
// Minimum 1hr time
// Only load from internally
if (isset($_SERVER['REMOTE_ADDR']) || !isset($_SERVER['argv'])) {
    die('Restricted access');
}
$sites = glob('./config/*.settings.inc.php');
if ($sites === false) {
    die('Restricted access');
}
include './includes/core.inc.php';
foreach ($sites as $site) {
    $site = str_replace(".settings.inc.php", "", $site);
    $site = substr($site, 9);
    $_SERVER['SERVER_NAME'] = $site;
    if ($site == 'default') {
        continue;
    }
    // Begin application startup
    ssc_init(SSC_INIT_EXTENSION);
    $lastrun = ssc_var_get("cron_last_run", 0);
    $now = time();
    // Run only if not up to hardcoded minimum per-run time
    if ($lastrun < $now - SSC_CRON_MIN_TIME) {
        module_hook('cron');
    }
    ssc_var_set("cron_last_run", $now);
    ssc_close();
}
コード例 #3
0
ファイル: fbapp.module.php プロジェクト: scott-t/ssc
function fbapp_mod_blog_post_publish($blog_id, $id, $title)
{
    global $ssc_site_url, $ssc_database, $ssc_site_path;
    require_once 'facebook.php';
    $api_key = "9c476aaa4b1654c09ede303a7d140a36";
    $secret_key = ssc_var_get('fbapp_blog_secret', '');
    if ($secret_key == '') {
        ssc_add_message(SSC_MSG_CRIT, "Facebook user secret key has not been set up yet!");
        return;
    }
    $session_key = ssc_var_get('fbapp_blog_session', '');
    if ($session_key == '') {
        ssc_add_message(SSC_MSG_CRIT, "Facebook user session key has not been set yet!");
        return;
    }
    $client = new FacebookRestClient($api_key, $secret_key, $session_key);
    if (!$client->users_getLoggedInUser()) {
        ssc_add_message(SSC_MSG_CRIT, "Unable to get userid");
        return;
    }
    $dbres = $ssc_database->query("SELECT body FROM #__blog_post WHERE id = %d LIMIT 1", $id);
    if (!$dbres) {
        ssc_add_message(SSC_MSG_CRIT, "Unable to retrieve posted item from database?!");
        return;
    }
    if (!($data = $ssc_database->fetch_assoc($dbres))) {
        ssc_add_message(SSC_MSG_CRIT, "Unable to retrieve posted item from database?!");
        return;
    }
    $img = null;
    // Extract the first image
    $i = strpos($data['body'], '[[img');
    if ($i !== false) {
        // Some basic error checking for a valid tag
        $j = strpos($data['body'], ']]', $i);
        $k = strpos($data['body'], '[[', $i + 3);
        if ($j !== false && ($j < $k || $k === FALSE)) {
            $path = explode("|", substr($data['body'], $i, $j - $i));
            if (count($path) > 1) {
                $path = $path[1];
                // Now match it up to the right path
                if (strpos($path, "://") === false) {
                    if ($path[0] == "/") {
                        $path = substr($path, 1);
                    }
                    // Relative path
                    if (file_exists($ssc_site_path . "/images/{$path}.jpg") || file_exists($ssc_site_path . "/images/{$path}.png") || file_exists($ssc_site_path . "/images/{$path}")) {
                        // Default to image directory base-dir
                        $img = $ssc_site_url . "/images/{$path}";
                    } elseif (file_exists($ssc_site_path . "/{$path}") || file_exists($ssc_site_path . "/{$path}.jpg") || file_exists($ssc_site_path . "/{$path}.png")) {
                        // Relative to site root instead
                        $img = $ssc_site_url . '/' . $path;
                    }
                }
            }
        }
    }
    // Hackish - TODO later for multiple blog paths, non-root based
    $uri = $ssc_site_url . "/id/{$id}";
    //$result = $client->feed_publishUserAction(30881549425, array("title"=>$title, "uri"=>$uri), '', '', 2);
    $attachment = array('name' => $title, 'href' => $uri, 'caption' => 'A blog post has just been made');
    if ($img != null) {
        $attachment['media'] = array(array('type' => 'image', 'src' => $img, 'href' => $uri));
    }
    $action_links = array(array('text' => 'Read this post', 'href' => $uri));
    $target_id = null;
    //array();
    $uid = null;
    $result = $client->stream_publish(" has been blogging", $attachment, $action_links, $target_id, $uid);
    if ($result) {
        ssc_var_set('fbapp_blog_lastid', $id);
    } else {
        ssc_add_message("Unable to post to FB");
    }
}