search
HomeBackend DevelopmentPHP Tutorialphp nine palace grid log

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


Statement
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
PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

How to make PHP applications fasterHow to make PHP applications fasterMay 12, 2025 am 12:12 AM

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

PHP Performance Optimization Checklist: Improve Speed NowPHP Performance Optimization Checklist: Improve Speed NowMay 12, 2025 am 12:07 AM

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

PHP Dependency Injection: Improve Code TestabilityPHP Dependency Injection: Improve Code TestabilityMay 12, 2025 am 12:03 AM

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

PHP Performance Optimization: Database Query OptimizationPHP Performance Optimization: Database Query OptimizationMay 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.