当前位置: 首页>>代码示例>>PHP>>正文


PHP Api::log方法代码示例

本文整理汇总了PHP中Api::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Api::log方法的具体用法?PHP Api::log怎么用?PHP Api::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Api的用法示例。


在下文中一共展示了Api::log方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cronDaily

 /** Function launched daily to do some kind of cleanup...
  */
 function cronDaily()
 {
     global $db;
     $api = new Api();
     $api->log_caller = "cron-daily";
     // TODO: delete the old transcodes (kept for more than MAX_KEEP_TRANSCODE_DAYS days)
     // TODO: delete the old original videos (kept for more than MAX_KEEP_ORIGINAL_DAYS days) after having no job to do with them?
     // Announce the public transcoder to the discovery service :
     if (defined('PUBLIC_TRANSCODER') && PUBLIC_TRANSCODER && defined('TRANSCODER_NAME') && TRANSCODER_NAME != '' && defined('TRANSCODER_ADMIN_EMAIL') && TRANSCODER_ADMIN_EMAIL != '') {
         $f = @fopen("http://discovery.open-mediakit.org/?action=transcoder_is_available&name=" . urlencode(TRANSCODER_NAME) . "&email=" . urlencode(TRANSCODER_ADMIN_EMAIL) . "&url=" . urlencode(FULL_URL . "api") . "&version=" . OMKT_VERSION . "&application=OpenMediakitTranscoder", "rb");
         if ($f) {
             $js = "";
             while ($s = fgets($f, 1024)) {
                 $js .= $s;
             }
             fclose($f);
             $result = @json_decode($js);
             if (isset($result->code)) {
                 if ($result->code == 0) {
                     $api->log(LOG_INFO, "Successfully announced ourself as a Public Transcoder service at discovery.open-mediakit.org");
                 } else {
                     $api->log(LOG_INFO, "Something special happened when announcing ourself as a Public Transcoder service at discovery.open-mediakit.org. The message was : '" . $result->message . "'");
                 }
             } else {
                 $api->log(LOG_INFO, "An error was received when announcing ourself as a Public Transcoder service at discovery.open-mediakit.org. No error message reported");
             }
         }
     }
     // We disable (enabled=0) (and tell it by mail) daily, any user account whose last activity is more than 2 month ago AND last successfull cron is more than a month ago
     $disables = $db->qlist("SELECT * FROM users WHERE enabled=1 AND validated=1 AND lastactivity < DATE_SUB(NOW(), INTERVAL 62 DAY) AND lastcronsuccess < DATE_SUB(NOW(), INTERVAL 31 DAY);", NULL, PDO::FETCH_ASSOC);
     foreach ($disables as $disable) {
         $db->q("UPDATE users SET enabled=0 WHERE uid='" . $disable["uid"] . "';");
         $api->log(LOG_INFO, "disabled user " . $disable["uid"] . " (url was " . $disable["url"] . ") as being inactive and in error for too long.");
         $to = $disable["email"];
         $subject = _("Account disabled in the public OpenMediakit Transcoder");
         $message = sprintf(_("\nHi,\n\nDays ago, you subscribed to a public transcoder service.\n\nSince then, your account has not used our service for more than 2 months, and your website seems down since more than 1 month.\n\nAs a result, we just disabled your account for the application using our transcoding service.  \n\nFor your records, your website was located at %s.\n\nFeel free to resubscribe if you need to use this service later again,\n\n--\nRegards,\n\nThe OpenMediakit Transcoder public instance at\n%s\n"), $disable["url"], FULL_URL);
         $headers = 'From: ' . MAIL_FROMNAME . ' <' . MAIL_FROM . '>' . "\r\n" . 'Reply-To: ' . MAIL_FROM . "\r\n" . 'Content-type: text/plain; charset=utf-8' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
         mail($to, $subject, $message, $headers);
     }
     // for each disabled account
 }
开发者ID:ninetian,项目名称:omk-server,代码行数:43,代码来源:cron.php

示例2: sleep

            break;
    }
}
pcntl_signal(SIGTERM, "sig_handler");
pcntl_signal(SIGHUP, "sig_handler");
pcntl_signal(SIGINT, "sig_handler");
pcntl_signal(SIGQUIT, "sig_handler");
while (true) {
    // Cleanup daemons from this host
    $api->cleanupQueueLocks();
    // Search for a task
    $task = $api->getQueuedTaskLock(array(TASK_SEND_METADATA, TASK_SEND_TRANSCODE, TASK_SEND_METADATAERROR));
    if (!$task) {
        // we sleep for a little while, thanks to that, we can launch that process as soon as we want:
        // it will still do *nothing* for a little while when there is nothing to do ;)
        $api->log(LOG_DEBUG, "Nothing to do, sleeping...");
        sleep(60);
        continue;
    }
    $media = $api->mediaSearch(array("id" => $task["mediaid"]));
    if (!$media) {
        $api->log(LOG_CRIT, "Got task '" . $task["id"] . "' but media '" . $task["mediaid"] . "' not found!!");
        $api->setTaskFailedUnlock($task["id"]);
        continue;
    }
    $media = $media[0];
    $api->me = Users::get($task["user"]);
    $url = $api->me["url"];
    if (strpos($url, "?") !== false) {
        $url .= "&";
    } else {
开发者ID:ninetian,项目名称:omk-server,代码行数:31,代码来源:api.daemon.php

示例3: sleep

            break;
    }
}
pcntl_signal(SIGTERM, "sig_handler");
pcntl_signal(SIGHUP, "sig_handler");
pcntl_signal(SIGINT, "sig_handler");
pcntl_signal(SIGQUIT, "sig_handler");
while (true) {
    // Cleanup daemons from this host
    $api->cleanupQueueLocks();
    // Search for a task
    $task = $api->getQueuedTaskLock(TASK_DOWNLOAD, "http");
    if (!$task) {
        // we sleep for a little while, thanks to that, we can launch that process as soon as we want:
        // it will still do *nothing* for a little while when there is nothing to do ;)
        $api->log(LOG_DEBUG, "Nothing to do, sleeping...");
        sleep(60);
        continue;
    }
    $media = $api->mediaSearch(array("id" => $task["mediaid"]));
    if (!$media) {
        $api->log(LOG_CRIT, "got task '" . $task["id"] . "' but media '" . $task["mediaid"] . "' not found");
        $api->setTaskFailedUnlock($task["id"]);
        continue;
    }
    $media = $media[0];
    $api->me = Users::get($task["user"]);
    // ok, we try to download the file, with curl, with timeout and range management
    $curl = curl_init();
    $options = array(CURLOPT_USERAGENT => $useragent, CURLOPT_HEADER => false, CURLOPT_FAILONERROR => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_TIMEOUT => 600);
    curl_setopt_array($curl, $options);
开发者ID:ninetian,项目名称:omk-server,代码行数:31,代码来源:downloader.daemon.php

示例4: cron_callback

        if (substr($onecron["url"], 0, 7) == "http://" || substr($onecron["url"], 0, 8) == "https://") {
            if (strpos($onecron["url"], "?") !== false) {
                $onecron["url"] .= "&action=transcoder_cron&app_key=" . $onecron['clientkey'];
            } else {
                $onecron["url"] .= "?action=transcoder_cron&app_key=" . $onecron['clientkey'];
            }
            $urllist[] = array("url" => $onecron["url"], "uid" => $onecron["uid"]);
        }
    }
    if (empty($urllist)) {
        // nothing to do :
        sleep(60);
        // Let's try again in a minute
        continue;
    }
    $api->log(LOG_INFO, "Launching " . count($urllist) . " cron calls");
    // cron_callback($url, $content, $curlobj) will be called at the end of each http call.
    $cron->rolling_curl($urllist, "cron_callback");
}
// while true
function cron_callback($url, $content, $curl)
{
    global $cron, $api;
    $api->log(LOG_DEBUG, "return from cron call for url " . implode(":", $url) . " has http_code " . $curl["http_code"]);
    if (empty($url["uid"])) {
        return;
    }
    // not normal...
    if ($curl["http_code"] == 200) {
        $cron->cronCallOk($url["uid"]);
    } else {
开发者ID:ninetian,项目名称:omk-server,代码行数:31,代码来源:cron.daemon.php

示例5: sleep

    }
    echo "oups";
}
pcntl_signal(SIGTERM, "sig_handler");
pcntl_signal(SIGHUP, "sig_handler");
pcntl_signal(SIGINT, "sig_handler");
pcntl_signal(SIGQUIT, "sig_handler");
while (true) {
    // Cleanup daemons from this host
    $api->cleanupQueueLocks();
    // Search for a task
    $task = $api->getQueuedTaskLock(TASK_DO_METADATA);
    if (!$task) {
        // we sleep for a little while, thanks to that, we can launch that process as soon as we want:
        // it will still do *nothing* for a little while when there is nothing to do ;)
        $api->log(LOG_DEBUG, "Nothing to do, sleeping...");
        sleep(60);
        continue;
    }
    // Get the task's parameters */
    $params = unserialize($task["params"]);
    $media = $api->mediaSearch(array("id" => $task["mediaid"]));
    if (!$media) {
        $api->log(LOG_CRIT, "Got task '" . $task["id"] . "' but media '" . $task["mediaid"] . "' not found!!");
        $api->setTaskFailedUnlock($task["id"]);
        continue;
    }
    $media = $media[0];
    $api->me = Users::get($task["user"]);
    $adapterObject = $api->getAdapter($media["adapter"]);
    if (!$adapterObject) {
开发者ID:ninetian,项目名称:omk-server,代码行数:31,代码来源:metadata.daemon.php

示例6: sleep

    echo "oups";
}
pcntl_signal(SIGTERM, "sig_handler");
pcntl_signal(SIGHUP, "sig_handler");
pcntl_signal(SIGINT, "sig_handler");
pcntl_signal(SIGQUIT, "sig_handler");
$all_settings = $api->getAllSettings();
while (true) {
    // Cleanup daemons from this host
    $api->cleanupQueueLocks();
    // Search for a task
    $task = $api->getQueuedTaskLock(TASK_DO_TRANSCODE);
    if (!$task) {
        // we sleep for a little while, thanks to that, we can launch that process as soon as we want:
        // it will still do *nothing* for a little while when there is nothing to do ;)
        $api->log(LOG_DEBUG, "Nothing to do, sleeping...");
        sleep(60);
        continue;
    }
    // Get the task's parameters */
    $params = $task["params"];
    $media = $api->mediaSearch(array("id" => $task["mediaid"]));
    if (!$media) {
        $api->log(LOG_CRIT, "Got task '" . $task["id"] . "' but media '" . $task["mediaid"] . "' not found!!");
        $api->setTaskFailedUnlock($task["id"]);
        continue;
    }
    $media = $media[0];
    $transcode = $api->transcodeSearch(array("id" => $params["transcode"]));
    $api->log(LOG_DEBUG, "Transcode search '" . $params["transcode"] . "' returns '" . print_r($transcode, 1) . "'");
    if (!$transcode) {
开发者ID:ninetian,项目名称:omk-server,代码行数:31,代码来源:transcoder.daemon.php

示例7: exit

    exit(1);
}
require_once __DIR__ . '/../../common.php';
require_once MODULES . '/api/libs/api.php';
$useragent = "OpenMediaKit-Transcoder/" . OMKT_VERSION . " (Download Daemon)";
$api = new Api();
$api->log_caller = "dummy-download-daemon";
while (true) {
    // Cleanup daemons from this host
    $api->cleanupQueueLocks();
    // Search for a task
    $task = $api->getQueuedTaskLock(TASK_DOWNLOAD, "dummy");
    if (!$task) {
        // we sleep for a little while, thanks to that, we can launch that process as soon as we want:
        // it will still do *nothing* for a little while when there is nothing to do ;)
        $api->log(LOG_DEBUG, "Nothing to do, sleeping...");
        sleep(60);
        continue;
    }
    $media = $api->mediaSearch(array("id" => $task["mediaid"]));
    if (!$media) {
        $api->log(LOG_CRIT, "got task '" . $task["id"] . "' but media '" . $task["mediaid"] . "' not found");
        $api->setTaskFailedUnlock($task["id"]);
        continue;
    }
    $media = $media[0];
    // ok, we try to download the file, with curl, with timeout and range management
    $curl = curl_init();
    $options = array(CURLOPT_USERAGENT => $useragent, CURLOPT_HEADER => false, CURLOPT_FAILONERROR => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_TIMEOUT => 600);
    curl_setopt_array($curl, $options);
    curl_setopt($curl, CURLOPT_URL, $task["params"]["url"]);
开发者ID:ninetian,项目名称:omk-server,代码行数:31,代码来源:daemon.php


注:本文中的Api::log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。