function xsns_xoops_smilies($textarea_id) { $ts =& XsnsTextSanitizer::getInstance(); $smiles = $ts->getSmileys(); if (empty($smiles)) { $db =& Database::getInstance(); if ($result = $db->query('SELECT * FROM '.$db->prefix('smiles').' WHERE display=1')) { while ($smile = $db->fetchArray($result)) { //hack smilies move for the smilies !! echo "<img src='".XOOPS_UPLOAD_URL."/".htmlspecialchars($smile['smile_url'])."' border='0' onmouseover='style.cursor=\"hand\"' alt='' onclick='xoopsCodeSmilie(\"".$textarea_id."\", \" ".$smile['code']." \");' />"; //fin du hack } } } else { $count = count($smiles); for ($i = 0; $i < $count; $i++) { if ($smiles[$i]['display'] == 1) { //hack bis echo "<img src='".XOOPS_UPLOAD_URL."/".htmlspecialchars($smiles[$i]['smile_url'])."' border='0' onmouseover='style.cursor=\"hand\"' alt='' onclick='xoopsCodeSmilie(\"".$textarea_id."\", \" ".$smiles[$i]['code']." \");' />"; //fin du hack } } } //hack for more echo " [<a href='#moresmiley' onmouseover='style.cursor=\"hand\"' alt='' onclick='openWithSelfMain(\"".XOOPS_URL."/misc.php?action=showpopups&type=smilies&target=".$textarea_id."\",\"smilies\",300,475);'>"._MORE."</a>]"; } //fin du hack
function getTextRequest($key, $req_type=XSNS_REQUEST_POST, $sanitize_mode=NULL) { $value = $this->getRequestVar($key, $req_type); if(!isset($value)){ return NULL; } $ts =& XsnsTextSanitizer::getInstance(); switch($sanitize_mode){ case XOBJ_DTYPE_STRING: case XOBJ_DTYPE_TXTBOX: $value = $ts->makeTboxData4PreviewInForm($value); break; case XOBJ_DTYPE_TEXT: case XOBJ_DTYPE_TXTAREA: $value = $ts->makeTareaData4PreviewInForm($value); break; default: break; } return $value; }
function dispatch() { if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $sess_handler =& XsnsSessionHandler::getInstance(); $commu_temp = $sess_handler->getVar('community'); $sess_handler->clearVars(); $ts =& XsnsTextSanitizer::getInstance(); $default = array( 'name' => isset($commu_temp['name']) ? $ts->makeTboxData4PreviewInForm($commu_temp['name']) : '', 'info' => isset($commu_temp['info']) ? $ts->makeTareaData4PreviewInForm($commu_temp['info']) : '', 'cat_id' => isset($commu_temp['cat_id']) ? intval($commu_temp['cat_id']) : 0, 'public_id' => isset($commu_temp['public_id']) ? intval($commu_temp['public_id']) : 1, ); $image_handler =& XsnsImageHandler::getInstance(); $image_handler->deleteImageTemp(); $category_handler =& XsnsCategoryHandler::getInstance(); $category_selector = $category_handler->getSelectorHtml('category', $default['cat_id'], _MD_XSNS_SELBOX_DEFAULT); $public_id = $default['public_id']; $default['public'.$public_id] = ' checked'; $this->context->setAttribute('category_selector', $category_selector); $this->context->setAttribute('default', $default); }
function XsnsUser() { $this->XoopsUser(); $this->ts =& XsnsTextSanitizer::getInstance(); $this->handler = array( 'community' => XsnsCommunityHandler::getInstance(), 'member' => XsnsMemberHandler::getInstance(), 'user' => XsnsUserHandler::getInstance(), 'friend' => XsnsFriendHandler::getInstance(), 'confirm' => XsnsConfirmHandler::getInstance(), 'module_config' => XsnsModuleConfigHandler::getInstance(), 'intro' => XsnsIntroductionHandler::getInstance(), ); }
function dispatch() { if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $cid = $this->getIntRequest('cid', XSNS_REQUEST_GET); if(!isset($cid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community) || !$community->checkAuthority()){ redirect_header(XOOPS_URL, 2, _NOPERM); } // 画像・ファイルのキャッシュを削除 $image_handler =& XsnsImageHandler::getInstance(); $image_handler->deleteImageTemp(); $file_handler =& XsnsFileHandler::getInstance(); $file_handler->deleteFileTemp(); $sess_handler =& XsnsSessionHandler::getInstance(); $topic_temp = $sess_handler->getVar('topic'); $sess_handler->clearVars(); $ts =& XsnsTextSanitizer::getInstance(); $default = array( 'name' => isset($topic_temp['name']) ? $ts->makeTboxData4PreviewInForm($topic_temp['name']) : '', 'body' => isset($topic_temp['body']) ? $ts->makeTareaData4PreviewInForm($topic_temp['body']) : '', ); $commu_info = array('id' => $cid, 'name' => $community->getVar('name')); $this->context->setAttribute('commu', $commu_info); $this->context->setAttribute('default', $default); }
function checkParams($cid, $name, $info, $cat_id, $public_id) { $ts =& XsnsTextSanitizer::getInstance(); $name = $ts->stripSlashesGPC($name); $this->errors = array(); // 名前が入力されていない if(empty($name)){ $this->errors[] = _MD_XSNS_INDEX_NAME_NG; } // 同じ名前が既に存在する if($this->nameExists($name)){ if($cid == 0){ $this->errors[] = _MD_XSNS_INDEX_NAME_EXISTS_NG; } else{ $community =& $this->get($cid); if(is_object($community) && $name != $community->getVar('name', 'n')){ // raw data $this->errors[] = _MD_XSNS_INDEX_NAME_EXISTS_NG; } } } // 説明文が入力されていない if(empty($info)){ $this->errors[] = _MD_XSNS_INDEX_DESC_NG; } // カテゴリが選択されていない if($cat_id < 1){ $this->errors[] = _MD_XSNS_INDEX_CATEGORY_NG; } if(count($this->errors) == 0){ return true; } return false; }
function dispatch() { require XSNS_FRAMEWORK_DIR.'/global.php'; require_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/user.php'; $ts =& XsnsTextSanitizer::getInstance(); if($this->isGuest() || !$this->validateToken('edituser')){ redirect_header(XSNS_URL_MYPAGE, 3, _US_NOEDITRIGHT); } $config_handler =& xoops_gethandler('config'); if(defined('XOOPS_CUBE_LEGACY')){ $xoopsConfigUser =& $config_handler->getConfigsByDirname('user'); $user_config =& $xoopsConfigUser; } else{ $xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER); $user_config =& $xoopsConfig; } if(!is_array($xoopsConfigUser)){ redirect_header(XSNS_URL_MYPAGE, 3, _US_NOEDITRIGHT); } $uid = 0; if (!empty($_POST['uid'])) { $uid = intval($_POST['uid']); } if (empty($uid) || $xoopsUser->getVar('uid') != $uid) { redirect_header(XSNS_URL_MYPAGE, 3, _US_NOEDITRIGHT); } $errors = array(); if ($xoopsConfigUser['allow_chgmail'] == 1) { $email = ''; if (!empty($_POST['email'])) { $email = $ts->stripSlashesGPC(trim($_POST['email'])); } if ($email == '' || !checkEmail($email)) { $errors[] = _US_INVALIDMAIL; } } $password = ''; if (!empty($_POST['password'])) { $password = $ts->stripSlashesGPC(trim($_POST['password'])); } if ($password != '') { if (strlen($password) < $xoopsConfigUser['minpass']) { $errors[] = sprintf(_US_PWDTOOSHORT,$xoopsConfigUser['minpass']); } $vpass = ''; if (!empty($_POST['vpass'])) { $vpass = $ts->stripSlashesGPC(trim($_POST['vpass'])); } if ($password != $vpass) { $errors[] = _US_PASSNOTSAME; } } if (count($errors) > 0) { redirect_header(XSNS_URL_MYPAGE, 3, _US_NOEDITRIGHT); } else { $member_handler =& xoops_gethandler('member'); $edituser =& $member_handler->getUser($uid); if(!is_object($edituser)){ redirect_header(XSNS_URL_MYPAGE, 3, _US_NOEDITRIGHT); } $vars = array( 'name' => isset($_POST['name']) ? $_POST['name'] : '', 'url' => isset($_POST['url']) ? formatURL($_POST['url']) : '', 'user_icq' => isset($_POST['user_icq']) ? $_POST['user_icq'] : '', 'user_from' => isset($_POST['user_from']) ? $_POST['user_from'] : '', 'user_viewemail' => !empty($_POST['user_viewemail']) ? 1 : 0, 'user_aim' => isset($_POST['user_aim']) ? $_POST['user_aim'] : '', 'user_yim' => isset($_POST['user_yim']) ? $_POST['user_yim'] : '', 'user_msnm' => isset($_POST['user_msnm']) ? $_POST['user_msnm'] : '', 'attachsig' => !empty($_POST['attachsig']) ? 1 : 0, 'timezone_offset' => isset($_POST['timezone_offset']) ? $_POST['timezone_offset'] : 0.0, 'user_occ' => isset($_POST['user_occ']) ? $_POST['user_occ'] : '', 'user_intrest' => isset($_POST['user_intrest']) ? $_POST['user_intrest'] : '', 'user_sig' => isset($_POST['user_sig']) ? xoops_substr($_POST['user_sig'], 0, 255) : '', 'uorder' => isset($_POST['uorder']) ? $_POST['uorder'] : 0, 'umode' => isset($_POST['umode']) ? $_POST['umode'] : 0, 'notify_method' => isset($_POST['notify_method']) ? $_POST['notify_method'] : 1, 'notify_mode' => isset($_POST['notify_mode']) ? $_POST['notify_mode'] : 0, 'bio' => isset($_POST['bio']) ? xoops_substr($_POST['bio'], 0, 255) : '', 'user_mailok' => !empty($_POST['user_mailok']) ? 1 : 0, ); if ($xoopsConfigUser['allow_chgmail'] == 1) { $vars['email'] = $email; } if(!empty($password)){ $vars['pass'] = md5($password); } $edituser->setVars($vars); if(!empty($user_config['usercookie'])){ if (!empty($_POST['usercookie'])) { setcookie($user_config['usercookie'], $xoopsUser->getVar('uname'), time()+ 31536000); } else { setcookie($user_config['usercookie']); } } if (!$member_handler->insertUser($edituser)) { redirect_header(XSNS_URL_MYPAGE, 3, _US_NOEDITRIGHT); } else { redirect_header(XSNS_URL_MYPAGE, 2, _US_PROFUPDATED); } } }
function &getList($uid, $view_mode=true) { global $xoopsUser; $ret = array(); $ts =& XsnsTextSanitizer::getInstance(); $gperm_handler =& xoops_gethandler('groupperm'); $module_handler =& xoops_gethandler('module'); $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; // モジュール表示順設定の取得 $module_config =& $this->getOne($uid); if(is_object($module_config)){ $config_arr = $module_config->getVar('config_values'); if(!is_array($config_arr)){ $config_arr = array(); } } else{ $config_arr = array(); } $default_image = XOOPS_URL.'/images/icons/posticon2.gif'; $order_max = 1; $criteria = new CriteriaCompo(new Criteria('hassearch', 1)); $criteria->add(new Criteria('isactive', 1)); $mids =& array_keys($module_handler->getList($criteria)); $checked = array(); // DBに登録されている設定順でモジュールを表示 foreach($config_arr as $mid => $config){ if(!isset($config[XSNS_MOD_CONFIG_ORDER]) || !isset($config[XSNS_MOD_CONFIG_VIEW])){ continue; } $checked[$mid] = true; if($view_mode && ($config[XSNS_MOD_CONFIG_VIEW] < 1)){ continue; } $module =& $module_handler->get($mid); if(!$module || !in_array($mid, $mids) || !$gperm_handler->checkRight('module_read', $mid, $groups)){ continue; } $module_dir = $module->getVar('dirname'); $module_url = XOOPS_URL.'/modules/'.$module_dir.'/'; $results =& $module->search('', '', $config[XSNS_MOD_CONFIG_VIEW], 0, $uid); $count = is_array($results)? count($results) : 0; if(($view_mode && $count>0) || !$view_mode){ for ($i = 0; $i < $count; $i++) { if (isset($results[$i]['image']) && $results[$i]['image'] != '') { $results[$i]['image'] = $module_url. $results[$i]['image']; } else { $results[$i]['image'] = $default_image; } $results[$i]['link'] = $module_url. $results[$i]['link']; $results[$i]['title'] = $ts->makeTboxData4Show($results[$i]['title']); $results[$i]['time'] = $results[$i]['time'] ? date("Y-m-d H:i:s", $results[$i]['time']) : ''; } $ret[$mid] = array( 'id' => $mid, 'order' => intval($config[XSNS_MOD_CONFIG_ORDER]), 'view' => intval($config[XSNS_MOD_CONFIG_VIEW]), 'name' => $module->getVar('name'), 'url' => $module_url, 'results' => $results, ); $order_max = intval($config[XSNS_MOD_CONFIG_ORDER]); } unset($module, $results); } // DBに未登録のモジュールを追加表示 foreach($mids as $mid) { if(isset($checked[$mid]) || !$gperm_handler->checkRight('module_read', $mid, $groups)) { continue; } $module =& $module_handler->get($mid); if(!$module){ continue; } $module_dir = $module->getVar('dirname'); $module_url = XOOPS_URL.'/modules/'.$module_dir.'/'; $results =& $module->search('', '', 5, 0, $uid); $count = is_array($results)? count($results) : 0; if(($view_mode && $count > 0) || !$view_mode){ for ($i = 0; $i < $count; $i++) { if (isset($results[$i]['image']) && $results[$i]['image'] != '') { $results[$i]['image'] = $module_url. $results[$i]['image']; } else { $results[$i]['image'] = $default_image; } $results[$i]['link'] = $module_url. $results[$i]['link']; $results[$i]['title'] = $ts->makeTboxData4Show($results[$i]['title']); $results[$i]['time'] = $results[$i]['time'] ? date("Y-m-d H:i:s", $results[$i]['time']) : ''; } $ret[$mid] = array( 'id' => $mid, 'order' => $order_max, 'view' => 5, 'name' => $module->getVar('name'), 'url' => $module_url, 'results' => $results, ); } unset($module, $results); } return $ret; }
function dispatch() { global $xoopsUser; $own_uid = is_object($xoopsUser)? $xoopsUser->getVar('uid') : 0; $limit = 20; $tid = $this->getIntRequest('tid', XSNS_REQUEST_GET); if(!isset($tid)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $start = $this->getIntRequest('s', XSNS_REQUEST_GET); $commu_handler =& XsnsCommunityHandler::getInstance(); $topic_handler =& XsnsTopicHandler::getInstance(); $user_handler =& XsnsUserHandler::getInstance(); $image_handler =& XsnsImageHandler::getInstance(); $file_handler =& XsnsFileHandler::getInstance(); // トピックの取得 $topic =& $topic_handler->get($tid); if(!is_object($topic)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $topic_uid = $topic->getVar('uid'); // コミュニティの取得 $cid = $topic->getVar('c_commu_id'); $community =& $commu_handler->get($cid); if(!is_object($community) || ($community->getVar('public_flag')==3 && !$community->checkAuthority())){ redirect_header(XOOPS_URL, 2, _NOPERM); } $main_comment =& $topic->getCommentList(1, 0); if(!is_array($main_comment) || !isset($main_comment[0])){ redirect_header(XOOPS_URL, 2, _NOPERM); } $comment_count_all = $topic->getCommentCount() - 1; if($comment_count_all > 1000){ $comment_count_all = 1000; } if($comment_count_all > 0){ if(!isset($start) || $start < 0 || $start > 1000){ $start = $limit * floor(($comment_count_all-1)/$limit); } if($start >= 1000){ $start = 1000 - $limit; } } else{ $start = 0; } $comment_list_temp =& $topic->getCommentList($limit, $start+1); // except No.0 if(is_array($comment_list_temp)){ $comment_list_temp = $main_comment + $comment_list_temp; } else{ $comment_list_temp = $main_comment; } $sess_handler =& XsnsSessionHandler::getInstance(); $comment_temp = $sess_handler->getVar('comment_body'); $sess_handler->clearVars(); $ts =& XsnsTextSanitizer::getInstance(); $default = array( 'comment' => !empty($comment_temp) ? $ts->makeTboxData4PreviewInForm($comment_temp) : '', ); // 引用レスのポップアップウィンドウ生成 ---------------- $res_ids_temp = array(); $this->vars = array( 'comment_list' => array(), 'comment_checked' => array(), 'res_depth' => 0, ); $this->vars['comment_list'] =& $comment_list_temp; foreach($comment_list_temp as $comment){ $this->vars['res_depth'] = 0; $res_ids_temp = $this->getResIds($tid, $comment['number'], $comment['body']); } if(is_array($this->vars['comment_checked'])){ $res_ids = array_keys($this->vars['comment_checked']); $res_list =& $this->getResList($tid, $res_ids); $res_popup_list =& $this->getResPopupList($limit, $res_ids, $res_list); } else{ $res_list = NULL; } //------------------------------------------------------ $comment_list = array(); $commu_auth = $community->getAuthority(); foreach($comment_list_temp as $comment){ $comment_ids[] = $comment['c_commu_topic_comment_id']; } $image_list =& $image_handler->getListByIds(2, $comment_ids); $file_list =& $file_handler->getListByIds(2, $comment_ids); $author_obj_list = array(); foreach($comment_list_temp as $comment){ $comment_uid = intval($comment['uid']); if($comment_uid > 0){ $tcid = intval($comment['c_commu_topic_comment_id']); if(!isset($author_obj_list[$comment_uid])){ $author_obj_list[$comment_uid] =& $user_handler->get($comment_uid); } if(is_object($author_obj_list[$comment_uid])){ $author_info =& $author_obj_list[$comment_uid]->getInfo(); } else{ $author_info = array(); } $id = intval($comment['c_commu_topic_comment_id']); $images = isset($image_list[$id]) ? $image_list[$id] : array(); $files = isset($file_list[$id]) ? $file_list[$id] : array(); $comment_list[] = array( 'uid' => $comment_uid, 'body' => $this->getResQuotedCommentBody($tid, $comment['number'], $res_list), 'author' => $author_info, 'time' => $comment['r_datetime'], 'number' => $comment['number'], 'images' => $images, 'files' => $files, 'show_edit' => $commu_auth>=XSNS_AUTH_SUB_ADMIN || ($commu_auth>=XSNS_AUTH_MEMBER && ($comment_uid==$own_uid || $topic_uid==$own_uid)), 'show_res_add' => ($commu_auth>=XSNS_AUTH_MEMBER), 'url_edit' => XSNS_URL_TOPIC.'&'.XSNS_ACTION_ARG.'=edit&tcid='.$tcid, 'url_del' => XSNS_URL_TOPIC.'&'.XSNS_ACTION_ARG.'=del&tcid='.$tcid, ); } else{ // deleted topic/comment $comment_list[] = array( 'uid' => 0, 'body' => '', 'time' => $comment['r_datetime'], 'number' => $comment['number'], ); } } $comment_count = count($comment_list) - 1; $pager = $this->getPageSelector(XSNS_URL_TOPIC.'&tid='.$tid, $start, $limit, $comment_count, $comment_count_all); $image_handler->DeleteImageTemp(); $file_handler->DeleteFileTemp(); $commu_vars = array( 'id' => $community->getVar('c_commu_id'), 'name' => $community->getVar('name'), 'auth_level' => $commu_auth, ); $topic_vars = array( 'id' => $tid, 'name' => $topic->getVar('name'), ); $this->context->setAttribute('commu', $commu_vars); $this->context->setAttribute('topic', $topic_vars); $this->context->setAttribute('comment_list', $comment_list); $this->context->setAttribute('comment_count', $comment_count); $this->context->setAttribute('comment_count_all', $comment_count_all); $this->context->setAttribute('pager', $pager); $this->context->setAttribute('res_popup_list', $res_popup_list); $this->context->setAttribute('default', array('body' => $default['comment'])); }
function &getFriendBlogList($uid, $limit, $start, &$blog_count) { $ts =& XsnsTextSanitizer::getInstance(); $ret = array(); $blog_module =& $this->getModule(); if(is_null($blog_module)){ return $ret; } $user_blog_url = $this->getUserBlogUrl(); $module_url = XOOPS_URL.'/modules/'.$this->getModuleDirName(); $user_handler =& XsnsUserHandler::getInstance(); $user =& $user_handler->get($uid); if(!is_object($user)){ return $ret; } $friend_list =& $user->getFriendList(); $blog_list_temp = $order = array(); $blog_count = 0; foreach($friend_list as $friend){ $results =& $blog_module->search('', '', 0, 0, $friend['uid']); if (!is_array($results) || count($results) == 0) { continue; } foreach($results as $result){ if(isset($result['image']) && $result['image'] != ''){ $image_url = $module_url.'/'.$result['image']; } else{ $image_url = XOOPS_URL.'/images/icons/posticon2.gif'; } $blog_list_temp[] = array( 'image' => $image_url, 'link' => $module_url.'/'.$result['link'], 'link_author' => sprintf($user_blog_url, $friend['uid']), 'title' => $ts->makeTboxData4Preview($result['title']), 'time' => isset($result['time'])? date("Y-m-d H:i:s", $result['time']) : '', 'author' => $friend['name'], ); $order[$blog_count] = isset($result['time'])? $result['time'] : 0; $blog_count++; } unset($results); } if($start < 0){ $start = 0; } if(count($order) > 0){ arsort($order); $count = 0; foreach($order as $key => $value){ if($count>=$start && $count<$start+$limit){ $ret[] = $blog_list_temp[$key]; } $count++; } } return $ret; }
function &getListForCommunity($cid, $limit=0, $start=0, $get_body=false) { $ts =& XsnsTextSanitizer::getInstance(); $image_handler =& XsnsImageHandler::getInstance(); $file_handler =& XsnsFileHandler::getInstance(); $ret = array(); $base_url = XSNS_URL_TOPIC.'&tid='; $sql = "SELECT ". "ct.c_commu_topic_id AS tid,". "ct.name AS tname,". "MAX(ctc.r_datetime) AS max_r_datetime,". "ctc.c_commu_topic_comment_id AS tcid,". "COUNT(*) AS comment_count". " FROM ". $this->prefix('c_commu_topic_comment'). " ctc". " INNER JOIN ". $this->prefix('c_commu_topic'). " ct". " USING(c_commu_topic_id)". " WHERE ct.c_commu_id='".intval($cid)."'". " GROUP BY ctc.c_commu_topic_id". " ORDER BY max_r_datetime DESC"; $rs = $this->db->query($sql, $limit, $start); if(!$rs){ return $ret; } if($get_body){ $comment_handler =& XsnsTopicCommentHandler::getInstance(); while($row = $this->db->fetchArray($rs)){ $comment =& $comment_handler->getByNumber($row['tid'], 0); $ret[] = array( 'name' => $ts->makeTboxData4Show($row['tname']), 'time' => XsnsUtils::getUserTimestamp($row['max_r_datetime']), 'page_url' => $base_url. intval($row['tid']), 'comment_count' => intval($row['comment_count'])-1, // except comment No.0 'body' => $comment->getVar('body'), 'images' => $image_handler->getList(2, intval($row['tcid'])), 'files' => $file_handler->getList(2, intval($row['tcid'])), ); unset($comment); } } else{ while($row = $this->db->fetchArray($rs)){ $ret[] = array( 'name' => $ts->makeTboxData4Show($row['tname']), 'time' => XsnsUtils::getUserTimestamp($row['max_r_datetime']), 'page_url' => $base_url. intval($row['tid']), 'comment_count' => intval($row['comment_count'])-1, // except comment No.0 'body' => '', ); unset($comment); } } return $ret; }
/** * clean values of all variables of the object for storage. * also add slashes whereever needed * * @return bool true if successful * @access public */ function cleanVars() { // for XsnsTextSanitizer $ts =& XsnsTextSanitizer::getInstance(); foreach ($this->vars as $k => $v) { $cleanv = $v['value']; if (!$v['changed']) { } else { $cleanv = is_string($cleanv) ? trim($cleanv) : $cleanv; switch ($v['data_type']) { case XOBJ_DTYPE_TXTBOX: if ($v['required'] && $cleanv != '0' && $cleanv == '') { $this->setErrors("$k is required."); continue; } if (isset($v['maxlength']) && strlen($cleanv) > intval($v['maxlength'])) { $this->setErrors("$k must be shorter than ".intval($v['maxlength'])." characters."); continue; } if (!$v['not_gpc']) { $cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv)); } else { $cleanv = $ts->censorString($cleanv); } break; case XOBJ_DTYPE_TXTAREA: if ($v['required'] && $cleanv != '0' && $cleanv == '') { $this->setErrors("$k is required."); continue; } if (!$v['not_gpc']) { $cleanv = $ts->stripSlashesGPC($ts->censorString($cleanv)); } else { $cleanv = $ts->censorString($cleanv); } break; case XOBJ_DTYPE_SOURCE: if (!$v['not_gpc']) { $cleanv = $ts->stripSlashesGPC($cleanv); } else { $cleanv = $cleanv; } break; case XOBJ_DTYPE_INT: $cleanv = intval($cleanv); break; case XOBJ_DTYPE_FLOAT: $cleanv = floatval($cleanv); break; case XOBJ_DTYPE_BOOL: $cleanv = $cleanv ? 1 : 0; break; case XOBJ_DTYPE_EMAIL: if ($v['required'] && $cleanv == '') { $this->setErrors("$k is required."); continue; } if ($cleanv != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i",$cleanv)) { $this->setErrors("Invalid Email"); continue; } if (!$v['not_gpc']) { $cleanv = $ts->stripSlashesGPC($cleanv); } break; case XOBJ_DTYPE_URL: if ($v['required'] && $cleanv == '') { $this->setErrors("$k is required."); continue; } if ($cleanv != '' && !preg_match("/^http[s]*:\/\//i", $cleanv)) { $cleanv = 'http://' . $cleanv; } if (!$v['not_gpc']) { $cleanv =& $ts->stripSlashesGPC($cleanv); } break; case XOBJ_DTYPE_ARRAY: $cleanv = serialize($cleanv); break; case XOBJ_DTYPE_STIME: case XOBJ_DTYPE_MTIME: case XOBJ_DTYPE_LTIME: $cleanv = !is_string($cleanv) ? intval($cleanv) : strtotime($cleanv); break; case XOBJ_DTYPE_DATE: if(!is_string($cleanv)){ $cleanv = date("Y-m-d", intval($cleanv)); } else{ $cleanv = preg_replace("/[^\d-]/", "", $cleanv); } break; case XOBJ_DTYPE_DATETIME: if(!is_string($cleanv)){ $cleanv = date("Y-m-d H:i:s", intval($cleanv)); } else{ $cleanv = preg_replace("/[^0-9\s:-]/", "", $cleanv); } break; } } $this->cleanVars[$k] =& $cleanv; unset($cleanv); } if (count($this->_errors) > 0) { return false; } $this->unsetDirty(); return true; }