where('id', $userrow['upid']); $uprow = $db->getone($csql); if (!is_array($uprow)) return; self::usercashoe($db, 20, $uprow['id'], $money * $bonusset[0]['percent'], $bonusset[0]['name']); if ($uprow['upid'] <= 0) return; if (!isset($bonusset[1])) return; $csql = new \ciy\sql('ap_user'); $csql->where('id', $uprow['upid']); $up2row = $db->getone($csql); if (!is_array($up2row)) return; self::usercashoe($db, 21, $up2row['id'], $money * $bonusset[1]['percent'], $bonusset[1]['name']); if ($up2row['upid'] <= 0) return; if (!isset($bonusset[2])) return; $csql = new \ciy\sql('ap_user'); $csql->where('id', $up2row['upid']); $up3row = $db->getone($csql); if (!is_array($up3row)) return; self::usercashoe($db, 22, $up3row['id'], $money * $bonusset[2]['percent'], $bonusset[2]['name']); //最高三级代理 } static function usercashie($db, $type, $userid, $money, $name = '') { $updata = array(); if ($money > 0) $updata['mymoney'] = array('mymoney+' . $money); else $updata['mymoney'] = array('mymoney' . $money); $csql = new \ciy\sql('ap_user'); $csql->where('id', $userid); if ($db->update($csql, $updata) === false) throw new \Exception('账户余额更新失败:' . $db->error); //直接打款 $updata = array(); $updata['cashtype'] = $type; $updata['iemoney'] = $money; $updata['vuser'] = $userid; $updata['name'] = $name; $updata['addtimes'] = tostamp(); $csql = new \ciy\sql('ap_cash_ie'); if ($db->insert($csql, $updata) === false) throw new \Exception('新建消费收支失败:' . $db->error); } static function usercashoe($db, $type, $userid, $money, $name = '') { $updata = array(); if ($money > 0) $updata['mycashmoney'] = array('mycashmoney+' . $money); else $updata['mycashmoney'] = array('mycashmoney' . $money); $csql = new \ciy\sql('ap_user'); $csql->where('id', $userid); if ($db->update($csql, $updata) === false) throw new \Exception('账户余额更新失败:' . $db->error); //直接打款 $updata = array(); $updata['cashtype'] = $type; $updata['oemoney'] = $money; $updata['vuser'] = $userid; $updata['name'] = $name; $updata['addtimes'] = tostamp(); $csql = new \ciy\sql('ap_cash_oe'); if ($db->insert($csql, $updata) === false) throw new \Exception('新建佣金收支失败:' . $db->error); } static function www_showpage($count, $pageno, $pagecount, $pageurl, $pagecb) { if ($count <= 0) { // 1...3,4,5,6,7,8 $isend = (-$count < $pagecount); //if($pageno < 20) $isend = false; $epage = $pageno + 2; $spage = $pageno - 6; if ($isend) $epage = $pageno; if ($spage < 1) $spage = 1; echo '上页'; if ($spage > 1) echo '1'; if ($spage > 2) echo '...'; for ($i = $spage; $i <= $epage; $i++) echo '' . $i . ''; echo '下页'; } else { //1...3,4,5,6,7...n $epage = $pageno + 6; $spage = $pageno - 2; $pagemax = ceil($count / $pagecount); if ($spage < 1) $spage = 1; if ($epage > $pagemax) $epage = $pagemax; echo '上页'; if ($spage > 1) echo '1'; if ($spage > 2) echo '...'; for ($i = $spage; $i <= $epage; $i++) echo '' . $i . ''; if ($epage < $pagemax - 1) echo '...'; if ($epage < $pagemax) echo '' . $pagemax . ''; echo '= $pagemax ? ' class="disabled"' : " href=\"" . $pageurl . $pagecb($pageno + 1) . "\"") . '>下页'; } } static function www_convertseoword($seowords, $content, $keystr = '') { $seo = array(); $max = rand(2, 5); shuffle($seowords); foreach ($seowords as $row) { if ($row['rank'] > rand(0, 100)) $seo[$row['name']] = $row['url']; } $repcnt = 0; foreach ($seo as $key => $val) { $ind = strpos($content, $key); if ($ind === false) continue; $tmp = substr($content, 0, $ind); $inda = strrpos($tmp, '', $inda); if ($indb === false) //包含 continue; } $content = substr_replace($content, '' . $key . '', $ind, strlen($key)); $repcnt++; if ($repcnt >= $max) break; } if (!empty($keystr)) { $keystr = str_replace(',', ',', $keystr); $keystr = str_replace(';', ',', $keystr); $keystr = str_replace(';', ',', $keystr); $keys = explode(',', $keystr); foreach ($keys as $key) { if (empty($key)) continue; $ind = strpos($content, $key); if ($ind === false) continue; $tmp = substr($content, 0, $ind); $inda = strrpos($tmp, ''); if ($inda !== false) { $indb = strpos($tmp, '', $inda); if ($indb === false) //包含 continue; } $content = substr_replace($content, '' . $key . '', $ind, strlen($key)); } } return $content; } }