Example #1
0
    return basicBox('/newsletter', '#paper', 'Sign Up for our Newsletter');
}
function getTwitter()
{
    return basicBox('https://twitter.com/texansforrubio/', '#twitter', '@TexansForRubio', true);
}
function getMedia()
{
    return basicBox('/media', '#image', 'Media from TexansForRubio');
}
function getIssuesBox()
{
    return basicBox('/issues', '#image', 'More Issues');
}
function getVolunteerBox()
{
    return basicBox('https://docs.google.com/forms/d/1CVsxBpnqCFyoZpGImNmIqYSgDb6ItCT3upl274whsCA/viewform?c=0&w=1', '#hammer', 'Volunteer', true);
}
foreach ($data as $box) {
    if ($box === 'newsletter') {
        echo getNewsletter();
    } elseif ($box === 'twitter') {
        echo getTwitter();
    } elseif ($box === 'media') {
        echo getMedia();
    } elseif ($box === 'issues') {
        echo getIssuesBox();
    } elseif ($box === 'volunteer') {
        echo getVolunteerBox();
    }
}
Example #2
0
//Saves the current PID into the file run.pid
$loop = React\EventLoop\Factory::create();
//Init the event loop class
$socket = new React\Socket\Server($loop);
//Init the socket server class
$db = new PDO('sqlite::memory:');
//Init PDO SQLite into memory
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
createMediaTable();
//Create the media table
mapDirContentsToDB();
//Insert the initial list of file into the media table
/* Create the socket */
$socket->on('connection', function ($conn) use($loop, $PUSH_TIMER) {
    $loop->addPeriodicTimer($PUSH_TIMER, function () use($conn) {
        $media = getMedia();
        //Get Semi-Random Media file to push through the socket
        $conn->write($media);
        //Push Media through socket to the client
        updateMediaViews($media);
        //Update the media table to reflect that this media item has been sent.
    });
});
/* watch the dir for new images */
$loop->addPeriodicTimer($WATCH_DIR_TIMER, function () {
    mapDirContentsToDB();
});
echo "Socket server listening on port 4000.\n";
echo "You can connect to it by running: telnet localhost 4000\n";
$socket->listen($SOCKET_PORT);
//Start the socket lisining on port 400
Example #3
0
$app->register(new SearchProvider(), array(SearchProvider::SEARCH_INDEX => __DIR__ . '/../data/search_index'));
// set timezone
date_default_timezone_set($app['timezone']);
/**
 * Callbacks and helper functions
 */
/**
 * Page Converter callback - converts page name into SimpleXML object
 *
 * @param $page string
 * @throws Exception
 * @return SimpleXMLElement;
 */
$loadPageXML = function ($page) use($app) {
    // get page context
    getMedia($page, $app);
    // get page content
    return getPageContent($page);
};
/**
 * @param string $page
 * @return SimpleXMLElement
 * @throws Exception
 */
function getPageContent($page)
{
    $f = __DIR__ . '/../html/' . $page;
    $contents = file_get_contents($f);
    if ($contents === false) {
        throw new Exception('content file not found');
    }
    getOrgVdc();
    getOrgNet();
    getTask();
    getEvent();
    getUser();
    getRole();
    buildSummary();
} elseif ($type == "orguser") {
    getVApp();
    getVAppTemplate();
    getVAppNetwork();
    getVM();
    getVMNetwork();
    getCatalog();
    getCatalogItem();
    getMedia();
    getOrgVdc();
    getOrgNet();
    getTask();
    getEvent();
    getUser();
    buildSummary();
} else {
    $service->logout();
    echo "Invalid report type!\n";
    exit(1);
}
// log out
$service->logout();
buildHtmlFooter();
function buildSummary()
Example #5
0
        }
        echo json_encode($pages);
    }
});
$app->get('/admin/entryMedia/{entryId}', function ($request, $response, $args) {
    $db = getConnection();
    try {
        echo json_encode(getMediaForEntries($db, $args['entryId']));
    } catch (Exception $e) {
        error_status($response, $e->getMessage());
    }
});
$app->get('/admin/media/{id}', function ($request, $response, $args) {
    $db = getConnection();
    try {
        echo json_encode(getMedia($db, $args['id']));
    } catch (Exception $e) {
        error_status($response, $e->getMessage());
    }
});
$app->get('/admin/files', function ($request, $response, $args) {
    try {
        $file = $request->getQueryParams()['file'];
        if (file_exists($file) && is_file($file)) {
            $dispositionResponse = $response->withHeader('Content-disposition', 'attachment; filename=' . basename($file));
            $typeResponse = $dispositionResponse->withHeader('Content-type', filemime($file));
            $typeResponse->getBody()->write(file_get_contents(getcwd() . '/' . $file));
            return $typeResponse;
        } elseif (file_exists($file) && is_dir($file)) {
            $typeResponse = $response->withHeader('Content-type', 'text/x-dir');
            $files = scandir(getcwd() . '/' . $file);
function selectMedia($parameters)
{
    global $db;
    // check the parameters and add to where clause
    $where = '';
    // id_project
    if (!empty($parameters['id_project'])) {
        if (is_array($parameters['id_project'])) {
            $createdByArray = array();
            foreach ($parameters['id_project'] as $id_project) {
                if (is_numeric($id_project)) {
                    $createdByArray[] = $id_project;
                }
            }
            $where .= " AND id_project in (" . implode(', ', $createdByArray) . ") ";
        } else {
            $where .= " AND id_project = " . (0 + $parameters['id_project']) . " ";
        }
    }
    //updated since
    if (!empty($parameters['updatedSince'])) {
        // has to be unix timestamp
        if (is_numeric($parameters['updatedSince'])) {
            $where .= " AND ( created_at > '" . date('Y-m-d H:i:s', $parameters['updatedSince']) . "' or updated_at > '" . date('Y-m-d H:i:s', $parameters['updatedSince']) . "' )";
        }
    }
    //id media
    if (!empty($parameters['idMedia'])) {
        if (is_array($parameters['idMedia'])) {
            $mediaIdArray = array();
            foreach ($parameters['idMedia'] as $mediaIdEntry) {
                // numeric entries only
                if (is_numeric($mediaIdEntry)) {
                    $mediaIdArray[] = $mediaIdEntry;
                }
            }
            $where .= " AND media.id in (" . implode(', ', $mediaIdArray) . ")";
        } else {
            //single id
            $where .= " AND media.id = " . (0 + $parameters['idMedia']);
        }
    }
    // media type
    if (!empty($parameters['mediaType'])) {
        $mediaType = addslashes($parameters['mediaType']);
        // check in DB for entries matching the mediatype
        $query = "\n               SELECT\n                `id`\n               FROM\n                 `" . $GLOBALS['dataBaseToUse'] . "`.`media_type`\n               WHERE\n                 `deleted` = 0\n                 AND (`content_type` like '" . $mediaType . "' or `file_ending` = '" . $mediaType . "')\n               ";
        $result = $db->query($query);
        $mediaTypeIds = array();
        while ($row = mysqli_fetch_assoc($result)) {
            $mediaTypeIds[] = $row['id'];
        }
        // if we have results use id_media_type else try to find the given media_type as file ending
        if (!empty($mediaTypeIds)) {
            $where .= " AND `media`.`id_media_type` in (" . implode(', ', $mediaTypeIds) . ") ";
        } elseif ($mediaType != 'all') {
            $where .= " AND `media`.`file_ending` = '" . $mediaType . "' ";
        }
    }
    // find media by string
    if (!empty($parameters['searchAll'])) {
        // there are two possibilities: find string in keyword, file_ending or in context-info
        // first media_context
        // check in DB for entries matching the mediatype
        $query = "\n               SELECT\n                `id_media`\n               FROM\n                 `" . $GLOBALS['dataBaseToUse'] . "`.`media_context`\n               WHERE\n                 `deleted` = 0\n                 AND (`title` like '%" . addslashes($parameters['searchAll']) . "%'\n                   OR `subtitle` like '%" . addslashes($parameters['searchAll']) . "%'\n                   OR `description` like '%" . addslashes($parameters['searchAll']) . "%'\n                   OR `copyright` like '%" . addslashes($parameters['searchAll']) . "%')\n               ";
        $result = $db->query($query);
        $mediaIdArray = array(0);
        while ($row = mysqli_fetch_assoc($result)) {
            $mediaIdArray[] = $row['id_media'];
        }
        $where .= " AND (\n                         `media`.`id` in (" . implode(', ', $mediaIdArray) . ")\n                         OR\n                         `keywords` like '%" . addslashes($parameters['searchAll']) . "%'\n                         OR `file_ending` like '" . addslashes($parameters['searchAll']) . "')";
    }
    // paging contains results per block as blocksize and number of block used for the query
    if (!empty($parameters['paging'])) {
        // blocksize from setting or standard
        if (!empty($parameters['paging']['blocksize'])) {
            $blocksize = 0 + $parameters['paging']['blocksize'];
        } else {
            $blocksize = 20;
        }
        if (!empty($parameters['paging']['block'])) {
            $block = 0 + $parameters['paging']['block'];
        } else {
            $block = 1;
        }
        $parameters['limit'] = " LIMIT " . ($block - 1) * $blocksize . ", " . $blocksize . " ";
    }
    if (!empty($parameters['order'])) {
        $where .= addslashes($parameters['order']);
    }
    if (!empty($parameters['limit'])) {
        $where .= addslashes($parameters['limit']);
    }
    // select media
    // get ids for media entries
    $query = "\n\t\t SELECT\n                    SQL_CALC_FOUND_ROWS\n                    `media`.`id`\n                 FROM\n\t\t    `" . $GLOBALS['dataBaseToUse'] . "`.`media`\n\n\t\t WHERE\n\t\t    `media`.`deleted` = 0\n                    " . $where . "\n\t   ";
    $result = $db->query($query);
    $return = array();
    // reports
    $return['parameters'] = $parameters;
    $return['numResults'] = '';
    while ($row = mysqli_fetch_assoc($result)) {
        $return['data'][$row['id']] = array();
    }
    // number of possible results
    $countResult = $db->query("SELECT FOUND_ROWS()");
    $countArray = $row = mysqli_fetch_assoc($countResult);
    $return['numResults'] = $countArray['FOUND_ROWS()'];
    // now get the values
    if (!empty($return['data'])) {
        $mediaData = getMedia(array_keys($return['data']));
        #print_r($mediaData);
        foreach ($mediaData as $idMedia => $row) {
            $return['data'][$idMedia] = $row;
        }
    }
    return $return;
}
Example #7
0
if (isset($_SESSION['login']) && $_SESSION['login']) {
    if (isset($_GET['auto_reply'])) {
        if (isset($_GET['reply_type'])) {
            $mediaList = getMediaList($_GET['reply_type'], 0);
            foreach ($mediaList['item'] as $row) {
                $allList[] = json_encode($row, JSON_UNESCAPED_UNICODE);
            }
        }
        if (isset($_POST['content'])) {
            $_POST['key_word'] = trim($_POST['key_word']);
            $key = $_POST['key_word'] == '' ? '.' : preg_replace('/,|,/', '\\|', $_POST['key_word']);
            $content = addslashes($_POST['content']);
            switch ($_POST['type']) {
                case 'news':
                    $postjsondata = json_encode(array('media_id' => $_POST['content']));
                    $content = getMedia($postjsondata);
                    $content = addslashes($content);
                    break;
            }
            pdoInsert('default_reply_tbl', array('weixin_id' => $_SESSION['weixinId'], 'reply_type' => $_POST['type'], 'key_word' => $key, 'content' => $content), ' ON DUPLICATE KEY UPDATE content="' . $content . '"');
            header('location: ?auto_reply=1');
        }
        if (isset($_GET['deleteAutoReply'])) {
            $sql = 'delete from default_reply_tbl where weixin_id="' . $_SESSION['weixinId'] . '" and id=' . $_GET['deleteAutoReply'];
            $pdo->exec($sql);
            header('location: ?auto_reply=1');
        }
        $query = pdoQuery('default_reply_tbl', null, array('weixin_id' => $_SESSION['weixinId']), null);
        printView('/admin/view/autoreply.html.php', '自动回复设置');
    }
    if (isset($_GET['getDefultReply'])) {