Discuz! 5. PHP code highlighting plug-in (updated by dancers in the dark) _ PHP Tutorial

Source: Internet
Author: User
Discuz! 5. PHP code highlighting plug-in (updated by dancers in the dark ). Discuz! 5.0 forum display style php code highlight plug-in, the php code syntax coloring, like PHP comrades can easily read the code. Added the html code running function. This discuz! 5.0 forum display style php code highlighting plug-in,
Make the php code syntax coloring. comrades who like PHP can easily read the code.
Added the html code running function.
This plug-in was released by a previous comrade Discuz! 4. the php code is highlighted and the modification is complete.
In addition, my php learning has been stuck,
Hope someone can help me out of the learning difficulties of php
My QQ: 5642382. My QQ group: 2577162

Function: when posting a post, use the [php] php code [/php] Mark to highlight the php code,
Use the [runcode] Html code [/runcode] Mark to run HTML code (running non-server on the client ).

To add a plug-in, follow these steps:
1. modify include/common. js
Search
Function copycode (obj ){
Var rng = document. body. createTextRange ();
Rng. moveToElementText (obj );
Rng. scrollIntoView ();
Rng. select ();
Rng.exe cCommand ("Copy ");
Rng. collapse (false );
}
Add the following at the end of the function:


[Copy to clipboard] [-] CODE:
Function runCode (obj ){
Var winname = window. open (''," _ blank ",'');
Winname.doc ument. open ('text/html ', 'replace ');
Winname.doc ument. writeln (obj. value );
Winname.doc ument. close ();
}

Function saveCode (obj ){
Var winname = window. open ('', '_ blank', 'Top = 10000 ');
Winname.doc ument. open ('text/html ', 'replace ');
Winname.doc ument. writeln (obj. value );
Winname.document.execcommand('saveas', '', 'code.htm ');
Winname. close ();
}
2. modify include/discuzcode. func. php
Search


[Copy to clipboard] [-] CODE:
$ Discuzcodes ['codecs'] ++;
Return "[\ tDISCUZ_CODE _ $ discuzcodes [pcodecount] \ t]";
}
(Note: You can also use Editplus to directly find the 110th lines of code to add the following code)
Continue to add below:


/------- Add [runcode] Html code [/runcode] to run Html code
Function runcodedisp ($ code ){
Global $ discuzcodes;
$ Discuzcodes ['pcodecount'] ++;
$ Code = htmlspecialchars (str_replace ('\ "', '"', preg_replace ("/^ [\ n \ r] * (. + ?) [\ N \ r] * $/is "," \ 1 ", $ code )));
$ Discuzcodes ['codehtml'] [$ discuzcodes ['pcodecount'] ="

$ Code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.