Not Solved date and time help pleasse
#1
Not Solved
hey

iam useing mynetwork

and this is the result

http://prntscr.com/2ep7jr

i want this to show like in this pic

http://prntscr.com/2ep8o5

i mean i want to make this utf-8

to become like

לפני 5 יום

not
5 יום לפני

this is my code

<?php
/*
+---------------------------------------------------------------------------
|   MyNetwork Core
|	|- Relative Time
|   =============================================
|   by Tom Moore (www.xekko.co.uk)
|   Copyright 2010 Mooseypx Design / Xekko
|   =============================================
+---------------------------------------------------------------------------
|   > $Id: m_relativetime.php 67 2010-12-06 15:03:07Z Tomm $
|
|	Relative Time stuff
|	This file works out all the relative things around the forum
+---------------------------------------------------------------------------
*/

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$page_array = array("index.php", "forumdisplay.php", "showthread.php", "newreply.php", "private.php", "search.php", "usercp.php", "xmlhttp.php");

global $mybb;
if(isset($mybb->settings['relativetime_use_rel_time']) && $mybb->settings['relativetime_use_rel_time'] == 0 || !defined("REL_SKIP") && !in_array(THIS_SCRIPT, $page_array))
{
	return false;
}

// Plugin hooks based on this script
switch(THIS_SCRIPT)
{
	case "index.php":
	case "forumdisplay.php":		
		$GLOBALS['template_edits'] = array(
			"{\$lastpost_date} {\$lastpost_time}" => array(
				"templates" => array(
					"forumbit_depth1_forum_lastpost",
					"forumbit_depth2_forum_lastpost"
				),
				"extra" => "{\$lastpost_data['lastpost']}"
			),
			"{\$lastpostdate} {\$lastposttime}" => array(
				"templates" => "forumdisplay_thread",
				"extra" => "{\$thread['lastpost']}"
			),
			"{\$postdate} {\$posttime}" => array(
				"templates" => "forumdisplay_announcements_announcement",
				"extra" => "{\$announcement['startdate']}"
			)
		);

		$plugins->add_hook("forumdisplay_start", "relativetime_replace");
		$plugins->add_hook("index_start", "relativetime_replace");
		break;
	case "showthread.php":
	case "newreply.php":
		$GLOBALS['template_edits'] = array(
			"{\$post['postdate']}, {\$post['posttime']}" => array(
				"templates" => "postbit",
				"extra" => "{\$post['dateline']}"
			),
			"{\$post['postdate']} {\$post['posttime']}" => array(
				"templates" => "postbit_classic",
				"extra" => "{\$post['dateline']}"
			),
			"{\$reviewpostdate} {\$reviewposttime}" => array(
				"templates" => "newreply_threadreview_post",
				"extra" => "{\$post['dateline']}"
			)
		);

		$plugins->add_hook("postbit", "relativetime_postbit");
		$plugins->add_hook("showthread_start", "relativetime_replace");
		$plugins->add_hook("newreply_start", "relativetime_replace");
		break;
	case "private.php":
		if(!$mybb->input['action'] || $mybb->input['action'] == "read")
		{
			$GLOBALS['template_edits'] = array(
				"{\$post['postdate']}, {\$post['posttime']}" => array(
					"templates" => "postbit",
					"extra" => "{\$post['dateline']}"
				),
				"{\$post['postdate']} {\$post['posttime']}" => array(
					"templates" => "postbit_classic",
					"extra" => "{\$post['dateline']}"
				),
				"{\$senddate} {\$sendtime}" => array(
					"templates" => "private_messagebit",
					"extra" => "{\$message['dateline']}"
				)
			);

			$plugins->add_hook("private_read", "relativetime_replace");
			$plugins->add_hook("private_start", "relativetime_replace");
		}
		elseif($mybb->input['action'] == "tracking")
		{
			$GLOBALS['template_edits'] = array(
				"{\$readdate} {\$readtime}" => array(
					"templates" => "private_tracking_readmessage",
					"extra" => "{\$readmessage['readtime']}"
				),
				"{\$senddate} {\$sendtime}" => array(
					"templates" => "private_tracking_unreadmessage",
					"extra" => "{\$unreadmessage['dateline']}"
				),
			);

			$plugins->add_hook("private_tracking_start", "relativetime_pm_tracking");
		}
		break;
	case "search.php":
		$GLOBALS['template_edits'] = array(
			"{\$lastpostdate} {\$lastposttime}" => array(
				"templates" => "search_results_threads_thread",
				"extra" => "{\$thread['lastpost']}"
			),
			"{\$posted}" => array(
				"templates" => "search_results_posts_post",
				"extra" => "{\$post['dateline']}"
			)
		);

		$plugins->add_hook("search_results_start", "relativetime_replace");
		break;
	case "usercp.php":
		if(!$mybb->input['action'])
		{
			$GLOBALS['template_edits'] = array(
				"{\$lastpostdate} {\$lastposttime}" => array(
					"templates" => array(
						"usercp_latest_subscribed_threads",
						"usercp_latest_threads_threads"
					),
					"extra" => "{\$thread['lastpost']}",
					"force" => true
				)
			);

			$plugins->add_hook("usercp_start", "relativetime_replace");
		}
		elseif($mybb->input['action'] == "subscriptions" || $mybb->input['action'] == "forumsubscriptions")
		{
			$GLOBALS['template_edits'] = array(
				"{\$lastpostdate} {\$lastposttime}" => array(
					"templates" => "usercp_subscriptions_thread",
					"extra" => "{\$thread['lastpost']}",
					"force" => true
				),
				"{\$lastpost_date} {\$lastpost_time}" => array(
					"templates" => "forumbit_depth2_forum_lastpost",
					"extra" => "{\$forum['lastpost']}",
					"force" => true
				)
			);

			$plugins->add_hook("usercp_subscriptions_start", "relativetime_replace");
			$plugins->add_hook("usercp_forumsubscriptions_start", "relativetime_replace");
		}
		elseif($mybb->input['action'] == "attachments")
		{
			$GLOBALS['template_edits'] = array(
				"{\$attachdate}, {\$attachtime}" => array(
					"templates" => "usercp_attachments_attachment",
					"extra" => "{\$attachment['dateline']}"
				)
			);

			$plugins->add_hook("usercp_attachments_start", "relativetime_replace");
		}
		elseif($mybb->input['action'] == "drafts")
		{
			$GLOBALS['template_edits'] = array(
				"{\$savedate}, {\$savetime}" => array(
					"templates" => "usercp_drafts_draft",
					"extra" => "{\$draft['dateline']}",
					"force" => true
				)
			);

			$plugins->add_hook("usercp_drafts_start", "relativetime_replace");
		}
		break;
	case "xmlhttp.php":
		$plugins->add_hook("myn_global", "relativetime_xmlhttp");
		break;
}

function relativetime_info()
{
	return array(
		"name"			=> "Relative Time",
		"description"	=> "Replaces the default front end MyBB time formats with relative time.",
		"website"		=> "http://xekko.co.uk",
		"author"		=> "Tomm",
		"version"		=> "1.1.1"
	);
}

function relativetime_install()
{
	global $db;

	// We've got it now, Bones...
	$settings = array(
		"relativetime_use_rel_time" => array(
			"title" => "Use Relative Time?",
			"description" => "Display time formats in relative time",
			"optionscode" => "yesno",
			"value" => 1,
			"isdefault" => 0
		),
		"relativetime_options_limit" => array(
			"title" => "Cap Relative Time?",
			"description" => "Choose an option to cap the relative time at a certain point during the day.",
			"optionscode" => "radio
1=Up to an hour ago
2=Up to Today
3=Don't cap relative time",
			"value" => 1,
			"isdefault" => 0
		)
	);

	$query = $db->simple_select("settinggroups", "gid", "name = 'datetime'");
	$gid = $db->fetch_field($query, "gid");

	// Get the display order in this group
	$count = 1;
	$query = $db->simple_select("settings", "MAX(disporder) AS 'order'", "gid = '".$gid."'");
	$disporder = $db->fetch_field($query, "order");

	// Insert the settings
	foreach($settings as $name => $setting)
	{
		$insert_array = array(
			"name" => $db->escape_string($name),
			"title" => $db->escape_string($setting['title']),
			"description" => $db->escape_string($setting['description']),
			"optionscode" => $db->escape_string($setting['optionscode']),
			"value" => $db->escape_string($setting['value']),
			"gid" => $gid,
			"isdefault" => $setting['isdefault']
		);
		$insert_array['disporder'] = $disporder + $count;

		$db->insert_query("settings", $insert_array);			
		++$count;
	}

	rebuild_settings();
}

function relativetime_uninstall()
{
	global $db, $mybb;

	// Remove any setting like this...
	$db->delete_query("settings", "name LIKE 'relativetime_%'");
	rebuild_settings();

	if($mybb->input['remove_file'] == 1)
	{
		// We're wanting to remove all files here...
		$file_list = array(
			"inc/network/core/m_relativetime.php",
			"inc/network/core/javascript/relative_time.js"
		);

		foreach($file_list as $file)
		{
			if(is_file(MYBB_ROOT.$file))
			{
				@unlink(MYBB_ROOT.$file);
			}
		}
	}
}

function relativetime_is_installed()
{
	global $mybb;

	$plugin_cache = $mybb->cache->read("plugins");
	if(in_array("myn_relativetime", $plugin_cache['active']) || isset($mybb->settings['relativetime_use_rel_time']))
	{
		return true;
	}

	return false;
}

function relativetime_start()
{
	global $headerinclude, $footer, $lang, $mybb;

	$headerinclude .= "\n<script type=\"text/javascript\" src=\"".$mybb->settings['bburl']."/inc/network/core/javascript/relative_time.js?ver=1100\"></script>";

	if(!$lang->less_than)
	{
		$lang->time_ago = "ago";
		$lang->time_plural = "s";
		$lang->less_than = "Less than a minute ago";
	}

	$lang_array = array(
		"plural" => $lang->time_plural,
		"ago" => $lang->time_ago,
		"less_than" => $lang->less_than,
		"year" => $lang->year,
		"month" => $lang->month,
		"day" => $lang->day,
		"hour" => $lang->hour,
		"minute" => $lang->minute,
		"second" => $lang->second
	);

	$time_options = array(
		1 => $lang->second,
		60 => $lang->minute,
		60 * 60 => $lang->hour,
		24 * 60 * 60 => $lang->day,
		30 * 24 * 60 * 60 => $lang->month,
		12 * 30 * 24 * 60 * 60 => $lang->year
	);

	$footer .= "
<script type=\"text/javascript\">
<!--
	RelativeTime.init(\"".TIME_NOW."\", { lang: '".json_encode($lang_array)."', time: '".json_encode($time_options)."', limit: '".$mybb->settings['relativetime_options_limit']."' });
// -->
</script>";
}

function relativetime_replace()
{
	global $templates;

	relativetime_start();
	foreach($GLOBALS['template_edits'] as $find => $template)
	{		
		if(is_array($template['templates']))
		{
			foreach($template['templates'] as $template_name)
			{
				// An array of the same edits for a set of templates
				if(!isset($templates->cache[$template_name]))
				{
					if($template['force'] === true)
					{
						$templates->cache($template_name);
					}
					else
					{
						continue;
					}
				}

				$templates->cache[$template_name] = str_replace($find, "<span class=\"rt_inline ".$template['extra']."\">".$find."</span>", $templates->cache[$template_name]);
			}
		}
		else
		{
			// A single template update
			if(!isset($templates->cache[$template['templates']]))
			{
				if($template['force'] === true)
				{
					$templates->cache($template['templates']);
				}
				else
				{
					continue;
				}
			}

			$templates->cache[$template['templates']] = str_replace($find, "<span class=\"rt_inline ".$template['extra']."\">".$find."</span>", $templates->cache[$template['templates']]);
		}
	}
}

function relativetime_postbit(&$post)
{
	global $lang, $mybb, $templates, $usergroup;

	if($post['edituid'] != 0 && $post['edittime'] != 0 && $post['editusername'] != "" && ($mybb->settings['showeditedby'] != 0 && $usergroup['cancp'] == 0 || $mybb->settings['showeditedbyadmin'] != 0 && $usergroup['cancp'] == 1))
	{
		$edittime = $GLOBALS['post']['edittime'];

		$post['editdate'] = "<span class=\"rt_inline ".$edittime."\">".my_date($mybb->settings['dateformat'], $edittime);
		$post['edittime'] = my_date($mybb->settings['timeformat'], $edittime)."</span>";
		$post['editnote'] = $lang->sprintf($lang->postbit_edited, $post['editdate'], $post['edittime']);
		$post['editedprofilelink'] = build_profile_link($post['editusername'], $post['edituid']);
		eval("\$post['editedmsg'] = \"".$templates->get("postbit_editedby")."\";");
	}

	if($mybb->input['ajax'])
	{
		// For the quick reply
		$templates->cache['postbit'] = str_replace("{\$post['postdate']}, {\$post['posttime']}", "<span id=\"rt_inline_".$post['pid']."\" class=\"rt_inline ".$post['dateline']."\">{\$post['postdate']}, {\$post['posttime']}</span>", $templates->cache['postbit']);

		$post['dateline'] = TIME_NOW-2; // Pretend we're 2 seconds into the future
		$templates->cache['postbit'] .= "
<script type=\"text/javascript\">
<!--
	var relTime_".$post['pid']." = new relativeClock('rt_inline_".$post['pid']."', '".TIME_NOW."', '".$post['dateline']."');
// -->
</script>
		";
	}
}

function relativetime_xmlhttp()
{
	global $lang, $mybb, $templates;

	if($mybb->input['action'] == "edit_post" && $mybb->input['do'] == "update_post")
	{
		$templates->cache("postbit_editedby,postbit");

		if(!$lang->less_than)
		{
			$lang->less_than = "Less than a minute ago";
		}

		if(isset($templates->cache['postbit_editedby']))
		{
			// We've cached the template, so let's edit this bad boy...
			$editor = build_profile_link($mybb->user['username'], $mybb->user['uid']);

			$string = $lang->sprintf($lang->postbit_edited, $lang->less_than, "");
			$templates->cache['postbit_editedby'] = "(".$string." ".$editor.")";
		}
	}
}

function relativetime_pm_tracking()
{
	global $templates;

	$templates->cache['private_tracking_readmessage'] = str_replace("{\$readdate}<br />{\$readtime}", "{\$readdate} {\$readtime}", $templates->cache['private_tracking_readmessage']);
	$templates->cache['private_tracking_unreadmessage'] = str_replace("{\$senddate}<br />{\$sendtime}", "{\$senddate} {\$sendtime}", $templates->cache['private_tracking_unreadmessage']);

	relativetime_replace();
}
?>

anyone can help me please
Reply
#2
Not Solved
Bump?
Reply
#3
Not Solved
Bump>?
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)