 Okay, five minutes. Okay, thank you for having me here. My name is Zion. Today, I'll be sharing my personal experience on converting dynamic sites to static pages. So supposing if I would release all the events for this meetup, let's say there are 1,000 events, so I will have 1,000 static pages, and if I want to, let's say, one day I'll change the color of the word venue to red color, so I'll change 1,000 files. The other way of doing is I have one file, one dynamic page file event of PHP, and I'll just pass in IDs. The typical PHP code will look like this, I'll connect to a database of SQL query, and I'll just output the HTML, primitive, but it works. So the story goes that in my previous company when I joined, I introduced a Zen framework for web development. The sites that were done by the many developers first before me were coded in plain PHP, HTML. So the primitive code that I mentioned just now, yes, that was all the legacy code that I inherited. So one day, one fine day, the manager who was also the CIS admin, he said, I want to delete all the past data bases. So all the websites that were not done by you, that were in plain PHP, I want to convert the static. So first of all is why we invent a real, let me try out some tools that are out there, but it couldn't really meet my requirements. So I derived my own script. Why? First reason, downwards traverser. Supposing, let's say if I were to go example.com slash event 98, the two will actually eventually go up to event 97 and your crawl 99, 2000, and eventually the whole of example.com, which I don't want. I only want those web pages under event 98. Next one is, I do not want to save the images, CSS or JavaScript. I only want to generate the static web pages. And lastly, because of all the legacy code, sometimes there were some unusual links that the developer may view some agent's links. You click on this final picture and you go to another website. So I will have some code review on this code that I wrote. I'm not going to go through line by line, obviously. Just bring out some things that are of concern. This, let me see here, OK. So I have a function to actually add a link type. And I actually go by tag. So what are the links that are in the HTML document? Normally the A tag, area tag, everything tag, script tag. For A tag, normally I will get the href attribute. Fine. Let's see if I go to the script tag. Script tag, there's no attribute. I'll just get the whole contents. And after that, I'll just use a regular expression to extract out certain URLs like location.href. OK, now let me go on to the main function, which is the invoke. Basically, I use a queue. Every time I come across a link, I'll check. Is it a downward link? Is it? Example, event 98 slash test dot PHP. Yes, it's a downward link. I'll proceed if not, I'll skip. After that, I'll use Kerr to extract the web page. And this is an important part, DOM document. I actually learned that you're not supposed to use regular expression to pass the HTML document. For example, if I come up with a regular expression to actually find all the A tags in the document, it will break. Why? The A tag could be in two lines. The href attribute could be using single code, double code. In the legacy code that inherited, no codes. They didn't use code at all. So sometimes there are spacers and sometimes spelling errors. So you have no idea. Whatever you can write, you will break. So just use the PHP native DOM document. Over here, I will just go through all the register link types. I find I get all the DOM elements by tag name. Then I go through the attribute. So if there's an attribute, let's say like href for source, I will just get the whole value. And then I store it. And I put it into the queue. If not, if it's like a script tag, I will basically get the contents. I'll apply the rejects or something to find the relevant URLs. And finally, I will rename it. When I run the code, I will basically, you also return me something like this. The left hand side, the keys of the array is basically those web pages that I have saved. Those are inside the array. The values are the links that I have found. And finally, the web pages should be saved like this. So instead of one page and 1,000 IDs, I have now 1,000 static web pages that generated. And you'll be reading like this, event underscore id-1.php. Of course, yeah. And that's all. Thank you very much. Any questions? What framework are you using for your slide? Reveal.js. Reveal.js. Yes. Yeah. It's quite cool. I'll just coding HTML. You don't ask me what I use. I use it myself. OK. So basically, it is just an HTML file. And I just include the Reveal.js. And this is just it. Each slide is basically just one section. So some computers have PowerPoints. Some computers have keynotes. But every computer always has a test editor and a browser. So this will work everywhere. I'm really curious about why your assistant wanted to convert dynamic script into static HTML. Very cool question. You go one the other way around, right? Yes, correct. He was quite uptight on security. In fact, actually, he ran our web servers in the office. We have, as developers, we have no access to the command line. We cannot install any software. So talk about ComposerGit. You can forget about it. So his idea was he wanted to reduce the attack area. So the longer that you keep all those partial database and dynamic pages, someone could just enjoy the SQL injection. And many of our legacy websites, all the way from 97, they were actually kind of vulnerable to that. Because it's just primitive code. And sometimes, they don't do any escaping. Sometimes. But when I started using framework, the framework does your all for you. So that was one of his reasons for security reasons. I have a speaker in the group called Guy Henry, who gave this presentation, I think a year or two back. He actually prefers to produce everything into static pages, simply because perform, I mean, from a server standpoint perspective, hosting static stuff is so much more scalable. And especially now with S3 being able to map to a domain or whatever, you can scale it infinitely without having to do anything. So if you can convert whatever that is you're producing into static pages and product and mix it all up. Scaling problems almost disappear. Almost. Sorry? It's only zero mapping. Yeah, exactly. I mean, for certain kind of things, you can do it, not for everything. If you're hosting blogs, you're hosting content, things like that, you can do it. Thank you. Okay, thank you.