Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'users/init.php';
- require_once $abs_us_root.$us_url_root.'usersc/includes/header.php';
- require_once $abs_us_root.$us_url_root.'usersc/includes/n2.php';
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- $videos = '';
- $errors = [];
- $successes = [];
- if(isset($user) && $user->isLoggedIn()){
- }
- if (!securePage($_SERVER['PHP_SELF'])){die();}
- if(!empty($_POST))
- {
- $token = $_POST['csrf'];
- if(!Token::check($token)){
- die('Token doesn\'t match! <a href="ytadd.php">Try Again</a>');
- }
- if (isset($_POST['vnr']))
- {
- $fileid = trim($_POST['vnr']);
- $fileti = trim($_POST['vna']);
- try {
- // echo "Trying to create item";
- $time = time();
- $fields=array(
- 'v_files_userid' => $user->data()->id,
- 'v_files_title' => ucfirst(Input::get('vna')),
- 'v_files_filename' => $fileid,
- 'v_files_explain' => ucfirst(Input::get('explain')),
- 'v_files_timestamp' => $time,
- 'v_files_cachecode' => 2
- );
- $db->insert('uc_venus_files',$fields);
- $theNewId=$db->lastId();
- // bold($theNewId);
- $successes[] = 'Database Row Created: '.$theNewId;
- $successes[] = '<a href="/details.php?f='.$theNewId.'"><img src="/uploads/'.$fileti.'" class="img-responsive thumbnail" /></a>';
- logger($user->data()->id,"Item Manager","Added item $theNewId.");
- //Redirect::to($us_url_root.'users/admin_user.php?id='.$theNewId);
- } catch (Exception $e) {
- die($e->getMessage());
- }
- }
- if (isset($_POST['q']))
- {
- $qq = $_POST['q'];
- set_include_path(get_include_path() . PATH_SEPARATOR . '/var/www/vhosts/cw2/lib/');
- require_once("Google/autoload.php");
- require_once 'Google/Client.php';
- require_once 'Google/Service/YouTube.php';
- /*
- * Set $DEVELOPER_KEY to the "API key" value from the "Access" tab of the
- * {{ Google Cloud Console }} <{{ https://cloud.google.com/console }}>
- * Please ensure that you have enabled the YouTube Data API for your project.
- */
- $DEVELOPER_KEY = 'xyz';
- $client = new Google_Client();
- $client->setDeveloperKey($DEVELOPER_KEY);
- // Define an object that will be used to make all API requests.
- $youtube = new Google_Service_YouTube($client);
- try {
- // Call the search.list method to retrieve results matching the specified
- // query term.
- $searchResponse = $youtube->search->listSearch('id,snippet', array(
- 'q' => $qq,
- 'maxResults' => 24,
- 'videoEmbeddable' => 'true',
- 'type' => 'video'
- ));
- $videos = '';
- // Add each result to the appropriate list, and then display the lists of
- // matching videos, channels, and playlists.
- foreach ($searchResponse['items'] as $searchResult) {
- switch ($searchResult['id']['kind']) {
- case 'youtube#video':
- $title = urlencode($searchResult['snippet']['title']);
- $videos .= '
- <div class="col-xs-6 col-sm-4">
- <div class="embed-responsive embed-responsive-16by9">
- <iframe class="embed-responsive-item" src="//www.youtube.com/embed/'.$searchResult['id']['videoId'].'?autoplay=0"></iframe>
- </div>
- <h4>'.$title.'</h4>
- <input type="hidden" name="vid" value="'.$searchResult['id']['videoId'].'" />
- <input type="hidden" name="vna" value="'.substr($searchResult['snippet']['title'],0,24).'" />
- <input type="radio" name="vnr" value="'.$searchResult['id']['videoId'].'" />
- </div>
- ';
- break;
- }
- }
- } catch (Google_Service_Exception $e) {
- $htmlBody .= sprintf('<p>A service error occurred: <code>%s</code></p>',
- htmlspecialchars($e->getMessage()));
- } catch (Google_Exception $e) {
- $htmlBody .= sprintf('<p>An client error occurred: <code>%s</code></p>',
- htmlspecialchars($e->getMessage()));
- }
- }
- }
- $tok = Token::generate();
- ?>
- <div id="page-wrapper" style="display: none;">
- <div class="container">
- <?php require_once $abs_us_root.$us_url_root.'usersc/includes/m2.php'; ?>
- <?php echo resultBlock($errors,$successes); ?>
- <div id="imagestrip">
- <div class="row">
- <div class="col-md-12">
- <form method="POST">
- <div class="form-group">
- <label for="q">Search YouTube:</label>
- <input type="search" id="q" name="q" class="form-control input-lg" placeholder="Enter Title or Video ID">
- </div>
- <button type="submit" class="btn btn-default btn-lg">Search</button><a class="btn btn-danger btn-lg" href="upload.php">Cancel</a>
- <input type="hidden" value="<?=$tok;?>" name="csrf">
- </form>
- </div>
- </div>
- <div class="row">
- <div class="col-xs-12">
- <form method="post">
- <div class="row">
- <?php echo $videos;?>
- </div>
- <input type="hidden" value="<?=$tok;?>" name="csrf">
- <?php //print_r($_SESSION);?>
- <input type="submit" value="Add this" />
- </form>
- </div>
- </div>
- </div>
- </div> <!-- /container -->
- </div> <!-- /#page-wrapper -->
- <!-- footers -->
- <?php require_once $abs_us_root.$us_url_root.'usersc/includes/page_footer.php'; // the final html footer copyright row + the external js calls ?>
- <script>
- $(document).ready(function() {
- $('#page-wrapper').fadeIn();
- });
- </script>
- <?php require_once $abs_us_root.$us_url_root.'users/includes/html_footer.php'; // currently just the closing /body and /html ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement