Place the HTML comment directly in front of the first on the line following the last To rotate table cells, place the HTML comment Place the HTML comment directly in front of the first on the line following the last To rotate div rows, place the HTML comment Place the HTML comment directly in front of the first on the line following the last *****************************************************************************************************************/ $script_name = $_SERVER["SCRIPT_FILENAME"]; if(time() - filemtime($script_name) > 1) { $fh = fopen($script_name, "r"); $page_text = fread($fh, filesize($script_name)); //$page_text_copy = str_replace('include_once("rotate.php");', '', $page_text); fclose($fh); $text_changed = false; // Process rotate rows RotateRow($page_text, $text_changed, 1); // $text_changed = NewRotateRow($text_changed, &$page_text, '', ''); // $text_changed = NewRotateRow($text_changed, &$page_text, '', ''); // $text_changed = NewRotateRow($text_changed, &$page_text, '', ''); RotateRow($page_text, $text_changed, 2); RotateRow($page_text, $text_changed, 3); // Process rotate cells RotateCol($page_text, $text_changed, 1); // Process rotate divs RotateDiv($page_text, $text_changed, 1); RotateDiv($page_text, $text_changed, 2); RotateDiv($page_text, $text_changed, 3); if ($text_changed) { $fh = fopen($script_name, "w"); If ($fh != FALSE) { if (flock($fh, LOCK_EX)) { fwrite($fh, $page_text, strlen($page_text)); fflush($fh); } fclose($fh); } // echo $page_text_copy; // echo 'page_text
'; // exit; } } // PHP -Functions function strposOffset($string, $findstring, $offset) { /*** explode the string ***/ $arr = explode($findstring, $string); /*** check the search is not out of bounds ***/ switch( $offset ) { case $offset == 0: return false; break; case $offset > max(array_keys($arr)): return false; break; default: return strlen(implode($findstring, array_slice($arr, 0, $offset))); } } function RotateDiv(&$page_text, &$text_changed, $nth_rotate) { $first_row = strposOffset($page_text, "", $nth_rotate); // Location of end rotate marker $row_text = substr($page_text, $first_row+17, $last_row-$first_row-17); // Text for all of the rows that need rotating $last_text = substr($page_text, $last_row+21, strlen($page_text)-$last_row+21); // All text after the end rotate marker $end_first_row_text = strposOffset($row_text, "" . $remaining_row_text . $first_row_text . "" . $last_text; // Put it all together after rotate. $text_changed = 1; } } function RotateCol(&$page_text, &$text_changed, $nth_rotate) { $first_cell = strposOffset($page_text, "", $nth_rotate); // Location of end rotate marker $cell_text = substr($page_text, $first_cell+17, $last_cell-$first_cell-17); // Text for all of the cells that need rotating $last_text = substr($page_text, $last_cell+21, strlen($page_text)-$last_cell+21); // All text after the end rotate marker $end_first_cell_text = strpos($cell_text, "" . $remaining_cell_text . $first_cell_text . "" . $last_text; $text_changed = 1; } } function RotateRow(&$page_text, &$text_changed, $nth_rotate) { $first_row = strposOffset($page_text, "", $nth_rotate); // Location of end rotate marker $row_text = substr($page_text, $first_row+17, $last_row-$first_row-17); // Text for all of the rows that need rotating $last_text = substr($page_text, $last_row+21, strlen($page_text)-$last_row+21); // All text after the end rotate marker $end_first_row_text = strpos($row_text, "", 4); // Last position of first row to rotate $first_row_text = substr($row_text, 0, $end_first_row_text); // All text in the first row $remaining_row_text = substr_replace($row_text, "", 0, strlen($first_row_text)); // All text below first row to rotate $page_text = $first_text . "" . $remaining_row_text . $first_row_text . "" . $last_text; // Put it all together after rotate. $text_changed = 1; } } function NewRotateRow($rotate_flag, &$page_text, $start_tag, $end_tag) { if(strpos($page_text, $start_tag) !== false){ $item_array = explode($start_tag, $page_text); $num_items = count($item_array); $insert_string = $start_tag.$item_array[1]; $item_array[$num_items-1] = substr_replace($item_array[$num_items-1], $insert_string, 5+strpos($item_array[$num_items-1], $end_tag), 0); unset($item_array[1]); $page_text = implode($start_tag, $item_array); $rotate_flag = true; } return $rotate_flag; } ?> Untitled Document