当前位置:网站首页>Code sharing for making and developing small programs on the dating platform
Code sharing for making and developing small programs on the dating platform
2022-06-29 22:20:00 【51CTO】
This is a relatively common case analysis of the code for making and developing small programs on the dating platform at present , Many functions can be used for reference , For example, focus on functions , Member payment function , Permission setting and other functions .
Home page


class DiaryController extends CommonController
{
private $weather = array(" Please select "," a sunny day "," overcast "," cloudy "," rain "," thunder shower "," snowy day ");
private $feel = array(' Please select ',' Happy ',' surprised ',' Crazy ',' sad ',' Move your heart ',' anger ',' Giggle ',' doubt ',' sigh ',' depressed ',' depressed ',' commonly ');
private $power = array(1=>' Open ',2=>' Just see for yourself ');
// Personal center browsing diary
public function index(){
$mod = D("Diary");
$total = $mod->scope('read')->where("userid=".session('user')['id'])->count();
$page = new \Think\Page($total,15);
$diaryList = $mod->scope('read')->where("userid=".session('user')['id'])->limit($page->firstRow,$page->listRows)->select();
foreach($diaryList as &$diary){
$diary['catid'] = M("diary_category")->field("catname")->where("id=".$diary['catid'])->find();
$diary['comment'] = M('diary_comment')->where('diaryid='.$diary['id'])->count();
}
// dump($diaryList);
$page->setConfig('prev', " The previous page ");
$page->setConfig('next', " The next page ");
$show = $page->show();
$this->assign("show",$show);
$this->assign("diaryList",$diaryList);
$this->display("index");
}
// Get and add journal template
public function add(){
$this->assign("cat",M("Diary_category")->select());
$this->display("add");
}
// Execute add Journal
public function insert(){
$mod = D("Diary");
$_POST['userid'] = session('user')['id'];
if(!$mod->create($_POST)){
$this->error($mod->getError());
}
if($mod->add()){
// Add points
$userPoints = new \Home\Controller\UserPointsController();
$userPoints->insert('diary');
echo "<script>window.parent.doAdd('true');</script>";
}else{
echo "<script>window.parent.doAdd('false');</script>";
}
exit();
}
// Execute journal deletion
public function del(){
$mod = D("Diary");
$res = $mod->where("id=".$_POST['id'])->delete();
if($res){
echo json_encode("true");
}else{
echo json_encode("false");
}
}
// Load and modify journal template
public function edit(){
$mod = D("Diary");
$info = $mod->where("userid=".session('user')['id'])->find($_GET['id']);
$cat = M("Diary_category")->select();
$this->assign("info",$info);
$this->assign("cat",$cat);
$this->assign("weather",$this->weather);
$this->assign("feel",$this->feel);
$this->assign("power",$this->power);
$this->display("edit");
}
// Execute modification Journal
public function update(){
$mod = D("Diary");
if(!$mod->create()){
$this->error($mod->getError());
}
if($mod->save()){
echo "<script>window.parent.doEdit('true');</script>";
// $this->success(" Modification successful !",U("Diary/index"));
}else{
echo "<script>window.parent.doEdit('false');</script>";
// $this->error(" Modification successful !");
}
exit();
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
- 72.
- 73.
- 74.
- 75.
- 76.
- 77.
- 78.
- 79.
- 80.
- 81.
- 82.
- 83.
- 84.
- 85.
- 86.
- 87.
- 88.
- 89.
- 90.
- 91.
- 92.
- 93.
- 94.
- 95.
- 96.
permissions
function C($name=null, $value=null,$default=null) {
static $_config = array();
// Get all if no parameters
if (empty($name)) {
return $_config;
}
// Priority is given to setting acquisition or assignment
if (is_string($name)) {
if (!strpos($name, '.')) {
$name = strtolower($name);
if (is_null($value))
return isset($_config[$name]) ? $_config[$name] : $default;
$_config[$name] = $value;
return;
}
// Two dimensional array setting and getting support
$name = explode('.', $name);
$name[0] = strtolower($name[0]);
if (is_null($value))
return isset($_config[$name[0]][$name[1]]) ? $_config[$name[0]][$name[1]] : $default;
$_config[$name[0]][$name[1]] = $value;
return;
}
// Batch settings
if (is_array($name)){
$_config = array_merge($_config, array_change_key_case($name));
return;
}
return null; // Avoid illegal parameters
}
/**
* Throw exception handling
* @param string $msg Exception message
* @param integer $code Exception code The default is 0
* @return void
*/
function E($msg, $code=0) {
throw new Think\Exception($msg, $code);
}
/**
* Record and count time ( Microsecond ) And memory usage
* Usage method :
* <code>
* G('begin'); // Record start flag bit
* // ... Section run code
* G('end'); // Record end tag bit
* echo G('begin','end',6); // Count interval running time Accurate to the decimal 6 position
* echo G('begin','end','m'); // Statistics of interval memory usage
* If end The tag bit is not defined , Will automatically take the current as the marker bit
* The statistics of memory usage need MEMORY_LIMIT_ON The constant is true It works
* </code>
* @param string $start The start tag
* @param string $end End tag
* @param integer|string $dec Decimal places or m
* @return mixed
*/
function G($start,$end='',$dec=4) {
static $_info = array();
static $_mem = array();
if(is_float($end)) { // Recording time
$_info[$start] = $end;
}elseif(!empty($end)){ // Count time and memory usage
if(!isset($_info[$end])) $_info[$end] = microtime(TRUE);
if(MEMORY_LIMIT_ON && $dec=='m'){
if(!isset($_mem[$end])) $_mem[$end] = memory_get_usage();
return number_format(($_mem[$end]-$_mem[$start])/1024);
}else{
return number_format(($_info[$end]-$_info[$start]),$dec);
}
}else{ // Record time and memory usage
$_info[$start] = microtime(TRUE);
if(MEMORY_LIMIT_ON) $_mem[$start] = memory_get_usage();
}
}
/**
* Get and set language definitions ( Case insensitive )
* @param string|array $name Language variables
* @param string $value Language value
* @return mixed
*/
function L($name=null, $value=null) {
static $_lang = array();
// Null parameter returns all definitions
if (empty($name))
return $_lang;
// Judge language acquisition ( Or set )
// If it does not exist , Returns all uppercase directly $name
if (is_string($name)) {
$name = strtoupper($name);
if (is_null($value))
return isset($_lang[$name]) ? $_lang[$name] : $name;
$_lang[$name] = $value; // Language definition
return;
}
// Batch definition
if (is_array($name))
$_lang = array_merge($_lang, array_change_key_case($name, CASE_UPPER));
return;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
- 72.
- 73.
- 74.
- 75.
- 76.
- 77.
- 78.
- 79.
- 80.
- 81.
- 82.
- 83.
- 84.
- 85.
- 86.
- 87.
- 88.
- 89.
- 90.
- 91.
- 92.
- 93.
- 94.
- 95.
- 96.
- 97.
- 98.
- 99.
- 100.
- 101.
- 102.
- 103.
边栏推荐
- 数论-整除分块
- 这个flink cdc可以用在做oracle到mysql的,增量同步吗
- 细说GaussDB(DWS)复杂多样的资源负载管理手段
- How to make good use of data science?
- Analyze apache SH script
- 【无工具搭建PHP8+oracle11g+Windows环境】内网/无网络/Win10/PHP连接oracle数据库实例
- Spark cluster installation
- As a developer, you need to know about the codeless development platform IVX
- Houdini graphic notes: VAT (3.0) import ue4/5 setup wizard [official document translation]
- 客户端可以连接远程mysql
猜你喜欢

便携式4K音视频会议终端一体机带8倍数字变焦

Simple understanding of why to rewrite hashcode and equals methods at the same time

STM32 and gd32 notes

Dynamics 365online lookup lookup field multiple selection

cout 不明确问题

华为7年经验的软件测试总监,给所有想转行学软件测试的同学的几个建议

In the shop project, implement a menu (add, delete, modify and query)

ASP dynamically creates table table
![[multithreading] how to implement timer by yourself](/img/a9/dd9489c7a0028dd9d3a6dae9a71deb.png)
[multithreading] how to implement timer by yourself
![The inadvertently discovered [tidb cache table] can solve the read / write hotspot problem](/img/96/b1595b9d2b008b353765caa68fdd3c.png)
The inadvertently discovered [tidb cache table] can solve the read / write hotspot problem
随机推荐
Summer Challenge harmonyos ark development framework arkui streamer button effect
STM32 and gd32 notes
华为7年经验的软件测试总监,给所有想转行学软件测试的同学的几个建议
VS2013如何让编写的程序在其它电脑上面也能运行
Final training simple address book c language
R language plot visualization: plot visualization box graph and several box plots of multiple classification variables
Is it reliable to open an account on the compass with your mobile phone? Is there any hidden danger in this way
Common PostgreSQL data operation notes: time
Cloud native database query optimization - statistics and row count estimation
[multithreading] how to implement timer by yourself
夏日彩虹来下饭
论文浅尝 | KR-GCN: 知识感知推理的可解释推荐系统
jfinal中如何使用过滤器监控Druid监听SQL执行?
一键式文件共享软件Jirafeau
The child component of a single data flow modifies the value of the parent component
The soft youth under the blessing of devcloud makes education "smart" in the cloud
[force deduction 10 days SQL introduction] day7+8 calculation function
Shangsilicon Valley real-time data warehouse project (Alibaba cloud real-time data warehouse)
期末实训 简单通讯录 c语言
阶段性总结与思考