Example #1
0
function upd($link)
{
    $row_imp = @$_POST['row_imp'];
    //echo $row_imp;
    //$info = magicquotes_check($_POST['info'], 1); // addslashes
    $info = $_POST['info'];
    $pst_dt = $_POST['dt'];
    if (!isset($info) or !isset($pst_dt)) {
        exit;
    }
    $dt_pst_dt = formatmydate($pst_dt, 1);
    $r_dateinfo = $link->prepare("SELECT id FROM diary_main WHERE d=?");
    $r_dateinfo->execute(array((string) $pst_dt));
    $dy1 = date("D", strtotime($pst_dt));
    $iscurwk = isCurWk($pst_dt);
    //$nm_dateinfo = $r_dateinfo->rowCount();
    $str = '';
    // Check if entry exists for date
    if ($r_dateinfo->rowCount() == 0) {
        // Entry for date does not exist
        $ins_date = date('Y-m-d H:i:s', h99());
        // Date does not exist in database - create a row for it
        $r_ins = $link->prepare("INSERT INTO diary_main (d, info, ins_date) VALUES (?, '', ?)");
        $r_ins->execute(array((string) $pst_dt, (string) $ins_date));
        // Keep a text record of diary entries
        $file_path2 = "../temp/{$pst_dt}" . '_' . time() . '.php';
        $fp2 = fopen($file_path2, 'w');
        $write_file2 = fwrite($fp2, '');
        fclose($fp2);
        if (!$r_ins->rowCount()) {
            $str .= '<span class="updfail">The entry for ' . "{$dt_pst_dt} could not be CREATED at {$ins_date} </span>";
            exit;
            //} else {
        }
    }
    // End if.
    // Update existing row
    $ch_date = date('Y-m-d H:i:s', h99());
    // Get the number of edits:
    $r_nme = $link->prepare("SELECT numedit FROM diary_main WHERE d=?");
    $r_nme->execute(array((string) $pst_dt));
    $rw = $r_nme->fetch(PDO::FETCH_NUM);
    $nme = $rw[0] + 1;
    $r_upd = $link->prepare("UPDATE diary_main SET info=?, important=?, ch_date=?, numedit=? where d=?");
    $r_upd->execute(array((string) $info, (int) $row_imp, (string) $ch_date, (int) $nme, (string) $pst_dt));
    // Keep a text 'snapshot' record of updated diary entries
    list($uy, $um, $ud) = explode('-', $pst_dt);
    $uym = "{$uy}-{$um}";
    if (!is_dir("../temp/{$uym}")) {
        mkdir("../temp/{$uym}");
    }
    if (!is_dir("../temp/{$uym}/{$ud}")) {
        mkdir("../temp/{$uym}/{$ud}");
    }
    $file_path2 = "../temp/{$uym}/{$ud}/" . time() . '.txt';
    $fp2 = fopen($file_path2, 'w');
    $write_file2 = fwrite($fp2, stripslashes($info));
    fclose($fp2);
    if ($r_upd->rowCount() == 1) {
        // Record updated
        if (isset($r_ins)) {
            // New record created
            echo "<span class=\"updsuccess\">The entry for {$dt_pst_dt} was CREATED at " . formatmydate($ins_date, 0) . "</span>|{$ins_date}|None";
        } else {
            $str .= "<span class=\"updsuccess\">The entry for {$dt_pst_dt} was UPDATED at " . formatmydate($ch_date, 0) . "</span>|{$ch_date}";
        }
        // End if.
    } else {
        $str .= '<span class="updfail">RECORD WAS NOT UPDATED</span>';
    }
    // End if.
    $str .= "|{$pst_dt}|{$dy1}|{$iscurwk}";
    echo $str;
}
Example #2
0
function helpcal($link, $i, $subsequentrowcellcounter, $subseq = 0)
{
    global $tootipchars, $arr_d, $colspan_1;
    $full_date = "{$_GET['y']}-" . sing_num($_GET['m']) . '-' . sing_num($i);
    $full_date2 = date('l jS F, Y', strtotime($full_date));
    $popuptxt = get_info($link, $full_date, $tootipchars);
    if (strlen($popuptxt) > 0) {
        $popuptxt2 = '<div class=&quot;date_s&quot;>' . "{$full_date2}<br />[" . days_from_days_to($full_date) . "]</div>\r\n      <p>{$popuptxt}</p>";
        $tdclass = 'three_col';
    } else {
        // No entry
        $popuptxt2 = '';
        $tdclass = 'four_col';
    }
    // End if.
    $str = '';
    if ($subseq and $subsequentrowcellcounter > 6) {
        $subsequentrowcellcounter = $subsequentrowcellcounter % 7;
    }
    if (date("j") == $i and date("n") == $_GET['m'] and date("Y") == $_GET['y']) {
        // Highlight current date
        $str .= writetdcell('curDate', $popuptxt2, $full_date, $arr_d[$subsequentrowcellcounter], 1, $i);
    } else {
        if (isset($_GET['d']) and $_GET['d'] == $i) {
            // Selected day that is not the current day:
            $str .= writetdcell('sel_col', $popuptxt2, $full_date, $arr_d[$subsequentrowcellcounter], isCurWk($full_date), $i);
        } else {
            //
            $str .= writetdcell($tdclass, $popuptxt2, $full_date, $arr_d[$subsequentrowcellcounter], isCurWk($full_date), $i);
        }
    }
    // End if.
    return $str;
}