function sc_timedate($parm = '')
 {
     if ($parm == 'relative') {
         return e107::getDate()->computeLapse($this->var['comment_datestamp'], time(), false, false, 'short');
     }
     return e107::getDate()->convert_date($this->var['comment_datestamp'], "short");
 }
 function sc_dateplus_year($parm)
 {
     $date = e107::getDate();
     if (isset($parm['short'])) {
         $output = $date->convert_date(time(), '%y');
     } else {
         $output = $date->convert_date(time(), '%Y');
     }
     return $output;
 }
Example #3
0
 function checkTimezone()
 {
     $mes = e107::getMessage();
     $timezone = e107::pref('core', 'timezone');
     if (e107::getDate()->isValidTimezone($timezone) == false) {
         $mes->addWarning("Your timezone setting (" . $timezone . ") is invalid. It has been reset to UTC. To Modify, please go to Admin -> Preferences -> Date Display Options.", 'default', true);
         e107::getConfig()->set('timezone', 'UTC')->save(false, true, false);
         $this->refresh = true;
     }
 }
Example #4
0
 function dbCategory($mode)
 {
     global $pref, $sql, $ns, $qs, $rs, $aa, $tp, $plugintable, $e107cache, $content_cat_icon_path_large, $content_cat_icon_path_small;
     $_POST['cat_heading'] = $tp->toDB($_POST['cat_heading']);
     $_POST['cat_subheading'] = $tp->toDB($_POST['cat_subheading']);
     if (e_WYSIWYG) {
         $_POST['cat_text'] = $tp->createConstants($_POST['cat_text']);
         // convert e107_images/ to {e_IMAGE} etc.
     }
     $_POST['cat_text'] = $tp->toDB($_POST['cat_text']);
     $_POST['cat_class'] = $_POST['cat_class'] ? intval($_POST['cat_class']) : "0";
     //category create
     if (isset($qs[0]) && $qs[0] == 'cat' && isset($qs[1]) && $qs[1] == 'create') {
         if (isset($qs[2]) && is_numeric($qs[2])) {
             $parent = "0." . intval($qs[2]);
         } else {
             $parent = 0;
         }
         //category edit
     } elseif (isset($qs[0]) && $qs[0] == 'cat' && isset($qs[1]) && $qs[1] == 'edit') {
         if (isset($qs[2]) && is_numeric($qs[2])) {
             if (isset($qs[3]) && is_numeric($qs[3])) {
                 if (intval($qs[3]) == 0) {
                     $parent = 0;
                 } elseif ($qs[2] == $qs[3]) {
                     $parent = 0;
                 } else {
                     $parent = "0." . intval($qs[3]);
                 }
             } else {
                 if ($qs[2] == $_POST['cat_id']) {
                     $parent = intval($_POST['parent_id']);
                     $parent = $parent != 0 ? "0." . $parent : 0;
                 } else {
                 }
             }
         } else {
             $parent = 0;
         }
     }
     $_POST['parent'] = $parent;
     if (isset($_POST['cat_startdate']) && $_POST['cat_startdate'] != "0" && $_POST['cat_startdate'] != "") {
         $newstarttime = e107::getDate()->toTime($_POST['cat_startdate'], 'inputdatetime');
     } else {
         $newstarttime = time();
     }
     if (isset($_POST['content_datestamp']) && $_POST['content_datestamp'] != "" && $_POST['content_datestamp'] != "0") {
         if ($newstarttime != $starttime) {
             $starttime = $newstarttime;
         } else {
             $starttime = intval($_POST['content_datestamp']);
         }
     } else {
         $starttime = time();
     }
     if (isset($_POST['cat_enddate']) && $_POST['cat_enddate'] != "0" && $_POST['cat_enddate'] != "") {
         $endtime = e107::getDate()->toTime($_POST['cat_enddate'], 'inputdatetime');
     } else {
         $endtime = "0";
     }
     if ($mode == "create") {
         $sql->db_Insert($plugintable, "'0', '" . $_POST['cat_heading'] . "', '" . $_POST['cat_subheading'] . "', '', '" . $_POST['cat_text'] . "', '" . ADMINID . "', '" . $tp->toDB($_POST["cat_icon"]) . "', '', '', '" . $_POST['parent'] . "', '" . intval($_POST['cat_comment']) . "', '" . intval($_POST['cat_rate']) . "', '" . intval($_POST['cat_pe']) . "', '', '" . $starttime . "', '" . $endtime . "', '" . $_POST['cat_class'] . "', '', '0', '0', '', '' ");
         // check and insert default pref values if new main parent + create menu file
         if ($_POST['parent'] == "0") {
             $iid = mysql_insert_id();
             $content_pref = $aa->getContentPref($iid);
             $aa->CreateParentMenu($iid);
         }
         $e107cache->clear("{$plugintable}");
         //jsx_location(e_SELF."?".e_QUERY.".pc");
         $url = e_SELF . "?" . e_QUERY . ".pc";
         e107::getRedirect()->go($url);
     } elseif ($mode == "update") {
         $sql->db_Update($plugintable, "content_heading = '" . $_POST['cat_heading'] . "', content_subheading = '" . $_POST['cat_subheading'] . "', content_summary = '', content_text = '" . $_POST['cat_text'] . "', content_author = '" . ADMINID . "', content_icon = '" . $tp->toDB($_POST["cat_icon"]) . "', content_image = '', content_parent = '" . $_POST['parent'] . "', content_comment = '" . intval($_POST['cat_comment']) . "', content_rate = '" . intval($_POST['cat_rate']) . "', content_pe = '" . intval($_POST['cat_pe']) . "', content_refer = '0', content_datestamp = '" . $starttime . "', content_enddate = '" . $endtime . "', content_class = '" . intval($_POST['cat_class']) . "' WHERE content_id = '" . intval($_POST['cat_id']) . "' ");
         // check and insert default pref values if new main parent + create menu file
         if ($_POST['parent'] == "0") {
             @unlink(e_PLUGIN . "content/menus/content_" . $_POST['menuheading'] . "_menu.php");
             $content_pref = $aa->getContentPref($_POST['cat_id']);
             $aa->CreateParentMenu($_POST['cat_id']);
         }
         $e107cache->clear("{$plugintable}");
         //jsx_location(e_SELF."?".e_QUERY.".pu");
         $url = e_SELF . "?" . e_QUERY . ".pu";
         e107::getRedirect()->go($url);
     }
 }
Example #5
0
 /**
  *
  */
 function renderPreview()
 {
     global $FORUM_PREVIEW;
     // BC v1.x
     $tp = e107::getParser();
     $ns = e107::getRender();
     $this->processAttachments();
     require_once HEADERF;
     if (USER) {
         $poster = USERNAME;
     } else {
         $poster = $_POST['anonname'] ? $_POST['anonname'] : LAN_ANONYMOUS;
     }
     $postdate = e107::getDate()->convert_date(time(), "forum");
     $tsubject = $tp->post_toHTML($_POST['subject'], true);
     $tpost = $tp->post_toHTML($_POST['post'], true);
     if ($_POST['poll_title'] != '' && check_class($this->forumObj->prefs->get('poll'))) {
         require_once e_PLUGIN . "poll/poll_class.php";
         $poll = new poll();
         $poll_text = $poll->render_poll($_POST, 'forum', 'notvoted', true);
     } else {
         $poll_text = false;
     }
     if (empty($FORUM_PREVIEW)) {
         if (deftrue('BOOTSTRAP')) {
             $FORUM_PREVIEW = e107::getTemplate('forum', 'forum_preview', 'item');
         } else {
             if (file_exists(THEME . "forum_preview_template.php")) {
                 require_once THEME . "forum_preview_template.php";
             } else {
                 require_once e_PLUGIN . "forum/templates/forum_preview_template.php";
             }
         }
     }
     $shortcodes = array('PREVIEW_DATE' => $postdate, 'PREVIEW_SUBJECT' => $tsubject, 'PREVIEW_POST' => $tpost);
     $text = $tp->simpleParse($FORUM_PREVIEW, $shortcodes);
     if ($poll_text) {
         $ns->tablerender($_POST['poll_title'], $poll_text);
     }
     $ns->tablerender(LAN_FORUM_3005, $text);
     /*
     		if ($this->action == 'edit')
     		{
     			if ($_POST['subject'])
     			{
     				$action = 'edit';
     			}
     			else
     			{
     				$action = 'rp';
     			}
     			$eaction = true;
     		}
     		else if($this->action == 'quote')
     		{
     			$action = 'rp';
     			$eaction = false;
     		}*/
 }
Example #6
0
 /**
  * Display a Date in the browser. 
  * Includes support for 'livestamp' (http://mattbradley.github.io/livestampjs/)
  * @param integer $datestamp - unix timestamp
  * @param string $format - short | long | relative 
  * @return HTML with converted date. 
  */
 public function toDate($datestamp = null, $format = 'short')
 {
     if (!is_numeric($datestamp)) {
         return;
     }
     return '<span data-livestamp="' . $datestamp . '">' . e107::getDate()->convert($datestamp, $format) . '</span>';
 }
 /**
  * Render date for post used in the recent forum posts menu.
  *
  * @return string
  */
 function sc_recent_post_date()
 {
     // TODO: date format.
     $format = vartrue($this->plugPrefs['asdasdsad'], 'relative');
     $date = e107::getDate();
     return $date->convert_date(vartrue($this->var['post']['post_datestamp'], 0), $format);
 }
Example #8
0
} elseif ($action == 'active') {
    define('e_PAGETITLE', LAN_7);
} else {
    e107::redirect();
    exit;
}
require_once HEADERF;
if ($action == 'active') {
    require_once e_HANDLER . 'userclass_class.php';
    require_once e_PLUGIN . 'forum/forum_class.php';
    $forum = new e107forum();
    $forumList = implode(',', $forum->getForumPermList('view'));
    $qry = "\r\n\tSELECT\r\n\t\tt.*, u.user_name, ul.user_name AS user_last, f.forum_name\r\n\tFROM `#forum_thread` as t\r\n\tLEFT JOIN `#forum` AS f ON f.forum_id = t.thread_forum_id\r\n\tLEFT JOIN `#user` AS u ON u.user_id = t.thread_user\r\n\tLEFT JOIN `#user` AS ul ON ul.user_id = t.thread_lastuser\r\n\tWHERE t.thread_forum_id IN ({$forumList})\r\n\tORDER BY t.thread_views DESC\r\n\tLIMIT\r\n\t\t{$from}, {$view}\r\n\t";
    if ($sql->gen($qry)) {
        $text = "<div>\n<table style='width:auto' class='table fborder'>\n";
        $gen = e107::getDate();
        $text .= "<tr>\r\n\t\t\t<th style='width:5%' class='forumheader'>&nbsp;</th>\r\n\t\t\t<th style='width:45%' class='forumheader'>" . LAN_1 . "</th>\r\n\t\t\t<th style='width:15%; text-align:center' class='forumheader'>" . LAN_2 . "</th>\r\n\t\t\t<th style='width:5%; text-align:center' class='forumheader'>" . LAN_3 . "</th>\r\n\t\t\t<th style='width:5%; text-align:center' class='forumheader'>" . LAN_4 . "</th>\r\n\t\t\t<th style='width:25%; text-align:center' class='forumheader'>" . LAN_5 . "</th>\r\n\t\t\t</tr>\n";
        while ($row = $sql->db_Fetch(MYSQL_ASSOC)) {
            if ($row['user_name']) {
                $POSTER = "<a href='" . e107::getUrl()->create('user/profile/view', "name={$row['user_name']}&id={$row['thread_user']}") . "'>{$row['user_name']}</a>";
            } else {
                $POSTER = $row['thread_user_anon'];
            }
            $LINKTOTHREAD = e107::getUrl()->create('forum/thread/view', array('id' => $row['thread_id']));
            //$e107->url->getUrl('forum', 'thread', "func=view&id={$row['thread_id']}");
            $LINKTOFORUM = e107::getUrl()->create('forum/forum/view', array('id' => $row['thread_forum_id']));
            //$e107->url->getUrl('forum', 'forum', "func=view&id={$row['thread_forum_id']}");
            $lastpost_datestamp = $gen->convert_date($row['thread_lastpost'], 'forum');
            if ($row['user_last']) {
                $LASTPOST = "<a href='" . e107::getUrl()->create('user/profile/view', "name={$row['user_last']}&id={$row['thread_lastuser']}") . "'>{$row['user_last']}</a><br />" . $lastpost_datestamp;
            } else {
Example #9
0
 /**
  * Convert posted to model values after submit (based on field type)
  * @param array $data
  * @return void
  */
 protected function convertToData(&$data)
 {
     $model = new e_model($data);
     foreach ($this->getFields() as $key => $attributes) {
         $value = vartrue($attributes['dataPath']) ? $model->getData($attributes['dataPath']) : $model->get($key);
         if (null === $value) {
             continue;
         }
         switch ($attributes['type']) {
             case 'password':
                 //TODO more encryption options.
                 if (strlen($value) < 30) {
                     $value = md5($value);
                 }
                 break;
             case 'datestamp':
                 if (!is_numeric($value)) {
                     if (!empty($attributes['writeParms'])) {
                         if (is_string($attributes['writeParms'])) {
                             parse_str($attributes['writeParms'], $opt);
                         } elseif (is_array($attributes['writeParms'])) {
                             $opt = $attributes['writeParms'];
                         }
                     }
                     $format = $opt['type'] ? 'input' . $opt['type'] : 'inputdate';
                     $value = trim($value) ? e107::getDate()->toTime($value, $format) : 0;
                 }
                 break;
             case 'ip':
                 $value = trim($value) ? e107::getIPHandler()->ipEncode($value) : '';
                 break;
             case 'dropdown':
                 // TODO - ask Steve if this check is required
             // TODO - ask Steve if this check is required
             case 'lanlist':
             case 'userclasses':
             case 'comma':
             case 'checkboxes':
                 if (is_array($value)) {
                     // no sanitize here - data is added to model posted stack
                     // and validated & sanitized before sent to db
                     //$value = array_map(array(e107::getParser(), 'toDB'), $value);
                     $value = implode(',', $value);
                 }
                 break;
             case 'images':
             case 'files':
                 //	XXX Cam @ SecretR: didn't work here. See model_class.php line 2046.
                 // if(!is_array($value))
                 //		{
                 //		$value = e107::unserialize($value);
                 //	}
                 break;
         }
         /*
         			if($attributes['serialize'] == true)
         			{
         				$attributes['data'] = 'array';		
         			}
         
         			if($attributes['data'] != 'array')
         			{
         				$value = e107::unserialize($value);	
         			}
         */
         if (vartrue($attributes['dataPath'])) {
             $model->setData($attributes['dataPath'], $value);
         } else {
             $model->set($key, $value);
         }
     }
     $data = $model->getData();
     unset($model);
     $this->toData($data);
 }
Example #10
0
$text .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><label for='admin-separate-plugins'>" . PRFLAN_204 . "</label></td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t" . $frm->radio_switch('admin_separate_plugins', $pref['admin_separate_plugins']) . "\n\t\t\t\t\t\t\t<div class='field-help'>" . PRFLAN_205 . "</div>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t" . pref_submit('admindisp') . "\n\t\t</fieldset>\n\n\t";
// Date options.
$ga = new convert();
$date1 = $ga->convert_date(time(), "short");
$date2 = $ga->convert_date(time(), "long");
$date3 = $ga->convert_date(time(), "forum");
$date4 = e107::getDate()->convert(time(), "input");
$text .= "\n\t\t<fieldset class='e-hideme' id='core-prefs-date'>\n\t\t\t<legend>" . PRFLAN_21 . "</legend>\n\t\t\t<table class='table adminform'>\n\t\t\t\t<colgroup>\n\t\t\t\t\t<col class='col-label' />\n\t\t\t\t\t<col class='col-control' />\n\t\t\t\t</colgroup>\n\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><label for='shortdate'>" . PRFLAN_22 . "</label></td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t" . $frm->text('shortdate', $pref['shortdate'], 50) . "\n\t\t\t\t\t\t\t<div class='field-help'>" . PRFLAN_83 . ": {$date1}</div>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><label for='longdate'>" . PRFLAN_23 . "</label></td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t" . $frm->text('longdate', $pref['longdate'], 50) . "\n\t\t\t\t\t\t\t<div class='field-help'>" . PRFLAN_83 . ": {$date2}</div>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><label for='forumdate'>" . PRFLAN_24 . "</label></td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t" . $frm->text('forumdate', $pref['forumdate'], 50) . "\n\t\t\t\t\t\t\t<div class='field-help'>" . PRFLAN_83 . ": {$date3}</div>\n\t\t\t\t\t\t\t<div class='field-help'>" . PRFLAN_25 . " <a href='http://www.php.net/manual/en/function.strftime.php' rel='external'>" . PRFLAN_93 . "</a></div>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>";
$def = strtotime('December 21, 2012 3:45pm');
$inputdate = array("%A, %d %B, %Y" => strftime("%A, %d %B, %Y", $def), "%A, %d %b, %Y" => strftime("%A, %d %b, %Y", $def), "%a, %d %B, %Y" => strftime("%a, %d %B, %Y", $def), "%a, %d %b, %Y" => strftime("%a, %d %b, %Y", $def), "%A, %B %d, %Y" => strftime("%A, %B %d, %Y", $def), "%A, %b %d, %Y" => strftime("%A, %b %d, %Y", $def), "%A, %b %d, %y" => strftime("%A, %b %d, %y", $def), "%B %d, %Y" => strftime("%B %d, %Y", $def), "%b %d, %Y" => strftime("%b %d, %Y", $def), "%b %d, %y" => strftime("%b %d, %y", $def), "%d %B, %Y" => strftime("%d %B, %Y", $def), "%d %b, %Y" => strftime("%d %b, %Y", $def), "%d %b, %y" => strftime("%d %b, %y", $def), "%Y-%m-%d" => strftime("%Y-%m-%d", $def), "%d-%m-%Y" => strftime("%d-%m-%Y", $def), "%m/%d/%Y" => strftime("%m/%d/%Y", $def));
$inputtime = array();
$inputtime["%I:%M %p"] = strftime("%I:%M %p", $def);
if (e107::getDate()->supported('P')) {
    $inputtime["%I:%M %P"] = strftime("%I:%M %P", $def);
}
if (e107::getDate()->supported('l')) {
    $inputtime["%l:%M %p"] = strftime("%l:%M %p", $def);
    $inputtime["%l:%M %P"] = strftime("%l:%M %P", $def);
}
$inputtime["%H:%M"] = strftime("%H:%M", $def);
$inputtime["%H:%M:%S"] = strftime("%H:%M:%S", $def);
$text .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><label for='inputdate'>" . PRFLAN_230 . "</label></td>\n\t\t\t\t\t\t<td class='form-inline'>\n\t\t\t\t\t\t\t" . $frm->select('inputdate', $inputdate, e107::getPref('inputdate'));
$text .= $frm->select('inputtime', $inputtime, e107::getPref('inputtime'));
$text .= "\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><label for='time-offset'>" . PRFLAN_26 . "</label></td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t" . $frm->select_open('time_offset', 'class=tbox select time-offset');
//use form handler because of the tabindex
$toffset = array("-12", "-11", "-10", "-9", "-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1", "0", "+1", "+2", "+3", "+4", "+5", "+6", "+7", "+8", "+9", "+10", "+11", "+12", "+13", "+14", "+15", "+16");
if (!isset($pref['time_offset'])) {
    $pref['time_offset'] = "0";
}
//XXX TODO FIXME - Do we still need this?
foreach ($toffset as $o) {
Example #11
0
function calendar($req_day, $req_month, $req_year, $links = NULL, $ws = "sunday")
{
    $pref = e107::getPref();
    // prepare the day array
    $darray = e107::getDate()->terms('day-shortest');
    $marray = e107::getDate()->terms('month');
    // what day does the week start on?
    switch ($ws) {
        case "monday":
            $ws = "1";
            break;
        case "sunday":
            array_unshift($darray, array_pop($darray));
            $ws = "0";
    }
    // what's the padding we should use for the cells?
    $padding = isset($pref['blogcal_padding']) && $pref['blogcal_padding'] ? $pref['blogcal_padding'] : "2";
    $date = mktime(0, 0, 0, $req_month, 1, $req_year);
    $last_day = date('t', $date);
    $date_info = getdate($date);
    $day_of_week = $date_info['wday'];
    if ($ws && $day_of_week == 0) {
        $day_of_week = 7;
    }
    // print the daynames
    $calendar = "<table class='table blogcalendar fborder'>";
    $calendar .= '<thead><tr>';
    foreach ($darray as $dheader) {
        $calendar .= "<th class='forumheader blogcalendar-day-name'><span class='smalltext'>{$dheader}</span></th>";
    }
    $calendar .= "</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>";
    $calendar .= '<tr>';
    $day_of_month = 1;
    $tablerow = 1;
    // take care of the first "empty" days of the month
    if ($day_of_week - $ws > 0) {
        $calendar .= "<td class='muted blogcalendar-day-empty' colspan='";
        $calendar .= $day_of_week - $ws;
        $calendar .= "'>&nbsp;</td>";
    }
    // print the days of the month (take the $ws into account)
    while ($day_of_month <= $last_day) {
        if ($day_of_week - $ws == 7) {
            #start a new week
            $calendar .= "</tr><tr>";
            $day_of_week = 0 + $ws;
            $tablerow++;
        }
        if ($day_of_month == $req_day) {
            $day_style = isset($links[$day_of_month]) ? "indent blogcalendar-day-active" : "forumheader3 blogcalendar-day";
        } else {
            $day_style = isset($links[$day_of_month]) ? "indent blogcalendar-day-active " : "forumheader3 blogcalendar-day";
        }
        $label_style = isset($links[$day_of_month]) ? 'label label-info' : '';
        //TODO A pref in admin to choose between info, danger, etc.
        $calendar .= "<td class='{$day_style}' >";
        $calendar .= isset($links[$day_of_month]) ? "<a class='blogcalendar-day-link' href='" . $links[$day_of_month] . "'>" : "";
        $calendar .= "<span class='smalltext blogcalendar-day-link {$label_style}'>";
        $calendar .= $day_of_month;
        $calendar .= "</span>";
        $calendar .= isset($links[$day_of_month]) ? "</a>" : "";
        $calendar .= "</td>";
        $day_of_month++;
        $day_of_week++;
    }
    if ($day_of_week - $ws != 7) {
        $calendar .= '<td class="blogcalendar-day-empty" colspan="' . (7 - $day_of_week + $ws) . '">&nbsp;</td>';
    }
    $calendar .= "</tr>";
    if ($tablerow != 6) {
        $calendar .= "<tr><td class='blogcalendar-day-empty' colspan='7'>&nbsp;</td></tr>";
    }
    $calendar .= "</tbody></table>";
    //	$calendar .= "tablerow = ".$tablerow;
    if (deftrue('BOOTSTRAP')) {
        $active = date("n-Y") == $req_month . "-" . $req_year ? 'active' : '';
        $text = "<div class='item {$active}'>";
        $text .= "<h5>" . $marray[$req_month - 1] . " " . $req_year . "</h5>";
        $text .= $calendar;
        $text .= "</div>";
    } else {
        $text = $calendar;
    }
    return $text;
}
 function sc_goal()
 {
     $amount = $this->var['menu_item']['pd_goal_amount'];
     $currency = $this->var['menu_item']['pd_currency'];
     if (in_array($currency, array('HUF', 'JPY', 'TWD'))) {
         $formatted = number_format($amount, 0, '.', ',');
     } else {
         $formatted = number_format($amount, 2, '.', ',');
     }
     $text = LAN_PAYPAL_DONATION_FRONT_06 . ' <strong>' . $formatted . ' ' . $currency . '</strong>';
     $goalDate = $this->var['menu_item']['pd_goal_date'];
     if ((int) $goalDate > 0) {
         $format = isset($this->plugPrefs['date_format']) ? $this->plugPrefs['date_format'] : 'short';
         $date = e107::getDate();
         $text .= ' ' . LAN_PAYPAL_DONATION_FRONT_10;
         $text .= ' <strong>' . $date->convert_date($goalDate, $format) . '</strong>';
     }
     return $text;
 }
 /**
  * Comment created time.
  */
 function sc_latest_comment_time()
 {
     $format = isset($this->plugPrefs['date_format']) ? $this->plugPrefs['date_format'] : 'relative';
     $date = e107::getDate();
     return $date->convert_date($this->var['comment_datestamp'], $format);
 }
Example #14
0
 function strptime($str, $format)
 {
     return e107::getDate()->strptime($str, $format);
 }
Example #15
0
 function sc_user_daysregged($parm)
 {
     return e107::getDate()->computeLapse($this->var['user_join']) . " " . LAN_USER_34;
 }
Example #16
0
 function _observe_submit_item($sub_action, $id)
 {
     // ##### Format and submit item to DB
     $ix = new news();
     $_POST['news_start'] = vartrue(e107::getDate()->convert($_POST['news_start'], 'inputdatetime'), 0);
     if ($_POST['news_start']) {
         //	$_POST['news_start'] = e107::getDate()->convert($_POST['news_start']);
     } else {
         //		$_POST['news_start'] = 0;
     }
     if ($_POST['news_end']) {
         $_POST['news_end'] = e107::getDate()->convert($_POST['news_end'], 'inputdatetime');
     } else {
         $_POST['news_end'] = 0;
     }
     if ($_POST['news_datestamp']) {
         $_POST['news_datestamp'] = e107::getDate()->convert($_POST['news_datestamp'], 'inputdatetime');
     } else {
         $_POST['news_datestamp'] = time();
     }
     /*
     $matches = array();
     if(preg_match('#(.*?)/(.*?)/(.*?) (.*?):(.*?):(.*?)$#', $_POST['news_datestamp'], $matches))
     {
     	$_POST['news_datestamp'] = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]);
     }
     else
     {
     	$_POST['news_datestamp'] = time();
     }
     
     if($_POST['update_datestamp'])
     {
     	$_POST['news_datestamp'] = time();
     }
     */
     if ($id && $sub_action != "sn" && $sub_action != "upload") {
         $_POST['news_id'] = $id;
     } else {
         e107::getDb()->db_Update('submitnews', "submitnews_auth=1 WHERE submitnews_id ={$id}");
         e107::getAdminLog()->log_event('NEWS_07', $id, E_LOG_INFORMATIVE, '');
     }
     if (!isset($_POST['cat_id'])) {
         $_POST['cat_id'] = 0;
     }
     $_POST['news_category'] = $_POST['cat_id'];
     if (!isset($this->news_categories[$_POST['news_category']])) {
         $this->noPermissions();
     }
     /*if(isset($_POST['news_thumbnail']))
     		{
     			$_POST['news_thumbnail'] = urldecode(basename($_POST['news_thumbnail']));
     		}*/
     $_POST['news_render_type'] = implode(",", $_POST['news_render_type']);
     //		print_a($_POST);
     //	 exit;
     $tmp = explode(chr(35), $_POST['news_author']);
     $_POST['news_author'] = $tmp[0];
     $ret = $ix->submit_item($_POST, !vartrue($_POST['create_edit_stay']));
     if ($ret['error']) {
         e107::getMessage()->mergeWithSession()->add($id ? LAN_UPDATED_FAILED : LAN_CREATED_FAILED, E_MESSAGE_ERROR);
         $_POST['news_sef'] = $ret['data']['news_sef'];
         return false;
     }
     $this->clear_cache();
     if (isset($_POST['create_edit_stay']) && !empty($_POST['create_edit_stay'])) {
         if ($this->getSubAction() != 'edit') {
             session_write_close();
             $rurl = e_SELF . (varsettrue($ret['id']) ? "?create.edit." . $ret['id'] : '');
             header('Location:' . ($rurl ? $rurl : e_SELF));
             exit;
         }
     } else {
         session_write_close();
         header('Location:' . e_SELF);
         exit;
     }
 }
Example #17
0
    if ($admin_log->logArrayDiffs($temp, $menu_pref, 'BANNER_01')) {
        $menuPref = e107::getConfig('menu');
        //e107::getConfig('menu')->setPref('', $menu_pref);
        //e107::getConfig('menu')->save(false, true, false);
        foreach ($temp as $k => $v) {
            $menuPref->setPref($k, $v);
        }
        $menuPref->save(false, true, false);
        e107::getMessage()->addSuccess(LAN_SAVED);
        $menu_pref = e107::getConfig('menu')->getPref('');
        //banners_adminlog('01', $menu_pref['banner_caption'].'[!br!]'.$menu_pref['banner_amount'].', '.$menu_pref['banner_rendertype'].'[!br!]'.$menu_pref['banner_campaign']);
    }
}
if (vartrue($_POST['createbanner']) || vartrue($_POST['updatebanner'])) {
    $start_date = vartrue(e107::getDate()->convert($_POST['banner_startdate'], 'inputdate'), 0);
    $end_date = vartrue(e107::getDate()->convert($_POST['banner_enddate'], 'inputdate'), 0);
    $cli = $tp->toDB($_POST['client_name'] ? $_POST['client_name'] : $_POST['banner_client_sel']);
    $cLogin = $tp->toDB($_POST['client_login']);
    $cPassword = $tp->toDB($_POST['client_password']);
    $banImage = $tp->toDB($_POST['banner_image']);
    $banURL = $tp->toDB($_POST['click_url']);
    $cam = $tp->toDB($_POST['banner_campaign'] ? $_POST['banner_campaign'] : $_POST['banner_campaign_sel']);
    $logString .= $cam . '[!br!]' . $cli . '[!br!]' . $banImage . '[!br!]' . $banURL;
    if ($_POST['createbanner']) {
        e107::getMessage()->addAuto($sql->db_Insert("banner", "0, '" . $cli . "', '" . $cLogin . "', '" . $cPassword . "', '" . $banImage . "', '" . $banURL . "', '" . intval($_POST['impressions_purchased']) . "', '" . $start_date . "', '" . $end_date . "', '" . intval($_POST['banner_class']) . "', 0, 0, '', '" . $cam . "'"), 'insert', LAN_CREATED, false, false);
        banners_adminlog('02', $logString);
    } else {
        e107::getMessage()->addAuto($sql->db_Update("banner", "banner_clientname='" . $cli . "', banner_clientlogin='******', banner_clientpassword='******', banner_image='" . $banImage . "', banner_clickurl='" . $banURL . "', banner_impurchased='" . intval($_POST['impressions_purchased']) . "', banner_startdate='" . $start_date . "', banner_enddate='" . $end_date . "', banner_active='" . intval($_POST['banner_class']) . "', banner_campaign='" . $cam . "' WHERE banner_id=" . intval($_POST['eid'])), 'update', LAN_UPDATED, false, false);
        banners_adminlog('03', $logString);
    }
    unset($_POST['client_name'], $_POST['client_login'], $_POST['client_password'], $_POST['banner_image'], $_POST['click_url'], $_POST['impressions_purchased'], $start_date, $end_date, $_POST['banner_enabled'], $_POST['banner_startdate'], $_POST['banner_enddate'], $_POST['banner_class'], $_POST['banner_listtype']);
Example #18
0
 /**
  * Render Field Value
  * @param string $field field name
  * @param mixed $value field value
  * @param array $attributes field attributes including render parameters, element options - see e_admin_ui::$fields for required format
  * @return string
  */
 function renderValue($field, $value, $attributes, $id = 0)
 {
     if (!empty($attributes['multilan']) && is_array($value)) {
         $value = varset($value[e_LANGUAGE], '');
     }
     $parms = array();
     if (isset($attributes['readParms'])) {
         if (!is_array($attributes['readParms'])) {
             parse_str($attributes['readParms'], $attributes['readParms']);
         }
         $parms = $attributes['readParms'];
     }
     if (vartrue($attributes['inline'])) {
         $parms['editable'] = true;
     }
     // attribute alias
     if (vartrue($attributes['sort'])) {
         $parms['sort'] = true;
     }
     // attribute alias
     if (!empty($parms['type'])) {
         $attributes['type'] = $parms['type'];
     }
     $this->renderValueTrigger($field, $value, $parms, $id);
     $tp = e107::getParser();
     switch ($field) {
         case 'options':
             if (varset($attributes['type']) == "method") {
                 $attributes['mode'] = "read";
                 if (isset($attributes['method']) && $attributes['method'] && method_exists($this, $attributes['method'])) {
                     $method = $attributes['method'];
                     return $this->{$method}($parms, $value, $id, $attributes);
                 } elseif (method_exists($this, 'options')) {
                     //return  $this->options($field, $value, $attributes, $id);
                     // consistent method arguments, fixed in admin cron administration
                     return $this->options($parms, $value, $id, $attributes);
                     // OLD breaks admin->cron 'options' column
                 }
             }
             if (!$value) {
                 parse_str(str_replace('&amp;', '&', e_QUERY), $query);
                 //FIXME - FIX THIS
                 // keep other vars in tact
                 $query['action'] = 'edit';
                 $query['id'] = $id;
                 //$edit_query = array('mode' => varset($query['mode']), 'action' => varset($query['action']), 'id' => $id);
                 $query = http_build_query($query);
                 $value = "<div class='btn-group'>";
                 if (vartrue($parms['sort'])) {
                     $mode = preg_replace('/[^\\w]/', '', vartrue($_GET['mode'], ''));
                     $from = intval(vartrue($_GET['from'], 0));
                     $value .= "<a class='e-sort sort-trigger btn btn-default' style='cursor:move' data-target='" . e_SELF . "?mode={$mode}&action=sort&ajax_used=1&from={$from}' title='" . LAN_RE_ORDER . "'>" . ADMIN_SORT_ICON . "</a> ";
                 }
                 $cls = false;
                 if (varset($parms['editClass'])) {
                     $cls = deftrue($parms['editClass']) ? constant($parms['editClass']) : $parms['editClass'];
                 }
                 if ((false === $cls || check_class($cls)) && varset($parms['edit'], 1) == 1) {
                     /*
                     						$value .= "<a href='".e_SELF."?{$query}' class='e-tip btn btn-large' title='".LAN_EDIT."' data-placement='left'>
                     <img class='icon action edit list' src='".ADMIN_EDIT_ICON_PATH."' alt='".LAN_EDIT."' /></a>";
                     */
                     $value .= "<a href='" . e_SELF . "?{$query}' class='btn btn-default' title='" . LAN_EDIT . "' data-toggle='tooltip' data-placement='left'>\r\n\t\t\t\t\t\t" . ADMIN_EDIT_ICON . "</a>";
                 }
                 $delcls = vartrue($attributes['noConfirm']) ? ' no-confirm' : '';
                 if (varset($parms['deleteClass']) && varset($parms['delete'], 1) == 1) {
                     $cls = deftrue($parms['deleteClass']) ? constant($parms['deleteClass']) : $parms['deleteClass'];
                     if (check_class($cls)) {
                         $value .= $this->submit_image('etrigger_delete[' . $id . ']', $id, 'delete', LAN_DELETE . ' [ ID: ' . $id . ' ]', array('class' => 'action delete btn btn-default' . $delcls));
                     }
                 } else {
                     $value .= $this->submit_image('etrigger_delete[' . $id . ']', $id, 'delete', LAN_DELETE . ' [ ID: ' . $id . ' ]', array('class' => 'action delete btn btn-default' . $delcls));
                 }
             }
             //$attributes['type'] = 'text';
             $value .= "</div>";
             return $value;
             break;
         case 'checkboxes':
             $value = $this->checkbox(vartrue($attributes['toggle'], 'multiselect') . '[' . $id . ']', $id);
             //$attributes['type'] = 'text';
             return $value;
             break;
     }
     switch ($attributes['type']) {
         case 'number':
             if (!$value) {
                 $value = '0';
             }
             if ($parms) {
                 if (!isset($parms['sep'])) {
                     $value = number_format($value, $parms['decimals']);
                 } else {
                     $value = number_format($value, $parms['decimals'], vartrue($parms['point'], '.'), vartrue($parms['sep'], ' '));
                 }
             }
             if (!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) {
                 $mode = preg_replace('/[^\\w]/', '', vartrue($_GET['mode'], ''));
                 $value = "<a class='e-tip e-editable editable-click' data-name='" . $field . "' title=\"" . LAN_EDIT . " " . $attributes['title'] . "\" data-type='text' data-pk='" . $id . "' data-url='" . e_SELF . "?mode={$mode}&action=inline&id={$id}&ajax_used=1' href='#'>" . $value . "</a>";
             }
             $value = vartrue($parms['pre']) . $value . vartrue($parms['post']);
             // else same
             break;
         case 'ip':
             //$e107 = e107::getInstance();
             $value = e107::getIPHandler()->ipDecode($value);
             // else same
             break;
         case 'templates':
         case 'layouts':
             $pre = vartrue($parms['pre']);
             $post = vartrue($parms['post']);
             unset($parms['pre'], $parms['post']);
             if ($parms) {
                 $attributes['writeParms'] = $parms;
             } elseif (isset($attributes['writeParms'])) {
                 if (is_string($attributes['writeParms'])) {
                     parse_str($attributes['writeParms'], $attributes['writeParms']);
                 }
             }
             $attributes['writeParms']['raw'] = true;
             $tmp = $this->renderElement($field, '', $attributes);
             // Inline Editing.  //@SecretR - please FIXME!
             if (!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) {
                 $mode = preg_replace('/[^\\w]/', '', vartrue($_GET['mode'], ''));
                 $source = str_replace('"', "'", json_encode($wparms));
                 $value = "<a class='e-tip e-editable editable-click' data-name='" . $field . "' data-source=\"" . $source . "\" title=\"" . LAN_EDIT . " " . $attributes['title'] . "\" data-type='select' data-pk='" . $id . "' data-url='" . e_SELF . "?mode=&amp;action=inline&amp;id={$id}&amp;ajax_used=1' href='#'>" . $value . "</a>";
             }
             //	$value = $pre.vartrue($tmp[$value]).$post; // FIXME "Fatal error: Only variables can be passed by reference" featurebox list page.
             break;
         case 'checkboxes':
         case 'comma':
         case 'dropdown':
             // XXX - should we use readParams at all here? see writeParms check below
             if ($parms && is_array($parms)) {
                 //FIXME return no value at all when 'editable=1' is a readParm. See FAQs templates.
                 //	$value = vartrue($parms['pre']).vartrue($parms[$value]).vartrue($parms['post']);
                 //	break;
             }
             // NEW - multiple (array values) support
             // FIXME - add support for multi-level arrays (option groups)
             if (!is_array($attributes['writeParms'])) {
                 parse_str($attributes['writeParms'], $attributes['writeParms']);
             }
             $wparms = $attributes['writeParms'];
             if (!is_array(varset($wparms['__options']))) {
                 parse_str($wparms['__options'], $wparms['__options']);
             }
             if (!empty($wparms['optArray'])) {
                 $fopts = $wparms;
                 $wparms = $fopts['optArray'];
                 unset($fopts['optArray']);
                 $wparms['__options'] = $fopts;
             }
             $opts = $wparms['__options'];
             unset($wparms['__options']);
             $_value = $value;
             if ($attributes['type'] == 'checkboxes' || $attributes['type'] == 'comma') {
                 $opts['multiple'] = true;
             }
             if (vartrue($opts['multiple'])) {
                 $ret = array();
                 $value = is_array($value) ? $value : explode(',', $value);
                 foreach ($value as $v) {
                     if (isset($wparms[$v])) {
                         $ret[] = $wparms[$v];
                     }
                 }
                 $value = implode(', ', $ret);
             } else {
                 $ret = '';
                 if (isset($wparms[$value])) {
                     $ret = $wparms[$value];
                 }
                 $value = $ret;
             }
             $value = $value ? vartrue($parms['pre']) . defset($value, $value) . vartrue($parms['post']) : '';
             // Inline Editing.
             // Inline Editing with 'comma' @SecretR - please FIXME - empty values added. @see news 'render type' or 'media-manager' category for test examples.
             if (!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) {
                 $xtype = $attributes['type'] == 'dropdown' ? 'select' : 'checklist';
                 //	$value = "<a class='e-tip e-editable editable-click' data-name='".$field."' data-value='{$_value}' data-source=\"".$source."\" title=\"".LAN_EDIT." ".$attributes['title']."\" data-type='".$xtype."' data-pk='".$id."' data-url='".e_SELF."?mode=&amp;action=inline&amp;id={$id}&amp;ajax_used=1' href='#'>".$value."</a>";
                 $value = $this->renderInline($field, $id, $attributes['title'], $_value, $value, $xtype, $wparms);
             }
             // return ;
             break;
         case 'radio':
             if ($parms && is_array($parms)) {
                 $value = vartrue($parms['pre']) . vartrue($parms[$value]) . vartrue($parms['post']);
                 break;
             }
             if (!is_array($attributes['writeParms'])) {
                 parse_str($attributes['writeParms'], $attributes['writeParms']);
             }
             $value = vartrue($attributes['writeParms']['__options']['pre']) . vartrue($attributes['writeParms'][$value]) . vartrue($attributes['writeParms']['__options']['post']);
             break;
         case 'tags':
             if (!empty($parms['constant'])) {
                 $value = defset($value, $value);
             }
             if (vartrue($parms['truncate'])) {
                 $value = $tp->text_truncate($value, $parms['truncate'], '...');
             } elseif (vartrue($parms['htmltruncate'])) {
                 $value = $tp->html_truncate($value, $parms['htmltruncate'], '...');
             }
             if (vartrue($parms['wrap'])) {
                 $value = $tp->htmlwrap($value, (int) $parms['wrap'], varset($parms['wrapChar'], ' '));
             }
             if (vartrue($parms['link']) && $id) {
                 $link = str_replace('[id]', $id, $parms['link']);
                 $link = $tp->replaceConstants($link);
                 // SEF URL is not important since we're in admin.
                 $dialog = vartrue($parms['target']) == 'dialog' ? " e-dialog" : "";
                 // iframe
                 $ext = vartrue($parms['target']) == 'blank' ? " rel='external' " : "";
                 // new window
                 $modal = vartrue($parms['target']) == 'modal' ? " data-toggle='modal' data-cache='false' data-target='#uiModal' " : "";
                 if ($parms['link'] == 'sef' && $this->getController()->getListModel()) {
                     $model = $this->getController()->getListModel();
                     // copy url config
                     if (!$model->getUrl()) {
                         $model->setUrl($this->getController()->getUrl());
                     }
                     // assemble the url
                     $link = $model->url();
                 } elseif (vartrue($data[$parms['link']])) {
                     $link = $tp->replaceConstants(vartrue($data[$parms['link']]));
                 }
                 // in case something goes wrong...
                 if ($link) {
                     $value = "<a class='e-tip{$dialog}' {$ext} href='" . $link . "' {$modal} title='Quick View' >" . $value . "</a>";
                 }
             }
             if (empty($value)) {
                 $value = '-';
                 $setValue = "data-value=''";
             } else {
                 $setValue = "";
                 if ($attributes['type'] == 'tags' && !empty($value)) {
                     $setValue = "data-value='" . $value . "'";
                     $value = str_replace(",", ", ", $value);
                     // add spaces so it wraps, but don't change the actual values.
                 }
             }
             if (!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) {
                 $options['selectize'] = array('create' => true, 'maxItems' => 7, 'mode' => 'multi', 'e_editable' => $field . '_' . $id);
                 $tpl = $this->text($field, $value, 80, $options);
                 $mode = preg_replace('/[^\\w]/', '', vartrue($_GET['mode'], ''));
                 $value = "<a id='" . $field . '_' . $id . "' class='e-tip e-editable editable-click editable-tags' data-emptytext='-' data-tpl='" . str_replace("'", '"', $tpl) . "' data-name='" . $field . "' title=\"" . LAN_EDIT . " " . $attributes['title'] . "\" data-type='text' data-pk='" . $id . "' " . $setValue . " data-url='" . e_SELF . "?mode={$mode}&amp;action=inline&amp;id={$id}&amp;ajax_used=1' href='#'>" . $value . "</a>";
             }
             $value = vartrue($parms['pre']) . $value . vartrue($parms['post']);
             break;
         case 'text':
             if (!empty($parms['constant'])) {
                 $value = defset($value, $value);
             }
             if (vartrue($parms['truncate'])) {
                 $value = $tp->text_truncate($value, $parms['truncate'], '...');
             } elseif (vartrue($parms['htmltruncate'])) {
                 $value = $tp->html_truncate($value, $parms['htmltruncate'], '...');
             }
             if (vartrue($parms['wrap'])) {
                 $value = $tp->htmlwrap($value, (int) $parms['wrap'], varset($parms['wrapChar'], ' '));
             }
             if (vartrue($parms['link']) && $id) {
                 $link = str_replace('[id]', $id, $parms['link']);
                 $link = $tp->replaceConstants($link);
                 // SEF URL is not important since we're in admin.
                 $dialog = vartrue($parms['target']) == 'dialog' ? " e-dialog" : "";
                 // iframe
                 $ext = vartrue($parms['target']) == 'blank' ? " rel='external' " : "";
                 // new window
                 $modal = vartrue($parms['target']) == 'modal' ? " data-toggle='modal' data-cache='false' data-target='#uiModal' " : "";
                 if ($parms['link'] == 'sef' && $this->getController()->getListModel()) {
                     $model = $this->getController()->getListModel();
                     // copy url config
                     if (!$model->getUrl()) {
                         $model->setUrl($this->getController()->getUrl());
                     }
                     // assemble the url
                     $link = $model->url();
                 } elseif (vartrue($data[$parms['link']])) {
                     $link = $tp->replaceConstants(vartrue($data[$parms['link']]));
                 }
                 // in case something goes wrong...
                 if ($link) {
                     $value = "<a class='e-tip{$dialog}' {$ext} href='" . $link . "' {$modal} title='Quick View' >" . $value . "</a>";
                 }
             }
             if (empty($value)) {
                 $value = '-';
                 $setValue = "data-value=''";
             } else {
                 $setValue = "";
                 if ($attributes['type'] == 'tags' && !empty($value)) {
                     $setValue = "data-value='" . $value . "'";
                     $value = str_replace(",", ", ", $value);
                     // add spaces so it wraps, but don't change the actual values.
                 }
             }
             if (!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) {
                 $mode = preg_replace('/[^\\w]/', '', vartrue($_GET['mode'], ''));
                 $value = "<a class='e-tip e-editable editable-click' data-emptytext='-' data-name='" . $field . "' title=\"" . LAN_EDIT . " " . $attributes['title'] . "\" data-type='text' data-pk='" . $id . "' " . $setValue . " data-url='" . e_SELF . "?mode={$mode}&amp;action=inline&amp;id={$id}&amp;ajax_used=1' href='#'>" . $value . "</a>";
             }
             $value = vartrue($parms['pre']) . $value . vartrue($parms['post']);
             break;
         case 'bbarea':
         case 'textarea':
             if ($attributes['type'] == 'textarea' && !vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) {
                 return $this->renderInline($field, $id, $attributes['title'], $value, substr($value, 0, 50) . "...", 'textarea');
                 //FIXME.
             }
             $expand = '...';
             $toexpand = false;
             if ($attributes['type'] == 'bbarea' && !isset($parms['bb'])) {
                 $parms['bb'] = true;
             }
             //force bb parsing for bbareas
             $elid = trim(str_replace('_', '-', $field)) . '-' . $id;
             if (!vartrue($parms['noparse'])) {
                 $value = $tp->toHTML($value, vartrue($parms['bb']) ? true : false, vartrue($parms['parse']));
             }
             if (vartrue($parms['expand']) || vartrue($parms['truncate']) || vartrue($parms['htmltruncate'])) {
                 $ttl = vartrue($parms['expand']);
                 if ($ttl == 1) {
                     $ttl = $expand . "<button class='btn btn-default btn-xs btn-mini pull-right'>More..</button>";
                     $ttl1 = "<button class='btn btn-default btn-xs btn-mini pull-right'>..Less</button>";
                 } else {
                     $ttl1 = null;
                 }
                 $expands = '<a href="#' . $elid . '-expand" class="e-show-if-js e-expandit">' . defset($ttl, $ttl) . "</a>";
                 $contracts = '<a href="#' . $elid . '-expand" class="e-show-if-js e-expandit">' . defset($ttl1, $ttl1) . "</a>";
             }
             $oldval = $value;
             if (vartrue($parms['truncate'])) {
                 $value = $oldval = strip_tags($value);
                 $value = $tp->text_truncate($value, $parms['truncate'], '');
                 $toexpand = $value != $oldval;
             } elseif (vartrue($parms['htmltruncate'])) {
                 $value = $tp->html_truncate($value, $parms['htmltruncate'], '');
                 $toexpand = $value != $oldval;
             }
             if ($toexpand) {
                 // force hide! TODO - core style .expand-c (expand container)
                 // TODO: Hide 'More..' button when text fully displayed.
                 $value .= '<span class="expand-c" style="display: none" id="' . $elid . '-expand"><span>' . str_replace($value, '', $oldval) . $contracts . '</span></span>';
                 $value .= $expands;
                 // 'More..' button. Keep it at the bottom so it does't cut the sentence.
             }
             break;
         case 'icon':
             $value = $tp->toIcon($value, array('size' => '2x'));
             break;
         case 'file':
             if (vartrue($parms['base'])) {
                 $url = $parms['base'] . $value;
             } else {
                 $url = e107::getParser()->replaceConstants($value, 'full');
             }
             $name = basename($value);
             $value = '<a href="' . $url . '" title="Direct link to ' . $name . '" rel="external">' . $name . '</a>';
             break;
         case 'image':
             //TODO - thumb, js tooltip...
             if ($value) {
                 if (strpos($value, ",") !== false) {
                     $tmp = explode(",", $value);
                     $value = $tmp[0];
                     unset($tmp);
                 }
                 $vparm = array('thumb' => 'tag', 'w' => vartrue($parms['thumb_aw'], '80'));
                 if ($video = e107::getParser()->toVideo($value, $vparm)) {
                     return $video;
                 }
                 $fileOnly = basename($value);
                 // Not an image but a file.  (media manager)
                 if (!preg_match("/\\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF)\$/", $fileOnly) && false !== strpos($fileOnly, '.')) {
                     $icon = "{e_IMAGE}filemanager/zip_32.png";
                     $src = $tp->replaceConstants(vartrue($parms['pre']) . $icon, 'abs');
                     //	return $value;
                     return e107::getParser()->toGlyph('fa-file', 'size=2x');
                     //		return '<img src="'.$src.'" alt="'.$value.'" class="e-thumb" title="'.$value.'" />';
                 }
                 if (vartrue($parms['thumb'])) {
                     $thparms = array();
                     // Support readParms example: thumb=1&w=200&h=300
                     // Support readParms example: thumb=1&aw=80&ah=30
                     if (isset($parms['h'])) {
                         $thparms['h'] = intval($parms['h']);
                     }
                     if (isset($parms['ah'])) {
                         $thparms['ah'] = intval($parms['ah']);
                     }
                     if (isset($parms['w'])) {
                         $thparms['w'] = intval($parms['w']);
                     }
                     if (isset($parms['aw'])) {
                         $thparms['aw'] = intval($parms['aw']);
                     }
                     // Support readParms example: thumb=200x300 (wxh)
                     if (strpos($parms['thumb'], 'x') !== false) {
                         list($thparms['w'], $thparms['h']) = explode('x', $parms['thumb']);
                     }
                     // Support readParms example: thumb={width}
                     if (!isset($parms['w']) && is_numeric($parms['thumb']) && '1' != $parms['thumb']) {
                         $thparms['w'] = intval($parms['thumb']);
                     } elseif (vartrue($parms['thumb_aw'])) {
                         $thparms['aw'] = intval($parms['thumb_aw']);
                     }
                     //	return print_a($thparms,true);
                     $src = $tp->replaceConstants(vartrue($parms['pre']) . $value, 'abs');
                     $thsrc = $tp->thumbUrl(vartrue($parms['pre']) . $value, $thparms, varset($parms['thumb_urlraw']));
                     $alt = basename($src);
                     $ttl = '<img src="' . $thsrc . '" alt="' . $alt . '" class="thumbnail e-thumb" />';
                     $value = '<a href="' . $src . '" data-modal-caption="' . $alt . '" data-target="#uiModal" class="e-modal e-image-preview" title="' . $alt . '" rel="external">' . $ttl . '</a>';
                 } else {
                     $src = $tp->replaceConstants(vartrue($parms['pre']) . $value, 'abs');
                     $alt = $src;
                     //basename($value);
                     $ttl = vartrue($parms['title'], 'LAN_PREVIEW');
                     $value = '<a href="' . $src . '" class="e-image-preview" title="' . $alt . '" rel="external">' . defset($ttl, $ttl) . '</a>';
                 }
             }
             break;
         case 'files':
             $ret = '<ol>';
             for ($i = 0; $i < 5; $i++) {
                 $k = $key . '[' . $i . '][path]';
                 $ival = $value[$i]['path'];
                 $ret .= '<li>' . $ival . '</li>';
             }
             $ret .= '</ol>';
             $value = $ret;
             break;
         case 'datestamp':
             $value = $value ? e107::getDate()->convert_date($value, vartrue($parms['mask'], 'short')) : '';
             break;
         case 'date':
             // just show original value
             break;
         case 'userclass':
             $dispvalue = $this->_uc->uc_get_classname($value);
             // Inline Editing.
             if (!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) {
                 $mode = preg_replace('/[^\\w]/', '', vartrue($_GET['mode'], ''));
                 $uc_options = vartrue($parms['classlist'], 'public,guest,nobody,member,admin,main,classes');
                 // defaults to 'public,guest,nobody,member,classes' (userclass handler)
                 unset($parms['classlist']);
                 $array = e107::getUserClass()->uc_required_class_list($uc_options);
                 //XXX Ugly looking (non-standard) function naming - TODO discuss name change.
                 $source = str_replace('"', "'", json_encode($array, JSON_FORCE_OBJECT));
                 //NOTE Leading ',' required on $value; so it picks up existing value.
                 $value = "<a class='e-tip e-editable editable-click' data-placement='left' data-value='" . $value . "' data-name='" . $field . "' data-source=\"" . $source . "\" title=\"" . LAN_EDIT . " " . $attributes['title'] . "\" data-type='select' data-pk='" . $id . "' data-url='" . e_SELF . "?mode={$mode}&amp;action=inline&amp;id={$id}&amp;ajax_used=1' href='#'>" . $dispvalue . "</a>";
             } else {
                 $value = $dispvalue;
             }
             break;
         case 'userclasses':
             //	return $value;
             $classes = explode(',', $value);
             $uv = array();
             foreach ($classes as $cid) {
                 if (!empty($parms['defaultLabel']) && $cid === '') {
                     $uv[] = $parms['defaultLabel'];
                     continue;
                 }
                 $uv[] = $this->_uc->getName($cid);
             }
             $dispvalue = implode(vartrue($parms['separator'], "<br />"), $uv);
             // Inline Editing.
             if (!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) {
                 $uc_options = vartrue($parms['classlist'], 'public,guest, nobody,member,admin,main,classes');
                 // defaults to 'public,guest,nobody,member,classes' (userclass handler)
                 $array = e107::getUserClass()->uc_required_class_list($uc_options);
                 //XXX Ugly looking (non-standard) function naming - TODO discuss name change.
                 //$mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], ''));
                 $mode = $tp->filter(vartrue($_GET['mode'], ''), 'w');
                 $source = str_replace('"', "'", json_encode($array, JSON_FORCE_OBJECT));
                 //NOTE Leading ',' required on $value; so it picks up existing value.
                 $value = "<a class='e-tip e-editable editable-click' data-placement='bottom' data-value='," . $value . "' data-name='" . $field . "' data-source=\"" . $source . "\" title=\"" . LAN_EDIT . " " . $attributes['title'] . "\" data-type='checklist' data-pk='" . $id . "' data-url='" . e_SELF . "?mode={$mode}&amp;action=inline&amp;id={$id}&amp;ajax_used=1' href='#'>" . $dispvalue . "</a>";
             } else {
                 $value = $dispvalue;
             }
             unset($parms['classlist']);
             break;
             /*case 'user_name':
             		case 'user_loginname':
             		case 'user_login':
             		case 'user_customtitle':
             		case 'user_email':*/
         /*case 'user_name':
         		case 'user_loginname':
         		case 'user_login':
         		case 'user_customtitle':
         		case 'user_email':*/
         case 'user':
             /*if(is_numeric($value))
             		{
             			$value = e107::user($value);
             			if($value)
             			{
             				$value = $value[$attributes['type']] ? $value[$attributes['type']] : $value['user_name'];
             			}
             			else
             			{
             				$value = 'not found';
             			}
             		}*/
             $row_id = $id;
             // Dirty, but the only way for now
             $id = 0;
             $ttl = LAN_ANONYMOUS;
             //Defaults to user_id and user_name (when present) and when idField and nameField are not present.
             // previously set - real parameters are idField && nameField
             $id = vartrue($parms['__idval']);
             if ($value && !is_numeric($value)) {
                 $id = vartrue($parms['__idval']);
                 $ttl = $value;
             } elseif ($value && is_numeric($value)) {
                 $id = $value;
                 if (vartrue($parms['__nameval'])) {
                     $ttl = $parms['__nameval'];
                 } else {
                     $user = e107::user($value);
                     if (vartrue($user['user_name'])) {
                         $ttl = $user['user_name'];
                     }
                 }
             }
             if (!empty($parms['link']) && $id && $ttl && is_numeric($id)) {
                 // Stay in admin area.
                 $link = e_ADMIN . "users.php?mode=main&action=edit&id=" . $id . "&readonly=1&iframe=1";
                 // e107::getUrl()->create('user/profile/view', array('id' => $id, 'name' => $ttl))
                 $value = '<a class="e-modal" data-modal-caption="User #' . $id . ' : ' . $ttl . '" href="' . $link . '" title="Go to user profile">' . $ttl . '</a>';
             } else {
                 $value = $ttl;
             }
             // Inline Editing.
             if (!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) {
                 // Need a Unique Field ID to store field settings using e107::js('settings').
                 $fieldID = $this->name2id($field . '_' . microtime(true));
                 // Unique ID for each rows.
                 $eEditableID = $this->name2id($fieldID . '_' . $row_id);
                 $tpl = $this->userpicker($field, '', $ttl, $id, array('id' => $fieldID, 'selectize' => array('e_editable' => $eEditableID)));
                 $mode = preg_replace('/[^\\w]/', '', vartrue($_GET['mode'], ''));
                 $value = "<a id='" . $eEditableID . "' class='e-tip e-editable editable-click editable-userpicker' data-clear='false' data-tpl='" . str_replace("'", '"', $tpl) . "' data-name='" . $field . "' title=\"" . LAN_EDIT . " " . $attributes['title'] . "\" data-type='text' data-pk='" . $row_id . "' data-value='" . $id . "' data-url='" . e_SELF . "?mode={$mode}&amp;action=inline&amp;id={$row_id}&amp;ajax_used=1' href='#'>" . $ttl . "</a>";
             }
             break;
         case 'bool':
         case 'boolean':
             $false = vartrue($parms['trueonly']) ? "" : ADMIN_FALSE_ICON;
             if (!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) {
                 if (isset($parms['false'])) {
                     $false = $parms['false'];
                 } else {
                     $false = $value === '' ? "&square;" : "&cross;";
                 }
                 $true = varset($parms['true'], '&check;');
                 // custom representation for 'true'. (supports font-awesome when set by css)
                 $value = intval($value);
                 $wparms = vartrue($parms['reverse']) ? array(0 => $true, 1 => $false) : array(0 => $false, 1 => $true);
                 $dispValue = $wparms[$value];
                 return $this->renderInline($field, $id, $attributes['title'], $value, $dispValue, 'select', $wparms);
             }
             if (vartrue($parms['reverse'])) {
                 $value = $value ? $false : ADMIN_TRUE_ICON;
             } else {
                 $value = $value ? ADMIN_TRUE_ICON : $false;
             }
             break;
         case 'url':
             if (!$value) {
                 break;
             }
             $ttl = $value;
             if (vartrue($parms['href'])) {
                 return $tp->replaceConstants(vartrue($parms['pre']) . $value, varset($parms['replace_mod'], 'abs'));
             }
             if (vartrue($parms['truncate'])) {
                 $ttl = $tp->text_truncate($value, $parms['truncate'], '...');
             }
             $value = "<a href='" . $tp->replaceConstants(vartrue($parms['pre']) . $value, 'abs') . "' title='{$value}'>" . $ttl . "</a>";
             break;
         case 'email':
             if (!$value) {
                 break;
             }
             $ttl = $value;
             if (vartrue($parms['truncate'])) {
                 $ttl = $tp->text_truncate($value, $parms['truncate'], '...');
             }
             $value = "<a href='mailto:" . $value . "' title='{$value}'>" . $ttl . "</a>";
             break;
         case 'method':
             // Custom Function
             $method = $attributes['field'];
             // prevents table alias in method names. ie. u.my_method.
             $_value = $value;
             if ($attributes['data'] == 'array') {
                 $value = e107::unserialize($value);
                 // (saved as array, return it as an array)
             }
             $meth = !empty($attributes['method']) ? $attributes['method'] : $method;
             if (method_exists($this, $meth)) {
                 $parms['field'] = $field;
                 $value = call_user_func_array(array($this, $meth), array($value, 'read', $parms));
             } else {
                 return "<span class='label label-important label-danger'>Missing: " . $method . "()</span>";
             }
             //	 print_a($attributes);
             // Inline Editing.
             if (!vartrue($attributes['noedit']) && vartrue($parms['editable'])) {
                 $mode = preg_replace('/[^\\w]/', '', vartrue($_GET['mode'], ''));
                 $methodParms = call_user_func_array(array($this, $method), array($value, 'inline', $parms));
                 if (!empty($methodParms['inlineType'])) {
                     $attributes['inline'] = $methodParms['inlineType'];
                     $methodParms = !empty($methodParms['inlineData']) ? $methodParms['inlineData'] : null;
                 }
                 if (is_string($attributes['inline'])) {
                     switch ($attributes['inline']) {
                         case 'checklist':
                             $xtype = 'checklist';
                             break;
                         case 'select':
                         case 'dropdown':
                             $xtype = 'select';
                             break;
                         case 'textarea':
                             $xtype = 'textarea';
                             break;
                         default:
                             $xtype = 'text';
                             $methodParms = null;
                             break;
                     }
                 }
                 if (!empty($xtype)) {
                     $value = $this->renderInline($field, $id, $attributes['title'], $_value, $value, $xtype, $methodParms);
                 }
             }
             break;
         case 'hidden':
             return vartrue($parms['show']) ? $value ? $value : vartrue($parms['empty']) : '';
             break;
         case 'language':
             // All Known Languages.
             if (!empty($value)) {
                 $_value = $value;
                 if (strlen($value) === 2) {
                     $value = e107::getLanguage()->convert($value);
                 }
             }
             if (!vartrue($attributes['noedit']) && vartrue($parms['editable'])) {
                 $wparms = e107::getLanguage()->getList();
                 return $this->renderInline($field, $id, $attributes['title'], $_value, $value, 'select', $wparms);
             }
             return $value;
             break;
         case 'lanlist':
             // installed languages.
             $options = e107::getLanguage()->getLanSelectArray();
             if ($options) {
                 if (!is_array($attributes['writeParms'])) {
                     parse_str($attributes['writeParms'], $attributes['writeParms']);
                 }
                 $wparms = $attributes['writeParms'];
                 if (!is_array(varset($wparms['__options']))) {
                     parse_str($wparms['__options'], $wparms['__options']);
                 }
                 $opts = $wparms['__options'];
                 if ($opts['multiple']) {
                     $ret = array();
                     $value = is_array($value) ? $value : explode(',', $value);
                     foreach ($value as $v) {
                         if (isset($options[$v])) {
                             $ret[] = $options[$v];
                         }
                     }
                     $value = implode(', ', $ret);
                 } else {
                     $ret = '';
                     if (isset($options[$value])) {
                         $ret = $options[$value];
                     }
                     $value = $ret;
                 }
                 $value = $value ? vartrue($parms['pre']) . $value . vartrue($parms['post']) : '';
             } else {
                 $value = '';
             }
             break;
             //TODO - order
         //TODO - order
         default:
             //unknown type
             break;
     }
     return $value;
 }
Example #19
0
 function banlist_banexpires($curVal, $mode)
 {
     $pref = e107::getPref();
     $date = e107::getDate();
     $opts = $this->banexpires();
     switch ($mode) {
         case 'read':
             // List Page
             $id = $this->getController()->getListModel()->get('banlist_ip');
             //	$val =  ($curVal ? strftime($pref['ban_date_format'], $curVal).(($curVal < time()) ? ' ('.BANLAN_34.')' : '') : LAN_NEVER); // ."<br />".$this->banexpires();
             //	$val .= " (".$curVal.")";
             // $mod = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], ''));
             $val = vartrue($curVal) ? $date->computeLapse(time(), $curVal) : LAN_NEVER;
             $val = str_replace("ago", "", $val);
             // quick fix for the 'ago'.
             if (vartrue($curVal) && $curVal < time()) {
                 $val = BANLAN_34;
             }
             $source = str_replace('"', "'", json_encode($opts));
             return "<a class='e-tip e-editable' data-name='banlist_banexpires' data-source=\"" . $source . "\"  data-type='select' data-pk='" . $id . "' data-url='" . e_SELF . "?mode=&amp;action=inline&amp;id={$id}&amp;ajax_used=1' href='#'>" . $val . "</a>";
             break;
         case 'write':
             // Edit Page
             if (!empty($curVal)) {
                 $opts[$curVal] = e107::getParser()->toDate($curVal, 'short');
             }
             return $this->selectbox('banlist_banexpires', $opts, $curVal);
             // return $frm->text('banlist_banexpires',$curVal);
             break;
         case 'filter':
         case 'batch':
             return false;
             break;
     }
 }
Example #20
0
 /**
  * Render Field Value
  * @param string $field field name
  * @param mixed $value field value
  * @param array $attributes field attributes including render parameters, element options - see e_admin_ui::$fields for required format
  * @return string
  */
 function renderValue($field, $value, $attributes, $id = 0)
 {
     $parms = array();
     if (isset($attributes['readParms'])) {
         if (!is_array($attributes['readParms'])) {
             parse_str($attributes['readParms'], $attributes['readParms']);
         }
         $parms = $attributes['readParms'];
     }
     $tp = e107::getParser();
     switch ($field) {
         case 'options':
             if ($attributes['type'] == 'method') {
                 $attributes['mode'] = "read";
                 if (isset($attributes['method']) && $attributes['method'] && method_exists($this, $attributes['method'])) {
                     $method = $attributes['method'];
                     return $this->{$method}($parms, $value, $id, $attributes);
                 } elseif (method_exists($this, 'options')) {
                     //return  $this->options($field, $value, $attributes, $id);
                     // consistent method arguments, fixed in admin cron administration
                     return $this->options($parms, $value, $id, $attributes);
                     // OLD breaks admin->cron 'options' column
                 }
             }
             if (!$value) {
                 parse_str(str_replace('&amp;', '&', e_QUERY), $query);
                 //FIXME - FIX THIS
                 // keep other vars in tact
                 $query['action'] = 'edit';
                 $query['id'] = $id;
                 //$edit_query = array('mode' => varset($query['mode']), 'action' => varset($query['action']), 'id' => $id);
                 $query = http_build_query($query);
                 $value = "";
                 if (vartrue($parms['sort'])) {
                     $value .= "<a class='e-sort' style='cursor:move' href='" . e_SELF . "?" . (e_QUERY ? e_QUERY . "&amp;ajax_used=1" : "ajax_used=1") . "' title='Re-order'>" . ADMIN_SORT_ICON . "</a> ";
                 }
                 $value .= "<a href='" . e_SELF . "?{$query}' class='e-tip' title='" . LAN_EDIT . "' data-placement='left'>\r\n\t\t\t\t\t<img class='icon action edit list' src='" . ADMIN_EDIT_ICON_PATH . "' alt='" . LAN_EDIT . "' /></a>";
                 $delcls = vartrue($attributes['noConfirm']) ? ' no-confirm' : '';
                 if (varset($parms['deleteClass'])) {
                     $cls = deftrue($parms['deleteClass']) ? constant($parms['deleteClass']) : $parms['deleteClass'];
                     if (check_class($cls)) {
                         $value .= $this->submit_image('etrigger_delete[' . $id . ']', $id, 'delete', LAN_DELETE . ' [ ID: ' . $id . ' ]', array('class' => 'action delete' . $delcls));
                     }
                 } else {
                     $value .= $this->submit_image('etrigger_delete[' . $id . ']', $id, 'delete', LAN_DELETE . ' [ ID: ' . $id . ' ]', array('class' => 'action delete' . $delcls));
                 }
             }
             //$attributes['type'] = 'text';
             return $value;
             break;
         case 'checkboxes':
             $value = $this->checkbox(vartrue($attributes['toggle'], 'multiselect') . '[' . $id . ']', $id);
             //$attributes['type'] = 'text';
             return $value;
             break;
     }
     switch ($attributes['type']) {
         case 'number':
             if (!$value) {
                 $value = '0';
             }
             if ($parms) {
                 if (!isset($parms['sep'])) {
                     $value = number_format($value, $parms['decimals']);
                 } else {
                     $value = number_format($value, $parms['decimals'], vartrue($parms['point'], '.'), vartrue($parms['sep'], ' '));
                 }
             }
             $value = vartrue($parms['pre']) . $value . vartrue($parms['post']);
             // else same
             break;
         case 'ip':
             //$e107 = e107::getInstance();
             $value = e107::getIPHandler()->ipDecode($value);
             // else same
             break;
         case 'templates':
         case 'layouts':
             $pre = vartrue($parms['pre']);
             $post = vartrue($parms['post']);
             unset($parms['pre'], $parms['post']);
             if ($parms) {
                 $attributes['writeParms'] = $parms;
             } elseif (isset($attributes['writeParms'])) {
                 if (is_string($attributes['writeParms'])) {
                     parse_str($attributes['writeParms'], $attributes['writeParms']);
                 }
             }
             $attributes['writeParms']['raw'] = true;
             $tmp = $this->renderElement($field, '', $attributes);
             //	$value = $pre.vartrue($tmp[$value]).$post; // FIXME "Fatal error: Only variables can be passed by reference" featurebox list page.
             break;
         case 'dropdown':
             // XXX - should we use readParams at all here? see writeParms check below
             if ($parms && is_array($parms)) {
                 $value = vartrue($parms['pre']) . vartrue($parms[$value]) . vartrue($parms['post']);
                 break;
             }
             // NEW - multiple (array values) support
             // FIXME - add support for multi-level arrays (option groups)
             if (!is_array($attributes['writeParms'])) {
                 parse_str($attributes['writeParms'], $attributes['writeParms']);
             }
             $wparms = $attributes['writeParms'];
             if (!is_array(varset($wparms['__options']))) {
                 parse_str($wparms['__options'], $wparms['__options']);
             }
             $opts = $wparms['__options'];
             unset($wparms['__options']);
             if ($opts['multiple'] || $attributes['data'] == 'comma') {
                 $ret = array();
                 $value = is_array($value) ? $value : explode(',', $value);
                 foreach ($value as $v) {
                     if (isset($wparms[$v])) {
                         $ret[] = $wparms[$v];
                     }
                 }
                 $value = implode(', ', $ret);
             } else {
                 $ret = '';
                 if (isset($wparms[$value])) {
                     $ret = $wparms[$value];
                 }
                 $value = $ret;
             }
             $value = $value ? vartrue($parms['pre']) . defset($value, $value) . vartrue($parms['post']) : '';
             // return ;
             break;
         case 'radio':
             if ($parms && is_array($parms)) {
                 $value = vartrue($parms['pre']) . vartrue($parms[$value]) . vartrue($parms['post']);
                 break;
             }
             if (!is_array($attributes['writeParms'])) {
                 parse_str($attributes['writeParms'], $attributes['writeParms']);
             }
             $value = vartrue($parms['pre']) . vartrue($parms[$value]) . vartrue($parms['post']);
             break;
         case 'text':
             if (vartrue($parms['truncate'])) {
                 $value = $tp->text_truncate($value, $parms['truncate'], '...');
             } elseif (vartrue($parms['htmltruncate'])) {
                 $value = $tp->html_truncate($value, $parms['htmltruncate'], '...');
             }
             if (vartrue($parms['wrap'])) {
                 $value = $tp->htmlwrap($value, (int) $parms['wrap'], varset($parms['wrapChar'], ' '));
             }
             if (vartrue($parms['link']) && $id && is_numeric($id)) {
                 $link = str_replace('[id]', $id, $parms['link']);
                 $link = $tp->replaceConstants($link);
                 // SEF URL is not important since we're in admin.
                 $dialog = vartrue($parms['dialog']) ? "e-dialog" : "";
                 $value = "<a class='e-tip {$dialog}' href='" . $link . "' title='Quick View'>" . $value . "</a>";
             }
             $value = vartrue($parms['pre']) . $value . vartrue($parms['post']);
             break;
         case 'bbarea':
         case 'textarea':
             $expand = '...';
             $toexpand = false;
             if ($attributes['type'] == 'bbarea' && !isset($parms['bb'])) {
                 $parms['bb'] = true;
             }
             //force bb parsing for bbareas
             $elid = trim(str_replace('_', '-', $field)) . '-' . $id;
             if (!vartrue($parms['noparse'])) {
                 $value = $tp->toHTML($value, vartrue($parms['bb']) ? true : false, vartrue($parms['parse']));
             }
             if (vartrue($parms['expand']) || vartrue($parms['truncate']) || vartrue($parms['htmltruncate'])) {
                 $ttl = vartrue($parms['expand'], '&nbsp;...');
                 $expand = '&nbsp;<a href="#' . $elid . '-expand" class="e-show-if-js e-expandit">' . defset($ttl, $ttl) . "</a>";
             }
             $oldval = $value;
             if (vartrue($parms['truncate'])) {
                 $value = $oldval = strip_tags($value);
                 $value = $tp->text_truncate($value, $parms['truncate'], $expand);
                 $truncated = str_replace($expand, '', $value);
                 $toexpand = $value != $oldval;
             } elseif (vartrue($parms['htmltruncate'])) {
                 $value = $tp->html_truncate($value, $parms['htmltruncate'], $expand);
                 $toexpand = $value != $oldval;
             }
             if ($toexpand) {
                 // force hide! TODO - core style .expand-c (expand container)
                 $value .= '<div class="expand-c" style="display: none" id="' . $elid . '-expand"><div>' . str_replace($truncated, ' ', $oldval) . '</div></div>';
             }
             break;
         case 'icon':
             $value = '<img src="' . $tp->replaceConstants(vartrue($parms['pre']) . $value, 'abs') . '" alt="' . basename($value) . '" class="icon' . (vartrue($parms['class']) ? ' ' . $parms['class'] : '') . '" />';
             break;
         case 'file':
             if (vartrue($parms['base'])) {
                 $url = $parms['base'] . $value;
             } else {
                 $url = e107::getParser()->replaceConstants($value, 'full');
             }
             $name = basename($value);
             $value = '<a href="' . $url . '" title="Direct link to ' . $name . '" rel="external">' . $name . '</a>';
             break;
         case 'image':
             //TODO - thumb, js tooltip...
             if ($value) {
                 if (!preg_match("/[a-zA-z0-9_-\\s\\(\\)]+\\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF)\$/", $value)) {
                     $icon = "{e_IMAGE}filemanager/zip_32.png";
                     $src = $tp->replaceConstants(vartrue($parms['pre']) . $icon, 'abs');
                     return '<img src="' . $src . '" alt="' . $value . '" class="e-thumb" title="' . $value . '" />';
                 }
                 if (vartrue($parms['thumb'])) {
                     $src = $tp->replaceConstants(vartrue($parms['pre']) . $value, 'abs');
                     $thumb = $parms['thumb'];
                     $thparms = array();
                     if (is_numeric($thumb) && '1' != $thumb) {
                         $thparms['w'] = intval($thumb);
                     } elseif (vartrue($parms['thumb_aw'])) {
                         $thparms['aw'] = intval($parms['thumb_aw']);
                     }
                     $thsrc = $tp->thumbUrl(vartrue($parms['pre']) . $value, $thparms, varset($parms['thumb_urlraw']));
                     $alt = $src;
                     $ttl = '<img src="' . $thsrc . '" alt="' . $alt . '" class="e-thumb" />';
                     $value = '<a href="' . $src . '" class="e-dialog e-image-preview" title="' . $alt . '" rel="external">' . $ttl . '</a>';
                 } else {
                     $src = $tp->replaceConstants(vartrue($parms['pre']) . $value, 'abs');
                     $alt = $src;
                     //basename($value);
                     $ttl = vartrue($parms['title'], 'LAN_PREVIEW');
                     $value = '<a href="' . $src . '" class="e-image-preview" title="' . $alt . '" rel="external">' . defset($ttl, $ttl) . '</a>';
                 }
             }
             break;
         case 'datestamp':
             $value = $value ? e107::getDate()->convert_date($value, vartrue($parms['mask'], 'short')) : '';
             break;
         case 'date':
             // just show original value
             break;
         case 'userclass':
             $value = $this->_uc->uc_get_classname($value);
             break;
         case 'userclasses':
             $classes = explode(',', $value);
             $value = array();
             foreach ($classes as $cid) {
                 $value[] = $this->_uc->uc_get_classname($cid);
             }
             $value = implode(vartrue($parms['separator'], "<br />"), $value);
             break;
             /*case 'user_name':
             		case 'user_loginname':
             		case 'user_login':
             		case 'user_customtitle':
             		case 'user_email':*/
         /*case 'user_name':
         		case 'user_loginname':
         		case 'user_login':
         		case 'user_customtitle':
         		case 'user_email':*/
         case 'user':
             /*if(is_numeric($value))
             		{
             			$value = get_user_data($value);
             			if($value)
             			{
             				$value = $value[$attributes['type']] ? $value[$attributes['type']] : $value['user_name'];
             			}
             			else
             			{
             				$value = 'not found';
             			}
             		}*/
             // Dirty, but the only way for now
             $id = 0;
             $ttl = '';
             //Defaults to user_id and user_name (when present) and when idField and nameField are not present.
             // previously set - real parameters are idField && nameField
             $id = vartrue($parms['__idval']);
             if ($value && !is_numeric($value)) {
                 $id = vartrue($parms['__idval']);
                 $ttl = $value;
             } elseif ($value && is_numeric($value)) {
                 $id = $value;
                 $ttl = vartrue($parms['__nameval']);
             }
             if (vartrue($parms['link']) && $id && $ttl && is_numeric($id)) {
                 $value = '<a href="' . e107::getUrl()->create('user/profile/view', array('id' => $id, 'name' => $ttl)) . '" title="Go to user profile">' . $ttl . '</a>';
             } else {
                 $value = $ttl;
             }
             break;
         case 'bool':
         case 'boolean':
             $false = vartrue($parms['trueonly']) ? "" : ADMIN_FALSE_ICON;
             if (vartrue($parms['reverse'])) {
                 $value = $value ? $false : ADMIN_TRUE_ICON;
             } else {
                 $value = $value ? ADMIN_TRUE_ICON : $false;
             }
             break;
         case 'url':
             if (!$value) {
                 break;
             }
             $ttl = $value;
             if (vartrue($parms['href'])) {
                 return $tp->replaceConstants(vartrue($parms['pre']) . $value, varset($parms['replace_mod'], 'abs'));
             }
             if (vartrue($parms['truncate'])) {
                 $ttl = $tp->text_truncate($value, $parms['truncate'], '...');
             }
             $value = "<a href='" . $tp->replaceConstants(vartrue($parms['pre']) . $value, 'abs') . "' title='{$value}'>" . $ttl . "</a>";
             break;
         case 'email':
             if (!$value) {
                 break;
             }
             $ttl = $value;
             if (vartrue($parms['truncate'])) {
                 $ttl = $tp->text_truncate($value, $parms['truncate'], '...');
             }
             $value = "<a href='mailto:" . $value . "' title='{$value}'>" . $ttl . "</a>";
             break;
         case 'method':
             // Custom Function
             $method = $attributes['field'];
             // prevents table alias in method names. ie. u.my_method.
             $value = call_user_func_array(array($this, $method), array($value, 'read', $parms));
             break;
         case 'hidden':
             return vartrue($parms['show']) ? $value ? $value : vartrue($parms['empty']) : '';
             break;
         case 'lanlist':
             $options = e107::getLanguage()->getLanSelectArray();
             if ($options) {
                 if (!is_array($attributes['writeParms'])) {
                     parse_str($attributes['writeParms'], $attributes['writeParms']);
                 }
                 $wparms = $attributes['writeParms'];
                 if (!is_array(varset($wparms['__options']))) {
                     parse_str($wparms['__options'], $wparms['__options']);
                 }
                 $opts = $wparms['__options'];
                 if ($opts['multiple']) {
                     $ret = array();
                     $value = is_array($value) ? $value : explode(',', $value);
                     foreach ($value as $v) {
                         if (isset($options[$v])) {
                             $ret[] = $options[$v];
                         }
                     }
                     $value = implode(', ', $ret);
                 } else {
                     $ret = '';
                     if (isset($options[$value])) {
                         $ret = $options[$value];
                     }
                     $value = $ret;
                 }
                 $value = $value ? vartrue($parms['pre']) . $value . vartrue($parms['post']) : '';
             } else {
                 $value = '';
             }
             break;
             //TODO - order
         //TODO - order
         default:
             //unknown type
             break;
     }
     return $value;
 }
Example #21
0
 function mostActiveTopics()
 {
     //require_once (e_HANDLER.'userclass_class.php');
     $sql = e107::getDb();
     $tp = e107::getParser();
     $ns = e107::getRender();
     require_once e_PLUGIN . 'forum/forum_class.php';
     $forum = new e107forum();
     $forumList = implode(',', $forum->getForumPermList('view'));
     $qry = "\n\t\tSELECT\n\t\t\tt.*, u.user_name, ul.user_name AS user_last, f.forum_name\n\t\tFROM `#forum_thread` as t\n\t\tLEFT JOIN `#forum` AS f ON f.forum_id = t.thread_forum_id\n\t\tLEFT JOIN `#user` AS u ON u.user_id = t.thread_user\n\t\tLEFT JOIN `#user` AS ul ON ul.user_id = t.thread_lastuser\n\t\tWHERE t.thread_forum_id IN ({$forumList})\n\t\tORDER BY t.thread_views DESC\n\t\tLIMIT\n\t\t\t{$this->from}, {$this->view}\n\t\t";
     if ($sql->gen($qry)) {
         $text = "<div>\n<table style='width:auto' class='table fborder'>\n";
         $gen = e107::getDate();
         $text .= "<tr>\n\t\t\t<th style='width:5%' class='forumheader'>&nbsp;</th>\n\t\t\t<th style='width:45%' class='forumheader'>" . LAN_1 . "</th>\n\t\t\t<th style='width:15%; text-align:center' class='forumheader'>" . LAN_2 . "</th>\n\t\t\t<th style='width:5%; text-align:center' class='forumheader'>" . LAN_3 . "</th>\n\t\t\t<th style='width:5%; text-align:center' class='forumheader'>" . LAN_4 . "</th>\n\t\t\t<th style='width:25%; text-align:center' class='forumheader'>" . LAN_5 . "</th>\n\t\t\t</tr>\n";
         while ($row = $sql->fetch(MYSQL_ASSOC)) {
             if ($row['user_name']) {
                 $POSTER = "<a href='" . e107::getUrl()->create('user/profile/view', "name={$row['user_name']}&id={$row['thread_user']}") . "'>{$row['user_name']}</a>";
             } else {
                 $POSTER = $row['thread_user_anon'];
             }
             $LINKTOTHREAD = e107::getUrl()->create('forum/thread/view', array('id' => $row['thread_id']));
             //$e107->url->getUrl('forum', 'thread', "func=view&id={$row['thread_id']}");
             $LINKTOFORUM = e107::getUrl()->create('forum/forum/view', array('id' => $row['thread_forum_id']));
             //$e107->url->getUrl('forum', 'forum', "func=view&id={$row['thread_forum_id']}");
             $lastpost_datestamp = $gen->convert_date($row['thread_lastpost'], 'forum');
             if ($row['user_last']) {
                 $LASTPOST = "<a href='" . e107::getUrl()->create('user/profile/view', "name={$row['user_last']}&id={$row['thread_lastuser']}") . "'>{$row['user_last']}</a><br />" . $lastpost_datestamp;
             } else {
                 $LASTPOST = $row['thread_lastuser_anon'] . '<br />' . $lastpost_datestamp;
             }
             $text .= "<tr>\n\t\t\t\t\t<td style='width:5%; text-align:center' class='forumheader3'><img src='" . e_PLUGIN_ABS . "forum/images/" . IMODE . "/new_small.png' alt='' /></td>\n\t\t\t\t\t<td style='width:45%' class='forumheader3'><b><a href='{$LINKTOTHREAD}'>{$row['thread_name']}</a></b> <span class='smalltext'>(<a href='{$LINKTOFORUM}'>{$row['forum_name']}</a>)</span></td>\n\t\t\t\t\t<td style='width:15%; text-align:center' class='forumheader3'>{$POSTER}</td>\n\t\t\t\t\t<td style='width:5%; text-align:center' class='forumheader3'>{$row['thread_views']}</td>\n\t\t\t\t\t<td style='width:5%; text-align:center' class='forumheader3'>{$row['thread_total_replies']}</td>\n\t\t\t\t\t<td style='width:25%; text-align:center' class='forumheader3'>{$LASTPOST}</td>\n\t\t\t\t\t</tr>\n";
         }
         $text .= "</table>\n</div>";
         $ftotal = $sql->count('forum_thread', '(*)', 'WHERE `thread_parent` = 0');
         $parms = "{$ftotal},{$this->view},{$this->from}," . e_SELF . '?[FROM].active.forum.' . $this->view;
         $text .= "<div class='nextprev'>" . $tp->parseTemplate("{NEXTPREV={$parms}}") . '</div>';
         $ns->tablerender(LAN_7, $text, 'nfp');
     }
 }
Example #22
0
    } else {
        $up_button = "&nbsp;leave_32.png";
    }
    //FIXME - upload link not working, raplace with image
    $text .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class='center middle'><a href='#{$el_id}' class='e-expandit'>upload</a></td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<a class='action' href='" . e_SELF . "?" . $path . $dirs[$c] . "/'><img class='icon action S16' src='" . $imagedir . "folder.png' alt='" . $dirs[$c] . " " . FMLAN_31 . "' /></a>\n\t\t\t\t\t\t\t<a href='" . e_SELF . "?" . $path . $dirs[$c] . "/'>" . $dirs[$c] . "</a>\n\t\t\t\t\t\t\t<div class='e-hideme' id='{$el_id}'>\n\t\t\t\t\t\t\t\t<div class='field-spacer'>" . $frm->file('file_userfile[]', array('id' => false, 'size' => '20')) . $frm->admin_button('upload', FMLAN_22, '', '', array('id' => false)) . "</div>\n\t\t\t\t\t\t\t\t<input type='hidden' name='upload_dir[]' value='" . $path . $dirs[$c] . "' />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class='right'>" . $dirsize . "</td>\n\t\t\t\t\t\t<td class='right'>&nbsp;</td>\n\t\t\t\t\t</tr>\n\t";
    $c++;
}
$c = 0;
while ($files[$c]) {
    $img = strtolower(substr(strrchr($files[$c], "."), 1, 3));
    if (!$img || !preg_match("/css|exe|gif|htm|jpg|js|php|png|txt|xml|zip/i", $img)) {
        $img = "def";
    }
    $size = eHelper::parseMemorySize(filesize(e_BASE . $path . "/" . $files[$c]));
    $gen = new convert();
    $filedate = e107::getDate()->convert_date(filemtime(e_BASE . $path . "/" . $files[$c]), "forum");
    $text .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class='center middle autocheck'>\n\t\t\t\t\t\t\t" . $frm->checkbox("selectedfile[{$c}]", 1, false, array('id' => false)) . "\n\t\t\t\t\t\t\t<input type='hidden' name='deleteconfirm[{$c}]' value='" . $path . $files[$c] . "' />\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<img class='icon' src='" . $imagedir . $img . ".png' alt='" . $files[$c] . "' />\n\t\t\t\t\t\t\t<a href='" . e_SELF . "?" . $path . $files[$c] . "'>" . $files[$c] . "</a>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class='right'>" . $size . "</td>\n\t\t\t\t\t\t<td class='right'>" . $filedate . "</td>\n\t\t\t\t\t</tr>\n\t";
    $c++;
}
$text .= "\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t<div class='buttons-bar left'>\n\t\t\t\t" . $frm->admin_button('check_all', 'jstarget:selectedfile', 'action', LAN_CHECKALL, array('id' => false)) . "\n\t\t\t\t" . $frm->admin_button('uncheck_all', 'jstarget:selectedfile', 'action', LAN_UNCHECKALL, array('id' => false)) . "\n\t";
if ($pubfolder || e_QUERY == "") {
    require_once e_HANDLER . "file_class.php";
    $fl = new e_file();
    $dl_dirlist = $fl->get_dirs(e_DOWNLOAD);
    $movechoice = array();
    $movechoice[] = e_DOWNLOAD;
    foreach ($dl_dirlist as $dirs) {
        $movechoice[] = e_DOWNLOAD . $dirs . "/";
    }
    sort($movechoice);
    $movechoice[] = e_FILE . "downloadimages/";
Example #23
0
 function show_reported($sub_action)
 {
     $rs = new form();
     // FIXME - update to $frm
     $sql = e107::getDb();
     $ns = e107::getRender();
     $tp = e107::getParser();
     $mes = e107::getMessage();
     if ($sub_action) {
         $sql->select("generic", "*", "gen_id='" . $sub_action . "'");
         $row = $sql->fetch();
         $sql->select("user", "*", "user_id='" . $row['gen_user_id'] . "'");
         $user = $sql->fetch();
         //$con = new convert;
         $text = "\n\t\t\t<table class='table adminlist'>\n\t\t\t<colgroup span='2'>\n    \t\t\t<col class='col-label' />\n    \t\t\t<col class='col-control' />\n    \t\t</colgroup>\n\t\t\t<tr>\n\t\t\t\t<td>" . FORLAN_171 . ":</td>\n\t\t\t\t<td><a href='" . e_PLUGIN . "forum/forum_viewtopic.php?" . $row['gen_intdata'] . ".post' rel='external'>#" . $row['gen_intdata'] . "</a></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . FORLAN_173 . ":</td>\n\t\t\t\t<td>" . $row['gen_ip'] . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . FORLAN_174 . ":</td>\n\t\t\t\t<td><a href='" . e_BASE . "user.php?id." . $user['user_id'] . "'>" . $user['user_name'] . "</a>\n\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . FORLAN_175 . ":</td>\n\t\t\t\t<td>" . e107::getDate()->convert_date($row['gen_datestamp'], "long") . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>" . LAN_FORUM_2046 . ":</td>\n\t\t\t\t<td>" . $row['gen_chardata'] . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td style='text-align:center' colspan='2'>\n\t\t\t\t" . $rs->form_open("post", e_SELF . "?sr", "", "", "", " onsubmit=\"return confirm_('sr'," . $row['gen_datestamp'] . ")\"") . "\n\t\t\t\t" . $rs->form_button("submit", "delete[reported_{$row['gen_id']}]", FORLAN_172) . "\n\t\t\t\t" . $rs->form_close() . "\n\t\t\t</td>\n\t\t\t</tr>\n\t\t\t</table>";
         $ns->tablerender(FORLAN_116, $text);
     } else {
         if ($reported_total = $sql->select("generic", "*", "gen_type='reported_post' OR gen_type='Reported Forum Post'")) {
             $text = "\n\t\t\t\t\t<table class='table adminlist'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>" . FORLAN_170 . "</td>\n\t\t\t\t\t\t<td>" . LAN_OPTIONS . "</td>\n\t\t\t\t\t</tr>";
             while ($row = $sql->fetch()) {
                 $text .= " \n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td<a href='" . e_SELF . "?sr." . $row['gen_id'] . "'>" . FORLAN_171 . " #" . $row['gen_intdata'] . "</a></td>\n\t\t\t\t\t\t\t<td text-align:center; vertical-align:top; white-space: nowrap'>\n\t\t\t\t\t\t\t" . $rs->form_open("post", e_SELF . "?sr", "", "", "", " onsubmit=\"return confirm_('sr'," . $row['gen_datestamp'] . ")\"") . "\n\t\t\t\t\t\t\t" . $rs->form_button("submit", "delete[reported_{$row['gen_id']}]", FORLAN_172) . "\n\t\t\t\t\t\t\t" . $rs->form_close() . "\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>";
             }
             $text .= "</table>";
         } else {
             //$text = "<div style='text-align:center'>".FORLAN_121."</div>";
             $mes->addInfo(FORLAN_121);
         }
         $ns->tablerender(FORLAN_116, $mes->render() . $text);
     }
 }
Example #24
0
 function sc_user_daysregged($parm = '')
 {
     return e107::getDate()->computeLapse($this->var['user_join']);
 }
Example #25
0
 */
/*
| Based on code by: Thomas Bouve (crahan@gmx.net)
*/
require_once "../../class2.php";
require_once e_HANDLER . "userclass_class.php";
include_lan(e_PLUGIN . "blogcalendar_menu/languages/" . e_LANGUAGE . ".php");
require_once "calendar.php";
require_once "functions.php";
require_once HEADERF;
// ---------------------
// initialize some cruft
// ---------------------
$bcSql = new db();
$prefix = e_PLUGIN_ABS . "blogcalendar_menu";
$marray = e107::getDate()->terms('month');
// if nr of rows per month is not set, default to 3
$months_per_row = !empty($pref['blogcal_mpr']) ? $pref['blogcal_mpr'] : "3";
$pref['blogcal_ws'] = "monday";
// -------------------------------------
// what year are we supposed to display?
// -------------------------------------
$cur_year = date("Y");
$cur_month = date("n");
$cur_day = date("j");
if (strstr(e_QUERY, "year")) {
    $tmp = explode(".", e_QUERY);
    if (is_numeric($tmp[1])) {
        $req_year = intval($tmp[1]);
    }
}
Example #26
0
 function submit_download()
 {
     global $e107, $tp, $sql, $DOWNLOADS_DIRECTORY, $e_event;
     $action = $this->action;
     $subAction = $this->subAction;
     $id = $this->id;
     $sql = e107::getDb();
     $tp = e107::getParser();
     $fl = e107::getFile();
     $mes = e107::getMessage();
     $dlInfo = array();
     $dlMirrors = array();
     if ($subAction == 'edit') {
         if ($_POST['download_url_external'] == '') {
             $_POST['download_filesize_external'] = FALSE;
         }
     }
     if (!empty($_POST['download_url_external']) && empty($_POST['download_url']) && !empty($_POST['download_filesize_unit'])) {
         $dlInfo['download_url'] = $tp->toDB($_POST['download_url_external']);
         //	$filesize = intval($_POST['download_filesize_external']);
         $filesize = $this->calc_filesize($_POST['download_filesize_external'], $_POST['download_filesize_unit']);
     } else {
         $dlInfo['download_url'] = $tp->toDB($_POST['download_url']);
         if ($_POST['download_filesize_external']) {
             $filesize = intval($_POST['download_filesize_external']);
         } else {
             if (strpos($DOWNLOADS_DIRECTORY, "/") === 0 || strpos($DOWNLOADS_DIRECTORY, ":") >= 1) {
                 $filesize = filesize($DOWNLOADS_DIRECTORY . $dlInfo['download_url']);
             } elseif ($dlInfo['download_url'][0] == '{') {
                 $filesize = filesize($tp->replaceConstants($dlInfo['download_url']));
             } else {
                 $filesize = filesize(e_BASE . $DOWNLOADS_DIRECTORY . $dlInfo['download_url']);
             }
         }
     }
     if (!$filesize) {
         if ($sql->select("upload", "upload_filesize", "upload_file='{$dlInfo['download_url']}'")) {
             $row = $sql->fetch();
             $filesize = $row['upload_filesize'];
         }
     }
     $dlInfo['download_filesize'] = $filesize;
     //  ----   Move Images and Files ------------
     if ($_POST['move_image']) {
         if ($_POST['download_thumb']) {
             $oldname = e_UPLOAD . $_POST['download_thumb'];
             $newname = e_FILE . "downloadthumbs/" . $_POST['download_thumb'];
             if (!$this->move_file($oldname, $newname)) {
                 return;
             }
         }
         if ($_POST['download_image']) {
             $oldname = e_UPLOAD . $_POST['download_image'];
             $newname = e_FILE . "downloadimages/" . $_POST['download_image'];
             if (!$this->move_file($oldname, $newname)) {
                 return;
             }
         }
     }
     if ($_POST['move_file'] && $_POST['download_url']) {
         $oldname = e_UPLOAD . $_POST['download_url'];
         $newname = $_POST['move_file'] . $_POST['download_url'];
         if (!$this->move_file($oldname, $newname)) {
             return;
         }
         $dlInfo['download_url'] = str_replace(e_DOWNLOAD, "", $newname);
     }
     // ------------------------------------------
     $dlInfo['download_description'] = $tp->toDB($_POST['download_description']);
     $dlInfo['download_name'] = $tp->toDB($_POST['download_name']);
     $dlInfo['download_sef'] = vartrue($_POST['download_sef']) ? eHelper::secureSef($_POST['download_sef']) : eHelper::title2sef($_POST['download_name']);
     $dlInfo['download_keywords'] = $tp->toDB($_POST['download_keywords']);
     $dlInfo['download_author'] = $tp->toDB($_POST['download_author']);
     $dlInfo['download_author_email'] = $tp->toDB($_POST['download_author_email']);
     $dlInfo['download_author_website'] = $tp->toDB($_POST['download_author_website']);
     $dlInfo['download_category'] = intval($_POST['download_category']);
     $dlInfo['download_active'] = intval($_POST['download_active']);
     $dlInfo['download_thumb'] = $tp->toDB($_POST['download_thumb']);
     $dlInfo['download_image'] = $tp->toDB($_POST['download_image']);
     $dlInfo['download_comment'] = $tp->toDB($_POST['download_comment']);
     $dlInfo['download_class'] = $tp->toDB($_POST['download_class']);
     $dlInfo['download_visible'] = $tp->toDB($_POST['download_visible']);
     $dlInfo['download_datestamp'] = e107::getDate()->convert($_POST['download_datestamp'], 'inputdate');
     if ($_POST['update_datestamp']) {
         $dlInfo['download_datestamp'] = time();
     }
     $mirrorStr = "";
     $mirrorFlag = FALSE;
     // See if any mirrors defined
     // Need to check all the possible mirror names - might have deleted the first one if we're in edit mode
     if (count($_POST['download_mirror_name'])) {
         foreach ($_POST['download_mirror_name'] as $mn) {
             if ($mn) {
                 $mirrorFlag = TRUE;
                 break;
             }
         }
     }
     if ($mirrorFlag) {
         $mirrors = count($_POST['download_mirror_name']);
         $mirrorArray = array();
         $newMirrorArray = array();
         if ($id && $sql->select('download', 'download_mirror', 'download_id = ' . $id)) {
             if ($row = $sql->fetch()) {
                 $mirrorArray = $this->makeMirrorArray($row['download_mirror'], TRUE);
             }
         }
         for ($a = 0; $a < $mirrors; $a++) {
             $mid = trim($_POST['download_mirror_name'][$a]);
             $murl = trim($_POST['download_mirror'][$a]);
             $msize = trim($_POST['download_mirror_size'][$a]);
             if ($mid && $murl) {
                 $newMirrorArray[$mid] = array('id' => $mid, 'url' => $murl, 'requests' => 0, 'filesize' => $msize);
                 if (DOWNLOAD_DEBUG && !$id) {
                     $newMirrorArray[$mid]['requests'] = intval($_POST['download_mirror_requests'][$a]);
                 }
             }
         }
         // Now copy across any existing usage figures
         foreach ($newMirrorArray as $k => $m) {
             if (isset($mirrorArray[$k])) {
                 $newMirrorArray[$k]['requests'] = $mirrorArray[$k]['requests'];
             }
         }
         $mirrorStr = $this->compressMirrorArray($newMirrorArray);
     }
     $dlMirrors['download_mirror'] = $mirrorStr;
     $dlMirrors['download_mirror_type'] = intval($_POST['download_mirror_type']);
     if ($id) {
         // Process triggers before calling admin_update so trigger messages can be shown
         $data = array('method' => 'update', 'table' => 'download', 'id' => $id, 'plugin' => 'download', 'function' => 'update_download');
         $hooks = $e107->e_event->triggerHook($data);
         $mes->add($hooks, E_MESSAGE_SUCCESS);
         $updateArray = array_merge($dlInfo, $dlMirrors);
         $updateArray['WHERE'] = 'download_id=' . intval($id);
         $mes->addAuto($sql->db_Update('download', $updateArray), 'update', DOWLAN_2 . " (<a href='" . e_PLUGIN . "download/download.php?view." . $id . "'>" . $_POST['download_name'] . "</a>)");
         $dlInfo['download_id'] = $id;
         $this->downloadLog('DOWNL_06', $dlInfo, $dlMirrors);
         $dlInfo['download_datestamp'] = $time;
         // This is what 0.7 did, regardless of settings
         unset($dlInfo['download_class']);
         // Also replicating 0.7
         $e_event->trigger('dlupdate', $dlInfo);
         // @deprecated
         e107::getEvent()->trigger('admin_download_update', $dlInfo);
     } else {
         if ($download_id = $sql->insert('download', array_merge($dlInfo, $dlMirrors))) {
             // Process triggers before calling admin_update so trigger messages can be shown
             $data = array('method' => 'create', 'table' => 'download', 'id' => $download_id, 'plugin' => 'download', 'function' => 'create_download');
             $hooks = $e107->e_event->triggerHook($data);
             $mes->add($hooks, E_MESSAGE_SUCCESS);
             $mes->addAuto($download_id, 'insert', DOWLAN_1 . " (<a href='" . e_PLUGIN . "download/download.php?view." . $download_id . "'>" . $_POST['download_name'] . "</a>)");
             $dlInfo['download_id'] = $download_id;
             $this->downloadLog('DOWNL_05', $dlInfo, $dlMirrors);
             $dlInfo['download_datestamp'] = $time;
             // This is what 0.7 did, regardless of settings
             unset($dlInfo['download_class']);
             // Also replicating 0.7
             $e_event->trigger("dlpost", $dlInfo);
             // @deprecated
             e107::getEvent()->trigger('admin_download_create', $dlInfo);
             if ($_POST['remove_upload']) {
                 $sql->db_Update("upload", "upload_active='1' WHERE upload_id='" . $_POST['remove_id'] . "'");
                 $mess = "<br/>" . $_POST['download_name'] . " " . DOWLAN_104;
                 $mess .= "<br/><br/><a href='" . e_ADMIN . "upload.php'>" . DOWLAN_105 . "</a>";
                 $this->show_message($mess);
             }
         }
     }
 }
Example #27
0
 function sc_cb_timedate($parm = '')
 {
     return e107::getDate()->convert_date($this->var['cb_datestamp'], "relative");
 }
Example #28
0
 function sc_lastedit()
 {
     $gen = e107::getDate();
     if ($this->postInfo['post_edit_datestamp']) {
         return $gen->convert_date($this->postInfo['post_edit_datestamp'], 'forum');
     }
 }