当前位置:网站首页>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.
边栏推荐
- 软件快速交付真的需要以安全为代价吗?
- 科大讯飞 AI 学习机暑期新品发布会 AI + 教育深度结合再创产品新高度
- 这个flink cdc可以用在做oracle到mysql的,增量同步吗
- Kubernetes architecture that novices must know
- 华为云AOM 2.0版本发布
- Detailed description of gaussdb (DWS) complex and diverse resource load management methods
- Graduation summary of construction practice camp
- Taro2.* applet configuration sharing wechat circle of friends
- The correct method for Navicat to connect to mysql8.0 (valid for personal testing)
- 状态管理 利用Session限制页面访问 只有通过登录验证SessionLogin.aspx才能访问Session.aspx
猜你喜欢

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

Detailed explanation of MySQL and mvcc and the difference between RC and RR for snapshot reading

JD alliance API - universal chain transfer interface - Jingpin library interface - Interface Customization

一文2500字手把手教你使用jmeter进行分布式压力测试【保姆级教程】

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

ASP利用Panel实现简易注册页面

5分钟快速上手 pytest 测试框架

This time, I will talk about technology and life

What are the software testing methods and technical knowledge points?

华为云AOM 2.0版本发布
随机推荐
Divide the bonus pool of 10million + million yuan, and empower developers in the 2022 shengteng AI innovation competition
R language plot visualization: plot to visualize the normalized histograms of multiple data sets, set different histograms to use different bin sizes, and add edge axis whisker graph rugs at the botto
Huawei cloud AOM version 2.0 release
新手必须知道的 Kubernetes 架构
[crossbeam series] 5 crossbeam util and crossbeam queue: some practical gadgets
短视频平台搭建,淡入淡出 支持左滑右滑轮播图
The correct method for Navicat to connect to mysql8.0 (valid for personal testing)
Does rapid software delivery really need to be at the cost of security?
便携式4K音视频会议终端一体机带8倍数字变焦
细说GaussDB(DWS)复杂多样的资源负载管理手段
为什么要同时重写hashcode和equals方法之简单理解
Reading notes on how to connect the network - LAN on the server side (4)
软件测试方法和技术知识点有哪些?
这次跟大家聊聊技术,也聊聊人生
The child component of a single data flow modifies the value of the parent component
Reading notes on how to connect the network - Web server request and response (V)
Grep工具
科大讯飞 AI 学习机暑期新品发布会 AI + 教育深度结合再创产品新高度
Final training simple address book c language
Datakit acts as an API server for local data acquisition