class_CheckHelper.inc.php 8.66 KB
<?php
/**
 * @file	CheckHelper.inc.php
 * @category freeSN
 * @mailto	code [at] netz.coop
 * @version 0.4.200901
 * @link http://netz.coop
 * 
 *  @copyright Copyright by netz.coop e.G. 2015
 *  
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
class CheckHelper extends CreateHelper {




	protected function checkBasicRights() {
		$ary_rights = STTree::$ary_checkRights;
		if(is_array($ary_rights['checkReadRightsTrue'])) {
			foreach($ary_rights['checkReadRightsTrue'] as $var_key1 => $var_value1) {
				$this->curlRightsTest($var_value1['Urlshow'],'checkReadRightsTrue',$var_value1['User'],$var_value1['Subject'],$var_value1);
			}
		}
		if(is_array($ary_rights['checkWriteRightsTrue'])) {
			foreach($ary_rights['checkWriteRightsTrue'] as $var_key1 => $var_value1) {
				$this->curlRightsTest($var_value1['Urledit'],'checkWriteRightsTrue',$var_value1['User'],$var_value1['Subject'],$var_value1);
			}
		}
		if(is_array($ary_rights['checkReadRightsFalse'])) {
			foreach($ary_rights['checkReadRightsFalse'] as $var_key1 => $var_value1) {
				$this->curlRightsTest($var_value1['Urlshow'],'checkReadRightsFalse',$var_value1['User'],$var_value1['Subject'],$var_value1);
			}
		}
		if(is_array($ary_rights['checkWriteRightsFalse'])) {
			foreach($ary_rights['checkWriteRightsFalse'] as $var_key1 => $var_value1) {
				$this->curlRightsTest($var_value1['Urledit'],'checkWriteRightsFalse',$var_value1['User'],$var_value1['Subject'],$var_value1);
			}
		}
	}

	protected function searchoutputrights($param_url,$param_output,$param_case,$param_search,$param_ary) {
		$ary_searchout['True'] =$this->searchRegExpInTagCategory($param_output,$param_search['True']);
		$ary_searchout['False'] =$this->searchRegExpInTagCategory($param_output,$param_search['False']);
		$varUrlString = SendReceiveTools::makeLinkFromGET($param_url,'',TRUE);
		$this->assertRegExpTestsSmall($ary_searchout['True'],$param_output,$param_ary['CurWalkAry'],$param_case.': '.$varUrlString .' WriteRights: '. $param_ary['Write'].' ReadRights: '.$param_ary['Read'].' Method: '.__METHOD__.' Zeile: '.__LINE__,null);
		$this->assertRegExpTestsSmall($ary_searchout['False'],$param_output,$param_ary['CurWalkAry'],$param_case.': '.$varUrlString .' WriteRights: '. $param_ary['Write'].' ReadRights: '.$param_ary['Read'].' Method: '.__METHOD__.' Zeile: '.__LINE__,'1');
	}


	protected function curlRightsTest($param_url,$param_case,$param_user,$param_search,$param_ary) {
		$ary_get = SendReceiveTools::createGET($param_url,'',TRUE);
		$ary_post = array();
		$obj_curl = new cURLTools();
		$var_httphost= STMANAGEData::getGenCfgSTStd('0');
		$var_httphost = 'http://'.$var_httphost['HTTP_HOST'].'/index.php';
		if($param_case == 'checkWriteRightsFalse' | $param_case == 'checkWriteRightsTrue' ) {
                    if(isset($param_ary['Check'])){
                        $ary_post = $param_ary['Check'];
                    }else{
                        $ary_post= TRUE;
                    }
                    
		}
                if(!isset ($param_ary['return'])){
                    $param_ary['return']=TRUE;
                }
		$param_ary['return'] = $obj_curl->curllogin($param_user,$this->var_userPW,$param_user,null,$var_httphost,$param_ary['return']);
		$curlout = $obj_curl->curlSend($ary_get,$ary_post);
		if($param_case == 'checkReadRightsTrue') {

                $var_cfgSTStd = STMANAGEData::getGenCfgSTStd();
                $var_cfgSTStd = $var_cfgSTStd['0'];
                $param_search = array(
                'True'=>array(
                '0'=> $param_search
			),
                'False'=>array(
                    '0'=> $var_cfgSTStd['Errors'][0],
                    '1' => $var_cfgSTStd['Errors'][1]
			),
			);
		}else if($param_case == 'checkWriteRightsTrue') {
			$param_search = array(
                    'True'=>array(
                    '0'=> $param_search
			),
                    'False'=>array(
                    '0'=> $var_cfgSTStd['Errors'][0],
                    '1' => $var_cfgSTStd['Errors'][1]
                    ),
                    );
		}else if($param_case == 'checkReadRightsFalse') {
			$param_search = array(
                        'True'=>array(
                        '0'=> $var_cfgSTStd['Errors'][0]
                        ),
                        'False'=>array(
                        '0'=> $param_search
                        ),
                        );
		}else if($param_case == 'checkWriteRightsFalse') {
			$param_search = array(
                            'True'=>array(
                            '0'=> $var_cfgSTStd['Errors'][0]
                            ),
                            'False'=>array(
                            '0'=> $param_search
                            ),
                            );
		}


		$this->searchoutputrights($ary_get,$curlout,$param_case,$param_search,$param_ary);
	}


	protected function checkCloudCategory($param_which = 'Tagcloud',$param_ary) {
		if($param_which == 'Tagcloud') {
			$ary_which = STTree::$ary_usedTagCloud;
		}else if($param_which == 'Category') {
			$ary_which = STTree::$ary_usedCategory;
		}else {
			return;
		}
                if(isset($ary_which['Testobj'])){
                    $ary_which = $ary_which['Testobj'];
                }
		if(!is_array($ary_which)) {
			return;
		}
		foreach($ary_which as $var_key => $var_value) {
//                        D::show($var_value,'$var_value',1,1);
			$ary_keys = array_keys($var_value);
//			D::show($var_value,'VALUE: '.$param_which,1,1);
                        foreach($var_value as $var_key2 => $var_value2) {

				$var_num = count($var_value2);
                                if($var_num == '1'){
                                    if($param_which == 'Tagcloud'){
                                       $var_ID =$var_value2[0]['ID'];
                                    }   
                                } elseif($param_which == 'Category'){
                                    $var_ID =$var_value2[0]['ID'];
                                }
				if($var_num > '1') {
					for($i=0;$i<$var_num;$i++) {
						$ary_srch[] = $var_value2[$i]['Subject'];
					}
					$ary_get = SendReceiveTools::createGET($var_value2['0']['url'],'',TRUE,null,1);

//                                        unset($ary_get[p][0]);
//                                        unset($ary_get[p][1]);
                                        $ary_temp =array('p' => array('0'=>'showSingle', '1'=> 'ID', '2'=> $var_ID,'3'=>$ary_get['p'][2],'4'=>$ary_get['p'][3],'5'=>$ary_get['p'][4],'6'=>$ary_get['p'][5] ));
					$ary_get =$ary_temp;
//                                        D::show($ary_get,'ARY_GET',1,1);
                                        $obj_curl = new cURLTools();
					$var_httphost= STMANAGEData::getGenCfgSTStd('0');
//					$var_httphost = 'http://'.$var_httphost['HTTP_HOST'].'/index.php';
                                        $var_httphost = 'http://'.$var_httphost['HTTP_HOST'].'/service.php';
					$param_ary['return'] = $obj_curl->curllogin($this->var_userID,$this->var_userPW,$this->var_userID,null,$var_httphost,$param_ary['return']);
					$curlout = $obj_curl->curlSend($ary_get,null,TRUE);
                                        
//					D::show($curlout,'$curlout PartOfID'.$this->var_partOfID,1,1);
                                        $ary_searchout =$this->searchRegExpInTagCategory($curlout,$ary_srch);
					$varUrlString = SendReceiveTools::makeLinkFromGET($ary_get,'all',TRUE,null,TRUE);
					$this->assertRegExpTestsSmall($ary_searchout,$curlout,$var_value2['0']['CurWalkAry'],$param_which .' '. $varUrlString.' '. $var_value2['0']['Case'].' Method: '.__METHOD__.' Zeile: '.__LINE__ );// urlstring
					/**
					* Arraay Search for Errors defined in config_ST.php $_ST_cfgStd['Errors']
					*/
					$var_cfgSTStd = STMANAGEData::getGenCfgSTStd();
					$var_cfgSTStd = $var_cfgSTStd['0'];
					$ary_searchoutErrors =$this->searchRegExpInTagCategory($curlout,$var_cfgSTStd['Errors']);
					$this->assertRegExpTestsSmall($ary_searchoutErrors ,$curlout,$var_value2['0']['CurWalkAry'],$param_which .' '. $varUrlString.' '. $var_value2['0']['Case'].'Method: '.__METHOD__.' Zeile: '.__LINE__,'1' );// urlstring
					unset($ary_srch);
				}
			}
		}
	}




}


?>