Home > Backend Development > PHP Tutorial > php nine palace grid log

php nine palace grid log

WBOY
Release: 2016-07-25 09:01:08
Original
1135 people have browsed it
According to the requirements, text must be written in nine tables, the title can be edited, and weather, background, and expressions can be selected. Finally, a picture is generated, which can be shared and the results can also be stored in the database. github address: 9Diary GitHub
  1. /**
  2. * Add log
  3. * bgid background image
  4. * title log title
  5. * Table title and content are separated into 1, 2, 3, 4, 6, 7, 8, 9 tables with '-|*dt*|-' Information
  6. * Table 5 related: mid_title, emoticons
  7. * Template id: tempid, to be developed
  8. * open: privacy
  9. */
  10. //dump($_POST);
  11. $bgid = intval(htmlspecialchars($_REQUEST['bgid']));
  12. $title = htmlspecialchars($_POST[' title']);
  13. $cnt = str_replace(PHP_EOL, '',$_POST['cnt']);
  14. //Title and content cannot be empty
  15. if (!isset($title) || !isset($cnt )){
  16. echo 'Title and content cannot be empty!';
  17. }
  18. $imgid = intval($_POST['imgId']);
  19. $weatherId = intval($_POST['weatherId']);
  20. $mid_title = htmlspecialchars($_POST['mid_title']);
  21. $cnt_titles = $_POST['cnt_titles'];
  22. $tempId = intval($_POST['tempId']);
  23. $open = intval($_POST['open ']);
  24. //Write image
  25. require_once('AppDiary.class.php');
  26. $image = new AppDiary();
  27. $path = dirname(__FILE__);
  28. $backimage = $path.'/ images/preview/'.$bgid.'.jpg';
  29. $weatherimg = $path.'/images/weather/'.$weatherId.'.gif';
  30. $emoticons_img = $path.'/images/emoticons/ '.$imgid.'.gif';
  31. $contents = explode('-|*dt*|-',$cnt);
  32. $contents_title = explode('-|*dt*|-', $cnt_titles);
  33. $str = array(
  34. array($weatherimg,528,1,61,62),//Weather
  35. array($contents_title[0],35,83,146,28,'cnt'),//Table 1 title
  36. array($contents[0],35,111,160,100,'cnt_titles'),//Table 1 content
  37. array($contents_title[1],222,83,146,28,'cnt'),//Table 2 title
  38. array($contents [1],222,111,160,100,'cnt_titles'),//Table 2 content
  39. array($contents_title[2],407,83,146,28,'cnt'),//Table 3 title
  40. array($contents[2], 407,111,160,100,'cnt_titles'),//Table 3 content
  41. array($contents_title[3],35,244,146,28,'cnt'),//Table 4 title
  42. array($contents[3],35,273,160,100,'cnt_titles') ,//Table 4 content
  43. array($mid_title,240,235,146,38,'mid_title'),//Table 5 title
  44. array($emoticons_img,261,283,80,80),//Table 5 content
  45. array($contents_title[ 4],407,244,146,28,'cnt'),//Table 6 title
  46. array($contents[4],407,273,160,100,'cnt_titles'),//Table 6 content
  47. array($contents_title[5],35,409,146,28 ,'cnt'),//Table 7 title
  48. array($contents[5],35,436,160,100,'cnt_titles'),//Table 7 content
  49. array($contents_title[6],221,409,146,28,'cnt'), //Table 8 title
  50. array($contents[6],221,436,160,100,'cnt_titles'),//Table 8 content
  51. array($contents_title[7],407,409,146,28,'cnt'),//Table 9 title
  52. array($contents[7],407,436,160,100,'cnt_titles'),//Table 9 content
  53. );
  54. //var_dump($str);
  55. $pic = $image->topaste($backimage,$str);
  56. $filename = $path.'/upfile/'.$pic;
  57. //Added a time() mainly to prevent the same file name
  58. $newname = $title.'_'.time().strrchr($ pic, '.');
  59. $newfile = $path.'/upfile/'.$newname;
  60. //This is mainly used for Chinese titles
  61. $newfile = iconv( 'UTF-8', 'GB18030', $newfile );
  62. if (file_exists($filename)){
  63. //Change file name successfully
  64. if (rename($filename,$newfile)){
  65. $pic = $newname;
  66. }
  67. echo json_encode(array('info' =>$pic,'status'=>1));
  68. }else{
  69. //Failed to generate file
  70. echo json_encode(array('info'=>'Error'.$pic,'status'=> ;0));
  71. }
Copy code
php nine palace grid log php nine palace grid log php nine palace grid log


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template