$staleAge) { rmdir($lockDir); } } $locked = @mkdir($lockDir); if ($locked === false) { $timeStart = microtime_float(); do { if ((microtime_float() - $timeStart) > $timeLimit) break; $locked = @mkdir($lockDir); } while ($locked === false); } $success = false; if ($locked === true) { $fp = @fopen($filename, 'at'); if (@fwrite($fp, $data)) $success = true; @fclose($fp); rmdir($lockDir); } ignore_user_abort(0); return $success; } // END: BORROWED FROM http://de2.php.net/manual/en/function.flock.php //display html header echo '
'; $result = db_query("SELECT time FROM {$db_prefix}sbox_content ORDER BY time DESC LIMIT 1", __FILE__, __LINE__); $row = mysql_fetch_assoc($result); $refreshBlocked = false; $delta = time() - $row['time']; if ((!empty($_REQUEST['action'])) && ($_REQUEST['action'] == 'write')) $dontblock = true; else $dontblock = false; if (($delta > $modSettings['lastActive']*60) && ($modSettings['sbox_BlockRefresh'] == '1') && (!$dontblock)) { $refreshBlocked = true; } else { echo ' '; } echo ' '; if (!empty($_REQUEST['action'])) switch ($_REQUEST['action']) { case 'write': if (((!$context['user']['is_guest']) || ($modSettings['sbox_GuestAllowed'] == '1')) && !empty($_REQUEST['sboxText'])) { $content=$_REQUEST['sboxText']; // get current timestamp $date = time(); $posterip = $user_info['ip']; $pip = explode('.', $posterip); $piph = sprintf("%02s%02s%02s%02s", dechex($pip[0]), dechex($pip[1]), dechex($pip[2]), dechex($pip[3])); // handle special characters $content = addslashes($piph . $content); // insert shout message into database $sql = "INSERT INTO " . $db_prefix . "sbox_content (ID_MEMBER, content, time) VALUES ('" . $context['user']['id'] . "', '" . $content . "', '$date')"; db_query($sql, __FILE__, __LINE__); // delete old shout messages (get id of last shouting and delete all shoutings as defined in settings $result = db_query("SELECT id FROM " . $db_prefix . "sbox_content WHERE ID_MEMBER='" . $context['user']['id'] . "' AND content='" . $content . "' AND time='$date'", __FILE__, __LINE__); $rows = mysql_fetch_assoc($result); $sql = 'DELETE FROM ' . $db_prefix . "sbox_content WHERE id < '" . ($rows["id"]-$modSettings['sbox_MaxLines']) . "'"; db_query($sql, __FILE__, __LINE__); // write into history if needed if ($modSettings['sbox_DoHistory'] == '1') { $ds = date('Y-m-d', $date) . ' | ' . date('H:i.s', $date); $content = stripslashes($content); // shouting content $content = substr($content, 8); $content = htmlentities($content); if ($modSettings['sbox_AllowBBC'] == '1' && ($context['user']['id'] > 0 || $modSettings['sbox_GuestBBC'] == '1')) { $content = parse_bbc($content); } $output = '[ ' . $ds . ' ] ' . $sbox_NickPrefix; if ($context['user']['id'] > 0) { $output .= ''; $output .= ((!empty($context['user']['name']))?$context['user']['name']:$context['user']['username']); $output .= ''; } else { $output .= 'Guest-' . base_convert($piph, 16, 36); } $output .= $sbox_NickSuffix . ' ' . $content . '