function extract_section($inputstring, $start, $end, $includestart, $includeend, $returnarray = 0, $separator = "", $leave_start_elements = 0, $leave_end_elements = 0, $striphtml = 0, $search_arr = 0, $replace_arr = 0)
{
    // ---------------- extract_section v 2.0 -------------------- //
    $final_result_arr = array();
    if ($returnarray == 1) {
        $result_arr = explode($separator ? $result : $start . $result, $inputstring);
        //print_r($result_arr);
        foreach ($result_arr as $result) {
            $temp = extract_section($separator ? $result : $start . $result, $start, $end, $includestart, $includeend, 0, "", 0, 0, $striphtml, $search_arr, $replace_arr);
            //echo "$result<br>***************<br>$temp"; break;
            array_push($final_result_arr, $temp);
        }
        $arr_count = count($final_result_arr);
        //print_r($final_result_arr);
        if ($leave_start_elements > 0 || $leave_end_elements > 0) {
            if ($leave_end_elements > $arr_count || $leave_start_elements > $arr_count) {
                return $final_result_arr;
            } elseif ($leave_start_elements + $leave_end_elements > $arr_count) {
                return array_slice($final_result_arr, $leave_start_elements);
            } else {
                return array_slice($final_result_arr, $leave_start_elements, $arr_count - $leave_start_elements - $leave_end_elements);
            }
        }
        return $final_result_arr;
    }
    //echo "$inputstring,$start,$end,$includestart,$includeend";
    $startpos = strpos($inputstring, $start);
    if ($startpos === false) {
        return 0;
    }
    $startlength = strlen($start);
    $endpos = $startpos + strpos(strstr($inputstring, $start), $end);
    $endlength = strlen($end);
    if ($includestart == 0) {
        if ($includeend == 0) {
            $outputstring = substr($inputstring, $startpos + $startlength, $endpos - $startpos - $startlength);
        } else {
            $outputstring = substr($inputstring, $startpos + $startlength, $endpos - $startpos - $startlength + $endlength);
        }
    } else {
        if ($includeend == 0) {
            $outputstring = substr($inputstring, $startpos, $endpos - $startpos);
        } else {
            $outputstring = substr($inputstring, $startpos, $endpos - $startpos + $endlength);
        }
    }
    //echo "<br><br><br>$outputstring";
    if ($search_arr && $replace_arr) {
        $outputstring = str_replace($search_arr, $replace_arr, trim($outputstring));
    }
    if ($striphtml == 1) {
        $outputstring = strip_tags($outputstring);
    }
    $outputstring = trim($outputstring);
    return $outputstring;
}
Ejemplo n.º 2
0
function compile_plugin($file='') {
	global $plugin;

	if (empty($file))
		$file = $_SERVER['SCRIPT_FILENAME'];
    
	if (!isset($plugin['name'])) {
		$plugin['name'] = basename($file, '.php');
	}

	# Read the contents of this file, and strip line ends
    $content = read_file($file);

    $plugin['help'] = trim(extract_section($content, 'HELP'));
    $plugin['code'] = extract_section($content, 'CODE');

    if (isset($plugin['help_file'])) {
        $plugin_content =  read_file($plugin['help_file']);
        $plugin['help'] = trim(extract_section($plugin_content, 'HELP'));
    }

    // textpattern will textile it, and encode html
    $plugin['help_raw'] = $plugin['help'];

	@include('classTextile.php');
	if (class_exists('Textile')) {
		$textile = new Textile();
		$plugin['help'] = $textile->TextileThis($plugin['help']);
	}

	$plugin['md5'] = md5( $plugin['code'] );

	// to produce a copy of the plugin for distribution, load this file in a browser. 

	header('Content-type: text/plain');
	$header = <<<EOF
# {$plugin['name']} v{$plugin['version']}
# {$plugin['description']}
# {$plugin['author']}
# {$plugin['author_uri']}

# ......................................................................
# This is a plugin for Textpattern - http://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the 'Install plugin' box:
# ......................................................................
EOF;

	return $header . "\n\n" . trim(chunk_split(base64_encode(serialize($plugin)), 72)). "\n";

}
Ejemplo n.º 3
0
    $gBitSmarty->assign('comments_count', $numComments);
}
#edit preview needs this
if (!isset($_REQUEST['title']) && isset($gContent->mInfo['title'])) {
    $_REQUEST['title'] = $gContent->mInfo['title'];
}
if ($gContent->isLocked()) {
    $gBitSystem->fatalError('Cannot edit page because it is locked');
}
$gContent->invokeServices('content_edit_function');
if (!empty($gContent->mInfo)) {
    $formInfo = $gContent->mInfo;
    $data_to_edit = !empty($gContent->mInfo['data']) ? $gContent->mInfo['data'] : '';
    if (!empty($_REQUEST['section'])) {
        $section = $_REQUEST['section'];
        $data_to_edit = extract_section($data_to_edit, $section);
        $formInfo['data'] = $data_to_edit;
        $formInfo['edit_section'] = 1;
        $formInfo['section'] = $_REQUEST['section'];
    }
    $formInfo['edit'] = $data_to_edit;
    $formInfo['edit_comment'] = '';
}
$gBitSmarty->assign('footnote', '');
$gBitSmarty->assign('has_footnote', 'n');
if ($gBitSystem->isFeatureActive('wiki_footnotes')) {
    if ($gBitUser->mUserId) {
        $footnote = $gContent->getFootnote($gBitUser->mUserId);
        $gBitSmarty->assign('footnote', $footnote);
        if ($footnote) {
            $gBitSmarty->assign('has_footnote', 'y');
    }
    // Pagination
    $pagination = extract_section($content, $start = '<ul class="m-results-pagination">', $end = '<li class="last">', 0, 0, 0, "", 0, 0, 0, 0, 0);
    $pagination = str_replace('</li>', '', str_replace('<li>', '', str_replace('<li class="is-active">', '', $pagination)));
    $pagination_exp = explode('</a>', $pagination);
    //print_r($pagination_exp);
    if (is_array($pagination_exp)) {
        echo '<br>';
        foreach ($pagination_exp as $key => $val) {
            if ($key !== 10) {
                echo '<a href="?search=' . str_replace(' ', '-', $search) . '&counter=' . strip_tags($val) . '">' . strip_tags($val) . '</a>';
                echo ' | ';
            }
        }
    }
    $pagination = extract_section($pagination, $start = '>', $end = '<', 0, 0, 0, "", 0, 0, 0, 0, 0);
}
//echo array2csv($emails);
$_SESSION['emails'] = $emails;
?>
<script>
function copy_to_csv()
{
  var data = '<?php 
echo json_encode($emails);
?>
';
  alert(data);   
}
function popitup(url,windowName) {
       newwindow=window.open(url,windowName,'height=300,width=500');
function get_paging_recent($base_content)
{
    $section = extract_section($base_content, $start_node = '<div class="pagination', $end_node = '<!-- #content -->', 0, 0, 0, "", 0, 0, 0, 0, 0);
    $content = extract_section($section, $start_node = '<ul>', $end_node = '</ul>', 0, 0, 0, "", 0, 0, 0, 0, 0);
}