Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Mon, Aug 25, 6:58 AM

in-portal

Index: branches/unlabeled/unlabeled-1.15.2/core/kernel/processors/tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.15.2/core/kernel/processors/tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.15.2/core/kernel/processors/tag_processor.php (revision 7641)
@@ -0,0 +1,193 @@
+<?php
+
+ class TagProcessor extends kBase {
+
+ /**
+ * Processes tag
+ *
+ * @param Tag $tag
+ * @return string
+ * @access public
+ */
+ function ProcessTag(&$tag)
+ {
+ return $this->ProcessParsedTag($tag->Tag, $tag->NP, $tag->getPrefixSpecial());
+
+ /*$Method=$tag->Tag;
+ if(method_exists($this, $Method))
+ {
+ //echo htmlspecialchars($tag->GetFullTag()).'<br>';
+ return $this->$Method($tag->NP);
+ }
+ else
+ {
+ if ($this->Application->hasObject('TagsAggregator')) {
+ $aggregator =& $this->Application->recallObject('TagsAggregator');
+ $tag_mapping = $aggregator->GetArrayValue($tag->Prefix, $Method);
+ if ($tag_mapping) {
+
+ $mapped_tag =& new Tag('', $this->Application->Parser);
+ $mapped_tag->CopyFrom($tag);
+ $mapped_tag->Processor = $tag_mapping[0];
+ $mapped_tag->Tag = $tag_mapping[1];
+ $mapped_tag->NP['PrefixSpecial'] = $tag->getPrefixSpecial();
+ $mapped_tag->RebuildTagData();
+ return $mapped_tag->DoProcessTag();
+ }
+ }
+ trigger_error('Tag '.$Method.' Undefined in '.get_class($this).'[Agregated Tag]:<br><b>'.$tag->RebuildTagData().'</b>',E_USER_WARNING);
+ return false;
+ }*/
+ }
+
+ function ProcessParsedTag($tag, $params, $prefix)
+ {
+ $Method = $tag;
+ if(method_exists($this, $Method))
+ {
+ if ($this->Application->isDebugMode() && constOn('DBG_SHOW_TAGS')) {
+ $this->Application->Debugger->appendHTML('Processing PreParsed Tag '.$Method.' in '.$this->Prefix);
+ }
+
+ $backup_prefix = $this->Prefix;
+ $backup_special = $this->Special;
+
+ // process all possible flags: begin
+ $flags = Array('js_escape', 'result_to_var', 'pass_params', 'html_escape');
+ $flag_values = Array();
+
+ foreach ($flags as $flag_name) {
+ $flag_values[$flag_name] = false;
+ if (isset($params[$flag_name])) {
+ $flag_values[$flag_name] = $params[$flag_name];
+ unset($params[$flag_name]);
+ }
+ }
+ // process all possible flags: end
+
+ // pass_params for non ParseBlock tags :)
+ if ($flag_values['pass_params']) {
+ $params = array_merge_recursive2($this->Application->Parser->Params, $params);
+ }
+
+ $ret = $this->$Method($params);
+
+ $this->Prefix = $backup_prefix;
+ $this->Special = $backup_special;
+
+ if ($flag_values['js_escape']) {
+ $ret = str_replace('\'', '&#39;', $ret);
+ $ret = addslashes($ret);
+ $ret = str_replace(Array("\r", "\n"), Array('\r', '\n'), $ret);
+ $ret = str_replace('</script>', "</'+'script>", $ret);
+ }
+ if ($flag_values['html_escape']) {
+ $ret = htmlspecialchars($ret);
+ }
+ if ($flag_values['result_to_var']) {
+ $this->Application->Parser->SetParam($flag_values['result_to_var'], $ret);
+ $ret = '';
+ }
+ return $ret;
+ }
+ else
+ {
+ if ($this->Application->hasObject('TagsAggregator')) {
+ $aggregator =& $this->Application->recallObject('TagsAggregator');
+ $tmp = $this->Application->processPrefix($prefix);
+ $tag_mapping = $aggregator->GetArrayValue($tmp['prefix'], $Method);
+ if ($tag_mapping) {
+ $tmp = $this->Application->processPrefix($tag_mapping[0]);
+ $__tag_processor = $tmp['prefix'].'_TagProcessor';
+ $processor =& $this->Application->recallObject($__tag_processor);
+ $processor->Prefix = $tmp['prefix'];
+ $processor->Special = getArrayValue($tag_mapping, 2) ? $tag_mapping[2] : $tmp['special'];
+ $params['PrefixSpecial'] = $prefix;
+ $ret = $processor->ProcessParsedTag($tag_mapping[1], $params, $prefix);
+ if (isset($params['result_to_var'])) {
+ $this->Application->Parser->SetParam($params['result_to_var'], $ret);
+ $ret = '';
+ }
+ return $ret;
+ }
+ if ($this->Application->isDebugMode()) {
+ $this->Application->Debugger->appendTrace();
+ }
+ trigger_error('Tag <b>'.$Method.'</b> Undefined in '.get_class($this).'[Agregated Tag]:<br><b>'.$tag.'</b>', E_USER_WARNING);
+ }
+ trigger_error('Tag Undefined:<br><b>'.$prefix.':'.$tag.'</b>',E_USER_WARNING);
+ return false;
+ }
+ }
+
+
+ /**
+ * Not tag, method for parameter
+ * selection from list in this TagProcessor
+ *
+ * @param Array $params
+ * @param string $possible_names
+ * @return string
+ * @access public
+ */
+ function SelectParam($params, $possible_names)
+ {
+ if (!is_array($params)) return;
+ if (!is_array($possible_names))
+
+ $possible_names = explode(',', $possible_names);
+ foreach ($possible_names as $name)
+ {
+ if( isset($params[$name]) ) return $params[$name];
+ }
+ return false;
+ }
+ }
+
+/*class ProcessorsPool {
+ var $Processors = Array();
+ var $Application;
+ var $Prefixes = Array();
+ var $S;
+
+ function ProcessorsPool()
+ {
+ $this->Application =& KernelApplication::Instance();
+ $this->S =& $this->Application->Session;
+ }
+
+ function RegisterPrefix($prefix, $path, $class)
+ {
+ // echo " RegisterPrefix $prefix, $path, $class <br>";
+ $prefix_item = Array(
+ 'path' => $path,
+ 'class' => $class
+ );
+ $this->Prefixes[$prefix] = $prefix_item;
+ }
+
+ function CreateProcessor($prefix, &$tag)
+ {
+ // echo " prefix : $prefix <br>";
+ if (!isset($this->Prefixes[$prefix]))
+ $this->Application->ApplicationDie ("<b>Filepath and ClassName for prefix $prefix not defined while processing ".htmlspecialchars($tag->GetFullTag())."!</b>");
+ include_once($this->Prefixes[$prefix]['path']);
+ $ClassName = $this->Prefixes[$prefix]['class'];
+ $a_processor =& new $ClassName($prefix);
+ $this->SetProcessor($prefix, $a_processor);
+ }
+
+ function SetProcessor($prefix, &$a_processor)
+ {
+ $this->Processors[$prefix] =& $a_processor;
+ }
+
+ function &GetProcessor($prefix, &$tag)
+ {
+ if (!isset($this->Processors[$prefix]))
+ $this->CreateProcessor($prefix, $tag);
+ return $this->Processors[$prefix];
+ }
+}*/
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.15.2/core/kernel/processors/tag_processor.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.15
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.15.2/core/units/users/users_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.15.2/core/units/users/users_tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.15.2/core/units/users/users_tag_processor.php (revision 7641)
@@ -0,0 +1,194 @@
+<?php
+
+ class UsersTagProcessor extends kDBTagProcessor
+ {
+
+ function LogoutLink($params)
+ {
+ $pass = Array('pass' => 'all,m,u', 'u_event' => 'OnLogout', 'm_cat_id'=>0);
+ $logout_template = $this->SelectParam($params, 'template,t');
+ return $this->Application->HREF($logout_template, '', $pass);
+ }
+
+ function UseUsernames($params)
+ {
+ return $this->Application->ConfigValue('Email_As_Login') != 1;
+ }
+
+ function RegistrationEnabled($params)
+ {
+ return $this->Application->ConfigValue('User_Allow_New') != 2;
+ }
+
+ function SuggestRegister($params)
+ {
+ return !$this->Application->LoggedIn() && !$this->Application->ConfigValue('Comm_RequireLoginBeforeCheckout') && $this->RegistrationEnabled($params);
+ }
+
+ function ConfirmPasswordLink($params)
+ {
+ //global $m_var_list_update, $var_list_update, $objSession, $objConfig;
+
+ $template = "forgotpw_reset_result";
+
+ $tmp_user_id = $this->Application->RecallVar("tmp_user_id");
+
+ $saved_denerated_code = $this->Application->GetVar('saved_denerated_code');
+ if ($saved_denerated_code){
+ $code = $saved_denerated_code;
+ }
+ else {
+ $code = md5($this->GenerateCode());
+ $this->Application->SetVar('saved_denerated_code', $code);
+ }
+
+
+
+ $sql = 'UPDATE '.TABLE_PREFIX.'PortalUser SET PwResetConfirm="'.$code.'", PwRequestTime='.adodb_mktime().' WHERE PortalUserId='.$tmp_user_id;
+
+ $this->Conn->Query($sql);
+
+ $params = array_merge($params, array('pass'=>'m', 'user_key'=>$code));
+
+ $main_processor =& $this->Application->recallObject('m_TagProcessor');
+
+ return $main_processor->T($params);
+
+ }
+
+ function GenerateCode()
+ {
+ list($usec, $sec) = explode(" ",microtime());
+
+ $id_part_1 = substr($usec, 4, 4);
+ $id_part_2 = mt_rand(1,9);
+ $id_part_3 = substr($sec, 6, 4);
+ $digit_one = substr($id_part_1, 0, 1);
+ if ($digit_one == 0) {
+ $digit_one = mt_rand(1,9);
+ $id_part_1 = ereg_replace("^0","",$id_part_1);
+ $id_part_1=$digit_one.$id_part_1;
+ }
+ return $id_part_1.$id_part_2.$id_part_3;
+ }
+
+ function ForgottenPassword($params)
+ {
+ return $this->Application->GetVar('ForgottenPassword');
+ }
+
+ function TestCodeIsValid($params)
+ {
+ $passed_key = $this->Application->GetVar('user_key');
+
+ $user_object = &$this->Application->recallObject('u.forgot');
+
+ // used for error reporting only -> rewrite code + theme (by Alex)
+ $user_current_object = &$this->Application->recallObject('u', null, Array('skip_autoload' => true)); // TODO: change theme too
+
+ if (strlen(trim($passed_key)) == 0) {
+
+ $user_current_object->ErrorMsgs['code_is_not_valid'] = $this->Application->Phrase('lu_code_is_not_valid');
+ $user_current_object->FieldErrors['PwResetConfirm']['pseudo'] = 'code_is_not_valid';
+ return false;
+ }
+
+
+ if ($user_object->Load(array('PwResetConfirm'=>$passed_key))) {
+ $exp_time = $user_object->GetDBField('PwRequestTime') + 3600;
+ if ($exp_time > adodb_mktime())
+ {
+
+
+ } else {
+ $user_current_object->ErrorMsgs['code_expired'] = $this->Application->Phrase('lu_code_expired');
+ $user_current_object->FieldErrors['PwResetConfirm']['pseudo'] = 'code_expired';
+ return false;
+
+ }
+ }
+ else {
+ $user_current_object->ErrorMsgs['code_is_not_valid'] = $this->Application->Phrase('lu_code_is_not_valid');
+ $user_current_object->FieldErrors['PwResetConfirm']['pseudo'] = 'code_is_not_valid';
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns sitem administrator email
+ *
+ * @param Array $params
+ * @return string
+ */
+ function SiteAdminEmail($params)
+ {
+ return $this->Application->ConfigValue('Smtp_AdminMailFrom');
+ }
+
+ function AffiliatePaymentTypeChecked($params)
+ {
+ static $checked = false;
+
+ if( $this->Application->GetVar('PaymentTypeId') )
+ {
+ $apt_object =& $this->Application->recallObject('apt.active');
+ if( $this->Application->GetVar('PaymentTypeId') == $apt_object->GetDBField('PaymentTypeId') )
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ if(!$checked)
+ {
+ $checked = true;
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ function HasError($params)
+ {
+ $res = parent::HasError($params);
+ if($this->SelectParam($params,'field,fields') == 'any')
+ {
+ $res = $res || $this->Application->GetVar('MustAgreeToTerms'); // need to do it not put module fields into kernel ! (noticed by Alex)
+ $res = $res || $this->Application->GetVar('SSNRequiredError');
+ }
+ return $res;
+ }
+
+ /**
+ * Returns login name of user
+ *
+ * @param Array $params
+ */
+ function LoginName($params)
+ {
+ $object =& $this->getObject($params);
+ return $object->GetID() != -1 ? $object->GetDBField('Login') : 'root';
+ }
+
+ function CookieUsername($params)
+ {
+ $submit_value = $this->Application->GetVar($params['submit_field']);
+ if ($submit_value !== false) {
+ return $submit_value;
+ }
+
+ return $this->Application->GetVar('save_username'); // from cookie
+ }
+
+ }
+
+
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.15.2/core/units/users/users_tag_processor.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.15
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Event Timeline