MyBBDepo - Türkiyenin MyBB Deposu Forumuna Hoşgeldiniz
Eğer sitemize yaptığınız ilk ziyaretiniz ise, lütfen öncelikle Forum Kurallarını okuyunuz. Forumumuzda bilgi alışverişinde bulunabilmeniz için Kayıt olmalısınız. Üye olmayanlar forumumuzdan yararlanamazlar.
Eğer zaten kayıtlı kullanıcı iseniz, lütfen kullanıcı adınız ve şifreniz ile, Giriş yapınız. (Sitemize üyelik ücretsizdir).
üyelikj avatar
Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5

Derecelendirme: 0/5 - 0 oy

Mybb Mobil Tema Sorunu ve Bildirim Sorunu


Sponsor Reklam

Çevrimdışı üyelikj
 Tarih: 23-03-2015, Saat:18:12
#7
Kod:
<?php
/**
* MyBB 1.6
* Copyright 2010 MyBB Group, All Rights Reserved
*
* Website: http://mybb.com
* License: http://mybb.com/about/license
*
* $Id: functions_task.php 5297 2010-12-28 22:01:14Z Tomm $
*/

/**
* Execute a scheduled task.
*
* @param int The task ID. If none specified, the next task due to be ran is executed
* @return boolean True if successful, false on failure
*/
function run_task($tid=0)
{
    global $db, $mybb, $cache, $plugins, $task, $lang;

    // Run a specific task
    if($tid > 0)
    {
        $query = $db->simple_select("tasks", "*", "tid='{$tid}'");
        $task = $db->fetch_array($query);
    }

    // Run the next task due to be run
    else
    {
        $query = $db->simple_select("tasks", "*", "enabled=1 AND nextrun<='".TIME_NOW."'", array("order_by" => "nextrun", "order_dir" => "asc", "limit" => 1));
        $task = $db->fetch_array($query);
    }

    // No task? Return
    if(!$task['tid'])
    {
        $cache->update_tasks();
        return false;
    }

    // Is this task still running and locked less than 5 minutes ago? Well don't run it now - clearly it isn't broken!
    if($task['locked'] != 0 && $task['locked'] > TIME_NOW-300)
    {
        $cache->update_tasks();
        return false;
    }
    // Lock it! It' mine, all mine!
    else
    {
        $db->update_query("tasks", array("locked" => TIME_NOW), "tid='{$task['tid']}'");
    }

    // The task file does not exist
    if(!file_exists(MYBB_ROOT."inc/tasks/{$task['file']}.php"))
    {
        if($task['logging'] == 1)
        {
            add_task_log($task, $lang->missing_task);
        }
        $cache->update_tasks();
        return false;
    }
    // Run the task
    else
    {
        // Update the nextrun time now, so if the task causes a fatal error, it doesn't get stuck first in the queue
        $nextrun = fetch_next_run($task);
        $db->update_query("tasks", array("nextrun" => $nextrun), "tid='{$task['tid']}'");
        
        include_once MYBB_ROOT."inc/tasks/{$task['file']}.php";
        $function = "task_{$task['file']}";
        if(function_exists($function))
        {
            $function($task);
        }
    }

    $updated_task = array(
        "lastrun" => TIME_NOW,
        "locked" => 0
    );
    $db->update_query("tasks", $updated_task, "tid='{$task['tid']}'");

    $cache->update_tasks();

    return true;
}

/**
* Adds information to the scheduled task log.
*
* @param int The task array to create the log entry for
* @param string The message to log
*/
function add_task_log($task, $message)
{
    global $db;
    
    if(!$task['logging'])
    {
        return;    
    }
    
    $log_entry = array(
        "tid" => intval($task['tid']),
        "dateline" => TIME_NOW,
        "data" => $db->escape_string($message)
    );
    $db->insert_query("tasklog", $log_entry);
}

/**
* Generate the next run time for a particular task.
*
* @param array The task array as fetched from the database.
* @return int The next run time as a UNIX timestamp
*/
function fetch_next_run($task)
{
    $time = TIME_NOW;
    $next_minute = $current_minute = date("i", $time);
    $next_hour = $current_hour = date("H", $time);
    $next_day = $current_day = date("d", $time);
    $next_weekday = $current_weekday = date("w", $time);
    $next_month = $current_month = date("m", $time);
    $next_year = $current_year = date("Y", $time);

    if($task['minute'] == "*")
    {
        ++$next_minute;
        if($next_minute > 59)
        {
            $reset_hour = 1;
            $next_minute = 0;
        }
    }
    else
    {
        if(build_next_run_bit($task['minute'], $current_minute) != false)
        {
            $next_minute = build_next_run_bit($task['minute'], $current_minute);
        }
        else
        {
            $next_minute = fetch_first_run_time($task['minute']);
        }
        if($next_minute <= $current_minute)
        {
            $reset_hour = 1;
        }
    }

    if($reset_hour || !run_time_exists($task['hour'], $current_hour))
    {
        if($task['hour'] == "*")
        {
            ++$next_hour;
            if($next_hour > 23)
            {
                $reset_day = 1;
                $next_hour = 0;
            }
        }
        else
        {
            if(build_next_run_bit($task['hour'], $current_hour) != false)
            {
                $next_hour = build_next_run_bit($task['hour'], $current_hour);
            }
            else
            {
                $next_hour = fetch_first_run_time($task['hour']);
                $reset_day = 1;
            }
            if($next_hour < $current_hour)
            {
                $reset_day = 1;
            }
        }
        $next_minute = fetch_first_run_time($task['minute']);
    }

    if($reset_day || ($task['weekday'] == "*" && !run_time_exists($task['day'], $current_day) || $task['day'] == "*" && !run_time_exists($task['weekday'], $current_weekday)))
    {
        if($task['weekday'] == "*")
        {
            if($task['day'] == "*")
            {
                ++$next_day;
                if($next_day > date("t", $time))
                {
                    $reset_month = 1;
                    $next_day = 1;
                }
            }
            else
            {
                if(build_next_run_bit($task['day'], $current_day) != false)
                {
                    $next_day = build_next_run_bit($task['day'], $current_day);
                }
                else
                {
                    $next_day = fetch_first_run_time($task['day']);
                    $reset_month = 1;
                }
                if($next_day < $current_day)
                {
                    $reset_month = 1;
                }
            }
        }
        else
        {
            if(build_next_run_bit($task['weekday'], $current_weekday) != false)
            {
                $next_weekday = build_next_run_bit($task['weekday'], $current_weekday);
            }
            else
            {
                $next_weekday = fetch_first_run_time($task['weekday']);
            }
            $next_day = $current_day + ($next_weekday-$current_weekday);
            if($next_day <= $current_day)
            {
                $next_day += 7;
            }

            if($next_day > date("t", $time))
            {
                $reset_month = 1;
            }
        }
        $next_minute = fetch_first_run_time($task['minute']);
        $next_hour = fetch_first_run_time($task['hour']);
        if($next_day == $current_day && $next_hour < $current_hour)
        {
            $reset_month = 1;
        }
    }

    if($reset_month || !run_time_exists($task['month'], $current_month))
    {
        if($task['month'] == "*")
        {
            $next_month++;
            if($next_month > 12)
            {
                $reset_year = 1;
                $next_month = 1;
            }
        }
        else
        {
            if(build_next_run_bit($task['month'], $current_month) != false)
            {
                $next_month = build_next_run_bit($task['month'], $current_month);
            }
            else
            {
                $next_month = fetch_first_run_time($task['month']);
                $reset_year = 1;
            }
            if($next_month < $current_month)
            {
                $reset_year = 1;
            }
        }
        $next_minute = fetch_first_run_time($task['minute']);
        $next_hour = fetch_first_run_time($task['hour']);
        if($task['weekday'] == "*")
        {
            $next_day = fetch_first_run_time($task['day']);
            if($next_day == 0) $next_day = 1;
        }
        else
        {
            $next_weekday = fetch_first_run_time($task['weekday']);
            $new_weekday = date("w", mktime($next_hour, $next_minute, 0, $next_month, 1, $next_year));
            $next_day = 1 + ($next_weekday-$new_weekday);
            if($next_weekday < $new_weekday)
            {
                $next_day += 7;
            }
        }
        if($next_month == $current_month && $next_day == $current_day && $new_hour < $current_hour)
        {
            $reset_year = 1;
        }
    }

    if($reset_year)
    {
        $next_year++;
        $next_minute = fetch_first_run_time($task['minute']);
        $next_hour = fetch_first_run_time($task['hour']);
        $next_month = fetch_first_run_time($task['month']);
        if($next_month == 0) $next_month = 1;
        if($task['weekday'] == "*")
        {
            $next_day = fetch_first_run_time($task['day']);
            if($next_day == 0) $next_day = 1;
        }
        else
        {
            $next_weekday = fetch_first_run_time($task['weekday']);
            $new_weekday = date("w", mktime($next_hour, $next_minute, 0, $next_month, 1, $next_year));
            $next_day = 1 + ($next_weekday-$new_weekday);
            if($next_weekday < $new_weekday)
            {
                $next_day += 7;
            }
        }
    }
    return mktime($next_hour, $next_minute, 0, $next_month, $next_day, $next_year);
}

/**
* Builds the next run time bit for a particular item (day, hour, month etc). Used by fetch_next_run().
*
* @param string A string containing the run timse for this particular item
* @param int The current value (be it current day etc)
* @return int The new or found value
*/
function build_next_run_bit($data, $bit)
{
    if($data == "*") return $bit;
    $data = explode(",", $data);
    foreach($data as $thing)
    {
        if($thing > $bit)
        {
            return $thing;
        }
    }
    return false;
}

/**
* Fetches the fist run bit for a particular item (day, hour, month etc). Used by fetch_next_run().
*
* @param string A string containing the run times for this particular item
* @return int The first run time
*/
function fetch_first_run_time($data)
{
    if($data == "*") return "0";
    $data = explode(",", $data);
    return $data[0];
}

/**
* Checks if a specific run time exists for a particular item (day, hour, month etc). Used by fetch_next_run().
*
* @param string A string containing the run times for this particular item
* @param int The bit we're checking for
* @return boolean True if it exists, false if it does not
*/
function run_time_exists($data, $bit)
{
    if($data == "*") return true;
    $data = explode(",", $data);
    if(in_array($bit, $data))
    {
        return true;
    }
    return false;
}
?>
Cevapla
Bunu Beğenenler:

 


Bu Konudaki Yorumlar
Mybb Mobil Tema Sorunu ve Bildirim Sorunu - Yazar: üyelikj - 21-03-2015, Saat:00:11
Cvp: Mybb Mobil Tema Sorunu ve Bildirim Sorunu - Yazar: Screwy - 21-03-2015, Saat:11:55
Cvp: Mybb Mobil Tema Sorunu ve Bildirim Sorunu - Yazar: Bloody - 23-03-2015, Saat:17:24
Cvp: Mybb Mobil Tema Sorunu ve Bildirim Sorunu - Yazar: üyelikj - 23-03-2015, Saat:18:12
Cvp: Mybb Mobil Tema Sorunu ve Bildirim Sorunu - Yazar: Bloody - 23-03-2015, Saat:19:28

Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  imza sorunu slckyel 0 3,873 22-01-2021, Saat:23:08
Son Yorum: slckyel
  MyBB Error (44) -Yardımcı Olabilir misiniz? glamours 0 1,538 18-01-2021, Saat:13:01
Son Yorum: glamours
  MyBB SSL Hatası Alıyorum . xGhos 3 4,418 17-04-2020, Saat:23:16
Son Yorum: YHancerTR
  Mybb Yukleme Sorunu babaf 1 2,483 18-06-2019, Saat:11:13
Son Yorum: eniyilerde
Öneri - Fikir [1.6] Merhaba Mybb 1.6 surumden en son surum hakkinda ! SERHATST 5 2,929 20-02-2019, Saat:21:30
Son Yorum: SERHATST



Konuyu Okuyanlar: 1 Ziyaretçi

istanbul escort - beşiktaş escort - şişli escort - ataköy escort - ataköy escort - taksim escort - escort mecidiyeköy - çapa escort - topkapı escort

escort - sex hikaye - altyazılı porno - türk ifşa - türk porno - escort bayan