function get_date(&$date, &$day, &$month, &$year)
{
    $date = $_GET['date'];
    $pattern = '/^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])/';
    preg_match($pattern, $date, $matches);
    if (count($matches) != 4) {
        $pattern = '/^([0-9][0-9][0-9][0-9])-([0-9][0-9])/';
        preg_match($pattern, $date, $matches);
        if (count($matches) != 3) {
            get_current_date($date, $day, $month, $year);
            return;
        } else {
            $day = "01";
            $month = $matches[2];
            $year = $matches[1];
        }
    } else {
        $day = $matches[3];
        $month = $matches[2];
        $year = $matches[1];
    }
    if (!checkdate($month, $day, $year)) {
        get_current_date($date, $day, $month, $year);
    }
}
Beispiel #2
0
 function writeLog()
 {
     $date = get_current_date();
     $filename = ROOT_DIR . 'log/log_info' . $date;
     if (!file_exists($filename)) {
         $fp = fopen($filename, "wa");
         fclose($fp);
     }
     $data = get_current_time() . " " . $this->getIp() . " " . $this->getInfo() . PHP_EOL;
     try {
         file_put_contents($filename, $data, FILE_APPEND | LOCK_EX);
     } catch (Exception $ex) {
         print_r("<pre>");
         print_r($ex->getMessage());
         print_r($ex->getTrace());
         print_r("</pre>");
         die;
     }
 }
 function format_date($date = "", $format = "")
 {
     global $Cfg, $current_date, $db;
     if ($format == "") {
         $format = "%day% %monname% '%ye%";
     }
     if ($date == "") {
         $date = date("Y-m-d-H-i", get_current_date());
     }
     list($yr, $mo, $da, $ho, $mi) = split("-", $date);
     $mktime = mktime(1, 1, 1, $mo, $da, $yr);
     $ho12 = $ho > 11 ? $ho - 12 : $ho;
     $ampm = $ho12 == $ho ? "am" : "pm";
     if ($ho12 == 0) {
         $ho12 = 12;
     }
     $format = str_replace("%minute%", $mi, $format);
     $format = str_replace("%hour12%", $ho12, $format);
     $format = str_replace("%ampm%", $ampm, $format);
     $format = str_replace("%hour24%", $ho, $format);
     $format = str_replace("%day%", $da, $format);
     $format = str_replace("%daynum%", @date("w", $mktime), $format);
     $format = str_replace("%dayname%", lang("days", @date("w", $mktime)), $format);
     $format = str_replace("%weekday%", lang("days", @date("w", $mktime)), $format);
     $format = str_replace("%weeknum%", @date("W", $mktime), $format);
     $format = str_replace("%month%", $mo, $format);
     $format = str_replace("%monthname%", lang('months', -1 + $mo), $format);
     $format = str_replace("%monname%", lang('months_abbr', -1 + $mo), $format);
     $format = str_replace("%year%", $yr, $format);
     $format = str_replace("%ye%", substr($yr, 2), $format);
     //debug("format: $date, $format");
     //while not part of 'dates', we also replace %title% with the
     //entry's, suitable for use in filenames
     //				$format=@str_replace("%title%", safe_string($db->entry['title'],TRUE) , $format);
     return $format;
 }
Beispiel #4
0
/**
 * Updates a post.
 *
 * @param string $uid
 * @param string $postid
 * @param string $title
 * @param string $content
 * @param array $categories
 * @return void
 */
function pivot_update_post($uid, $postid, $title, $content, $categories = '')
{
    global $db, $conversion_method, $body_separator;
    $oldentry = $db->read_entry($postid);
    $entry['code'] = $postid;
    $entry['date'] = $oldentry['date'];
    list($pivotintro, $pivotbody) = explode($body_separator, strip_trailing_space(stripslashes($content)));
    $entry['introduction'] = $pivotintro;
    $entry['body'] = $pivotbody;
    $entry['introduction'] = tidy_html($entry['introduction'], TRUE);
    $entry['body'] = tidy_html($entry['body'], TRUE);
    if (empty($categories)) {
        $entry['category'] = $oldentry['category'];
    } else {
        $entry['category'] = $categories;
    }
    $entry['publish_date'] = $oldentry['publish_date'];
    $entry['edit_date'] = date("Y-m-d-H-i", get_current_date());
    $entry['title'] = strip_trailing_space(stripslashes($title));
    $entry['subtitle'] = $oldentry['subtitle'];
    $entry['user'] = $uid;
    $entry['convert_lb'] = $conversion_method;
    $entry['status'] = "publish";
    $entry['allow_comments'] = 1;
    $entry['keywords'] = $oldentry['keywords'];
    $entry['vialink'] = $oldentry['vialink'];
    $entry['viatitle'] = $oldentry['viatitle'];
    $db->set_entry($entry);
    $db->save_entry(TRUE);
    generate_pages($db->entry['code'], TRUE, TRUE, TRUE, FALSE);
}
Beispiel #5
0
function doerror($msg)
{
    global $errors;
    load_cert_data();
    echo "<p>\n";
    echo $msg;
    echo "</p>\n";
    $reqdebug = print_r($_REQUEST, true);
    $errors[get_current_date()] = $reqdebug;
    update_cert_data();
}
Beispiel #6
0
function return_car($connection, $id)
{
    $query = "UPDATE Rental SET status = '2', returnDate = '" . get_current_date() . "' WHERE ID = '" . $id . "';" . "UPDATE Car SET status = '1' FROM Car INNER JOIN Rental ON Car.ID = Rental.carID" . "WHERE Rental.ID = '" . $id . "';";
    $result = mysqli_query($connection, $query);
    if (!$result) {
        return "failure";
    } else {
        return "success";
    }
}
Beispiel #7
0
function timedpublishcheck()
{
    global $serialize_cache, $Cfg, $Paths;
    $temp_db = new db();
    if (isset($Cfg['check_for_timed_publish']) && $Cfg['check_for_timed_publish'] > 0) {
        $amount = $Cfg['check_for_timed_publish'];
    } else {
        $amount = 10;
    }
    $entries = $temp_db->getlist(-$amount, 0, "", "", false, "date");
    $date = date("Y-m-d-H-i", get_current_date());
    $regen = false;
    foreach ($entries as $entry) {
        if ($entry['status'] == "timed") {
            $entry = $temp_db->read_entry($entry['code']);
            if ($entry['publish_date'] <= $date) {
                debug("toggle");
                $entry['date'] = $entry['publish_date'];
                $entry['status'] = "publish";
                $temp_db->set_entry($entry);
                $temp_db->save_entry(TRUE);
                notify_new('entry', $entry);
                $regen = TRUE;
                // 2004/10/17 =*=*= JM
                // can only do this if we know Cfg['search_index'] status...
                if (isset($Cfg)) {
                    // if the global index as they are made var is set - can continue
                    // the rest is copied from 'entrysubmit_screen()' in pv_core.php
                    if ('1' == $Cfg['search_index'] && can_search_cats(cfg_cat_nosearchindex(), $entry['category'])) {
                        include_once 'modules/module_search.php';
                        update_index($temp_db->entry);
                        debug('update search index: ' . $temp_db->entry['code']);
                    }
                }
            }
        }
    }
    if ($regen) {
        buildfrontpage_function();
        return TRUE;
    } else {
        return FALSE;
    }
}