'; $fuserID=get_cookie($mycookie); $specialjs=''; #echo '
'.$fuserID; die; $setUID=(isset($_GET['u']))?$_GET['u']:'';$setT=(isset($_GET['t']))?$_GET['t']:''; $fuserID=($setUID)?$setUID:$fuserID; $fuserID=(strlen($fuserID))?$fuserID:0; $userID=0; $pageID=(isset($pageID))?$pageID:0; $giwdirection=0; getinwardlogon(); ### inward login redirects $inwardlogon=($giwdirection==2 && isset($goafterlogin))?$goafterlogin:''; $inwardlogon=($giwdirection==1 && isset($goafterregister))?$goafterregister:$inwardlogon; if($inwardlogon){ $nloc=$inwardlogon.((preg_match("/\?/",$inwardlogon))?'&':'?').'t='.$setT.'&u='.$fuserID; print "\n\nLogon\n\n \n \n"; close_conn($db);exit;} ################ if(preg_match("/^[0-9]+\_[0-9]+$/",$fuserID,$g)){$a=split("_",$fuserID); $userID=$a[0];} #echo "$userID cc $fuserID $now
"; ### check database to see if this is a valid log return if($setUID && $setT && $userID && $db){ $crit="userID = $userID AND dateUpdated = $setT"; $ret=get_one($db,'iT_Tusers','userID',$crit); #echo $ret.' '.$crit; die; if(!$ret){$userID=0;}} #$userID=5; # temp correction for local login #$dbLogURL='http://localhost/cgi-bin/RichardPadwick/user.pl'; #$dbLogURL=$loginPageName; $nologforce=(isset($donotforcelogin))?$donotforcelogin:''; if(!($userID || $nologforce)){goLog($dbLogURL.'?or='.goHex(getenv("HTTP_REFERER")));close_conn($db); exit; } $now=time(); $logout=($userID)?'javascript:logMove(\''.$mycookie.'\',\''.$dbLogURL.'?logout='.$userID.'_3'.'\')': $dbLogURL.'?or='.goHex(getenv("HTTP_REFERER")); $logoutText=($userID)?'logout':'login'; $groupID=(isSet($groupID))?$groupID:0; #echo 'gg '.$groupID; #### organisation - iT_Organisations ############################### if(isset($organisationID) && $db){ $crit="organisationID = '$organisationID'"; $fldset="dateUpdated = $now"; $flds='orgKey,userID,organisationID,organisationName,Title,Forename,Surname,eMail,dateCreated,dateUpdated'; $vals="'',0,'$organisationID','','','','','',$now,$now"; $orgKey=get_one($db,'iT_Organisations','orgKey',$crit); if(!$orgKey){ $ret=insert_data($db,'iT_Organisations',$flds,$vals); #echo $ret.'
'; $orgKey=get_one($db,'iT_Organisations','orgKey',$crit);}} #echo "orgKey $orgKey
"; #### owner - iT_Owners ############################### if(isset($ownerID) && $db){ $orgKey=($orgKey)?$orgKey:0; $crit="ownerID = '$ownerID'"; $fldset="dateUpdated = $now"; $flds='ownerKey,userID,orgKey,ownerID,Title,Forename,Surname,eMail,dateCreated,dateUpdated'; $vals="'',0,$orgKey,'$ownerID','','','','',$now,$now"; $ownerKey=get_one($db,'iT_Owners','ownerKey',$crit); if(!$ownerKey){ $ret=insert_data($db,'iT_Owners',$flds,$vals); #echo $ret.'
'; $ownerKey=get_one($db,'iT_Owners','ownerKey',$crit);}} #echo "ownerKey $ownerKey
"; #### tutorial - iT_Tutorials ############################### if(isset($tutorialID) && $db){ $ownerKey=($ownerKey)?$ownerKey:0; $orgKey=($orgKey)?$orgKey:0; $crit="tutorialID = '$tutorialID'"; $fldset="dateUpdated = $now"; $flds='tutorialKey,ownerKey,tutorialID,tutorialName,tutorialURL,dateCreated,dateUpdated'; $vals="'',$ownerKey,'$tutorialID','','',$now,$now"; $tutorialKey=get_one($db,'iT_Tutorials','tutorialKey',$crit); if(!$tutorialKey){ $ret=insert_data($db,'iT_Tutorials',$flds,$vals); # echo "$ret".'
'; $tutorialKey=get_one($db,'iT_Tutorials','tutorialKey',$crit);} $tutorialURL='http://'.getenv("HTTP_HOST").getenv('REQUEST_URI'); $tutorialURL=preg_replace("/[^\/]+$/",'login.php',$tutorialURL); if($tutorialURL){update_data($db,'iT_Tutorials',"tutorialURL = '$tutorialURL'","tutorialKey = $tutorialKey");} } #echo "tutorialKey $tutorialKey
"; #### Page - iT_Pages ############################### if(isset($pageID) && $db){ $tutorialKey=($tutorialKey)?$tutorialKey:0; $pageUploaded=(isset($pageUploaded))?$pageUploaded:date("l dS F Y h:i:s A"); $crit="pageID = $pageID"; $fldset="dateUpdated = $now,groupID = '$groupID'"; $flds='pageKey,tutorialKey,pageID,groupID,pageUploaded,dateCreated,dateUpdated'; $vals="'',$tutorialKey,$pageID,'$groupID','$pageUploaded',$now,$now"; $pageKey=get_one($db,'iT_Pages','pageKey',$crit); if(!$pageKey){ $ret=insert_data($db,'iT_Pages',$flds,$vals); # echo "$ret".'
'; $pageKey=get_one($db,'iT_Pages','pageKey',$crit);}} #echo "pageKey $pageKey
"; ##### user details ################################################# $User_name=$Title=$Forename=$Surname=$Organisation=$Email=$Country=''; $LastResponse='None recorded'; if($userID){ get_user_data($userID); $crit="userID=$userID"; if(isInt($tutorialKey)){$crit.=" AND tutorialKey=$tutorialKey";} $LastResponseEp=get_max($db,'iT_Responses','dateUpdated',$crit); } if($LastResponseEp){$d=getdate($LastResponseEp);$LastResponse=$d["mday"].' '.$d["month"].' '.$d["year"];} #echo "$LastResponse $crit"; ##### end user details ################################################# ############ tutorial ID ########################################## $mylowestsubtutorialID=0; $subtutorialsList=getsubtutorialsList($tutorialKey,$userID); ## here to get min subtutorialID for following functs $subtutorialCookie='ziToolkitTutID'; $subFacts=(isset($_GET['subtutorialID']))?$_GET['subtutorialID']:get_cookie($subtutorialCookie); $mA=split("_",$subFacts); $subtutorialID=(isset($mA[0]))?$mA[0]:''; $subtutorialDate=(isset($mA[1]))?$mA[1]:''; $subtutorialID=($subtutorialID)?$subtutorialID:$mylowestsubtutorialID; $subtutorialID=($subtutorialID)?$subtutorialID:1; $subtutorialDate=($subtutorialDate)?$subtutorialDate:get_one($db,'iT_Responses','subtutorialDate',"userID = $userID AND tutorialKey = $tutorialKey and subtutorialID = $subtutorialID"); $subtutorialDate=($subtutorialDate)?$subtutorialDate:time(); echo ''; #setcookie($subtutorialCookie,$subtutorialID.'_'.$subtutorialDate,(time()+86400)); #echo "\$subtutorialID $subtutorialID $subtutorialDate
"; $subpageID=(isset($_GET['subpageID']))?$_GET['subpageID']:1; ##update database with input values storeInput($pageID,$tutorialKey,$groupID,$userID,$now,$subpageID,$subtutorialID,$subtutorialDate); ### here to get data following inserts $newinsertHREF=newsubpageID($pageID); $insertsList=getinsertsList($pageID,$tutorialKey,$subtutorialID,$userID); $newsubtutorialHREF=newsubtutorialID($tutorialKey); ### refresh following insert if(isset($_POST["Submit"])){$subtutorialsList=getsubtutorialsList($tutorialKey,$userID); } ### get stored responses for this tutorial/page/user $resp=($bypassresponses)?xinputString():getresponses($pageID,$tutorialKey,$groupID,$userID,1,0,'',$subpageID,$subtutorialID); #$resp='Field0101|a~Field0102|b~Field0103|c~Field0104|d~Field0105|e~Field0201|f~Field0202|g%0Ag~Field0203|h~Field0204|i~Field0205|j'; ########################## ########new pageID ########################## function newsubtutorialID($tutorialKey,$pageName='') { Global $userID; $db=oc(); $crit="userID = $userID AND tutorialKey = $tutorialKey"; $n=get_max($db,'iT_Responses','subtutorialID',$crit); $n++; $ret=$pageName."?subtutorialID=$n".'_'.time();close_conn($db); return $ret; } ########################## ########new pageID ########################## function newsubpageID($pageID,$pageName='') { Global $userID,$tutorialKey,$subtutorialID; $db=oc(); $crit="pageID = $pageID AND userID = $userID AND tutorialKey = $tutorialKey AND subtutorialID = $subtutorialID"; $n=get_max($db,'iT_Responses','subpageID',$crit); $n++; $ret=$pageName."?subpageID=$n";close_conn($db); return $ret; } ######################################################################## function makeinsertsList($pageID,$pageName='',$titlefield=''){ Global $tutorialKey,$userID,$subtutorialID; $x=getinsertsList($pageID,$tutorialKey,$subtutorialID,$userID,$pageName,$titlefield);return $x;} ######################################################################## function makesubtutorialsList($tutorialKey,$pageName=''){ Global $userID; $x=gesubtutorialsList($tutorialKey,$userID,$pageName);return $x;} ########################## ######## ########################## ### sets cookie and fills form ###### $specialjs=" var genexpdate = new Date(); var fuserID='".$fuserID."'; var gencookieName='".$mycookie."'; genexpdate.setTime(genexpdate.getTime() + (60 * 60 * 1000)); if(fuserID != 0){gensetCookie(gencookieName,fuserID,genexpdate);} var curvisval=autoSetCookie(gencookieName,'0',genexpdate); var DBinValues='".$resp."'; var logoutLink=\"$logout\"; var logoutText='$logoutText'; "; ## close database close_conn($db); $pageaftersubmit=(isset($pageaftersubmit))?$pageaftersubmit:''; if(isset($_POST['Submit']) && $pageaftersubmit && !$bypassresponses){print "\n";} #while(list($k)=each($DATABASE)){echo "$k $DATABASE[$k]
";} #phpinfo(); ############## function xinputString() { $out=''; if(isset($_POST["Submit"])){reset($_POST); while(list($k,$v)=each($_POST)){ if(strlen($k) > 0){ $out .= goHex($k).'|'.goHex($v).'~';}} } $out=preg_replace("/\~$/",'',$out); return $out;} ############## function ISvalidate($vString=''){ Global $validatemessage; $v=1; if(postval('Submit')){ $vString=preg_replace("/\r\n\t/"," ",$vString); $vString=preg_replace("/\s+/"," ",$vString); $vString=trim($vString); if($vString){$a=split("\~",$vString); for($x=0;$x"; if($n){ $t=1; if($ab && !(getNumber(postval($n))==$ab)){$t=0;} if($isnum && (preg_match("/[^0-9\.\-]/",postval($n)) || preg_match("/.+\-/",postval($n)) || preg_match("/\.[^\.]*\./",postval($n)) || preg_match("/\.$/",postval($n)))){$t=0;} if(preg_match("/^[\-]?[0-9]+$/",$min) && (getNumber(postval($n))<$min)){$t=0;} if(preg_match("/^[\-]?[0-9]+$/",$max) && (getNumber(postval($n))>$max)){$t=0;} $y=getNumber(postval($n)); #echo "y is $y
"; if(isInt($dec)){if($dec==0 && preg_match("/\./",$y)){$t=0;} else if($dec==1 && !preg_match("/\.[0-9]$/",$y)){$t=0;} else if($dec==2 && !preg_match("/\.[0-9][0-9]$/",$y)){$t=0;}} $y=trim(postval($n)); $emailpattern='^([a-zA-Z0-9\.\-\_\&]+)\@([a-zA-Z0-9\.\-\_\&]+)\.([a-zA-Z]{2,4})$'; if($em && !preg_match("/$emailpattern/",$y)){$t=0;} if(!strlen(postval($n))){$t=($req)?0:1;} if(!$t){$v=0;$validatemessage.=$m.'
';} }} # end for($x=0;$x function goHere(nLoc){\nself.location.replace(nLoc);\n}\ngoHere('$n');\n\n";exit;}} ############## function textCompile($groupID,$pageID=''){ Global $userID,$tutorialKey,$subtutorialID,$subpageID; #### add dummy questions so we have record of all q's when admin submits $result=''; $db=oc(); #### get dataset $byPage=($pageID)?1:0; $byGroup=($groupID)?1:0; $sortBy='questionID ASC'; #echo "$pageID,$tutorialKey,$groupID,$userID,$byPage,$byGroup,$sortBy
"; $mystring=getresponses($pageID,$tutorialKey,$groupID,$userID,$byPage,$byGroup,$sortBy,$subpageID,$subtutorialID); #echo $mystring.'

'; $qArray=split('~',$mystring); $myVals=(array) null; $mySort=(array) null; #echo count($qArray).'
'; //count is actual no of cells in array if(strlen($mystring)){ while(list($k)=each($qArray)){ $rArray=split('\|',$qArray[$k]); $r=stripslashes(rawurldecode($rArray[1])); $vArray=split('\|',$r); if(count($vArray)<2){ $a=$rArray[0]; $a=preg_replace("/^[a-zA-Z]+/",'',$a); while(strlen($a)<12){$a="$a".'0';} $a=$a.'f'; $myVals[$a]=$r; $mySort[count($mySort)]=$a; #echo "$a $r".'
'; }}} echo '

'; $sortBy='prepostID ASC'; $mystring=getprepost($pageID,$tutorialKey,$groupID,$byPage,$byGroup,$sortBy); #echo $mystring.'

'; if(strlen($mystring)){ $qArray=split('~',$mystring); # echo count($qArray).'
'; count is actual no of cells in array while(list($k)=each($qArray)){ $rArray=split('\|',$qArray[$k]); $r=stripslashes (rawurldecode($rArray[1])); $vArray=split('\|',$r); if(count($vArray)<2){ $a=$rArray[0]; if(preg_match("/^title/i",$a)){$f='a';}elseif(preg_match("/^intro/i",$a)){$f='b';} elseif(preg_match("/^section/i",$a)){$f='c';}elseif(preg_match("/^clause/i",$a)){$f='d';} elseif(preg_match("/^pre/i",$a)){$f='e';}elseif(preg_match("/^post/i",$a)){$f='g';} $a=preg_replace("/^[a-zA-Z]+/",'',$a); while(strlen($a)<12){$a="$a".'0';} $a=$a.$f; $myVals[$a]=$r; $mySort[count($mySort)]=$a; #echo "$a $r".'
'; }}} sort($mySort); $startdiv=0;$enddiv=0; $lastwasresponse=0; $isresponse=0; while(list($k)=each($mySort)){$ky=$mySort[$k]; $x=(isset($myVals[$ky]))?$myVals[$ky]:''; #$x=(strlen($x))?$x:'Response required!'; #echo "$k bb $ky bb $x
"; $td='';$class=''; $h=''; $h_out=''; if(preg_match("/a$/",$ky)){$td='div'; $class='ftitle'; $h='h1';$h_out='';} elseif(preg_match("/b$/i",$ky)){$td='div'; $class='finfo'; $h='p';$h_out='';} elseif(preg_match("/c$/i",$ky)){$td='div'; $class='fsection'; $h_out='h3';} elseif(preg_match("/d$/i",$ky)){$td='div'; $class='fclause'; $h_out='h4';} elseif(preg_match("/e$/i",$ky)){$td='span'; $class='fpre'; $h='';$h_out='';} elseif(preg_match("/f$/i",$ky) && preg_match("/^Response required\!$/i",$x)){$td='span'; $class='unanswered'; $h='';$h_out='';} elseif(preg_match("/f$/i",$ky)){$td='span'; $class='fresponse'; $h='';$h_out='';} elseif(preg_match("/g$/i",$ky)){$td='span'; $class='fpost'; $h='';$h_out='';} #echo "$ky c $class td $td
"; $h1=($h)?"<$h>":''; $h2=($h)?"":''; $h_out1=($h_out)?"<$h_out>":''; $h_out2=($h_out)?"":''; $isinner=(preg_match("/[efg]$/i",$ky))?1:0; $isresponse=(preg_match("/[f]$/i",$ky))?1:0; #$result.= "ii $isinner sd $startdiv
"; ## if(preg_match("/[e]$/i",$ky) && ($startdiv>0)){$startdiv=0; $result.="

\n\n";} if($isresponse && $lastwasresponse && ($startdiv>0)){$startdiv=0; $result.="

\n\n";} ## new div for inners if($isinner && ($startdiv<1)){$startdiv=1; $result.="
\n

\n";} if(($isinner<1) && ($startdiv>0)){$startdiv=0; $result.="

\n
\n";} if($isresponse){$x=preg_replace("/[\r\n]+/",'
',$x); } $result.= "$h_out1<$td class=\"$class\">$h1$x$h2$h_out2\n"; if(($isinner<1) && ($startdiv>0)){$startdiv=0; $result.="

\n\n";} $lastwasresponse=(preg_match("/[f]$/i",$ky))?1:0; } # end while(list($k)=each($mySort)){ close_conn($db); if(($startdiv>0)){$startdiv=0; $result.="

\n\n";} #echo $result; die; return $result;} ############## function QuestionAnalysis( $AnalysisType, $groupID,$pageID,$questionID, $AnalysisField, $ReturnNoOfItems,$TopOrBottomSet,$ScoreValueField, $FilterByField,$FilterByValue, $FilterByField2,$FilterByValue2, $GroupByField, $SortBy1stField,$SortBy1stOrder, $SortBy2ndField,$SortBy2ndOrder, $ExtraValueField='',$FilterByValueTo=''){ Global $userID,$tutorialKey,$subtutorialID,$subpageID; $db=oc(); ### results sorting $SortBy1stOrder=($SortBy1stOrder)?$SortBy1stOrder:'ASC'; $SortBy2ndOrder=($SortBy2ndOrder)?$SortBy2ndOrder:'ASC'; ## sort by element $sortElement1=(preg_match("/^[0-9]+$/",$SortBy1stField))?$SortBy1stField:''; $sortElement2=(preg_match("/^[0-9]+$/",$SortBy2ndField))?$SortBy2ndField:''; $SortBy1stField=($sortElement1)?'':$SortBy1stField; $SortBy2ndField=($sortElement2)?'':$SortBy2ndField; ### database sort $sortBy=($SortBy1stField)?"$SortBy1stField $SortBy1stOrder":''; $sortBy.=($sortBy && $SortBy2ndField)?',':''; $sortBy.=($SortBy2ndField)?"$SortBy2ndField $SortBy2ndOrder":''; #### get dataset $byPage=($pageID)?1:0; $byGroup=($groupID)?1:0; #echo "$pageID,$tutorialKey,$groupID,$userID,$byPage,$byGroup,$sortBy
"; $mystring=getresponses($pageID,$tutorialKey,$groupID,$userID,$byPage,$byGroup,$sortBy,$subpageID,$subtutorialID); #echo $mystring; if(preg_match("/^sum+$/i",$AnalysisType)){ $result=mySum($questionID,$AnalysisField,$ReturnNoOfItems,$TopOrBottomSet,$ScoreValueField, $FilterByField,$FilterByValue,$FilterByField2,$FilterByValue2,$GroupByField,$sortElement1,$SortBy1stOrder,$sortElement2,$SortBy2ndOrder,$ExtraValueField,$FilterByValueTo,$mystring,0); } # end Sum else if(preg_match("/^count+$/i",$AnalysisType)){ $result=mySum($questionID,$AnalysisField,$ReturnNoOfItems,$TopOrBottomSet,$ScoreValueField, $FilterByField,$FilterByValue,$FilterByField2,$FilterByValue2,$GroupByField,$sortElement1,$SortBy1stOrder,$sortElement2,$SortBy2ndOrder,$ExtraValueField,$FilterByValueTo,$mystring,1); } # end Count else if(preg_match("/^list+$/i",$AnalysisType)){ $result=myList($questionID,$AnalysisField,$ReturnNoOfItems,$TopOrBottomSet,$ScoreValueField, $FilterByField,$FilterByValue,$FilterByField2,$FilterByValue2,$GroupByField,$sortElement1,$SortBy1stOrder,$sortElement2,$SortBy2ndOrder,$ExtraValueField,$FilterByValueTo,$mystring); } # end List close_conn($db); return $result;} ######################################################################## function mySum($questionID,$AnalysisField,$ReturnNoOfItems,$TopOrBottomSet,$ScoreValueField, $FilterByField,$FilterByValue,$FilterByField2,$FilterByValue2,$GroupByField,$sortElement1,$SortBy1stOrder,$sortElement2,$SortBy2ndOrder,$ExtraValueField,$FilterByValueTo,$mystring,$iscount){ $qArray=split('~',$mystring); $rawsum=0; $tally1=(array) null; $tally2=(array) null; $myGroupNums=(array) null; $myGroups=(array) null; $myGroupTags=(array) null; # echo count($qArray).'
'; count is actual no of cells in array while(list($k)=each($qArray)){ $rArray=split('\|',$qArray[$k]); $r=(isset($rArray[1]))?rawurldecode($rArray[1]):''; $vArray=split('\|',$r); if(count($vArray)==4){ ## so has elements for($x=0;$x<4;$x++){$vArray[$x]=trim($vArray[$x]);} ## filter $FilterByValue=trim($FilterByValue); $FilterByValueTo=trim($FilterByValueTo); $FilterByValue2=trim($FilterByValue2); if((isEl($FilterByField) && (preg_match("/^$FilterByValue$/i",$vArray[$FilterByField-1]) || # numeric range between FilterByValue and $FilterByValueTo (isInt($FilterByValue)&& isInt($FilterByValueTo) && isInt($vArray[$FilterByField-1]) && ($vArray[$FilterByField-1]>=$FilterByValue && $vArray[$FilterByField-1]<=$FilterByValueTo ) ) )) || # no value in $FilterByField (!isEl($FilterByField)) ){ if(isEl($FilterByField2) && preg_match("/^$FilterByValue2$/i",$vArray[$FilterByField2-1]) || !isEl($FilterByField2)){ if(isEl($AnalysisField)){ ## $AnalysisField is an element number ## sorting $addplug1=''; $isgrouping='noGroup'; if(isEl($GroupByField)){ if($vArray[$GroupByField-1]){ $isgrouping=$vArray[$GroupByField-1];}} $xtally1=(isset($tally1[$isgrouping]))?$tally1[$isgrouping]:0; if(isEl($sortElement1)){ $addplug1=(isInt($vArray[$sortElement1-1]))?lzero($vArray[$sortElement1-1]+$xtally1):$vArray[$sortElement1-1]; ## correct for count $addplug1=($iscount)?lzero(1+$xtally1):$addplug1; if(isInt($vArray[$sortElement1-1])){$addbit=($iscount)?1:$vArray[$sortElement1-1]; if(isset($tally1[$isgrouping])){$tally1[$isgrouping]+=$addbit;}else{$tally1[$isgrouping]=$addbit;}} } # end if(isEl($sortElement1)){ $sb1=$addplug1; #echo "isgrouping $isgrouping $xtally1 v ".$vArray[$sortElement1-1]."
"; $addplug2=''; $isgrouping='noGroup'; if(isEl($GroupByField)){ if($vArray[$GroupByField-1]){ $isgrouping=$vArray[$GroupByField-1];}} $xtally2=(isset($tally2[$isgrouping]))?$tally2[$isgrouping]:0; if(isEl($sortElement2)){ $addplug2=(isInt($vArray[$sortElement2-1]))?lzero($vArray[$sortElement2-1]+$xtally2):$vArray[$sortElement2-1]; ## correct for count $addplug2=($iscount)?lzero(1+$xtally2):$addplug2; if(isInt($vArray[$sortElement2-1])){$addbit=($iscount)?1:$vArray[$sortElement2-1];if(isset($tally2[$isgrouping])){$tally2[$isgrouping]+=$addbit;}else{$tally2[$isgrouping]=$addbit;}} } # end if(isEl($sortElement2)) $sb2=$addplug2; ## grouping if(isEl($GroupByField)){ if($vArray[$GroupByField-1]){ $l=$vArray[$GroupByField-1]; if(isset($myGroupNums[$l])){ if(isset($myGroups[$myGroupTags[$l]])){$myGroups[$myGroupTags[$l]]=$sb1.'|'.$sb2.'|'.$l;} if(isInt($vArray[$AnalysisField-1])){$myGroupNums[$l]+=($iscount)?1:$vArray[$AnalysisField-1];}} else{$currentgroup=count($myGroups); $myGroups[$currentgroup]=$sb1.'|'.$sb2.'|'.$l; $myGroupTags[$l]=$currentgroup; $myGroupNums[$l]=($iscount)?1:$vArray[$AnalysisField-1];} }} # end if(isEl($GroupByField)){ - if($vArray[$GroupByField-1]){ ### raw sum if(isInt($vArray[$AnalysisField-1])){$rawsum+=($iscount)?1:$vArray[$AnalysisField-1];} } # end if(isEl($AnalysisField)){ }} # end filter conditions } # end if(count($vArray)==4){ } # end while(list($k) $return=$rawsum; if(isEl($GroupByField)){$return=''; ### sorting if(isEl($sortElement1) || isEl($sortElement2)){$sb=(strlen($SortBy1stOrder))?$SortBy1stOrder:$SortBy2ndOrder; #echo $sb; if(preg_match("/DESC/i",$sb)){rsort($myGroups);} else{sort($myGroups);} } for($x=0;$x'; $return.='

'."$s[2]: ".((isset($myGroupNums[$s[2]]))?''.$myGroupNums[$s[2]]:'').'

'; } # end for loop } # end if(isEl($GroupByField)){ # echo count($myGroups); return $return;} ######################################################################## function lzero($i,$n=10){ while(strlen($i)<$n){$i="0$i";} return $i;} ######################################################################## function sortString($ReturnNoOfItems,$TopOrBottomSet,$ScoreValueField,$sortElement1,$SortBy1stOrder,$sortElement2,$SortBy2ndOrder,$ExtraValueField,$mystring){ $mySorts=(array) null; $myxSorts=(array) null; $myOuts=(array) null; $qArray=split('~',$mystring); $myFields=(array) null; $xn=1; while(list($k)=each($qArray)){ $nsort=''; $sort1=''; $sort2=''; $dsort=''; ### default sort is numerical entry point $dsort=lzero($xn); $myOuts[$xn]=$qArray[$k]; $rArray=split('\|',$qArray[$k]); if(isset($rArray[1])){ $r=rawurldecode($rArray[1]); $vArray=split('\|',$r); if(count($vArray)==4){ ## so has elements for($x=0;$x<4;$x++){$vArray[$x]=trim($vArray[$x]);} ### top or bottom sort if(strlen(trim($TopOrBottomSet)) && isEl($ScoreValueField)){ $nsort=(isInt($vArray[$ScoreValueField-1]))?lzero($vArray[$ScoreValueField-1]):$vArray[$ScoreValueField-1];} if(isEl($sortElement1)){$sort1=$vArray[$sortElement1-1];} if(isEl($sortElement2)){$sort2=$vArray[$sortElement2-1];} } # end if(count($vArray)==4) $nl="$nsort|$sort1|$sort2|$dsort|$xn"; #echo $nl.'
'; $mySorts[count($mySorts)]=$nl; } # end if(isset($rArray[1])){ $xn++;} # end while(list($k) $mystring=''; if(preg_match("/top/i",$TopOrBottomSet) && isEl($ScoreValueField)){ rsort($mySorts); } elseif(preg_match("/bottom/i",$TopOrBottomSet) && isEl($ScoreValueField)){sort($mySorts);} else if(preg_match("/desc/i",$SortBy1stOrder) && isEl($sortElement1)){ rsort($mySorts); } else if(preg_match("/desc/i",$SortBy2ndOrder) && isEl($sortElement2)){ rsort($mySorts); } ## is $ReturnNoOfItems #if(isInt($ReturnNoOfItems)){ #for($x=0;($x<$ReturnNoOfItems && $x'; #$mySorts=$myxSorts; #echo 'ccc '.count($mySorts).'
'; #} ## end if(isInt($ReturnNoOfItems)){ for($x=0;$x'; $s=split('\|',$mySorts[$x]); $mystring.=$myOuts[$s[4]].'~';} $mystring=preg_replace("/\~$/",'',$mystring); return $mystring;} ######################################################################## function myList($questionID,$AnalysisField,$ReturnNoOfItems,$TopOrBottomSet,$ScoreValueField, $FilterByField,$FilterByValue,$FilterByField2,$FilterByValue2,$GroupByField,$sortElement1,$SortBy1stOrder,$sortElement2,$SortBy2ndOrder,$ExtraValueField,$FilterByValueTo,$mystring){ $mystring=sortString($ReturnNoOfItems,$TopOrBottomSet,$ScoreValueField,$sortElement1,$SortBy1stOrder,$sortElement2,$SortBy2ndOrder,$ExtraValueField,$mystring); $qArray=split('~',$mystring); $myFields=(array) null; $myGroups=(array) null; $myGroupVals=(array) null; $havePrinted=(array) null; # echo count($qArray).'
'; count is actual no of cells in array while(list($k)=each($qArray)){ $rArray=split('\|',$qArray[$k]); if(isset($rArray[1])){ $r=rawurldecode($rArray[1]); $vArray=split('\|',$r); if(count($vArray)==4){ ## so has elements for($x=0;$x<4;$x++){$vArray[$x]=trim($vArray[$x]);} ## filter $FilterByValue=trim($FilterByValue); $FilterByValueTo=trim($FilterByValueTo); $FilterByValue2=trim($FilterByValue2); if((isEl($FilterByField) && (preg_match("/^$FilterByValue$/i",$vArray[$FilterByField-1]) || # numeric range between FilterByValue and $FilterByValueTo (isInt($FilterByValue)&& isInt($FilterByValueTo) && isInt($vArray[$FilterByField-1]) && ($vArray[$FilterByField-1]>=$FilterByValue && $vArray[$FilterByField-1]<=$FilterByValueTo ) ) )) || # no value in $FilterByField (!isEl($FilterByField)) ){ if(isEl($FilterByField2) && preg_match("/^$FilterByValue2$/i",$vArray[$FilterByField2-1]) || !isEl($FilterByField2)){ $sb1=(isEl($sortElement1))?$vArray[$sortElement1-1]:''; $sb2=(isEl($sortElement2))?$vArray[$sortElement2-1]:''; if(isEl($AnalysisField)){ ## $AnalysisField is an element number $fval=$sb1.'|'.$sb2.'|'.$vArray[$AnalysisField-1].'|'; if(isEl($ExtraValueField)){$fval.=$vArray[$ExtraValueField-1];} $myFields[count($myFields)]=$fval; ## grouping if(isEl($GroupByField)){ $l=$vArray[$GroupByField-1]; if(isset($myGroupVals[$l])){$myGroupVals[$l].='~'.goHex($fval); } else{$myGroups[count($myGroups)]=$l;$myGroupVals[$l]=goHex($fval); } } ## end if(isEl($GroupByField)){ } # if(isEl($AnalysisField)){ }} # end filter conditions } # end if(count($vArray)==4){ } # end if(isset($rArray[1])){ } # end while(list($k) $return=''; ### simple list ## $limit=(isInt($ReturnNoOfItems) && ($ReturnNoOfItems<=count($myFields)))?$ReturnNoOfItems:count($myFields); #### sorting $xmyFields=(array) null; for($x=0;$x<$limit;$x++){$xmyFields[$x]=$myFields[$x]; }$myFields=$xmyFields; if(isEl($sortElement1) && preg_match("/DESC/i",$SortBy1stOrder)){rsort($myFields);} elseif(isEl($sortElement1) && preg_match("/ASC/i",$SortBy1stOrder)){sort($myFields);} elseif(isEl($sortElement2) && preg_match("/DESC/i",$SortBy2ndOrder)){rsort($myFields);} elseif(isEl($sortElement2) && preg_match("/ASC/i",$SortBy2ndOrder)){sort($myFields);} for($x=0;$x<$limit;$x++){ #echo "xx $x $myFields[$x]
"; $s=split('\|',$myFields[$x]);$label=trim($s[2]);$label=($label)?$label:"[Element $AnalysisField is empty]"; if($label){ # echo 'x '.$x.'
'; $return.='

'.$label; if(isEl($ExtraValueField)){$return.=": ".''.$s[3];} $return.='

';} # end if(trim($s[0])){ } ### end for loop if(isEl($GroupByField)){$return=''; ### sort groups !! if((isEl($sortElement1) && $sortElement1==$GroupByField) || (isEl($sortElement2) && $sortElement2==$GroupByField)){ $sorder=($sortElement1==$GroupByField)?$SortBy1stOrder:$SortBy2ndOrder; if(preg_match("/DESC/i",$sorder)){rsort($myGroups); } else {sort($myGroups);} } ## end if((isEl($sortElement1) && $sortElement1 etc #echo "$GroupByField,$sortElement1,$SortBy1stOrder,$sortElement2,$SortBy2ndOrder
"; for($x=0;$x'; if(isset($myGroupVals[$l])){ $fArray=split('~',$myGroupVals[$l]); $limit=(isInt($ReturnNoOfItems) && ($ReturnNoOfItems<=count($fArray)))?$ReturnNoOfItems:count($fArray); $xfArray=(array) null; for($z=0;$z<$limit;$z++){$xfArray[$z]=rawurldecode($fArray[$z]);}$fArray=$xfArray; #echo "\$sortElement1 $sortElement1 \$SortBy1stOrder $SortBy1stOrder
"; if(isEl($sortElement1) && preg_match("/DESC/i",$SortBy1stOrder)){rsort($fArray);} elseif(isEl($sortElement1) && preg_match("/ASC/i",$SortBy1stOrder)){sort($fArray);} elseif(isEl($sortElement2) && preg_match("/DESC/i",$SortBy2ndOrder)){rsort($fArray);} elseif(isEl($sortElement2) && preg_match("/ASC/i",$SortBy2ndOrder)){sort($fArray);} for($y=0;$y<$limit;$y++){ $k=rawurldecode($fArray[$y]); $s=split('\|',$k); $label=trim($s[2]);$label=($label)?$label:"[Element $AnalysisField is empty]"; if($label){ $return.='

'.$label; if(isEl($ExtraValueField)){$return.=": ".''.$s[3];} $return.='

';} # end if$label{ } # end for loop $y } # end if(isset($myGroupVals[$l])){ } # end if(trim($myGroups[$x])){ } # end for loop $x } # end if(isEl($GroupByField)){ # echo count($myGroups); return $return;} ######################################################################## function getNumber($v){ $v=preg_replace("/[^[0-9]\.\-]/",'',$v); $v=preg_replace("/\.+/",'.',$v); $v=preg_replace("/\-+/",'-',$v); $v=preg_replace("/^([0-9\-]*\.[0-9\-]*)\..*/","$1",$v); $v=preg_replace("/([0-9\-]+)\-.*/","$1",$v); if(!preg_match("/[1-9]/",$v)){$v=0;} return $v;} ######################################################################## function IScalculate($c=''){ Global $DATABASE,$_POST; $DCAT=array(); $PCAT=array(); $c=preg_replace("/ +/",'',$c); $c=preg_replace("/\[[\'\"]/",'[',$c); $c=preg_replace("/[\'\"]\]/",']',$c); #$c=preg_replace("/\/D\[([^\]]+)\]/","/((isset(\$DATABASE['$1']))?\$DATABASE['$1']:1)",$c); $x=0; while(preg_match("/D\[([^\]]+)\]/",$c,$g)){ $DCAT['ZX'."$x".'XZ']=$g[1]; $c=preg_replace("/D\[([^\]]+)\]/",'ZX'."$x".'XZ',$c,1); $x++;} $x=0; while(preg_match("/P\[([^\]]+)\]/",$c,$g)){ $PCAT['PX'."$x".'XP']=$g[1]; $c=preg_replace("/P\[([^\]]+)\]/",'PX'."$x".'XP',$c,1); $x++;} while(list($k)=each($DCAT)){ $v=(isset($DATABASE[$DCAT[$k]]))?$DATABASE[$DCAT[$k]]:0; $v=getNumber($v); $c=preg_replace("/$k/","$v",$c);} while(list($k)=each($PCAT)){ $v=(isset($_POST[$PCAT[$k]]))?$_POST[$PCAT[$k]]:0; $v=getNumber($v); $c=preg_replace("/$k/","$v",$c);} $c=preg_replace("/\/([\-]*)0([^\.])/","/$1 1$2",$c); $c=preg_replace("/ +/",'',$c); $a='IScalculate input incorrect'; error_reporting(0); eval('$a='.$c.';'); return $a;} ############## function isVal($i){$x=(preg_match("/^[1-9][0-9]*$/",$i))?1:0;return $x;} function isInt($i){$x=(preg_match("/^[0-9]+$/",$i))?1:0;return $x;} function isEl($i){$x=(preg_match("/^[1-4]$/",$i))?1:0;return $x;} ############## function goLog($nLoc){ echo "\n \n\n";} ############## function get_cookie($mycookie) { $cookieval=0; $cookie_array=split(";",getenv("HTTP_COOKIE")); while(list($k,$v)=each($cookie_array)){$arr=split("=",$v); if(trim($arr[0])==$mycookie){$cookieval=trim($arr[1]);}} return $cookieval;} ############## function unHex($in){ ## not complete // Convert the string back to binary echo pack('H*', $hex_string).'
'; return $in;} ################ function goHex($q){ $q=cleanlinebreaks($q); $q=preg_replace("/\n/","",$q); $o=''; for($x=0;$x0-9a-zA-Z]/",$y))?'%'.sprintf("%.X",ord($y)):$y;} $o=preg_replace("/\/","%0A",$o); return $o;} ################ function cleanlinebreaks($in){$in=preg_replace("/\r\n/","\n",$in); $in=preg_replace("/\n\r/","\n",$in); if(!(preg_match("/\n/",$in))){$in=preg_replace("/\r/","\n",$in);}$in=preg_replace("/\r/","",$in); return($in);} echo(''); ########################################################################################## function commas($fig,$pre){$fig=preg_replace("/\,/",'',$fig); $A=preg_split("/\./",$fig); $figx=(isset($A[0]))?$A[0]:''; $ext=(isset($A[1]))?$A[1]:''; $ext=($ext)?"\.$ext":''; $figx=preg_replace("/^([0-9]+)([0-9][0-9][0-9])$/",'$1,$2',$figx); while(preg_match("/^([0-9]+)([0-9]{3})\,(.*?)$/",$figx)){ $figx=preg_replace("/^([0-9]+)([0-9]{3})\,(.*?)$/",'$1,$2,$3',$figx,1);} $figx=($figx.$ext); return $pre.$figx;} ########################################################################################## ?>
  • Go previous page
  •  4 of 20 
  • Go next page

Commissions checklist

3 Preliminary designs

  • In what format will the preliminary designs be submitted to the commissioner? ShowNote: Depending upon the nature of the proposed work the preliminary designs may take a number of forms (model, maquette, drawings, computer generated image).
  • What is the deadline for delivery of the preliminary designs or is this flexible?
  • How many times can the commissioner request changes to the designs within the agreed fee? ShowNote: The agreement may state the maximum number of changes to the design or additional designs that the commissioner can request for the agreed fee before additional payment is required.
  • How many stages will there be to the design process? ShowNote: In the case of large-scale public and more complex commissions there can be more than one stage in the design process. Acceptance of the initial designs can then be followed by a detailed design process during which the feasibility and costs of the initial designs are explored more fully. For large-scale commissions this design process is sometimes linked to the RIBA stages which are roughly equivalent to concept design, design development and implementation. For each stage in the design process details of payment, number of changes to the design and issues of acceptance/rejection should be clearly outlined.
  • Will the artist be expected to participate in any public consultation regarding the proposed designs? ShowNote: Particularly in the case of large-scale commissions, artists can be expected to participate in public events to discuss the proposals or in exhibitions of the proposed designs. Any such activities and associated fees should be outlined in the schedule.

  • Go previous page
  •  4 of 20 
  • Go next page