⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autogenprofile.php

📁 太烦了
💻 PHP
📖 第 1 页 / 共 2 页
字号:
					$age[$i-1]['number']=0;					$nocount++;				}				if (!isset($_POST[$field2]) || $_POST[$field2] == '') {					$_POST[$field2] = 16;				}				if (!isset($_POST[$field3]) || $_POST[$field3] == '') {					$_POST[$field3] = 90;				}				$age[$i-1]['min']=$_POST[$field2];				$age[$i-1]['max']=$_POST[$field3];				$sum+=$age[$i-1]['number'];			}			if($opt1 > $sum && $nocount == 0 ) $age[0]['number']=$opt1 - $sum;			if ($nocount > 0) {				/* There are age records without any percentage allocated. Let us				   allocate balance numbers equally to these. */				$cnt = $opt1 - $sum;				$cnt1 = 0;				for ($i=0;$i<$opt6;$i++) {					if ($age[$i]['number']==0) {						$age[$i]['number'] = (int)($cnt / $nocount);						$cnt1 += $age[$i]['number'];					}				}				if ($cnt1 < $cnt) {					$age[0]['number']+=$cnt-$cnt1;				}			}		}		$forms['age']=$age;		$male = $female = array();		//getting data from name files		$males=file($path.$file_male);		$females=file($path.$file_female);		$firstnames=file($path.$file_firstname);		/* Modified by Vijay Nair to keep only the required number of males and females			names in the $male and $female array. Unnecessary to have all combinations			to be built into array. System errors occur because of this. */		$male_names_cnt = count($males);		$female_names_cnt = count($females);		$firstnames_cnt = count($firstnames);		// firstnames array is infact last names array		//getting all possible numbers		for($i=0;$i<$nrmales;$i++) {			$r1 = rand(0, ($male_names_cnt-1));			$r2 = rand(0,($firstnames_cnt-1));			$male[$i]['firstname'] = $firstnames[$r2];			$male[$i]['lastname'] = $males[$r1];		}		for($i=0;$i<$nrfemales;$i++) {			$r1 = rand(0,$female_names_cnt-1);			$r2 = rand(0,$firstnames_cnt-1);			$female[$i]['firstname'] = $firstnames[$r2];			$female[$i]['lastname'] = $females[$r1];		}/* old code  - Modified by Vijay Nair given below		for($i=0;$i<count($firstnames);$i++) {			for($j=0;$j<count($males);$j++)			{				$male[$h]['firstname']=$firstnames[$i];				$male[$h]['lastname']=$males[$j];				$h++;			}		}		$h=0;		for($i=0;$i<count($firstnames);$i++) {			for($j=0;$j<count($females);$j++)			{				$female[$h]['firstname']=$firstnames[$i];				$female[$h]['lastname']=$females[$j];				$h++;			}		}*/		$h=0;		$j=0;		while($h<$nrmales)		{//			$sel=mt_rand(0,$nrtotmale-1);			$result[$j]=$male[$h];			$result[$j]['gender']="M";			$h++;			$j++;		}		$forms['gender']['male']=$j;		$h=0;		while($h<$nrfemales)		{//			$sel=mt_rand(0,$nrtotfemale-1);			$result[$j]=$female[$h];			$result[$j++]['gender']="F";			$h++;		}		$forms['gender']['female']=$j-$forms['gender']['male'];		if($forms['gender']['male']+$forms['gender']['female']==0) {$this->modSmartyAssign('error',1);$error=1;}			else {$this->modSmartyAssign('error',2);$this->modSmartyAssign('nrerror',$j);}		$forms=serialize($forms);		$ts=time();		$this->modAddRec($this->lang_autogenprofile_forms_table,array('ts'=>$ts,'form'=>$forms));		$fid=$this->modGetOne($this->lang_autogenprofile_forms_table,array('ts'=>$ts),'id');		$this->modSmartyAssign('fid',$fid);		//select user data and add to database		if(!$error)		{		foreach ($result as $item => $key)		{			do {				$username=$this->getUserName($key['firstname'],$key['lastname']);				$ret=$this->modGetAllUsers(array('username'=>$username));			} while($ret);			$resultitem=$key;			$resultitem['username']=$username;			$sel=array_rand($country);			$cntryprflcnt = $country[$sel]['number'];			$country[$sel]['number']--;			if(!$country[$sel]['country']) {$sel2=array_rand($countries);$resultitem['country']=$countries[$sel2]['name'];$code=$countries[$sel2]['code'];}			else {$resultitem['country']=$country[$sel]['country'];$code=$country[$sel]['code'];}			$resultitem['countrycode']=$code;			if(!$country[$sel]['number']) unset($country[$sel]);	/* Take cities for the selected country  - Vijay Nair */			if (!$city[$code] or count($city[$code]) < 1 ) {				$city = array();				$city[$code] = $this->modGetAllCities($code, $cntryprflcnt);			}			if($city[$code])				$resultitem['city']=$city[$code][array_rand($city[$code])]['name'];			$ok=0;			if($images[$key['gender']])			foreach ($images[$key['gender']] as $item2 => $key2) {				$selage=$key2['age'];				$seletn=$etn[$key2['ethnicity']];				$selfile=$key2['file'];				$selext=$key2['ext'];				$selpath=$pathimages.$selfile;				$ok=0;				if($ethnicity[$seletn]['number']) $ok=1;				else if($ethnicity[4]['number']) $ok=1;				if($ok)					foreach ($age as $item3 => $key3)					{						$selmin=$key3['min'];						$selmax=$key3['max'];						if($selmin<=$selage && $selage<=$selmax) {$ok=2;break;}					}				if($ok==2) {$resultitem['age']=$selage;							if($ethnicity[$seletn]['ethnicity']){								$resultitem['ethnicity']=$ethnicity[$seletn]['ethnicity'];								$ethnicity[$seletn]['number']--;								if(!$ethnicity[$seletn]['number']) unset($ethnicity[$seletn]);							} else {								$resultitem['ethnicity']=$etns[$etn[$key2['ethnicity']]];								$ethnicity[4]['number']--;								if(!$ethnicity[4]['number']) unset($ethnicity[4]);							}							$dbimg=$this->modCreateDbImage($selpath,$selext);							unlink($selpath);							$resultitem['image']=$dbimg['pic'];							$resultitem['image_ext']=$selext;							$resultitem['imagetn']=$dbimg['tn'];							$resultitem['imagetn_ext']="jpg";							unset($images[$key['gender']][$item2]);							$age[$item3]['number']--;							if(!$age[$item3]['number']) unset($age[$item3]);							break;}			}			if($ok!=2)			{				$sel=array_rand($age);				$age[$sel]['number']--;				$resultitem['age']=mt_rand($age[$sel]['min'],$age[$sel]['max']);				if(!$age[$sel]['number']) unset($age[$sel]);				$sel=array_rand($ethnicity);				if($sel!=4)				{				$ethnicity[$sel]['number']--;				$resultitem['ethnicity']=$ethnicity[$sel]['ethnicity'];				}				else $resultitem['ethnicity']=$etns[mt_rand(0,3)];				if(!$ethnicity[$sel]['number']) unset($ethnicity[$sel]);			}			$tsage = $resultitem['age']*365;			$tsage = mt_rand($tsage-364, $tsage);			$resultitem['birth_day'] = $GLOBALS['db']->getOne('select date_add(curdate(), interval -'.$tsage.' day)');			$this->modAddUser($resultitem);			$this->modAddRec($this->lang_autogenprofile_table,array('username'=>$resultitem['username'],'fid'=>$fid));		}		}	}	/* End of generation process */	if($_GET['showforms']==0 && isset($_GET['showforms']))	{		if(isset($_POST['txtdelete']))		{			$fid=$_POST['txtdelete'];			$deldata=$this->modGetAll($this->lang_autogenprofile_table,array('fid'=>$fid));			foreach ($deldata as $item)			{				$user=$this->modGetAllUsers(array('username'=>$item['username']));				$uid=$user[0]['id'];				if($uid)$this->modDeleteUser($uid);			}			$this->modDeleteRows($this->lang_autogenprofile_forms_table,array('id'=>$fid));			$this->modDeleteRows($this->lang_autogenprofile_table,array('fid'=>$fid));		}		$data=$this->modGetAll($this->lang_autogenprofile_forms_table,array(),'ts',2);		foreach($data as $item => $key)		{			$data[$item]['date']=$date;			$form=$key['form'];			$form=unserialize($form);			$data[$item]['male']=$form['gender']['male'];			$data[$item]['female']=$form['gender']['female'];		}		$this->modSmartyAssign('data',$data);		$this->modSmartyAssign('dateformat',DATE_TIME_FORMAT);		$text=$this->modSmartyFetch("admin/showforms.tpl");	}	if($_GET['showforms']>0)	{		$fid=$_GET['showforms'];		$rpp=$this->config['Users shown per page'];		$page=$_GET['page'];		if(!$page) $page=1;		$begin=($page-1)*$rpp;		$end=$rpp*$page-1;		$start=($page-1)*$rpp;		$data=$this->modGetAll($this->lang_autogenprofile_table,array('fid'=>$fid),"",1,$start,$rpp);		$count=$this->modGetOne($this->lang_autogenprofile_table,array('fid'=>$fid),"count(*)");		$countries=$this->modGetAllCountries();		foreach ($countries as $item)			$country[$item['code']]=$item['name'];		$form=$this->modGetRow($this->lang_autogenprofile_forms_table,array('id'=>$fid));		$date=date("Y-m-d H:i:s",$form['ts']);		$form=unserialize($form['form']);		foreach ($data as $item => $key)		{			$user=$this->modGetAllUsers(array('username'=>$key['username']));			$user=$user[0];			$data[$item]['gender']=$user['gender'];			$data[$item]['country']=$country[$user['country']];			$data[$item]['birth_date']=$user['birth_date'];			$data[$item]['id']=$user['id'];			$data[$item]['fullname']=$user['lastname']." ".$user['firstname'];		}		if($page!=1) $yprev=1; else $yprev=0;		$lastpage=(int)($count/$rpp)+1;		if($count%$rpp==0) $lastpage--;		if($page!=$lastpage) $ynext=1; else $ynext=0;		$this->modSmartyAssign('data',$data);		$this->modSmartyAssign('total',count($data));		$this->modSmartyAssign('date',$date);		$this->modSmartyAssign('start',$start);		$this->modSmartyAssign('previous',"plugin.php?plugin={$this->plugin_class_name}&amp;showforms=$fid&amp;page=".($page-1));		$this->modSmartyAssign('next',"plugin.php?plugin={$this->plugin_class_name}&amp;showforms=$fid&amp;page=".($page+1));		$this->modSmartyAssign('form',$form);		$this->modSmartyAssign('ynext',$ynext);		$this->modSmartyAssign('yprev',$yprev);		$this->modSmartyAssign('dateformat',DATE_FORMAT);		$text=$this->modSmartyFetch("admin/showusers.tpl");	}	if(!$text) {   		$this->modSmartyAssign("country",$countries);   		$text=$this->modSmartyFetch("admin/autogenprofile.tpl");	}   	return $text;   }}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -