Beispiel #1
0
function twitter_options_page()
{
    $strUserIdsForScript = get_option(TWITTER_USER_IDS);
    $arrNames = explode(',', $strUserIdsForScript);
    $arrUseNames = array();
    $strUserIdsValue = get_option(TWITTER_USER_IDS);
    $strIsShow = get_option(TWITTER_SHOW_STATUS);
    $strShowLogo = get_option(TWITTER_SHOW_LOGO);
    $strShowAtUsername = get_option(TWITTER_SHOW_AT_USERNAME);
    $intLimitNumber = (int) get_option(TWITTER_RESTRICT_TWEETS);
    $intAllTweetsPageId = (int) get_option(TWITTER_PAGE_ID);
    $arrPagesInfo = get_pages();
    $arrPageUrls = array();
    if (false == empty($arrPagesInfo)) {
        foreach ($arrPagesInfo as $element) {
            $arrPageIds[] = $element->ID;
        }
    }
    if ('post' === strtolower($_SERVER['REQUEST_METHOD'])) {
        if (isset($_POST['restrictupdate'])) {
            if (isset($_POST['restrictnumber'])) {
                $intLimitNumber = $_POST['restrictnumber'];
                update_option(TWITTER_RESTRICT_TWEETS, $intLimitNumber);
                echo '<div id="message" class="updated fade"><p><strong>Info updated.</strong></p></div>';
            }
        }
        if (isset($_POST['otheroptionsupdate'])) {
            // start: set to / not to display "@username" blogs
            if ($_POST['at']) {
                $strShowAtUsername = '******';
            } else {
                $strShowAtUsername = '******';
            }
            // end: set to / not to display "@username" blogs
            // start: set to / not to display "created by" footer
            if ($_POST['logo']) {
                $strShowLogo = 'checked';
            } else {
                $strShowLogo = 'unchecked';
            }
            // end: set to / not to display "created by" footer
            update_option(TWITTER_SHOW_LOGO, $strShowLogo);
            update_option(TWITTER_SHOW_AT_USERNAME, $strShowAtUsername);
            echo '<div id="message" class="updated fade"><p><strong>Info updated.</strong></p></div>';
        }
        if (isset($_POST['usernameupdate'])) {
            if (isset($_POST[TWITTER_USER_IDS])) {
                if (!empty($_POST[TWITTER_USER_IDS])) {
                    if (empty($strUserIdsValue)) {
                        $strUserIdsValue = $_POST[TWITTER_USER_IDS];
                        $strIsShow = 'checked';
                    } else {
                        $strUserIdsValue = $strUserIdsValue . ',' . $_POST[TWITTER_USER_IDS];
                        $strIsShow = $strIsShow . ',checked';
                    }
                }
                $arrRemoveValues = array();
                $arrNamesTemp = explode(',', $strUserIdsValue);
                // start: collect the list of users to delete
                foreach ($arrNamesTemp as $strElement) {
                    if ('delete' == $_POST['delete-' . $strElement]) {
                        $arrRemoveValues[] = $strElement;
                    }
                }
                // end: collect the list of users to delete
                $arrResult = array_diff($arrNamesTemp, $arrRemoveValues);
                if (isset($_POST['updateshownames'])) {
                    // start: set to / not to display blogs by a specific user
                    $arrShowValues = array();
                    foreach ($arrResult as $strElement) {
                        if ($strElement == $_POST['checkbox-' . $strElement]) {
                            $arrShowValues[] = 'checked';
                        } else {
                            $arrShowValues[] = 'unchecked';
                        }
                    }
                    // end: set to / not to display blogs by a specific user
                    $strIsShow = implode(",", $arrShowValues);
                }
                $strUserIdsValue = implode(",", $arrResult);
                // start: Save the posted values in the database
                update_option(TWITTER_USER_IDS, $strUserIdsValue);
                update_option(TWITTER_SHOW_STATUS, $strIsShow);
                // end: Save the posted values in the database
                echo '<div id="message" class="updated fade"><p><strong>Info updated.</strong></p></div>';
            }
        }
        if (isset($_POST['url'])) {
            $intAllTweetsPageId = $_POST['urllist'];
            if (-1 == $intAllTweetsPageId) {
                $intAllTweetsPageId = null;
            }
            update_option(TWITTER_PAGE_ID, $intAllTweetsPageId);
            echo '<div id="message" class="updated fade"><p><strong>URL Updated.</strong></p></div>';
        }
        if (isset($_POST['hidden'])) {
            $bolScriptHasRun = twitterScriptMain();
            if (true == $bolScriptHasRun) {
                echo '<div id="message" class="updated fade"><p><strong>Blogs Updated.</strong></p></div>';
            } else {
                echo '<div id="message" class="updated fade"><p><strong>WARNING: Blogs have NOT been Updated.</strong></p></div>';
            }
        }
    }
    displayTwitterOptionsPage($strUserIdsValue, $strIsShow, $strShowAtUsername, $strShowLogo, $intLimitNumber, $arrPageIds, $intAllTweetsPageId);
}
<?php

/*
	Twitter Feed
	Run Script File
	-allows external processes (such as an automated cron entry) to run the Twitter Script file

	Built by Plusnet
	http://community.plus.net/open-source/

	Developer Responsible: James Tuck (Web Development Team)
*/
require_once dirname(__FILE__) . '/twitterScript.php';
require_once dirname(__FILE__) . '/../../../wp-config.php';
$bolScriptHasRun = twitterScriptMain();
if (false == $bolScriptHasRun) {
    exit("ERROR: This script failed to run correctly.");
}