示例#1
0
function replaceValWithKey($str, $values, $replacements)
{
    $newStr = [];
    foreach ($values as $key => $value) {
        $numOcc = substr_count($str, $value);
        $thisKey = getKeyFromValue($replacements, $value);
        for ($i = 0; $i < $numOcc; $i++) {
            $newStr[] = str_replace_nth($value, $thisKey, $str, $i);
        }
    }
    return $newStr;
}
示例#2
0
}
?>

<?php 
// EVENTS // This is the event block on the homepage. */
if (is_home()) {
    ?>
	<div class="w-container dates2">
		<div class="w-row dates2-row">
			<?php 
    $eventhtml = sprintf(do_shortcode('[gcal id="503"]'), '', '', ' right');
    $today = current_time('l');
    $tomorrow = date('l', intval(current_time('U')) + 86400);
    $eventhtml = str_replace($tomorrow, 'Tomorrow', $eventhtml);
    $eventhtml = str_replace($today, 'Today', $eventhtml);
    $eventhtml = str_replace_nth('w-col w-col-4 dates2-col', 'w-col w-col-3 dates2-col', $eventhtml, 2);
    // Replaces third instance
    echo $eventhtml;
    ?>
			<div class="w-col w-col-1 dates2-arrow">
				<a href="http://horizonindy.org/youth/gce_feed/events/">
					<span class="phone-only">Event Calendar </span>
					<img src="<?php 
    echo get_template_directory_uri();
    ?>
/images/icon-arrow.svg"/>
				</a>
			</div>
		</div>
	</div>
<?php 
            if ($categoryHashtags[$categoryString]) {
                if (strlen($r . ' #' . $categoryHashtags[$categoryString]) <= 48) {
                    $r .= ' #' . $categoryHashtags[$categoryString];
                }
            } else {
                $t = ' #' . preg_split('/ |\\//', $categoryString)[0];
                if (strlen($r . $t) <= 38) {
                    $r .= $t;
                }
            }
        }
    }
    array_push($arr, $r);
}
function str_replace_nth($search, $replace, $subject, $nth)
{
    $found = preg_match_all('/' . $search . '/u', $subject, $matches, PREG_OFFSET_CAPTURE);
    if (false !== $found && $found > $nth) {
        return substr_replace($subject, $replace, $matches[0][$nth][1], strlen($search));
    }
    return $subject;
}
$feedXML = htmlspecialchars($feedXML);
$feedXML = preg_replace('/&lt;title&gt;(.{1,70})(.+)&lt;\\/title&gt;/u', "&lt;title&gt;\$1&lt;/title&gt;", $feedXML);
foreach ($arr as $m => $s) {
    $feedXML = str_replace_nth('&lt;\\/title&gt;', $arr[$m] . '&lt;/title&gt;', $feedXML, $m);
}
$report = fopen("feed.xml", w);
fwrite($report, htmlspecialchars_decode($feedXML));
fclose($report);
header('Location: feed.xml');
if (count($notification) > 0) {
    ?>
                    <ul class="msginbx">
                        
                        <?php 
    foreach ($notification as $notif_data) {
        if ($notif_data['notif_data']['template_id'] == 6) {
            $image = get_profile_pic($notif_data['notif_data']['from_user_id'], $notif_data['notif_data']['user']['data']['profile_pic']);
            if ($notif_data['notif_data']['caller_stream']['data']['data_type'] == "stream") {
                $detail = str_replace_nth("Stream", "<a href='" . base_url() . $config['single_stream_url'] . '/' . $notif_data['notif_data']['caller_stream']['data']['id'] . "'>" . $notif_data['notif_data']['caller_stream']['data']['title'] . "</a>", $notif_data['notification']['notification'], 0);
                $detail = str_replace_nth("Stream", "<a href='" . base_url() . $config['single_stream_url'] . '/' . $notif_data['notif_data']['receiver_stream']['data']['id'] . "'>" . $notif_data['notif_data']['receiver_stream']['data']['title'] . "</a>", $detail, 0);
                $a_link = "accept-river-invite";
                $r_link = "reject-river-invite";
            } else {
                $detail = str_replace_nth(ucwords($notif_data['notif_data']['caller_stream']['data']['data_type']), "<a href='" . base_url() . $notif_data['notif_data']['caller_stream']['data']['data_type'] . '/' . $notif_data['notif_data']['caller_stream']['data']['id'] . "'>" . $notif_data['notif_data']['caller_stream']['data']['title'] . "</a>", $notif_data['notification']['notification'], 0);
                $detail = str_replace_nth(ucwords($notif_data['notif_data']['caller_stream']['data']['data_type']), "<a href='" . base_url() . $notif_data['notif_data']['caller_stream']['data']['data_type'] . '/' . $notif_data['notif_data']['receiver_stream']['data']['id'] . "'>" . $notif_data['notif_data']['receiver_stream']['data']['title'] . "</a>", $detail, 0);
                $a_link = "accept-ocean-invite";
                $r_link = "reject-ocean-invite";
            }
            ?>
                            
                        <li class="mrgntoptn">
                            <div class="usrimgmsg"><img alt="" src="<?php 
            echo $image;
            ?>
" /></div>
                            <div class="usritxtmsg"> 
                                <strong><?php 
            echo $notif_data['notif_data']['user']['data']['name'];
            ?>
</strong><br />