public function get_rework() { $this->is_admin_or_vendor(); $layouts = array(); if (isset($_POST['path']) && isset($_POST['event_id'])) { $dbxClient = new \Dropbox\Client(getenv('DROPBOX_ACCESS_TOKEN'), "chaar-bhai/1.0"); $layouts_folder_url = $dbxClient->createShareableLink($_POST['path']); if ($layouts_folder_url !== null) { $this->load->model('event_model', 'event'); $this->load->model('layout_comment_model', 'layout_comment'); $event = $this->event->get((int) $this->input->post('event_id')); if (strpos($_POST['event_id'], '.') === FALSE) { $layouts_uploaded_date = $event->event_layouts_uploaded_date; } else { $layouts_uploaded_date = $event->photoshoot_layouts_uploaded_date; } $page = $this->curl($layouts_folder_url); $photo_container = $this->scrape_between($page, '{"files":', ' "folders": []'); if ($photo_container !== FALSE && !empty($photo_container)) { $photos = explode('{', $photo_container); foreach ($photos as $photo) { $photo_name = pathinfo($this->scrape_between($photo, '"filename": "', '",'), PATHINFO_FILENAME); $photo_ext = '.' . pathinfo($this->scrape_between($photo, '"filename": "', '",'), PATHINFO_EXTENSION); $photo_url = str_replace('\\u0026', '&', $this->scrape_between($photo, '"preview_url": "', 'size=32x32"')) . 'size=1024x768'; if ($_SESSION['user']['role'] === 'Admin') { $layout_comments = $this->layout_comment->get_many_by('event_id = ' . $_POST['event_id'] . ' AND title = "' . $photo_name . '"'); } else { $layout_comments = $this->layout_comment->get_many_by('event_id = ' . $_POST['event_id'] . ' AND title = "' . $photo_name . '" AND reworked = 0'); } if (!empty($layout_comments)) { $layouts[] = array('name' => $photo_name, 'ext' => $photo_ext, 'url' => $photo_url, 'added' => $layouts_uploaded_date); } } if (!empty($layouts)) { $this->response(array('layouts' => $layouts), 200); } else { $this->response(array('layouts' => $layouts, 'status' => 'All layouts have been revised.', 'resend_layouts' => 'enabled'), 200); } } else { $photo_container = $this->scrape_between($page, '<ol id="gallery-view-media" class="gallery-view-section gallery-icon-view clearfix">', '</ol>'); if ($photo_container !== FALSE && !empty($photo_container)) { $photos = explode('<li style="position:relative">', $photo_container); foreach ($photos as $photo) { if (!empty($photo)) { $parsed_photo_url = parse_url($this->scrape_between($photo, 'href="', '?dl=0'), PHP_URL_PATH); $photo_name = rawurldecode(pathinfo($parsed_photo_url, PATHINFO_FILENAME)); $photo_ext = '.' . rawurldecode(pathinfo($parsed_photo_url, PATHINFO_EXTENSION)); $photo_url = $this->scrape_between($photo, '<img data-src="', '?size_mode') . '?size_mode=3&size=1024x768'; if ($_SESSION['user']['role'] === 'Admin') { $layout_comments = $this->layout_comment->get_many_by('event_id = ' . $_POST['event_id'] . ' AND title = "' . $photo_name . '"'); } else { $layout_comments = $this->layout_comment->get_many_by('event_id = ' . $_POST['event_id'] . ' AND title = "' . $photo_name . '" AND reworked = 0'); } if (!empty($layout_comments)) { $layouts[] = array('name' => $photo_name, 'ext' => $photo_ext, 'url' => $photo_url, 'added' => $layouts_uploaded_date); } } } if (!empty($layouts)) { $this->response(array('layouts' => $layouts), 200); } else { $this->response(array('layouts' => $layouts, 'status' => 'All layouts have been revised.', 'resend_layouts' => 'enabled'), 200); } } else { $this->response(array('layouts' => $layouts, 'status' => 'Layouts could not be found.'), 200); } } } else { $this->response(array('layouts' => $layouts, 'status' => 'Layouts could not be found.'), 200); } } else { $this->response(array('error' => 'Bad request'), 400); } }
function loadTable() { $connect = mysql_connect("localhost", "root", "123"); mysql_select_db("POKS"); $mail = $_SESSION["user"]; $query_relult = mysql_query("select userId from User where email = '{$mail}'") or die("Не удалось провести запрос к базе данных function isExist"); $id_user = mysql_fetch_array($query_relult); $id_user = $id_user[0]; $query_relult = mysql_query("select * from userStorrage where idUser = {$id_user}") or die("Не удалось провести запрос к базе данных -- loadTable()"); # Include the Dropbox SDK libraries require_once './dropbox-sdk-php-1.1.5/lib/Dropbox/autoload.php'; //MODX_BASE_PATH. //use \Dropbox as dbx; $accessToken = "-QAlimGqvKAAAAAAAAAAjRWBUFnqWI0AuJV06CSJtnvDKFYMpujYYU2h4fN7-Hlv"; // Здесь ваш Access token $dbxClient = new \Dropbox\Client($accessToken, "ITMO_POKS_FOLDER"); while ($mail_array = mysql_fetch_array($query_relult)) { $img_link = $dbxClient->createTemporaryDirectLink("/" . $mail . "/" . $mail_array[5]); $shared_link = $dbxClient->createShareableLink("/" . $mail . "/" . $mail_array[5]); echo "<tr>"; echo "\n\t\t\t\t<td>\n\t\t\t\t\t<img class = 'well modal-image' src = '{$img_link['0']}' width = '100' height = '100'/>\n\t\t\t\t</td>\n\t\t\t\t\n\t\t\t\t<td>{$mail_array['2']}</td>\n\t\t\t\t<td>{$mail_array['3']}</td>\n\t\t\t\t<td>{$mail_array['4']}</td>\n\t\t\t\t<td>{$mail_array['5']}</td>"; echo "\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<a class='btn btn-success btn-block' href = 'removeImage.php?image_id={$mail_array['0']}&image_name={$mail_array['5']}'>\n\t\t\t\t\t\t\tRemove\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</td>\n\t\t\t\t"; echo "\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<p><a href= {$shared_link}> Скачать файл</a> </p>\n\t\t\t\t\t</td>\n\t\t\t\t"; echo "</tr>"; } mysql_close($connect); }