改进php日历脚本,平日不显示

时间:2019-06-28 04:59:54

标签: php

我从互联网上获得了此日历脚本,但结果仅显示日期编号,而不显示工作日和图像。 脚本导出为pdf文件

上传表单没有,但是在PHP中是即时消息,所以任何人都可以帮助我修复它。

非常感谢您!

<?php
      set_time_limit( 120 );                                                                          
      require('../fpdf/fpdf.php');                                                                    

      $month = date("n");       
      $year = date("Y");    
      $imageurl = isset( $HTTP_POST_VARS["imageurl"] ) ? $HTTP_POST_VARS["imageurl"] : "";        

      if (isset( $HTTP_POST_FILES['imagefile']['tmp_name'] )) $imageurl = $HTTP_POST_FILES['imagefile']['tmp_name'];     
      $thetime = mktime( 1, 0, 0, $month, 15, $year );                                                
      $titlestring = date( "F Y", $thetime );                                                         
      $daysinmonth = date( "t", $thetime);                                                            
      $numweeks = WeeksInMonth( $month, $year );                                                      
      $cellheight = $cellwidth = 2;                                                                   
      $x = (21.59 - 7*$cellwidth) / 2;                                                                
      $y = 26.94 - ($numweeks * $cellheight);

      $pdf=new FPDF( "P", "cm", "Letter" );                                                           
      $pdf->SetCreator("Jeff Lee's PDF Calendar Creator");                                            
      $pdf->SetTitle($titlestring);                                                                   
      $pdf->AddPage();                                                                                
      $pdf->SetLineWidth(0.02);                                                                       
      $pdf->AddFont("PalatinoLinotype-Roman", "", "pala.php");                                        
      $pdf->SetFont("PalatinoLinotype-Roman", "", "18" );                                             
      $pdf->SetXY( ((21.59 - $pdf->GetStringWidth($titlestring)) / 2), $y-1 );                       
      $pdf->Cell( 0, 0, $titlestring, 0, 1 );                                                         
      $pdf->SetFillColor( 230 );                                                                      
      $pdf->Rect( $x, $y, $cellwidth, $numweeks*$cellheight, "F" );                                   
      $pdf->Rect( $x+6*$cellwidth, $y, $cellwidth, $numweeks*$cellheight, "F" );                    
      $pdf->Rect( $x, $y, 7*$cellwidth, $numweeks*$cellheight );                                      
      for ($i = 1; $i < 7; $i++) {                                                                    
        $pdf->Line( $x+$i*$cellwidth, $y, $x+$i*$cellwidth, $y+$numweeks*$cellheight );               //   (vertical lines)
        if ($i < $numweeks) $pdf->Line( $x, $y+$i*$cellheight, $x+7*$cellwidth, $y+$i*$cellheight );  //   (horizontal lines)
      }
      $dow = date( "w", mktime( 1, 0, 0, $month, 1, $year ));                                         
      $xpos = $x + 0.05 + $cellwidth * $dow;                                                          
      $ypos = $y + 0.25;                                                                              
      $pdf->SetFontSize( 12 );                                                                        
      for ($i = 1; $i <= $daysinmonth; $i++) {                                                        
        $pdf->SetXY( $xpos, $ypos );                                                                  
        $pdf->Cell( 0, 0, $i, 0, 0 );                                                                 
        $xpos += $cellwidth;                                                                          
        if (++$dow == 7) {                                                                            
          $dow = 0;                                                                                   
          $xpos = $x + 0.05;                                                                          
          $ypos += $cellheight;                                                                       
        }
      }

The result when run script

这是完整代码 https://codepen.io/nguyen-manh/post/photo-calendar

对不起,我的用户不能发布太多代码。

0 个答案:

没有答案