Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
de:clf:file0 [2007-10-29 22:10] – angelegt thorsten | de:clf:file0 [2018-05-23 23:37] (aktuell) – gelöscht thorsten | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== clf_main.php ====== | ||
- | **Version: | ||
- | **Standalone: | ||
- | **Interpreter: | ||
- | **Includes: | ||
- | **Required functions: | ||
- | **Required variables: | ||
- | |||
- | <code php> | ||
- | <?php | ||
- | |||
- | // Security Check: Is this script called by a valid phpBB script? | ||
- | if (!defined(' | ||
- | header(' | ||
- | die('< | ||
- | } | ||
- | |||
- | |||
- | // Define the current script version and upload path | ||
- | | ||
- | | ||
- | | ||
- | // Retrieve chat log | ||
- | | ||
- | |||
- | |||
- | // Do local file upload when set | ||
- | if (isset($_POST[' | ||
- | |||
- | // Did we receive a file? | ||
- | if (!isset($_FILES[' | ||
- | | ||
- | | ||
- | // Did we receive a text file? | ||
- | } elseif (!substr($_FILES[' | ||
- | | ||
- | | ||
- | // Is the text file to huge? | ||
- | } elseif ($_FILES[' | ||
- | | ||
- | | ||
- | // Move file and get its content | ||
- | } else { | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | | ||
- | | ||
- | | ||
- | // Analyse chat log when there is a chat log | ||
- | if ($clf_src != '' | ||
- | |||
- | // Define this as parsed stage | ||
- | $clf_stage = 1; | ||
- | |||
- | // Load predefined messages | ||
- | require_once($phpbb_root_path . ' | ||
- | |||
- | // Prepare predefined arrays for preg_match | ||
- | $clf_systemmsg_preg = clfCreateRegExList($clf_systemmsg); | ||
- | $clf_actionmsg_preg = clfCreateRegExList($clf_actionmsg); | ||
- | | ||
- | // Init some variables | ||
- | $clf_atom = array(); | ||
- | $clf_players = array(); | ||
- | $m = 0; | ||
- | |||
- | // Split chat log to single lines | ||
- | $clf_line = explode(" | ||
- | | ||
- | // Scan every single line | ||
- | for ($n=0; $n< | ||
- | if ($clf_line[$n] != '' | ||
- | $clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | |||
- | switch ($clf_atom[$m][' | ||
- | case 0: // Player Chat Message | " | ||
- | $clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | $clf_players[] = $clf_atom[$m][' | ||
- | break; | ||
- | | ||
- | case 1: // Player Status Message | " | ||
- | // | ||
- | // | ||
- | // | ||
- | // | ||
- | break; | ||
- | | ||
- | case 2: // Private Message Incoming | "From {player} in {location}: {text}" | ||
- | $clf_msg = substr($clf_atom[$m][' | ||
- | $clf_referer = clfGetMsgReferer($clf_msg); | ||
- | $clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | $clf_players[] = $clf_atom[$m][' | ||
- | break; | ||
- | | ||
- | case 3: // Private Reply Outgoing | "To {player} in {location}: {text}" | ||
- | $clf_msg = substr($clf_atom[$m][' | ||
- | $clf_referer = clfGetMsgReferer($clf_msg); | ||
- | $clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | $clf_players[] = $clf_atom[$m][' | ||
- | break; | ||
- | | ||
- | case 4: // Private Message Outgoing | "To {playername}: | ||
- | $clf_msg = substr($clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | $clf_players[] = $clf_atom[$m][' | ||
- | break; | ||
- | |||
- | case 5: // System Message | " | ||
- | clfExplodeSystemMsg($clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | break; | ||
- | | ||
- | case 6: // Action Message | " | ||
- | clfExplodeActionMsg($clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | $clf_players[] = $clf_atom[$m][' | ||
- | break; | ||
- | | ||
- | case 7: // Personal Action Message | " | ||
- | // We cannot get any useful information in this stage, needs a second pass | ||
- | break; | ||
- | | ||
- | case 8: // Error Message | " | ||
- | $clf_atom[$m][' | ||
- | break; | ||
- | | ||
- | case 9: // Private Reply Incoming | "From {playername}: | ||
- | $clf_msg = substr($clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | $clf_atom[$m][' | ||
- | $clf_players[] = $clf_atom[$m][' | ||
- | break; | ||
- | | ||
- | case 10: // Fun Messages | "There is no feather." | ||
- | // Nobody needs them in a chatlog anyway, so dump them | ||
- | break; | ||
- | } | ||
- | $m++; | ||
- | } | ||
- | } | ||
- | |||
- | // Remove duplicates from player list and sort it | ||
- | $clf_players = array_unique($clf_players); | ||
- | sort($clf_players); | ||
- | | ||
- | // Second pass for personal action messages | ||
- | for ($n=0; $n< | ||
- | if ($clf_atom[$n][' | ||
- | $clf_playerfound = clfExplodePersActionMsg($clf_atom[$n][' | ||
- | $clf_atom[$n][' | ||
- | $clf_atom[$n][' | ||
- | | ||
- | if (!$clf_playerfound) { | ||
- | | ||
- | | ||
- | } | ||
- | } | ||
- | } | ||
- | | ||
- | // If there are new players in the list after second pass, remove duplicates and sort again | ||
- | if ($clf_playersexpanded) { | ||
- | | ||
- | | ||
- | } | ||
- | |||
- | // Format the chat log | ||
- | if (isset($_POST[' | ||
- | | ||
- | // Define this as final stage | ||
- | | ||
- | | ||
- | // Preserve the chat log and clear it | ||
- | // $clf_old = $clf_src; | ||
- | | ||
- | |||
- | // Create a format string for the selected date format | ||
- | | ||
- | case 0: // Remove the date | ||
- | | ||
- | case 1: // Uru Live format | ||
- | | ||
- | case 2: // Format of the forum | ||
- | | ||
- | case 3: // Format of the user, if available; otherwise as case 2 | ||
- | | ||
- | case 4: // User-defined format | ||
- | | ||
- | case 5: // Only time (European) | ||
- | | ||
- | case 6: // Only time (American) | ||
- | | ||
- | } | ||
- | |||
- | // Determine the missing year | ||
- | if ($_POST[' | ||
- | $clf_dateyear = (int)$_POST[' | ||
- | } else { | ||
- | $clf_dateyear = date(' | ||
- | } | ||
- | |||
- | // Compile every single line | ||
- | for ($n=0; $n< | ||
- | $clf_date = ''; | ||
- | $clf_output = ''; | ||
- | |||
- | // Format the date/time stamp | ||
- | if ($clf_dateformat != '' | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | | ||
- | // Dertemine the player key | ||
- | $clf_playerkey = clfGetPlayerKey($clf_atom[$n][' | ||
- | | ||
- | switch ($clf_atom[$n][' | ||
- | case 0: // Player Chat Message | ||
- | if ($_POST[' | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | break; | ||
- | |||
- | case 1: // Player Status Message | ||
- | //if ($_POST[' | ||
- | // $clf_output = $clf_atom[$n][' | ||
- | // $clf_output = chatlog_format($clf_output, | ||
- | // $clf_output = $clf_date . $clf_output . " | ||
- | //} | ||
- | break; | ||
- | |||
- | case 2: // Private Message Incoming | ||
- | if ($_POST[' | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | break; | ||
- | | ||
- | case 3: // Private Replay Outgoing | ||
- | if (($_POST[' | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | break; | ||
- | | ||
- | case 4: // Private Message Outgoing | ||
- | if (($_POST[' | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | break; | ||
- | | ||
- | case 5: // System Message | ||
- | if ($_POST[' | ||
- | if ($_POST[' | ||
- | $clf_output = $clf_atom[$n][' | ||
- | } else { | ||
- | $clf_output = clfSystemMsgTranslate($clf_atom[$n][' | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | break; | ||
- | |||
- | case 6: // Action Message | ||
- | if ($_POST[' | ||
- | if ($_POST[' | ||
- | $clf_output = $clf_atom[$n][' | ||
- | } else { | ||
- | $clf_output = clfActionMsgTranslate($clf_atom[$n][' | ||
- | } | ||
- | | ||
- | | ||
- | } | ||
- | break; | ||
- | | ||
- | case 7: // Personal Action Message | ||
- | if ($_POST[' | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | break; | ||
- | | ||
- | case 8: // Error Message | ||
- | if ($_POST[' | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | break; | ||
- | | ||
- | case 9: // Private Reply Incoming | ||
- | if (($_POST[' | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | break; | ||
- | } | ||
- | //$chatlog .= ' | ||
- | $clf_src .= $clf_output; | ||
- | } | ||
- | } | ||
- | } | ||
- | |||
- | |||
- | // Extracts the date/time stamp from a chatline | ||
- | | ||
- | return substr($chatline, | ||
- | } | ||
- | |||
- | // Extracts the message from a chatline | ||
- | | ||
- | return substr($chatline, | ||
- | } | ||
- | |||
- | // Extracts the referer from a message | ||
- | | ||
- | $chatreferer = substr($chatmsg, | ||
- | return trim($chatreferer); | ||
- | } | ||
- | |||
- | // Extracts the text from a message | ||
- | | ||
- | $chattext = substr($chatmsg, | ||
- | return trim($chattext); | ||
- | } | ||
- | |||
- | // Extracts the player from a referer | ||
- | | ||
- | $chatplayer = substr($chatreferer, | ||
- | return trim($chatplayer); | ||
- | } | ||
- | |||
- | // Extracts the location of the player from a referer | ||
- | | ||
- | $chatlocation = substr($chatreferer, | ||
- | return trim($chatlocation); | ||
- | | ||
- | |||
- | |||
- | |||
- | |||
- | | ||
- | return substr($chatreferer, | ||
- | } | ||
- | |||
- | // Extracts player and text from a sytem message | ||
- | | ||
- | global $clf_systemmsg_preg; | ||
- | | ||
- | if (preg_match($clf_systemmsg_preg[$msgid], | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | | ||
- | |||
- | // Extracts player and text from a action message | ||
- | | ||
- | global $clf_actionmsg_preg; | ||
- | | ||
- | if (preg_match($clf_actionmsg_preg[$msgid], | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | } | ||
- | |||
- | // Extracts player and text from a personal action message | ||
- | | ||
- | global $clf_players; | ||
- | | ||
- | // First try: Check player list for matching player names | ||
- | for ($n=0; $n< | ||
- | if (substr($chatmsg, | ||
- | $chatplayer = $clf_players[$n]; | ||
- | $chattext = substr($chatmsg, | ||
- | return true; | ||
- | } | ||
- | } | ||
- | | ||
- | // Second try: Suppose player name has no whitespaces in between and split at first whitespace | ||
- | $whitespace_pos = strpos($chatmsg, | ||
- | $chatplayer = substr($chatmsg, | ||
- | $chattext = substr($chatmsg, | ||
- | return false; | ||
- | } | ||
- | |||
- | // Tries to determine the type of a message | ||
- | | ||
- | if (substr($chatmsg, | ||
- | if (substr($chatmsg, | ||
- | return 10; // Fun Message | ||
- | } else { | ||
- | $chatmsg = trim($chatmsg); | ||
- | if (substr($chatmsg, | ||
- | | ||
- | } else { | ||
- | | ||
- | } | ||
- | } | ||
- | } else { | ||
- | if (substr($chatmsg, | ||
- | if (strpos(clfGetMsgReferer($chatmsg), | ||
- | | ||
- | } else { | ||
- | | ||
- | } | ||
- | } elseif (substr($chatmsg, | ||
- | if (strpos(clfGetMsgReferer($chatmsg), | ||
- | | ||
- | } else { | ||
- | | ||
- | } | ||
- | } elseif (substr($chatmsg, | ||
- | return 8; // Error | ||
- | } elseif (clfIsSystemMsg($chatmsg, | ||
- | return 5; // System Message | ||
- | } elseif (clfIsActionMsg($chatmsg, | ||
- | return 6; // Action Message | ||
- | } else { | ||
- | return 7; // Personal Action Message | ||
- | } | ||
- | } | ||
- | } | ||
- | |||
- | // Detects if message matches a known system message | ||
- | | ||
- | global $clf_systemmsg_preg; | ||
- | | ||
- | for ($n=0; $n< | ||
- | if (preg_match($clf_systemmsg_preg[$n], | ||
- | $msgid = $n; return true; | ||
- | } | ||
- | } | ||
- | } | ||
- | |||
- | // Detects if message matches a known action message | ||
- | | ||
- | global $clf_actionmsg_preg; | ||
- | | ||
- | for ($n=0; $n< | ||
- | if (preg_match($clf_actionmsg_preg[$n], | ||
- | $msgid = $n; return true; | ||
- | } | ||
- | } | ||
- | } | ||
- | |||
- | // Converts all strings inside an array to a regular expression, replacing %1 with a | ||
- | // variable term | ||
- | | ||
- | for ($n=0; $n< | ||
- | | ||
- | } | ||
- | return $list; | ||
- | } | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | | ||
- | $chatreferer = substr($chatreferer, | ||
- | return substr($chatrefer, | ||
- | } | ||
- | |||
- | |||
- | |||
- | |||
- | // Converts a date/time stamp to another format | ||
- | | ||
- | $datestring = substr($datestring, | ||
- | | ||
- | $datestring_split = explode(' | ||
- | $datestring_date = $datestring_split[0]; | ||
- | $datestring_time = $datestring_split[1]; | ||
- | | ||
- | $datestring_date_split = explode('/', | ||
- | $datestring_date_month = $datestring_date_split[0]; | ||
- | $datestring_date_day = $datestring_date_split[1]; | ||
- | | ||
- | $datestring_time_split = explode(':', | ||
- | $datestring_time_hour = $datestring_time_split[0]; | ||
- | $datestring_time_minute = $datestring_time_split[1]; | ||
- | $datestring_time_second = $datestring_time_split[2]; | ||
- | | ||
- | $timestamp = mktime($datestring_time_hour, | ||
- | | ||
- | |||
- | return date($dateformat, | ||
- | } | ||
- | |||
- | // BB code format a string | ||
- | | ||
- | if (isset($_POST[$key1 . ' | ||
- | | ||
- | if (isset($_POST[$key1 . ' | ||
- | | ||
- | if (isset($_POST[$key1 . ' | ||
- | | ||
- | if ($_POST[$key1 . ' | ||
- | | ||
- | elseif ($_POST[$key2 . ' | ||
- | | ||
- | return $string; | ||
- | } | ||
- | |||
- | // Create a unique, html valid player key | ||
- | | ||
- | return ' | ||
- | | ||
- | |||
- | // Translate a system message | ||
- | | ||
- | global $clf_systemmsg_de; | ||
- | return str_replace(' | ||
- | } | ||
- | |||
- | // Translate an action message | ||
- | | ||
- | global $clf_actionmsg_de; | ||
- | return str_replace(' | ||
- | } | ||
- | |||
- | // Replace paraphrased German diacritics with umlauts and sharp S | ||
- | | ||
- | if ($mode > 0) { | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | if ($mode > 1) { | ||
- | $string = preg_replace('/ | ||
- | } | ||
- | } | ||
- | return $string; | ||
- | } | ||
- | |||
- | ?> | ||
- | </ |