예제 #1
0
function printMonths($areaUrlString, array $rooms, $roomUrlString, $year, $month, $day, $selected, $selectedType)
{
    /* New overview of dates */
    /*
    	This one will display
    	- current month and the 2 next months
    	- Links to switch months
    	
    	Current month is set by the date currently selected
    */
    echo '<table><tr><td style="border: 1px solid black;">' . chr(10);
    printMonth($areaUrlString, $rooms, $roomUrlString, $year, $month, $selected, $selectedType);
    echo '</td><td style="border: 1px solid black;">' . chr(10);
    printMonth($areaUrlString, $rooms, $roomUrlString, $year, $month + 1, 0);
    echo '</td><td style="border: 1px solid black;">' . chr(10);
    printMonth($areaUrlString, $rooms, $roomUrlString, $year, $month + 2, 0);
    echo '</td></tr></table>' . chr(10);
}
예제 #2
0
     $day = date('d');
 }
 // printMonth ($year, $month, $theSelectedDay/Week/Month, $selectedType)
 if (!isset($selectedType)) {
     $selectedType = 'day';
     $selected = $day;
 }
 if (!isset($selected)) {
     $selected = 0;
 }
 echo '<table><tr><td style="border: 1px solid black;">' . chr(10);
 printMonth($year, $month, $selected, $selectedType);
 echo '</td><td style="border: 1px solid black;">' . chr(10);
 printMonth($year, $month + 1, 0);
 echo '</td><td style="border: 1px solid black;">' . chr(10);
 printMonth($year, $month + 2, 0);
 echo '</td></tr></table>' . chr(10);
 /* The old overview */
 /*
 echo "<style>";
 echo ".trail_td1{";
 echo "text-align:center; border-bottom-style:solid;border-bottom-width:1px;";
 echo "border-right-style:solid;border-right-width:1px";
 echo "}";
 echo ".trail_td2{";
 echo "border-left-style:solid;border-left-width:1px;";
 echo "border-top-style:solid;border-top-width:1px;";
 echo "text-align:center; border-bottom-style:solid;border-bottom-width:1px;";
 echo "border-right-style:solid;border-right-width:1px";
 echo "}";
 echo "</style>";
예제 #3
0
function blog2FB2($task)
{
    global $db_conn, $rootdir;
    foreach ($task as $parameters) {
        updateTaskStatus($parameters["id"], 3);
        // Setting path for FB2 files
        // Permissions for this directory must be set to 777
        if (!file_exists($rootdir . "/books/" . $parameters["id"])) {
            mkdir($rootdir . "/books/" . $parameters["id"]);
        }
        $fpath = $rootdir . "/books/" . $parameters["id"] . "/" . $parameters["name"] . ".fb2";
        // Creating a new file with an XMLWriter instance
        $fb2 = new XMLWriter();
        $fb2->openURI($fpath);
        $fb2->setIndent(true);
        $fb2->setIndentString("\t");
        $fb2->startDocument('1.0', 'windows-1251');
        // Writing annotation
        writeAnnotation($fb2, $parameters["site"], $parameters["author_id"], $parameters["name"], $parameters["real_name"], $parameters["real_surname"]);
        $sth = $db_conn->prepare("SELECT YEAR(min(time)),YEAR(max(time)) FROM gmj_posts WHERE site='" . $parameters["site"] . "' AND author='" . $parameters["author_id"] . "'");
        $sth->execute();
        $years = $sth->fetchAll(PDO::FETCH_ASSOC);
        // Setting parameters of image selection
        if ($parameters["images"] == 1) {
            $images = ",image";
        } else {
            $images = "";
        }
        // Selecting posts from the DB
        for ($i = $years[0]["YEAR(min(time))"]; $i <= $years[0]["YEAR(max(time))"]; $i++) {
            // Gettings posts for a specific year $i
            $sth = $db_conn->prepare("SELECT id,title,post,time" . $images . " FROM gmj_posts WHERE site='" . $parameters["site"] . "' AND author='" . $parameters["author_id"] . "' AND LEFT(time,4)=" . $i . " ORDER BY id ASC");
            $sth->execute();
            $posts = $sth->fetchAll(PDO::FETCH_ASSOC);
            if ($posts) {
                $lastElement = end($posts);
                $lastElement = $lastElement["id"];
                $old_month = "";
                // Writing an opening section for a year
                $fb2->startElement('section');
                $fb2->startElement('title');
                $fb2->writeRaw('<p>' . $i . '</p>');
                $fb2->endElement();
                foreach ($posts as $post) {
                    $month = substr($post["time"], 5, 2);
                    $message = preg_replace('/(<br \\/>)+$/', '', $post["post"]);
                    $message = preg_replace('#(<br />)+#i', '</p>
					<p>', $message);
                    $message = str_replace('&nbsp;', ' ', $message);
                    // Removing links
                    //$pattern = "/[a-zA-Z]*[:\/\/]*[A-Za-z0-9\-_]+\.+[A-Za-z0-9\.\/%&=\?\-_]+/i";
                    //$replacement = "[ссылка удалена]";
                    //$message = preg_replace($pattern, $replacement, $message);
                    if ($month != $old_month) {
                        // Writing  an closing section for a previous month, if needed
                        if (current($post) != $posts[0]["id"]) {
                            $fb2->endElement();
                        }
                        // Writing  an opening section for a new month
                        $fb2->startElement('section');
                        $fb2->startElement('title');
                        $fb2->writeRaw('<p>' . printMonth($month) . '</p>');
                        $fb2->endElement();
                    }
                    // Writing post date
                    $fb2->startElement('subtitle');
                    $fb2->writeAttribute('id', $post["id"]);
                    $fb2->text(rus_date("j F, l. H:i", strtotime($post["time"])));
                    $fb2->endElement();
                    $fb2->startElement('p');
                    // Writing post title
                    if ($post["title"]) {
                        $fb2->writeRaw('<strong>' . $post["title"] . '</strong> ');
                    }
                    // Writing post itself
                    $fb2->writeRaw($message);
                    $fb2->endElement();
                    // Including reference to an image, if any
                    if ($parameters["images"] == 1 && $post["image"] != 0) {
                        if ($post["image"] == 2) {
                            $ext = "jpg";
                        }
                        if ($post["image"] == 3) {
                            $ext = "png";
                        }
                        if (isset($ext)) {
                            $fb2->startElement('image');
                            $fb2->writeAttribute('xlink:href', '#image' . $post["id"] . '.' . $ext);
                            $fb2->endElement();
                        }
                    }
                    if (current($post) == $lastElement) {
                        // </section> for month
                        $fb2->endElement();
                        // </section> for year
                        $fb2->endElement();
                        if ($i == $years[0]["YEAR(max(time))"]) {
                            // </section> for main section
                            $fb2->endElement();
                            // </body>
                            $fb2->endElement();
                        }
                    } else {
                        $old_month = $month;
                    }
                    $db_conn->exec("UPDATE gmj_posts SET post_in_book='1' WHERE id='" . $post["id"] . "' AND site='" . $parameters["site"] . "'");
                }
            }
        }
        if ($parameters["images"] == 0) {
            // </FictionBook>
            $fb2->endElement();
            // Closing the document
            $fb2->endDocument();
        }
        // Flushing buffer
        $fb2->flush();
        // Updating posts counter and status
        $sth = $db_conn->prepare("SELECT COUNT(*) FROM gmj_posts WHERE author='" . $parameters["author_id"] . "' AND site='" . $parameters["site"] . "' AND post_in_book='1'");
        $sth->execute();
        $postsCount = $sth->fetchColumn();
        $db_conn->exec("UPDATE gmj_tasks SET posts_count='" . $postsCount . "', status='4' WHERE id='" . $parameters["id"] . "'");
    }
}
예제 #4
0
        <td>&nbsp;</td>
      </tr>
      <tr>
        <th>Oct</th><?php 
printMonth($year[9]);
?>
      </tr>
      <tr>
        <th>Nov</th><?php 
printMonth($year[10]);
?>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <th>Dec</th><?php 
printMonth($year[11]);
?>
      </tr>
    </table>
    <div class="panel-footer">You found a geocache on <?php 
echo $total;
?>
 of 365 days (<?php 
echo round($total / 365 * 100, 2);
?>
%).</div>
  </div>
<?php 
function removeFoundDates($month)
{
    foreach (array_keys($month, '-1') as $key) {