function generateCaption($userId, $authToken, $videoUrl, $language = 'en-GB')
{
    // after this function we have video file stored locally
    $fileName = getVideoAndReturnFileName($videoUrl);
    $jobId = uploadVideoAndReturnJobId($userId, $authToken, $fileName, $language);
    while (isset(getVideoTranslation($userId, $authToken, $jobId)->code)) {
        sleep(10);
    }
    $translationFile = getVideoTranslation($userId, $authToken, $jobId);
    $lineCharacterCounter = 0;
    $fileContent = "WEBVTT\n\n";
    $line = '';
    foreach ($translationFile->words as $word) {
        $name = $word->name;
        if ($lineCharacterCounter == 0 && $name == '.') {
            continue;
        }
        $duration = $word->duration;
        $time = $word->time;
        if ($lineCharacterCounter == 0) {
            $startTime = $time;
        }
        if ($name == '.') {
            $line .= $name;
        } else {
            $line .= ' ' . $name;
        }
        $lineCharacterCounter += strlen($name);
        $endTime = $time + $duration;
        if (35 <= $lineCharacterCounter) {
            $timing = "\n\n" . convertTime($startTime) . " --> " . convertTime($endTime) . "\n{$line}";
            $fileContent .= $timing;
            $lineCharacterCounter = 0;
            $line = '';
        }
    }
    $captionFile = getIdFromUrl($videoUrl);
    file_put_contents($captionFile . '.vtt', $fileContent);
    echo "Done";
}
Пример #2
0
<?php

include_once "../core/model.php";
include_once "../models/categories.php";
include_once "../models/goods.php";
include_once "../views/functions.php";
$id_category = getIdFromUrl();
$category = new Categories();
$GLOBALS['title'] = $category->getNameCategory($id_category);
include_once "header.php";
?>

<div id="sidebar">
<?php 
$parent_path = $category->getParentPath($id_category);
$main_category = $parent_path[0];
$child_categories = $category->getAllChildCategories($id_category);
$main_child_categories = $category->getChildCategories($main_category);
drawMenu($main_category, $category, $parent_path);
?>
</div>

<div id="content">

<?php 
$good = new Goods();
$all_goods = $good->getGoodsFromCategories($child_categories);
foreach ($all_goods as $array => $each) {
    if ($each['is_showed'] == 1) {
        echo "<div class='good'>";
        echo "<a href='" . PATHSITE . "/good/" . $each['id'] . "'><p class='good-name'>" . $each['name'] . "</p>";
Пример #3
0
<?php

session_start();
include_once "../views/functions.php";
include_once "../models/cart.php";
$action = getIdFromUrl();
// with parameters
if (stripos($action, "?") !== FALSE) {
    $action = substr($action, 0, stripos($action, "?"));
}
// without parameters
class Purchase
{
    protected static $instance;
    public $id, $id_good, $id_user, $data, $count, $cost;
    static function getInstance()
    {
        return self::$instance === null ? self::$instance = new self() : self::$instance;
    }
    function buy()
    {
        if (isset($_POST['id']) & isset($_POST['count']) & isset($_POST['cost']) & Cart::getInstance()->IsCookie($_POST['id'])) {
            try {
                //header("Location: ".$_SERVER['PHP_SELF']); //решаем проблему повторной отправки данных формы
                $dbh = new PDO('mysql:host=localhost;dbname=iba', USER, PASS);
                $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                $zapros = 'INSERT INTO purchases (id, id_good, id_user, data, count, cost) VALUES (null, :id_good, :id_user, :data, :count, :cost)';
                $sth = $dbh->prepare($zapros);
                $data = array('id_good' => $_POST['id'], 'id_user' => $_SESSION['id_user'], 'data' => date("Y.n.j"), 'count' => $_POST['count'], 'cost' => $_POST['cost']);
                $sth->execute($data);
                $result = $dbh->lastInsertId();
Пример #4
0
<?php

include_once "../core/model.php";
include_once "../models/users.php";
include_once "../views/functions.php";
$id_user = getIdFromUrl();
$user = new Users();
$user->getUser($id_user);
include_once "admin-header.php";
echo "<a href='" . PATHSITE . "/admin-users'>Вернуться</a>";
// or href="javascript:history.go(-1)"
?>
<h2>Настройки пользователя</h2>
<form name="admin-user" action="http://localhost/iba/user/update" method="post" onsubmit="alert('Данные успешно сохранены!');">

 <input type="hidden" id="id_user" name="id_user" value="<?php 
echo $user->id;
?>
">

 <label>Ваше имя:</label>
 <input type="text" id="name" name="name" maxlength="25" value="<?php 
echo $user->name;
?>
" required>

 <label>Фамилия:</label>
 <input type="text" id="surname" name="surname" maxlength="25" value="<?php 
echo $user->surname;
?>
" required>
Пример #5
0
<?php

include_once "../core/model.php";
include_once "../models/users.php";
include_once "../models/goods.php";
include_once "../models/purchase.php";
include_once "../views/functions.php";
$id_purchase = getIdFromUrl();
Purchase::getInstance()->getPurchase($id_purchase);
$user = new Users();
$user->getUser(Purchase::getInstance()->id_user);
$good = new Goods();
$good->getGood(Purchase::getInstance()->id_good);
include_once "admin-header.php";
echo "<a href='" . PATHSITE . "/admin-purchases'>Вернуться</a>";
// or href="javascript:history.go(-1)"
?>
<h2>Просмотр покупки</h2>
<form name="admin-purchase" action="http://localhost/iba/purchase/update" method="post" onsubmit="alert('Данные успешно сохранены!');">

 <label>Номер заказа:</label>
 <input type="text" id="purchase_id" name="purchase_id" maxlength="25" value="<?php 
echo Purchase::getInstance()->id;
?>
" readonly="readonly">

 <label>Товар:</label>
 <a href="<?php 
echo PATHSITE . "/good/" . $good->id;
?>
"> <?php 
Пример #6
0
<?php

include_once "../core/model.php";
include_once "../models/categories.php";
include_once "../models/goods.php";
include_once "../views/functions.php";
$id_good = getIdFromUrl();
$good = new Goods();
$good->getGood($id_good);
$GLOBALS['title'] = $good->name;
include_once "header.php";
echo "<a href=" . $_SERVER['HTTP_REFERER'] . ">Вернуться к просмотру</a>";
// or href="javascript:history.go(-1)"
echo "<br><label><b>Название:</b></label><br>";
echo "<p><b> {$good->name} </b></p>";
echo "<label><b>Цена:</b></label><br>";
echo "<p> {$good->price} </p>";
echo "<label><b>Размеры:</b></label><br>";
echo "<p> {$good->size} </p>";
echo "<label><b>Описание:</b></label><br>";
echo "<p> {$good->review} </p>";
if ($good->img_link != "") {
    ?>
 <img id="good_img" src="<?php 
    echo PATHSITE . "/img/" . $good->img_link;
    ?>
" width="300px" height="300px"><br>
<?php 
}
if ($good->in_sale == 1) {
    echo "<button><a href = '" . PATHSITE . "/cart/add?id={$good->id}&count=1'>Добавить в корзину</a></button>";