/** * 推送初始化 * * */ private function pushinit() { echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; PushQueue::where('cus_id', $this->cus_id)->delete(); PushQueue::where('pushtime', '<', time() - 60)->delete(); $maxpushid = PushQueue::max('id'); $pushqueuecount = PushQueue::where('push', 1)->count(); $pushqueue = new PushQueue(); $pushqueue->id = $maxpushid ? $maxpushid + 1 : 1; $pushqueue->pushtime = time(); $pushqueue->cus_id = $this->cus_id; if ($pushqueuecount < $this->allow_push_count) { $pushqueue->push = 1; $pushqueue->save(); } else { $pushqueue->push = 0; $pushqueue->save(); while (1) { sleep(3); echo '<div class="prompt">繁忙等待.......</div><script type="text/javascript">refresh("繁忙等待.......");</script>'; ob_flush(); flush(); $push_table = PushQueue::where('cus_id', $this->cus_id)->first(); if ($push_table->push == 1) { break; } else { $pushqueuecount = PushQueue::where('push', 1)->count(); if ($pushqueuecount < $this->allow_push_count) { PushQueue::where('cus_id', $this->cus_id)->update(['push' => 1]); break; } } $this->clearpushqueue(); } } if ($this->quickbarpush && !$this->mobilepush) { $m_template = new PrintController('online', 'mobile'); $config_str = file_get_contents(public_path('/templates/' . $m_template->themename) . '/config.ini'); $search = "/QuickBar=(.*)/i"; $result = preg_match($search, $config_str, $config_arr); if ($result) { if (trim($config_arr[1]) == 'custom') { $this->mobilepush = 1; $this->mobilehomepagepush = 0; } } } if ($this->pcpush) { $pc_template = new PrintController('online', 'pc'); $this->pushpc['result'] = $pc_template->publicdata(); $this->pushpc['navs'] = $pc_template->publicnavs(); $dir = app_path('views/templates/' . $pc_template->themename); if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) != FALSE) { if (strpos($file, '.html')) { $this->pushpc['repleace'][$file] = file_get_contents($dir . '/' . $file); $this->pushpc['pattern'][$file] = "#{include((\\s)+)?file=[\\',\"].\\/" . $file . "[\\',\"]}#"; if ($file == '_footer.html') { $this->pushpc['repleace'][$file] = preg_replace('/\\$navs/', '\\$footer_navs', $this->pushpc['repleace'][$file]); } } } } } $dir = public_path('templates/' . $pc_template->themename . '/json/'); if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) != FALSE) { if (strpos($file, '.json')) { $this->pushpc['pagedata'][$file] = file_get_contents($dir . '/' . $file); } } } } } if ($this->mobilepush || $this->mobilehomepagepush) { $m_template = new PrintController('online', 'mobile'); $this->pushmobile['result'] = $m_template->publicdata(); $this->pushmobile['navs'] = $m_template->publicnavs(); $dir = app_path('views/templates/' . $m_template->themename); if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) != FALSE) { if (strpos($file, '.html')) { $this->pushmobile['repleace'][$file] = file_get_contents($dir . '/' . $file); $this->pushmobile['pattern'][$file] = "#{include((\\s)+)?file=[\\',\"].\\/" . $file . "[\\',\"]}#"; } } } } $dir = public_path('templates/' . $m_template->themename . '/json/'); if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) != FALSE) { if (strpos($file, '.json')) { $this->pushmobile['pagedata'][$file] = file_get_contents($dir . '/' . $file); } } } } } }