nixsolutions /
yandex-php-library
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | $settings = require_once '../settings.php'; |
||
| 3 | use Yandex\DataSync\DataSyncClient; |
||
| 4 | use Yandex\Common\Exception\ForbiddenException; |
||
| 5 | |||
| 6 | $errorMessage = false; |
||
| 7 | |||
| 8 | // Is auth |
||
| 9 | if (isset($_COOKIE['yaAccessToken']) && isset($_COOKIE['yaClientId'])) { |
||
| 10 | $dataSync = new DataSyncClient($_COOKIE['yaAccessToken']); |
||
| 11 | $context = DataSyncClient::CONTEXT_USER; |
||
| 12 | //Устанавливаем Контекст базы данных (app или user) |
||
| 13 | $dataSync->setContext($context); |
||
| 14 | |||
| 15 | try { |
||
| 16 | |||
| 17 | if (isset($_REQUEST['action'])) { |
||
| 18 | if ($_REQUEST['action'] === 'createDb' && isset($_REQUEST['databaseId']) && $_REQUEST['databaseId']) { |
||
| 19 | //Создание базы данных |
||
| 20 | //@see https://tech.yandex.ru/datasync/http/doc/tasks/add-database-docpage/ |
||
| 21 | $dataSync->createDatabase($_REQUEST['databaseId']); |
||
| 22 | } elseif ($_REQUEST['action'] === 'deleteDb' && isset($_REQUEST['databaseId']) && $_REQUEST['databaseId']) { |
||
| 23 | //Удаление базы данных |
||
| 24 | //@see https://tech.yandex.ru/datasync/http/doc/tasks/delete-database-docpage/ |
||
| 25 | $dataSync->deleteDatabase($_REQUEST['databaseId']); |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | //Получение ответа со списком баз данных |
||
| 30 | //@see https://tech.yandex.ru/datasync/http/doc/tasks/get-databases-docpage/ |
||
| 31 | $databasesResponse = $dataSync->getDatabases(); |
||
| 32 | //Баз данных |
||
| 33 | $databases = $databasesResponse->getItems()->getAll(); |
||
| 34 | } catch (ForbiddenException $ex) { |
||
| 35 | $errorMessage = $ex->getMessage(); |
||
| 36 | $errorMessage .= '<p>Возможно, у приложения нет прав на доступ к ресурсу. Попробуйте ' |
||
| 37 | . '<a href="' . rtrim(str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__), "/") . "/../OAuth/" . |
||
| 38 | '">авторизироваться</a> и повторить.</p>'; |
||
| 39 | } catch (Exception $ex) { |
||
| 40 | $errorMessage = $ex->getMessage(); |
||
| 41 | } |
||
| 42 | } |
||
| 43 | ?> |
||
| 44 | <!doctype html> |
||
| 45 | <html lang="en-US"> |
||
| 46 | <head> |
||
| 47 | <meta charset="UTF-8"> |
||
| 48 | <title>Yandex PHP Library: DataSync Demo</title> |
||
| 49 | <link rel="stylesheet" href="//yandex.st/bootstrap/3.0.0/css/bootstrap.min.css"> |
||
| 50 | <link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet"> |
||
| 51 | <link rel="stylesheet" href="/examples/Disk/css/style.css"> |
||
| 52 | </head> |
||
| 53 | <body> |
||
| 54 | <div class="container"> |
||
| 55 | <div class="jumbotron"> |
||
| 56 | <h2><span class="glyphicon glyphicon-shopping-cart"></span> Пример работы с Яндекс DataSync HTTP API</h2> |
||
| 57 | </div> |
||
| 58 | <ol class="breadcrumb"> |
||
| 59 | <li><a href="/examples">Examples</a></li> |
||
| 60 | <li class="active">DataSync</li> |
||
| 61 | </ol> |
||
| 62 | <?php |
||
| 63 | if (!isset($_COOKIE['yaAccessToken']) || !isset($_COOKIE['yaClientId'])) { |
||
| 64 | ?> |
||
| 65 | <div class="alert alert-info"> |
||
| 66 | Для просмотра этой страници вам необходимо авторизироваться. |
||
| 67 | <a id="goToAuth" |
||
| 68 | href="<?php echo rtrim(str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__), "/") . '/../OAuth/' ?>" |
||
| 69 | class="alert-link">Перейти на страницу авторизации</a>. |
||
| 70 | </div> |
||
| 71 | <?php |
||
| 72 | } elseif ($errorMessage) { |
||
|
0 ignored issues
–
show
|
|||
| 73 | ?> |
||
| 74 | <div class="alert alert-danger"> |
||
| 75 | <?= $errorMessage ?> |
||
| 76 | </div> |
||
| 77 | <?php |
||
| 78 | } elseif (isset($databases)) { |
||
| 79 | ?> |
||
| 80 | <div> |
||
| 81 | <h3>Базы данных:</h3> |
||
| 82 | <table id="accountTable" class="table table-striped table-bordered table-hover"> |
||
| 83 | <thead> |
||
| 84 | <tr> |
||
| 85 | <td>Идентификатор</td> |
||
| 86 | <td>Название</td> |
||
| 87 | <td>Номер ревизии</td> |
||
| 88 | <td>Количество записей</td> |
||
| 89 | <td>Дата и время модификации</td> |
||
| 90 | <td>Дата и время создания</td> |
||
| 91 | <td>Размер</td> |
||
| 92 | <td>Действия</td> |
||
| 93 | </tr> |
||
| 94 | </thead> |
||
| 95 | <tbody> |
||
| 96 | <?php |
||
| 97 | foreach ($databases as $database) { |
||
| 98 | ?> |
||
| 99 | <tr> |
||
| 100 | <td> |
||
| 101 | <a href="database.php?databaseId=<?= $database->getDatabaseId() ?>"> |
||
| 102 | <?= $database->getDatabaseId() ?> |
||
| 103 | </a> |
||
| 104 | </td> |
||
| 105 | <td><?= $database->getTitle() ?></td> |
||
| 106 | <td><?= $database->getRevision() ?></td> |
||
| 107 | <td><?= $database->getRecordsCount() ?></td> |
||
| 108 | <td><?= $database->getModified() ?></td> |
||
| 109 | <td><?= $database->getCreated() ?></td> |
||
| 110 | <td><?= $database->getSize() ?></td> |
||
| 111 | <td> |
||
| 112 | <a href="index.php?action=deleteDb&databaseId=<?= $database->getDatabaseId() ?>"> |
||
| 113 | <button type="button" class="btn btn-danger">Удалить</button> |
||
| 114 | </a> |
||
| 115 | </td> |
||
| 116 | </tr> |
||
| 117 | <?php |
||
| 118 | } |
||
| 119 | ?> |
||
| 120 | </tbody> |
||
| 121 | </table> |
||
| 122 | <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#createDbModal"> |
||
| 123 | Создать новую БД |
||
| 124 | </button> |
||
| 125 | </div> |
||
| 126 | |||
| 127 | <!-- Modal --> |
||
| 128 | <div class="modal fade" id="createDbModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> |
||
| 129 | <div class="modal-dialog" role="document"> |
||
| 130 | <div class="modal-content"> |
||
| 131 | <form class="form-horizontal" action="index.php" method="post"> |
||
| 132 | <div class="modal-header"> |
||
| 133 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span |
||
| 134 | aria-hidden="true">×</span></button> |
||
| 135 | <h4 class="modal-title" id="myModalLabel">Создать новую БД</h4> |
||
| 136 | </div> |
||
| 137 | <div class="modal-body"> |
||
| 138 | <div class="form-group"> |
||
| 139 | <label for="inputDatabaseId" class="col-sm-4 control-label">Идентификатор БД</label> |
||
| 140 | |||
| 141 | <div class="col-sm-8"> |
||
| 142 | <input type="text" class="form-control" id="inputDatabaseId" name="databaseId" |
||
| 143 | placeholder="Идентификатор БД"> |
||
| 144 | <input type="hidden" name="action" value="createDb"> |
||
| 145 | </div> |
||
| 146 | </div> |
||
| 147 | </div> |
||
| 148 | <div class="modal-footer"> |
||
| 149 | <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
||
| 150 | <button type="submit" class="btn btn-primary">Save changes</button> |
||
| 151 | </div> |
||
| 152 | </form> |
||
| 153 | </div> |
||
| 154 | </div> |
||
| 155 | </div> |
||
| 156 | |||
| 157 | <?php |
||
| 158 | } |
||
| 159 | ?> |
||
| 160 | <script src="http://yandex.st/jquery/2.0.3/jquery.min.js"></script> |
||
| 161 | <script src="http://yandex.st/jquery/cookie/1.0/jquery.cookie.min.js"></script> |
||
| 162 | <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> |
||
| 163 | <script> |
||
| 164 | $(function () { |
||
| 165 | $('#goToAuth').click(function (e) { |
||
| 166 | $.cookie('back', location.href, {expires: 256, path: '/'}); |
||
| 167 | }); |
||
| 168 | }); |
||
| 169 | </script> |
||
| 170 | </body> |
||
| 171 | </html> |
||
| 172 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: