Making This Compatable With Trap17's Php

free web hosting
Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Making This Compatable With Trap17's Php

AlternativeNick
ok, i have a php script that is not compatable with trap17's php (4.4.4) i believe it was made to run on php 5, if anyone could help, id really appreciate it, thanks smile.gif

CODE

<?php
function something($info) {
$script = new mirc_script($info);
$script->highlight();
return $script->get_script();
}
class mirc_script {
private $data = array();
public $chars = array();

// By specifying TRUE for $beautify here you can save a bit a processing time rather than call the beautify method later
public function __construct($script = NULL,$beautify = FALSE) {
if ($beautify && $script !== NULL) {
$this->beautify($script);
} else {
$this->script = $script;
}
}

// Attempt to beautify the script a bit
public function beautify($input = NULL) {
// Beautify the script
$script = ($input === NULL ? $this->script : $input);

// Break apart commands separated by |
$script = preg_replace('/\s+\|\s+/',"\n",$script);

// Put newlines before } and after {
$script = preg_replace('/\s+\}\s*(?:\s|$)/',"\n}\n",$script);
$script = preg_replace('/(?<=\s|^)\{\s+/',"{\n",$script);

// Put () around some if conditions
$script = preg_replace('/(if|elseif|while)\s+([^\(].*?)\s+\{/','\1 (\2) {',$script);
$this->script = $script;
}

public function __set($var,$value) {
$this->data[$var] = $value;

if ($var == 'script') {
if ($value !== NULL) {
$this->split_script();
}
}
}

public function __get($var) {
return $this->data[$var];
}

// Split the script into an array of characters
private function split_script() {
$this->script = str_replace("\r",'',$this->script);

$this->chars = array_slice(preg_split('//',$this->script),1,strlen($this->script));
array_map(array(&$this,'escape_chars'),&$this->chars);
}

// Escape HTML characters
private function escape_chars(&$char) {
$char = str_replace(array('&','<','>'),array('&amp;','&lt;','&gt;'),$char);
}

// Apply highlighting to the script
public function highlight() {
$open = '\s,!@^&*\050='; // Characters that start a token
$close = '\s,!@^&*\051'; // Characters that end a token

$script = $this->script;

// Conditional Operators
$operators = '!?(?:=|==|===|>|<|>=|<=|\/\/|\\\\|&|isin|isincs|iswm|isnum|isletter'.
'|isalnum|isalpha|islower|isupper|ison|isop|ishop|isvoice|isvo|isreg|ischan|' .
'isban|isaop|isavoice|isignore|isprotect|isnotify|iswmcs|\|\||&&|\+|\-|\*|%|\^)';

// Patterns to match for different parts of mIRC scripts
$patterns = array(
// Comments
//Block Style
// Here I've put a d in front of the pattern. This is a lazy thing I did to tell the script to delete the matched portion of text. It's not part of the regular expression.
'd/\\013?\s*(\/\*.*?\*\/)\s*\\013?/s'
// The first element of the replacement will go before each callback, and the second element after each callback
=> array('<span class="mirc_comment">','</span>'),
// Single Line
'd/^\s*(;.*)$/m'
=> array('<span class="mirc_comment">','</span>'),

// Number
'/(?<=^|['.$open.'])([+-]?[\d]+?(?:\.[\d]+?)?)(?=$|['.$close.'%])/m'
=> array('<span class="mirc_number">','</span>'),

// Identifier
'/(?<=^|['.$open.'])(\$[^\s\050\051\[,]+)/m'
=> array('<span class="mirc_identifier">','</span>'),
// Identifier Property
'/(?<=\051)(\.[^\s$\051]+)/m'
=> array('<span class="mirc_identifier">','</span>'),

// Variable
'/(?<=^|['.$open.'])(\%[^'.$close.']+)(?=$|['.$close.'])/m'
=> array('<span class="mirc_variable">','</span>'),

// Operators
'/(?<=[\s])('.$operators.')(?=[\s])/m'
=> array('<span class="mirc_operator">','</span>'),

// Special Characters
'/([\[\]\{\}\050\051\|]+)/m'
=> array('<span class="mirc_character">','</span>'),

// Events
'/(?<=^)\s*(on|ctcp|raw)\s+([^\:]+?)sad.gif[^\:]+?):/m'
=> array('<span class="mirc_event">','</span>'),

// Commands
'/(?<=^|[\{\|]\s)\s*([^\$\%\s]+?)(?=\s|$)/m'
=> array('<span class="mirc_command">','</span>'),
// Command Switches
'/(?<=^|[\{\|]\s)\s*(?:[^\$\%\s]+?)\s+(-[^\s]+)(?=\s|$)/m'
=> array('<span class="mirc_command_switch">','</span>'),
);

$patterns_keys = array_keys($patterns);
foreach ($patterns_keys as $rpattern) {
// Iterate through each pattern
if ($rpattern{0} == 'd') {
// The 'd' switch means delete the text after matching
$delete = TRUE;
$pattern = substr($rpattern,1);
} else {
$delete = FALSE;
$pattern = $rpattern;
}
if (preg_match_all($pattern,$script,$matches,PREG_OFFSET_CAPTURE)) {
// Get all matches for this pattern
array_shift($matches); // Shift off the part we don't want
foreach ($matches as $matches2) {
// Iterate through each callback
foreach ($matches2 as $match) {
// Iterate through each match of each callback
list($text,$offset) = $match;
// Put the first element before the first character of the callback
$this->chars[$offset] = $patterns[$rpattern][0] . $this->chars[$offset] ;
// Put the second element after the last character of the callback
$this->chars[$offset -1 + strlen($text)] = $this->chars[$offset-1 + strlen($text)] .
$patterns[$rpattern][1];
if ($delete) {
// Delete the entire matched text so we don't match it again
$script = substr($script,0,$offset) . str_repeat(' ',strlen($text)) .
substr($script,$offset + strlen($text));
}
} // End iterate through each match of callback
} // End iterate through each callback
} // End if
} // End iterate through each pattern
return $line;
}

// Returns the script after processing
// Specify TRUE for $indent to have the script indented
public function get_script($indent = FALSE) {
// Implode the array of characters into the finished script
$output = implode('',$this->chars);
if ($indent) {
$lines = explode("\n",$this->script);
$output = explode("\n",$output);
$level = 0;
foreach ($lines as $key => &$line) {
if ($in_comment) {
// Don't indent parts of the script that are commented out
if (preg_match('/^\s*\*\//',$line)) { $in_comment = FALSE; }
continue;
}
// Check for beginning of a comment
if (preg_match('/^\s*\/\*/',$line)) { $in_comment = TRUE; continue; }
if (preg_match('/^\s*;/',$line)) { continue; }

// Remove spaces at the beginning of the line
$output[$key] = preg_replace('/^\s*/','',$output[$key]);

// Decrease indentation if there's a }
$decrease = preg_match_all('/(?<=\s|^)}(?=\s|$)/',$line);
// Increase indentation if there's a {
$increase = preg_match_all('/(?<=\s|^|smile.gif{(?=\s|$)/',$line);
// Increase indentation if there's a $&
$increase = preg_match_all('/\$\&\s*$/',$line);

$difference = $increase - $decrease;

if ($difference < 0) { $level += $difference; $difference = 0; }
if ($level < 0) $level = 0;

$output[$key] = str_repeat(' ',$level * 2) . $output[$key];

$level += $difference;
$difference = 0;
}
$output = implode("\n",$output);
}
return $output;
}
}

?>

 

 

 


Reply

fffanatics
Post the errors it shows when you run it so we know where exactly to look in order to fix it. Im not an expert on what is in what version of php even though i do a ton of programming in it. Let us know where the errors are and we will help you.

Reply

AlternativeNick
this is the error that im getting right now

QUOTE

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/altscr/public_html/forum/Sources/highlight.php on line 8

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. isvo isvoice mirc - 828.19 hr back. (1)
Similar Topics

Keywords : making, compatable, trap17s, php

  1. How Would I Go About Making A Simple "counting" Script?
    (3)
  2. Making Sure They Did Not Leave Any Required Fields Blank
    (3)
    how to make sure they did not leave any required fields blank? CODE <?php
        include("config/config.inc.php");
        include("config/dbcon.php");     include("checksession.php");
                 if(isset($_POST['action'])){         $gname =
    $_POST['gname'];         $gemail = $_POST['mail'];
            $gmsg = $_POST['gmsg'];         $date =
    date("m.d.y"); $sql = "insert into tblg....
  3. Making A New Bbcode For Smf 1.09
    (0)
    Im using SMF version 1.09 i would like to make a bbcode so that it shows mirc syntax highlighting
    (as i have an mirc based site) i have a php script that will do the highlighting, im just really
    not sure how to incoporate that with the forum. http://www.mirc.net/tye/mirc_script.phps is the
    link for the script, it is not mine, but made by tye of mirc.net thanks for the help. Ive asked on
    the simple machines forum but theres been absolutely no help, so if anyone here can help me out, id
    really appreciate it.....
  4. Making A Sig With Php
    just wondering how it works (7)
    I was just wondering how to make an image that uses stuff given to it by php, yet remains only an
    image - say I want the site's title in an image. I believe it has something to do with putting
    an index.php inside a folder called image.png or whatever. Am I right? thanks....
  5. How To Make Oscommerce Work With Phpbb
    making oscommerce work with phpbb (1)
    i'd like to make oscommerce work with phpbb.imean that any person register to phpbb is
    automatically regitered to oscommerce and vice versa. if you have any advice or idea that may help
    plz send it.(any help would be appricated)....
  6. Intranet Search Engine
    Need help in making one! (4)
    Hmm.. I am assigned a work of doing a project in PHP to build a intranet search engine. Can any
    body help? Moving from Introductions to PHP Programming. Also edited the topic title &
    description. Please be more descriptive in title & description. And it will be nice if you can be
    more descriptive in your posts ....
  7. Blocking Pages & Making Ranks
    (4)
    I would like to know how and where to put the code that would block certain pages so people could
    only get to them if they logged in. And I would like to have ranks on the site and when you get to a
    certain rank you get more options like being able to add members and stuff. And also. I would like
    some code for a news sytem for the homepage. Like where you have to be logged in to post something
    and only people with certain ranks will have access to it and only certain people can delete it. I
    would like to be able to make it so on the members page it displays members and y....
  8. Php G-mail Login
    Compatable on all browsers (8)
    I fount a PHP G-mail login script to login to your g-mail using any browser. Even IE1, I installed
    it on my site at http://www.gmail.mbd5882.trap17.com/ I tested it myself, Its safe. gmail-lite is
    an html-only interface of GMail. It was develope it with PDA browser (mostly Netfront) in mind, it
    should be workable with any browser on Earth (e.g. lynx, ie3, netscape4, opera5. The only tags being
    used are A, B, FORM, H1, I, INPUT, P, SELECT, TEXTAREA, TABLE, TR, and TD (and META and STYLE in
    HEAD). It alows you to send 10 invites at once and is fast. It uses cookies i, An....

    1. Looking for making, compatable, trap17s, php

Searching Video's for making, compatable, trap17s, php
advertisement



Making This Compatable With Trap17's Php



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE