Exemplo n.º 1
0
 /**
  * @param $mode - check || process
  * @param array $data - usually email, date, id - but dependent on unsubscribe link above.
  */
 function unsubscribe($mode, $data = null)
 {
     if ($mode == 'check') {
         $ucl = intval($data['userclass']);
         return e107::getDb()->select('user', '*', 'FIND_IN_SET(' . $ucl . ',user_class) AND user_id=' . intval($data['id']) . " AND user_join=" . intval($data['date']) . " AND user_email=\"" . $data['email'] . "\"");
     }
     //	print_a($data);
     if ($mode == 'process') {
         $uid = intval($data['id']);
         $ucl = intval($data['userclass']);
         return e107::getSystemUser($uid)->removeClass($ucl);
         // best way to remove userclass from user.
     }
 }
Exemplo n.º 2
0
 /**
  * Update user (admin) permissions.
  * NOTE: exit if $uid is not an integer or is 0.
  *
  * @param integer $uid
  * @param array $permArray eg. array('A', 'K', '1');
  * @return void
  */
 function updatePerms($uid, $permArray)
 {
     global $admin_log;
     $sql = e107::getDb();
     $tp = e107::getParser();
     $modID = intval($uid);
     $mes = e107::getMessage();
     if ($modID == 0) {
         $mes->addError("Malfunction at line " . __LINE__ . " of user_handler.php");
         return;
     }
     $sysuser = e107::getSystemUser($modID, false);
     $row = $sysuser->getData();
     $a_name = $row['user_name'];
     $perm = "";
     foreach ($permArray as $value) {
         $value = $tp->toDB($value);
         if ($value == "0") {
             if (!getperms('0')) {
                 $value = "";
                 break;
             }
             $perm = "0";
             break;
         }
         if ($value) {
             $perm .= $value . ".";
         }
     }
     //$sql->db_Update("user", "user_perms='{$perm}' WHERE user_id='{$modID}' ")
     if (!$sysuser->isAdmin()) {
         $sysuser->set('user_admin', 1)->save();
         $lan = str_replace(array('--UID--', '--NAME--', '--EMAIL--'), array($sysuser->getId(), $sysuser->getName(), $sysuser->getValue('email')), USRLAN_164);
         e107::getLog()->add('USET_08', $lan, E_LOG_INFORMATIVE);
     }
     e107::getMessage()->addAuto($sysuser->set('user_perms', $perm)->save(), 'update', sprintf(LAN_UPDATED, $tp->toDB($_POST['ad_name'])), false, false);
     $logMsg = str_replace(array('--ID--', '--NAME--'), array($modID, $a_name), ADMSLAN_72) . $perm;
     e107::getLog()->add('ADMIN_01', $logMsg, E_LOG_INFORMATIVE, '');
 }
Exemplo n.º 3
0
 /**
  * Auto-render Form Element
  * @param string $key
  * @param mixed $value
  * @param array $attributes field attributes including render parameters, element options - see e_admin_ui::$fields for required format
  * #param array (under construction) $required_data required array as defined in e_model/validator
  * @return string
  */
 function renderElement($key, $value, $attributes, $required_data = array(), $id = 0)
 {
     //	return print_a($value,true);
     $parms = vartrue($attributes['writeParms'], array());
     $tp = e107::getParser();
     if (is_string($parms)) {
         parse_str($parms, $parms);
     }
     if (!empty($attributes['multilan'])) {
         $value = is_array($value) ? varset($value[e_LANGUAGE], '') : $value;
         $parms['post'] = "<small class='e-tip admin-multilanguage-field input-group-addon' style='cursor:help; padding-left:10px' title='Multi-language field'>" . $tp->toGlyph('fa-language') . "</small>";
     }
     if (empty($value) && !empty($parms['default'])) {
         $value = $parms['default'];
     }
     // Two modes of read-only. 1 = read-only, but only when there is a value, 2 = read-only regardless.
     if (vartrue($attributes['readonly']) && (vartrue($value) || vartrue($attributes['readonly']) === 2)) {
         if (vartrue($attributes['writeParms'])) {
             $attributes['readParms'] = $attributes['writeParms'];
         }
         return $this->renderValue($key, $value, $attributes) . $this->hidden($key, $value);
         //
     }
     // FIXME standard - writeParams['__options'] is introduced for list elements, bundle adding to writeParms is non reliable way
     $writeParamsOptionable = array('dropdown', 'comma', 'radio', 'lanlist', 'language', 'user');
     $writeParamsDisabled = array('layouts', 'templates', 'userclass', 'userclasses');
     // FIXME it breaks all list like elements - dropdowns, radio, etc
     if (vartrue($required_data[0]) || vartrue($attributes['required'])) {
         // FIXME - another approach, raise standards, remove checks
         if (in_array($attributes['type'], $writeParamsOptionable)) {
             $parms['__options']['required'] = 1;
         } elseif (!in_array($attributes['type'], $writeParamsDisabled)) {
             $parms['required'] = 1;
         }
     }
     // FIXME it breaks all list like elements - dropdowns, radio, etc
     if (vartrue($required_data[3]) || vartrue($attributes['pattern'])) {
         // FIXME - another approach, raise standards, remove checks
         if (in_array($attributes['type'], $writeParamsOptionable)) {
             $parms['__options']['pattern'] = vartrue($attributes['pattern'], $required_data[3]);
         } elseif (!in_array($attributes['type'], $writeParamsDisabled)) {
             $parms['pattern'] = vartrue($attributes['pattern'], $required_data[3]);
         }
     }
     // XXX Fixes For the above.  - use optArray variable. eg. $field['key']['writeParms']['optArray'] = array('one','two','three');
     if (($attributes['type'] == 'dropdown' || $attributes['type'] == 'radio' || $attributes['type'] == 'checkboxes') && !empty($parms['optArray'])) {
         $fopts = $parms;
         $parms = $fopts['optArray'];
         unset($fopts['optArray']);
         $parms['__options'] = $fopts;
     }
     $this->renderElementTrigger($key, $value, $parms, $required_data, $id);
     switch ($attributes['type']) {
         case 'number':
             $maxlength = vartrue($parms['maxlength'], 255);
             unset($parms['maxlength']);
             if (!vartrue($parms['size'])) {
                 $parms['size'] = 'mini';
             }
             if (!vartrue($parms['class'])) {
                 $parms['class'] = 'tbox number e-spinner';
             }
             if (!$value) {
                 $value = '0';
             }
             $ret = vartrue($parms['pre']) . $this->number($key, $value, $maxlength, $parms) . vartrue($parms['post']);
             break;
         case 'ip':
             $ret = vartrue($parms['pre']) . $this->text($key, e107::getIPHandler()->ipDecode($value), 32, $parms) . vartrue($parms['post']);
             break;
         case 'email':
             $maxlength = vartrue($parms['maxlength'], 255);
             unset($parms['maxlength']);
             $ret = vartrue($parms['pre']) . $this->email($key, $value, $maxlength, $parms) . vartrue($parms['post']);
             // vartrue($parms['__options']) is limited. See 'required'=>true
             break;
         case 'url':
             $maxlength = vartrue($parms['maxlength'], 255);
             unset($parms['maxlength']);
             $ret = vartrue($parms['pre']) . $this->url($key, $value, $maxlength, $parms) . vartrue($parms['post']);
             // vartrue($parms['__options']) is limited. See 'required'=>true
             break;
             //	case 'email':
         //	case 'email':
         case 'password':
             // encrypts to md5 when saved.
             $maxlength = vartrue($parms['maxlength'], 255);
             unset($parms['maxlength']);
             $ret = vartrue($parms['pre']) . $this->password($key, $value, $maxlength, $parms) . vartrue($parms['post']);
             // vartrue($parms['__options']) is limited. See 'required'=>true
             break;
         case 'text':
             $maxlength = vartrue($parms['maxlength'], 255);
             unset($parms['maxlength']);
             if (!empty($parms['password'])) {
                 $ret = vartrue($parms['pre']) . $this->password($key, $value, $maxlength, $parms) . vartrue($parms['post']);
             } else {
                 $ret = vartrue($parms['pre']) . $this->text($key, $value, $maxlength, $parms) . vartrue($parms['post']);
                 // vartrue($parms['__options']) is limited. See 'required'=>true
             }
             if (!empty($attributes['multilan'])) {
                 $ret = "<span class='input-group input-xxlarge'>" . $ret . "</span>";
             }
             break;
         case 'tags':
             $maxlength = vartrue($parms['maxlength'], 255);
             $ret = vartrue($parms['pre']) . $this->tags($key, $value, $maxlength, $parms) . vartrue($parms['post']);
             // vartrue($parms['__options']) is limited. See 'required'=>true
             break;
         case 'textarea':
             $text = "";
             if (vartrue($parms['append']) && vartrue($value)) {
                 $attributes['readParms'] = 'bb=1';
                 $text = $this->renderValue($key, $value, $attributes);
                 $text .= '<br />';
                 $value = "";
                 // Appending needs is  performed and customized using function: beforeUpdate($new_data, $old_data, $id)
             }
             $text .= vartrue($parms['pre']) . $this->textarea($key, $value, vartrue($parms['rows'], 5), vartrue($parms['cols'], 40), vartrue($parms['__options'], $parms), varset($parms['counter'], false)) . vartrue($parms['post']);
             $ret = $text;
             break;
         case 'bbarea':
             $options = array('counter' => varset($parms['counter'], false));
             // Media = media-category owner used by media-manager.
             $ret = vartrue($parms['pre']) . $this->bbarea($key, $value, vartrue($parms['template']), vartrue($parms['media']), vartrue($parms['size'], 'medium'), $options) . vartrue($parms['post']);
             break;
         case 'image':
             //TODO - thumb, image list shortcode, js tooltip...
             $label = varset($parms['label'], 'LAN_EDIT');
             unset($parms['label']);
             $ret = $this->imagepicker($key, $value, defset($label, $label), $parms);
             break;
         case 'images':
             //	return print_a($value, true);
             $ret = "";
             $label = varset($parms['label'], 'LAN_EDIT');
             for ($i = 0; $i < 5; $i++) {
                 $k = $key . '[' . $i . '][path]';
                 $ival = $value[$i]['path'];
                 $ret .= $this->imagepicker($k, $ival, defset($label, $label), $parms);
             }
             break;
         case 'files':
             if ($attributes['data'] == 'array') {
                 $parms['data'] = 'array';
             }
             $ret = '<ol>';
             for ($i = 0; $i < 5; $i++) {
                 //	$k 		= $key.'['.$i.'][path]';
                 //	$ival 	= $value[$i]['path'];
                 $k = $key . '[' . $i . ']';
                 $ival = $value[$i];
                 $ret .= '<li>' . $this->filepicker($k, $ival, defset($label, $label), $parms) . '</li>';
             }
             $ret .= '</ol>';
             break;
         case 'file':
             //TODO - thumb, image list shortcode, js tooltip...
             $label = varset($parms['label'], 'LAN_EDIT');
             unset($parms['label']);
             $ret = $this->filepicker($key, $value, defset($label, $label), $parms);
             break;
         case 'icon':
             $label = varset($parms['label'], 'LAN_EDIT');
             $ajax = varset($parms['ajax'], true) ? true : false;
             unset($parms['label'], $parms['ajax']);
             $ret = $this->iconpicker($key, $value, defset($label, $label), $parms, $ajax);
             break;
         case 'date':
             // date will show the datepicker but won't convert the value to unix. ie. string value will be saved. (or may be processed manually with beforeCreate() etc. Format may be determined by $parm.
         // date will show the datepicker but won't convert the value to unix. ie. string value will be saved. (or may be processed manually with beforeCreate() etc. Format may be determined by $parm.
         case 'datestamp':
             // If hidden, value is updated regardless. eg. a 'last updated' field.
             // If not hidden, and there is a value, it is retained. eg. during the update of an existing record.
             // otherwise it is added. eg. during the creation of a new record.
             if (vartrue($parms['auto']) && ($value == null || vartrue($parms['hidden']))) {
                 $value = time();
             }
             if (vartrue($parms['readonly'])) {
                 $ret = $this->renderValue($key, $value, $attributes) . $this->hidden($key, $value);
             } elseif (vartrue($parms['hidden'])) {
                 $ret = $this->hidden($key, $value);
             } else {
                 $ret = $this->datepicker($key, $value, $parms);
             }
             break;
         case 'layouts':
             //to do - exclude param (exact match)
             $location = varset($parms['plugin']);
             // empty - core
             $ilocation = vartrue($parms['id'], $location);
             // omit if same as plugin name
             $where = vartrue($parms['area'], 'front');
             //default is 'front'
             $filter = varset($parms['filter']);
             $merge = vartrue($parms['merge']) ? true : false;
             $layouts = e107::getLayouts($location, $ilocation, $where, $filter, $merge, true);
             if (varset($parms['default']) && !isset($layouts[0]['default'])) {
                 $layouts[0] = array('default' => $parms['default']) + $layouts[0];
             }
             $info = array();
             if ($layouts[1]) {
                 foreach ($layouts[1] as $k => $info_array) {
                     if (isset($info_array['description'])) {
                         $info[$k] = defset($info_array['description'], $info_array['description']);
                     }
                 }
             }
             //$this->selectbox($key, $layouts, $value)
             $ret = vartrue($parms['raw']) ? $layouts[0] : $this->radio_multi($key, $layouts[0], $value, array('sep' => "<br />"), $info);
             break;
         case 'templates':
             //to do - exclude param (exact match)
             $templates = array();
             if (varset($parms['default'])) {
                 $templates['default'] = defset($parms['default'], $parms['default']);
             }
             $location = vartrue($parms['plugin']) ? e_PLUGIN . $parms['plugin'] . '/' : e_THEME;
             $ilocation = vartrue($parms['location']);
             $tmp = e107::getFile()->get_files($location . 'templates/' . $ilocation, vartrue($parms['fmask'], '_template\\.php$'), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0));
             foreach ($tmp as $files) {
                 $k = str_replace('_template.php', '', $files['fname']);
                 $templates[$k] = implode(' ', array_map('ucfirst', explode('_', $k)));
                 //TODO add LANS?
             }
             // override
             $where = vartrue($parms['area'], 'front');
             $location = vartrue($parms['plugin']) ? $parms['plugin'] . '/' : '';
             $tmp = e107::getFile()->get_files(e107::getThemeInfo($where, 'rel') . 'templates/' . $location . $ilocation, vartrue($parms['fmask']), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0));
             foreach ($tmp as $files) {
                 $k = str_replace('_template.php', '', $files['fname']);
                 $templates[$k] = implode(' ', array_map('ucfirst', explode('_', $k)));
                 //TODO add LANS?
             }
             $ret = vartrue($parms['raw']) ? $templates : $this->selectbox($key, $templates, $value);
             break;
         case 'checkboxes':
             if (is_array($parms)) {
                 $eloptions = vartrue($parms['__options'], array());
                 if (is_string($eloptions)) {
                     parse_str($eloptions, $eloptions);
                 }
                 if ($attributes['type'] === 'comma') {
                     $eloptions['multiple'] = true;
                 }
                 unset($parms['__options']);
                 if (!is_array($value) && !empty($value)) {
                     $value = explode(",", $value);
                 }
                 $ret = vartrue($eloptions['pre']) . $this->checkboxes($key, $parms, $value, $eloptions) . vartrue($eloptions['post']);
             }
             return $ret;
             break;
         case 'dropdown':
         case 'comma':
             $eloptions = vartrue($parms['__options'], array());
             if (is_string($eloptions)) {
                 parse_str($eloptions, $eloptions);
             }
             if ($attributes['type'] === 'comma') {
                 $eloptions['multiple'] = true;
             }
             unset($parms['__options']);
             if (vartrue($eloptions['multiple']) && !is_array($value)) {
                 $value = explode(',', $value);
             }
             $ret = vartrue($eloptions['pre']) . $this->selectbox($key, $parms, $value, $eloptions) . vartrue($eloptions['post']);
             break;
         case 'radio':
             // TODO - more options (multi-line, help)
             $eloptions = vartrue($parms['__options'], array());
             if (is_string($eloptions)) {
                 parse_str($eloptions, $eloptions);
             }
             unset($parms['__options']);
             $ret = vartrue($eloptions['pre']) . $this->radio_multi($key, $parms, $value, $eloptions, false) . vartrue($eloptions['post']);
             break;
         case 'userclass':
         case 'userclasses':
             $uc_options = vartrue($parms['classlist'], 'public,guest,nobody,member,admin,main,classes');
             // defaults to 'public,guest,nobody,member,classes' (userclass handler)
             unset($parms['classlist']);
             //	$method = ($attributes['type'] == 'userclass') ? 'uc_select' : 'uc_select';
             if (vartrue($attributes['type']) == 'userclasses') {
                 $parms['multiple'] = true;
             }
             $ret = vartrue($parms['pre']) . $this->uc_select($key, $value, $uc_options, vartrue($parms, array())) . vartrue($parms['post']);
             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':
             //user_id expected
             // Just temporary solution, could be changed soon
             if (!isset($parms['__options'])) {
                 $parms['__options'] = array();
             }
             if (!is_array($parms['__options'])) {
                 parse_str($parms['__options'], $parms['__options']);
             }
             if (empty($value) && varset($parms['currentInit'], USERID) !== 0 || vartrue($parms['current'])) {
                 $value = USERID;
                 if (vartrue($parms['current'])) {
                     $parms['__options']['readonly'] = true;
                 }
             }
             if (!is_array($value)) {
                 $value = $value ? e107::getSystemUser($value, true)->getUserData() : array();
                 // e107::user($value);
             }
             $colname = vartrue($parms['nameType'], 'user_name');
             $parms['__options']['name'] = $colname;
             if (!$value) {
                 $value = array();
             }
             $uname = varset($value[$colname]);
             $value = varset($value['user_id'], 0);
             $ret = $this->userpicker(vartrue($parms['nameField'], $key), $key, $uname, $value, vartrue($parms['__options']));
             break;
         case 'bool':
         case 'boolean':
             if (varset($parms['label']) === 'yesno') {
                 $lenabled = 'LAN_YES';
                 $ldisabled = 'LAN_NO';
             } else {
                 $lenabled = vartrue($parms['enabled'], 'LAN_ENABLED');
                 $ldisabled = vartrue($parms['disabled'], 'LAN_DISABLED');
             }
             unset($parms['enabled'], $parms['disabled'], $parms['label']);
             $ret = vartrue($parms['pre']) . $this->radio_switch($key, $value, defset($lenabled, $lenabled), defset($ldisabled, $ldisabled), $parms) . vartrue($parms['post']);
             break;
         case "checkbox":
             $value = isset($parms['value']) ? $parms['value'] : $value;
             $ret = vartrue($parms['pre']) . $this->checkbox($key, 1, $value, $parms) . vartrue($parms['post']);
             break;
         case 'method':
             // Custom Function
             $meth = !empty($attributes['method']) ? $attributes['method'] : $key;
             $parms['field'] = $key;
             $ret = call_user_func_array(array($this, $meth), array($value, 'write', $parms));
             break;
         case 'upload':
             //TODO - from method
             // TODO uploadfile SC is now processing uploads as well (add it to admin UI), write/readParms have to be added (see uploadfile.php parms)
             $disbut = varset($parms['disable_button'], '0');
             $ret = $tp->parseTemplate("{UPLOADFILE=" . (vartrue($parms['path']) ? e107::getParser()->replaceConstants($parms['path']) : e_UPLOAD) . "|nowarn&trigger=etrigger_uploadfiles&disable_button={$disbut}}");
             break;
         case 'hidden':
             $value = isset($parms['value']) ? $parms['value'] : $value;
             $ret = vartrue($parms['show']) ? $value ? $value : varset($parms['empty'], $value) : '';
             $ret = $ret . $this->hidden($key, $value);
             break;
         case 'lanlist':
             // installed languages
         // installed languages
         case 'language':
             // all languages
             $options = $attributes['type'] === 'language' ? e107::getLanguage()->getList() : e107::getLanguage()->getLanSelectArray();
             $eloptions = vartrue($parms['__options'], array());
             if (!is_array($eloptions)) {
                 parse_str($eloptions, $eloptions);
             }
             unset($parms['__options']);
             if (vartrue($eloptions['multiple']) && !is_array($value)) {
                 $value = explode(',', $value);
             }
             $ret = vartrue($eloptions['pre']) . $this->selectbox($key, $options, $value, $eloptions) . vartrue($eloptions['post']);
             break;
         case null:
             //	Possibly used in db but should not be submitted in form. @see news_extended.
             break;
         default:
             // No LAN necessary, debug only.
             $ret = ADMIN ? "<span class='alert alert-error alert-danger'>" . LAN_ERROR . " Unknown 'type' : " . $attributes['type'] . "</span>" : $value;
             break;
     }
     if (vartrue($parms['expand'])) {
         $k = "exp-" . $this->name2id($key);
         $text = "<a class='e-expandit e-tip' href='#{$k}'>" . $parms['expand'] . "</a>";
         $text .= vartrue($parms['help']) ? '<div class="field-help">' . $parms['help'] . '</div>' : '';
         $text .= "<div id='{$k}' class='e-hideme'>" . $ret . "</div>";
         return $text;
     } else {
         $ret .= vartrue($parms['help']) ? '<div class="field-help">' . $tp->toHtml($parms['help'], false, 'defs') . '</div>' : '';
     }
     return $ret;
 }
Exemplo n.º 4
0
Arquivo: auth.php Projeto: notzen/e107
if (!defined('e107_INIT')) {
    exit;
}
/* done in class2
 @include_once(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_admin.php");
 @include_once(e_LANGUAGEDIR."English/admin/lan_admin.php");
 */
if (ADMIN) {
    define('ADMIN_PAGE', true);
    //don't include it if it'a an AJAX call or not wanted
    if (!e_AJAX_REQUEST && !defset('e_NOHEADER')) {
        // XXX LOGIN AS Temporary solution, we need something smarter, e.g. reserved message stack 'admin' which will be always printed
        // inside admin area
        if (e107::getUser()->getSessionDataAs()) {
            // TODO - lan
            $asuser = e107::getSystemUser(e107::getUser()->getSessionDataAs(), false);
            e107::getMessage()->addInfo('Successfully logged in as ' . ($asuser && $asuser->getValue('name') ? $asuser->getValue('name') : 'unknown') . ' <a href="' . e_ADMIN_ABS . 'users.php?logoutas">[logout]</a>');
        }
        // NEW, legacy 3rd party code fix, header called inside the footer o.O
        if (deftrue('e_ADMIN_UI')) {
            // boot.php already loaded
            require_once e_ADMIN . "header.php";
        } else {
            // boot.php is included in admin dispatcher constructor, so do it only for legacy code
            require_once e_ADMIN . 'boot.php';
        }
    }
    /*
     * FIXME - missing $style for tablerender
     * The Solution: parse_admin() without sending it to the browser if it's an ajax call
     * The Problem: doubled render time for the ajax called page!!!
Exemplo n.º 5
0
 protected function move2download($upload)
 {
     if (!$upload['upload_active']) {
         return 0;
     }
     $media = e107::getMedia();
     $uploadPath = e_UPLOAD;
     if (!file_exists($uploadPath . $upload['upload_file'])) {
         $this->getModel()->addValidationError(LAN_FILE_NOT_FOUND);
         return false;
     }
     $downloadPath = $media->importFile($upload['upload_file'], 'download_file', $uploadPath . $upload['upload_file'], array('media_caption' => $upload['upload_name']));
     if (false === $downloadPath) {
         $this->getModel()->addValidationError(UPLLAN_66);
         return false;
     }
     $imagePath = null;
     if ($upload['upload_ss'] && file_exists($uploadPath . $upload['upload_ss'])) {
         $imagePath = $media->importFile($upload['upload_ss'], '_common_image', $uploadPath . $upload['upload_ss'], array('media_caption' => $upload['upload_name'] . ' ' . LAN_PREVIEW));
     }
     $author = $upload['upload_poster'] ? e107::getSystemUser($upload['upload_poster'])->getRealName() : LAN_ANONYMOUS;
     $dl = array('download_name' => $upload['upload_name'], 'download_url' => $downloadPath, 'download_sef' => eHelper::title2sef($upload['upload_name']), 'download_author' => $author, 'download_author_email' => $upload['upload_email'], 'download_author_website' => $upload['upload_website'], 'download_description' => $upload['upload_description'], 'download_keywords' => null, 'download_filesize' => $upload['upload_filesize'], 'download_requested' => 0, 'download_category' => $upload['upload_category'], 'download_active' => 1, 'download_datestamp' => $upload['upload_datestamp'], 'download_thumb' => null, 'download_image' => $imagePath, 'download_comment' => 1, 'download_class' => e_UC_MEMBER, 'download_visible' => e_UC_MEMBER, 'download_mirror' => null, 'download_mirror_type' => 0);
     $sql = e107::getDb('activate');
     $id = $sql->insert('download', $dl);
     if (!$id) {
         $this->getModel()->addValidationError(UPLLAN_68 . ' #' . $sql->getLastErrorNumber() . ' ' . $sql->getLastErrorText());
         e107::getMessage()->addDebug($sql->getLastQuery());
         return;
     }
     return $id;
 }
Exemplo n.º 6
0
 public function signup($redirectUrl = true, $loginAfterSuccess = true, $emailAfterSuccess = true)
 {
     if (!e107::getPref('social_login_active', false)) {
         throw new Exception("Signup failed! This feature is disabled.", 100);
         // TODO lan
     }
     if (!$this->getProvider()) {
         throw new Exception("Signup failed! Wrong provider.", 2);
         // TODO lan
     }
     if ($redirectUrl) {
         if (true === $redirectUrl) {
             $redirectUrl = SITEURL;
         } elseif (strpos($redirectUrl, 'http://') !== 0 && strpos($redirectUrl, 'https://') !== 0) {
             $redirectUrl = e107::getUrl()->create($redirectUrl);
         }
     }
     if (e107::getUser()->isUser()) {
         throw new Exception("Signup failed! User already signed in. ", 1);
         // TODO lan
     }
     $this->adapter = $this->hybridauth->authenticate($this->getProvider());
     $profile = $this->adapter->getUserProfile();
     // returned back, if success...
     if ($profile->identifier) {
         $sql = e107::getDb();
         $userMethods = e107::getUserSession();
         $plainPwd = $userMethods->generateRandomString('************');
         // auto plain passwords
         // TODO - auto login name, shouldn't be used if system set to user_email login...
         $userdata['user_loginname'] = $this->getProvider() . $userMethods->generateUserLogin(e107::getPref('predefinedLoginName', '_..#..#..#'));
         $userdata['user_email'] = $sql->escape($profile->emailVerified ? $profile->emailVerified : $profile->email);
         $userdata['user_name'] = $sql->escape($profile->displayName);
         $userdata['user_login'] = $userdata['user_name'];
         $userdata['user_customtitle'] = '';
         // not used
         $userdata['user_password'] = $userMethods->HashPassword($plainPwd, $userdata['user_loginname']);
         // pwd
         $userdata['user_sess'] = '';
         //
         $userdata['user_image'] = $profile->photoURL;
         // avatar
         $userdata['user_signature'] = '';
         // not used
         $userdata['user_hideemail'] = 1;
         // hide it by default
         $userdata['user_xup'] = $sql->escape($this->userId());
         $userdata['user_class'] = '';
         // TODO - check (with Steve) initial class for new users feature...
         // user_name, user_xup, user_email and user_loginname shouldn't match
         if ($sql->db_Count("user", "(*)", "user_xup='" . $sql->escape($this->userId()) . "' OR user_email='{$userdata['user_email']}' OR user_loginname='{$userdata['user_loginname']}' OR user_name='{$userdata['user_name']}'")) {
             throw new Exception("Signup failed! User already exists. Please use 'login' instead.", 3);
             // TODO lan
         }
         if (empty($userdata['user_email'])) {
             throw new Exception("Signup failed! Can't access user email - registration without an email is impossible.", 4);
             // TODO lan
         }
         // other fields
         $now = time();
         $userdata['user_id'] = null;
         $userdata['user_join'] = $now;
         $userdata['user_lastvisit'] = 0;
         $userdata['user_currentvisit'] = 0;
         $userdata['user_comments'] = 0;
         $userdata['user_ip'] = e107::getIPHandler()->getIP(FALSE);
         $userdata['user_ban'] = USER_VALIDATED;
         $userdata['user_prefs'] = '';
         $userdata['user_visits'] = 0;
         $userdata['user_admin'] = 0;
         $userdata['user_perms'] = '';
         $userdata['user_realm'] = '';
         $userdata['user_pwchange'] = $now;
         $user = e107::getSystemUser(0, false);
         $user->setData($userdata);
         $user->getExtendedModel();
         // init
         //$user->setEditor(e107::getSystemUser(1, false));
         $user->save(true);
         // user model error
         if ($user->hasError()) {
             throw new Exception($user->renderMessages(), 5);
         }
         ### Successful signup!
         // FIXME documentation of new signup trigger - usersupprov
         //$user->set('provider', $this->getProvider());
         $userdata = $user->getData();
         $userdata['provider'] = $this->getProvider();
         $ret = e107::getEvent()->trigger('usersupprov', $userdata);
         // XXX - it's time to pass objects instead of array?
         if (true === $ret) {
             return $this;
         }
         // send email
         if ($emailAfterSuccess) {
             $user->set('user_password', $plainPwd)->email('signup');
         }
         e107::getUser()->setProvider($this);
         // auto login
         if ($loginAfterSuccess) {
             e107::getUser()->loginProvider($this->userId());
             // if not proper after-login, return true so user can see login screen
         }
         if ($redirectUrl) {
             e107::getRedirect()->redirect($redirectUrl);
         }
         return true;
     }
     return false;
 }
Exemplo n.º 7
0
 /**
  * Create email to send to user who just registered.
  * @param array $userInfo is the array of user-related DB variables
  * @return array of data for mailer - field names directly compatible
  */
 function render_email($userInfo, $preview = FALSE)
 {
     if ($preview == TRUE) {
         $userInfo['user_password'] = "******";
         $userInfo['user_loginname'] = "test-loginname";
         $userInfo['user_name'] = "test-username";
         $userInfo['user_email'] = "test-username@email";
         $userInfo['user_website'] = "www.test-site.com";
         // This may not be defined
         $userInfo['user_id'] = 0;
         $userInfo['user_sess'] = "1234567890ABCDEFGHIJKLMNOP";
         $userInfo['activation_url'] = 'http://whereever.to.activate.com/';
     }
     return e107::getSystemUser($userInfo['user_id'], false)->renderEmail('signup', $userInfo);
 }
Exemplo n.º 8
0
 require_once e_PLUGIN . 'forum/forum_class.php';
 $forum = new e107forum();
 $forumList = implode(',', $forum->getForumPermList('view'));
 /*if(is_numeric($id))
 	{
 		$uinfo = e107::user($id);
 		$fcaption = UP_LAN_0.' '.$uinfo['user_name'];
 	}
 	else
 	{
 		$user_name = 0;
 	}*/
 if ($id == e107::getUser()->getId()) {
     $user_name = USERNAME;
 } else {
     $user_name = e107::getSystemUser($id, false)->getName(LAN_ANONYMOUS);
 }
 if (!$user_name) {
     header("Location:" . SITEURL);
     exit;
 }
 $fcaption = UP_LAN_0 . ' ' . $user_name;
 /*
 	if (!$USERPOSTS_FORUM_TABLE)
 	{
 		if (file_exists(THEME.'userposts_template.php'))
 		{
 			require_once(THEME.'userposts_template.php');
 		}
 		else
 		{
Exemplo n.º 9
0
 /**
  * Quick Add user submit trigger
  */
 public function AddSubmitTrigger()
 {
     $e107cache = e107::getCache();
     $userMethods = e107::getUserSession();
     $mes = e107::getMessage();
     $sql = e107::getDb();
     $e_event = e107::getEvent();
     $admin_log = e107::getAdminLog();
     if (!$_POST['ac'] == md5(ADMINPWCHANGE)) {
         exit;
     }
     $e107cache->clear('online_menu_member_total');
     $e107cache->clear('online_menu_member_newest');
     $error = false;
     if (isset($_POST['generateloginname'])) {
         $_POST['loginname'] = $userMethods->generateUserLogin($pref['predefinedLoginName']);
     }
     $_POST['password2'] = $_POST['password1'] = $_POST['password'];
     // Now validate everything
     $allData = validatorClass::validateFields($_POST, $userMethods->userVettingInfo, true);
     // Fix Display and user name
     if (!check_class($pref['displayname_class'], $allData['data']['user_class'])) {
         if ($allData['data']['user_name'] != $allData['data']['user_loginname']) {
             $allData['data']['user_name'] = $allData['data']['user_loginname'];
             $mes->addWarning(str_replace('[x]', $allData['data']['user_loginname'], USRLAN_237));
             //$allData['errors']['user_name'] = ERR_FIELDS_DIFFERENT;
         }
     }
     // Do basic validation
     validatorClass::checkMandatory('user_name, user_loginname', $allData);
     // Check for missing fields (email done in userValidation() )
     validatorClass::dbValidateArray($allData, $userMethods->userVettingInfo, 'user', 0);
     // Do basic DB-related checks
     $userMethods->userValidation($allData);
     // Do user-specific DB checks
     if (!isset($allData['errors']['user_password'])) {
         // No errors in password - keep it outside the main data array
         $savePassword = $allData['data']['user_password'];
         // Delete the password value in the output array
         unset($allData['data']['user_password']);
     }
     // Restrict the scope of this
     unset($_POST['password2'], $_POST['password1']);
     if (count($allData['errors'])) {
         $temp = validatorClass::makeErrorList($allData, 'USER_ERR_', '%n - %x - %t: %v', '<br />', $userMethods->userVettingInfo);
         $mes->addError($temp);
         $error = true;
     }
     // Always save some of the entered data - then we can redisplay on error
     $user_data =& $allData['data'];
     if ($error) {
         $this->setParam('user_data', $user_data);
         return;
     }
     if (varset($_POST['perms'])) {
         $allData['data']['user_admin'] = 1;
         $allData['data']['user_perms'] = implode('.', $_POST['perms']);
     }
     $user_data['user_password'] = $userMethods->HashPassword($savePassword, $user_data['user_login']);
     $user_data['user_join'] = time();
     if ($userMethods->needEmailPassword()) {
         // Save separate password encryption for use with email address
         $user_prefs = e107::getArrayStorage()->unserialize($user_data['user_prefs']);
         $user_prefs['email_password'] = $userMethods->HashPassword($savePassword, $user_data['user_email']);
         $user_data['user_prefs'] = e107::getArrayStorage()->serialize($user_prefs);
         unset($user_prefs);
     }
     $userMethods->userClassUpdate($allData['data'], 'userall');
     //FIXME - (SecretR) there is a better way to fix this (missing default value, sql error in strict mode - user_realm is to be deleted from DB later)
     $allData['data']['user_realm'] = '';
     // Set any initial classes
     $userMethods->addNonDefaulted($user_data);
     validatorClass::addFieldTypes($userMethods->userVettingInfo, $allData);
     $userid = $sql->insert('user', $allData);
     if ($userid) {
         $sysuser = e107::getSystemUser(false, false);
         $sysuser->setData($allData['data']);
         $sysuser->setId($userid);
         $user_data['user_id'] = $userid;
         // Add to admin log
         e107::getLog()->add('USET_02', "UName: {$user_data['user_name']}; Email: {$user_data['user_email']}", E_LOG_INFORMATIVE);
         // Add to user audit trail
         e107::getLog()->user_audit(USER_AUDIT_ADD_ADMIN, $user_data, 0, $user_data['user_loginname']);
         e107::getEvent()->trigger('userfull', $user_data);
         e107::getEvent()->trigger('admin_user_created', $user_data);
         // send everything available for user data - bit sparse compared with user-generated signup
         if (isset($_POST['sendconfemail'])) {
             $check = false;
             // Send confirmation email to user
             switch ((int) $_POST['sendconfemail']) {
                 case 0:
                     // activate, don't notify
                     $check = -1;
                     break;
                 case 1:
                     // activate and send password
                     $check = $sysuser->email('quickadd', array('user_password' => $savePassword, 'mail_subject' => USRLAN_187 . SITENAME, 'activation_url' => USRLAN_238));
                     break;
                 case 2:
                     // require activation and send password and activation link
                     $sysuser->set('user_ban', 2)->set('user_sess', e_user_model::randomKey())->save();
                     $check = $sysuser->email('quickadd', array('user_password' => $savePassword, 'mail_subject' => USRLAN_187 . SITENAME, 'activation_url' => SITEURL . "signup.php?activate." . $sysuser->getId() . "." . $sysuser->getValue('sess')));
                     break;
             }
             if ($check && $check !== -1) {
                 $mes->addSuccess(USRLAN_188);
             } elseif (!$check) {
                 $mes->addError(USRLAN_189);
             }
         }
         //	$message = str_replace('--NAME--', htmlspecialchars($user_data['user_name'], ENT_QUOTES, CHARSET), USRLAN_174);
         $message = USRLAN_172;
         $mes->addSuccess($message)->addSuccess(USRLAN_128 . ': <strong>' . htmlspecialchars($user_data['user_loginname'], ENT_QUOTES, CHARSET) . '</strong>');
         $mes->addSuccess(LAN_PASSWORD . ': <strong>' . htmlspecialchars($savePassword, ENT_QUOTES, CHARSET) . '</strong>');
         return;
     } else {
         $mes->addError(LAN_CREATED_FAILED);
         $mes->addError($sql->getLastErrorText());
     }
 }
Exemplo n.º 10
0
/**
 * @deprecated
 * Get the user data from user and user_extended tables
 * SO MUCH DEPRECATED! Use e107::user($uid);
 * @return array
 */
function get_user_data($uid, $extra = '')
{
    if (e107::getPref('developer')) {
        e107::getAdminLog()->log_event('Deprecated call - get_user_data()', 'Call to deprecated function get_user_data() (class2.php) ' . "\n" . print_r(debug_backtrace(null, 2), true), E_LOG_INFORMATIVE, 'DEPRECATED');
        // TODO - debug screen Deprecated Functions (e107)
        e107::getMessage()->addDebug('Deprecated get_user_data() backtrace:<pre>' . "\n" . print_r(debug_backtrace(null, 2), true) . '</pre>');
    }
    $var = array();
    $user = e107::getSystemUser($uid, true);
    if ($user) {
        $var = $user->getUserData();
    }
    return $var;
}
Exemplo n.º 11
0
 function getRanks($userId, $moderator = false)
 {
     $e107 = e107::getInstance();
     if (!$userId && USER) {
         $userId = USERID;
     }
     if (isset($this->userRanks[$userId])) {
         return $this->userRanks[$userId];
     }
     $ret = array();
     if (is_array($userId)) {
         $userData = $userId;
         $userId = $userData['user_id'];
     } else {
         $userData = e107::getSystemUser($userId)->getData();
         //get_user_data($userId);
     }
     if ($userData['user_admin']) {
         if ($userData['user_perms'] == '0') {
             //Main Site Admin
             $data['special'] = "<img src='" . $this->_getImage($this->ranks['special'][1]) . "' alt='" . $this->_getName($this->ranks['special'][1]) . "' title='" . $this->_getName($this->ranks['special'][1]) . "' />";
         } else {
             //Site Admin
             $data['special'] = "<img src='" . $this->_getImage($this->ranks['special'][2]) . "' alt='" . $this->_getName($this->ranks['special'][2]) . "' title='" . $this->_getName($this->ranks['special'][2]) . "' />";
         }
     } elseif ($moderator) {
         $data['special'] = "<img src='" . $this->_getImage($this->ranks['special'][3]) . "' alt='" . $this->_getName($this->ranks['special'][3]) . "' title='" . $this->_getName($this->ranks['special'][3]) . "' />";
     }
     $userData['user_daysregged'] = max(1, round((time() - $userData['user_join']) / 86400));
     $level = $this->_calcLevel($userData);
     $lastRank = count($this->ranks['data']);
     $rank = false;
     if ($level <= $this->ranks['data'][0]['thresh']) {
         $rank = 1;
     } elseif ($level >= $this->ranks['data'][$lastRank]['thresh']) {
         $rank = $lastRank;
     } else {
         for ($i = 0; $i < $lastRank; $i++) {
             if ($level >= $this->ranks['data'][$i]['thresh'] && $level < $this->ranks['data'][$i + 1]['thresh']) {
                 $rank = $i + 1;
                 break;
             }
         }
     }
     if ($rank !== false) {
         $data['name'] = $this->_getName($this->ranks['data'][$rank]);
         $img_title = $this->ranks['data'][$rank]['name'] ? " alt='{$data['name']}' title='{$data['name']}'" : ' alt = ""';
         $data['pic'] = "<img {$img_title} src='" . $this->_getImage($this->ranks['data'][$rank]) . "'{$img_title} />";
     }
     $this->userRanks[$userId] = $data;
     return $data;
 }
Exemplo n.º 12
0
 /**
  * Auto-render Form Element
  * @param string $key
  * @param mixed $value
  * @param array $attributes field attributes including render parameters, element options - see e_admin_ui::$fields for required format
  * #param array (under construction) $required_data required array as defined in e_model/validator
  * @return string
  */
 function renderElement($key, $value, $attributes, $required_data = array())
 {
     $parms = vartrue($attributes['writeParms'], array());
     $tp = e107::getParser();
     if (is_string($parms)) {
         parse_str($parms, $parms);
     }
     // Two modes of read-only. 1 = read-only, but only when there is a value, 2 = read-only regardless.
     if (vartrue($attributes['readonly']) && (vartrue($value) || vartrue($attributes['readonly']) == 2)) {
         if (vartrue($attributes['writeParms'])) {
             $attributes['readParms'] = $attributes['writeParms'];
         }
         return $this->renderValue($key, $value, $attributes) . $this->hidden($key, $value);
         //
     }
     switch ($attributes['type']) {
         case 'number':
             $maxlength = vartrue($parms['maxlength'], 255);
             unset($parms['maxlength']);
             if (!vartrue($parms['size'])) {
                 $parms['size'] = 15;
             }
             if (!vartrue($parms['class'])) {
                 $parms['class'] = 'tbox number e-spinner';
             }
             if (!$value) {
                 $value = '0';
             }
             $ret = vartrue($parms['pre']) . $this->text($key, $value, $maxlength, $parms) . vartrue($parms['post']);
             break;
         case 'ip':
             $ret = $this->text($key, e107::getIPHandler()->ipDecode($value), 32, $parms);
             break;
         case 'url':
         case 'email':
         case 'text':
         case 'password':
             // encrypts to md5 when saved.
             $maxlength = vartrue($parms['maxlength'], 255);
             unset($parms['maxlength']);
             $ret = vartrue($parms['pre']) . $this->text($key, $value, $maxlength, vartrue($parms['__options'])) . vartrue($parms['post']);
             break;
         case 'textarea':
             $text = "";
             if ($parms['append']) {
                 $attributes['readParms'] = 'bb=1';
                 $text = $this->renderValue($key, $value, $attributes) . $this->hidden($key, $value) . '<br />';
                 $value = "";
             }
             $text .= $this->textarea($key, $value, vartrue($parms['rows'], 5), vartrue($parms['cols'], 40), vartrue($parms['__options']), varset($parms['counter'], false));
             $ret = $text;
             break;
         case 'bbarea':
             $options = array('counter' => varset($parms['counter'], false));
             $ret = $this->bbarea($key, $value, vartrue($parms['template']), vartrue($parms['helptag']), vartrue($parms['size'], 'medium'), $options);
             break;
         case 'image':
             //TODO - thumb, image list shortcode, js tooltip...
             $label = varset($parms['label'], 'LAN_EDIT');
             unset($parms['label']);
             $ret = $this->imagepicker($key, $value, defset($label, $label), $parms);
             break;
         case 'file':
             //TODO - thumb, image list shortcode, js tooltip...
             $label = varset($parms['label'], 'LAN_EDIT');
             unset($parms['label']);
             $ret = $this->filepicker($key, $value, defset($label, $label), $parms);
             break;
         case 'icon':
             $label = varset($parms['label'], 'LAN_EDIT');
             $ajax = varset($parms['ajax'], true) ? true : false;
             unset($parms['label'], $parms['ajax']);
             $ret = $this->iconpicker($key, $value, defset($label, $label), $parms, $ajax);
             break;
         case 'date':
             // date will show the datepicker but won't convert the value to unix. ie. string value will be saved. (or may be processed manually with beforeCreate() etc. Format may be determined by $parm.
         // date will show the datepicker but won't convert the value to unix. ie. string value will be saved. (or may be processed manually with beforeCreate() etc. Format may be determined by $parm.
         case 'datestamp':
             // If hidden, value is updated regardless. eg. a 'last updated' field.
             // If not hidden, and there is a value, it is retained. eg. during the update of an existing record.
             // otherwise it is added. eg. during the creation of a new record.
             if (vartrue($parms['auto']) && ($value == null || vartrue($parms['hidden']))) {
                 $value = time();
             }
             if (vartrue($parms['hidden'])) {
                 $ret = $this->hidden($key, $value);
             } else {
                 $ret = $this->datepicker($key, $value, $parms);
             }
             break;
         case 'layouts':
             //to do - exclude param (exact match)
             $location = varset($parms['plugin']);
             // empty - core
             $ilocation = vartrue($parms['id'], $location);
             // omit if same as plugin name
             $where = vartrue($parms['area'], 'front');
             //default is 'front'
             $filter = varset($parms['filter']);
             $merge = vartrue($parms['merge']) ? true : false;
             $layouts = e107::getLayouts($location, $ilocation, $where, $filter, $merge, true);
             if (varset($parms['default']) && !isset($layouts[0]['default'])) {
                 $layouts[0] = array('default' => $parms['default']) + $layouts[0];
             }
             $info = array();
             if ($layouts[1]) {
                 foreach ($layouts[1] as $k => $info_array) {
                     if (isset($info_array['description'])) {
                         $info[$k] = defset($info_array['description'], $info_array['description']);
                     }
                 }
             }
             //$this->selectbox($key, $layouts, $value)
             $ret = vartrue($parms['raw']) ? $layouts[0] : $this->radio_multi($key, $layouts[0], $value, true, $info);
             break;
         case 'templates':
             //to do - exclude param (exact match)
             $templates = array();
             if (varset($parms['default'])) {
                 $templates['default'] = defset($parms['default'], $parms['default']);
             }
             $location = vartrue($parms['plugin']) ? e_PLUGIN . $parms['plugin'] . '/' : e_THEME;
             $ilocation = vartrue($parms['location']);
             $tmp = e107::getFile()->get_files($location . 'templates/' . $ilocation, vartrue($parms['fmask'], '_template\\.php$'), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0));
             foreach ($tmp as $files) {
                 $k = str_replace('_template.php', '', $files['fname']);
                 $templates[$k] = implode(' ', array_map('ucfirst', explode('_', $k)));
                 //TODO add LANS?
             }
             // override
             $where = vartrue($parms['area'], 'front');
             $location = vartrue($parms['plugin']) ? $parms['plugin'] . '/' : '';
             $tmp = e107::getFile()->get_files(e107::getThemeInfo($where, 'rel') . 'templates/' . $location . $ilocation, vartrue($parms['fmask']), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0));
             foreach ($tmp as $files) {
                 $k = str_replace('_template.php', '', $files['fname']);
                 $templates[$k] = implode(' ', array_map('ucfirst', explode('_', $k)));
                 //TODO add LANS?
             }
             $ret = vartrue($parms['raw']) ? $templates : $this->selectbox($key, $templates, $value);
             break;
         case 'dropdown':
             $eloptions = vartrue($parms['__options'], array());
             if (is_string($eloptions)) {
                 parse_str($eloptions, $eloptions);
             }
             unset($parms['__options']);
             if (vartrue($eloptions['multiple']) && !is_array($value)) {
                 $value = explode(',', $value);
             }
             $ret = vartrue($eloptions['pre']) . $this->selectbox($key, $parms, $value, $eloptions) . vartrue($eloptions['post']);
             break;
         case 'radio':
             // TODO - more options (multi-line, help)
             /*$eloptions  = vartrue($parms['__options'], array());
             		if(is_string($eloptions)) parse_str($eloptions, $eloptions);
             		unset($parms['__options']);*/
             $ret = vartrue($eloptions['pre']) . $this->radio_multi($key, $parms, $value, false) . vartrue($eloptions['post']);
             break;
         case 'userclass':
         case 'userclasses':
             $uc_options = vartrue($parms['classlist'], 'public,guest,nobody,member,admin,main,classes');
             // defaults to 'public,guest,nobody,member,classes' (userclass handler)
             unset($parms['classlist']);
             $method = $attributes['type'] == 'userclass' ? 'uc_select' : 'uc_select';
             if ($atrributes['type'] == 'userclasses') {
                 $parms['multiple'] = true;
             }
             $ret = $this->{$method}($key, $value, $uc_options, vartrue($parms, array()));
             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':
             //user_id expected
             // Just temporary solution, could be changed soon
             if (!isset($parms['__options'])) {
                 $parms['__options'] = array();
             }
             if (!is_array($parms['__options'])) {
                 parse_str($parms['__options'], $parms['__options']);
             }
             if (empty($value) && vartrue($parms['currentInit']) || vartrue($parms['current'])) {
                 $value = USERID;
                 if (vartrue($parms['current'])) {
                     $parms['__options']['readonly'] = true;
                 }
             }
             if (!is_array($value)) {
                 $value = $value ? e107::getSystemUser($value, true)->getUserData() : array();
                 // get_user_data($value);
             }
             $colname = vartrue($parms['nameType'], 'user_name');
             $parms['__options']['name'] = $colname;
             if (!$value) {
                 $value = array();
             }
             $uname = varset($value[$colname]);
             $value = varset($value['user_id'], 0);
             $ret = $this->userpicker(vartrue($parms['nameField'], $key . '_usersearch'), $key, $uname, $value, vartrue($parms['__options']));
             break;
         case 'bool':
         case 'boolean':
             $lenabled = vartrue($parms['enabled'], 'LAN_ENABLED');
             $ldisabled = vartrue($parms['disabled'], 'LAN_DISABLED');
             unset($parms['enabled'], $parms['disabled']);
             $ret = $this->radio_switch($key, $value, defset($lenabled, $lenabled), defset($ldisabled, $ldisabled), $parms);
             break;
         case 'method':
             // Custom Function
             $ret = call_user_func_array(array($this, $key), array($value, 'write', $parms));
             break;
         case 'upload':
             //TODO - from method
             // TODO uploadfile SC is now processing uploads as well (add it to admin UI), write/readParms have to be added (see uploadfile.php parms)
             $disbut = varset($parms['disable_button'], '0');
             $ret = $tp->parseTemplate("{UPLOADFILE=" . (vartrue($parms['path']) ? e107::getParser()->replaceConstants($parms['path']) : e_UPLOAD) . "|nowarn&trigger=etrigger_uploadfiles&disable_button={$disbut}}");
             break;
         case 'hidden':
             $ret = vartrue($parms['show']) ? $value ? $value : varset($parms['empty'], $value) : '';
             $value = vartrue($parms['value']) ? $parms['value'] : $value;
             echo "key=" . $key . "<br />value=" . $value;
             $ret = $ret . $this->hidden($key, $value);
             break;
         case 'lanlist':
         case 'language':
             $options = e107::getLanguage()->getLanSelectArray();
             $eloptions = vartrue($parms['__options'], array());
             if (!is_array($eloptions)) {
                 parse_str($eloptions, $eloptions);
             }
             unset($parms['__options']);
             if (vartrue($eloptions['multiple']) && !is_array($value)) {
                 $value = explode(',', $value);
             }
             $ret = vartrue($eloptions['pre']) . $this->selectbox($key, $options, $value, $eloptions) . vartrue($eloptions['post']);
             break;
         default:
             $ret = $value;
             break;
     }
     if (vartrue($parms['expand'])) {
         $k = "exp-" . $this->name2id($key);
         $text = "<a class='e-expandit e-tip' href='#{$k}'>" . $parms['expand'] . "</a>";
         $text .= vartrue($parms['help']) ? '<div class="field-help">' . $parms['help'] . '</div>' : '';
         $text .= "<div id='{$k}' class='e-hideme'>" . $ret . "</div>";
         return $text;
     } else {
         $ret .= vartrue($parms['help']) ? '<div class="field-help">' . $tp->toHtml($parms['help'], false, 'defs') . '</div>' : '';
     }
     return $ret;
 }
Exemplo n.º 13
0
    e107::getMessage()->addError('FIXME, I\'m not working...');
    //$user->user_userclass($_POST['userid'], $_POST['userclass'],'clear');
}
if (isset($_POST['useraction']) && $_POST['useraction'] == 'userclass') {
    e107::getMessage()->addError('FIXME, I\'m not working...');
    //	header('location:'.e_ADMIN.'userclass.php?'.$e107->tp->toDB($_POST['userid'].'.'.e_QUERY));
    //	exit;
    //$user->show_userclass($_POST['userid']);
}
// ---- Login as another user --------------------
if (isset($_POST['useraction']) && $_POST['useraction'] == 'loginas') {
    if (e107::getUser()->getSessionDataAs()) {
        e107::getMessage()->addWarning(USRLAN_AS_3);
    } elseif (e107::getUser()->loginAs($_POST['userid'])) {
        // TODO - lan
        e107::getMessage()->addSuccess('Successfully logged in as ' . e107::getSystemUser($_POST['userid'])->getValue('name') . ' <a href="' . e_ADMIN_ABS . 'users.php?logoutas">[logout]</a>')->addSuccess('Please, <a href="' . SITEURL . '" rel="external">Leave Admin</a> to browse the system as this user. Use &quot;Logout&quot; option in Administration to end front-end session');
        e107::getEvent()->trigger('loginas', array('user_id' => $_POST['userid'], 'admin_id' => e107::getUser()->getId()));
    }
}
// ------- Resend Email Confirmation. --------------
if (isset($_POST['useraction']) && $_POST['useraction'] == 'resend') {
    $qry = e_QUERY ? "?" . e_QUERY : "";
    if ($sql->db_Select("user", "*", "user_id='" . $_POST['userid'] . "' ")) {
        $resend = $sql->db_Fetch();
        $text .= "<form method='post' action='" . e_SELF . $qry . "'><div style='text-align:center'>\n";
        $text .= USRLAN_116 . " <b>" . $resend['user_name'] . "</b><br /><br />\r\n\r\n\t\t<input type='hidden' name='resend_id' value='" . $_POST['userid'] . "' />\n\r\n\t\t<input type='hidden' name='resend_name' value='" . $resend['user_name'] . "' />\n\r\n\t\t<input type='hidden' name='resend_key' value='" . $resend['user_sess'] . "' />\n\r\n\t\t<input type='hidden' name='resend_email' value='" . $resend['user_email'] . "' />\n\r\n\t\t<input class='button' type='submit' name='resend_mail' value='" . USRLAN_112 . "' />\n</div></form>\n";
        $caption = USRLAN_112;
        $ns->tablerender($caption, $text);
        require_once "footer.php";
        exit;
    }