<?php //header('Content-Type: text/xml; charset=UTF-8'); ?> <?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; ?> <rss version="0.92"> <?php $user = idfromnick($_GET["user"]); if ($_GET["user"]) { $sql2 = "SELECT status_id,user_id,status, DATE_FORMAT(date_set,'%M %e, %Y @ %l:%i:%s %p') AS ds FROM mt_statuses WHERE user_id='" . avoid_injection($user) . "' ORDER BY date_set DESC limit 15"; } else { $sql2 = "SELECT status_id,user_id,status, DATE_FORMAT(date_set,'%M %e, %Y @ %l:%i:%s %p') AS ds FROM mt_statuses ORDER BY date_set DESC limit 15"; } $resultado2 = mysql_query($sql2, $connuni); if ($_GET["user"]) { echo " <channel>\n <title>miniTwitter / " . name_hide($user) . "</title>\n <link>" . $pth . "index.php?user="******"</link>\n <description>miniTwitter updates from " . name_hide($user) . "</description>\n <language>en-us</language>\n <ttl>15</ttl>"; } else { echo " <channel>\n <title>miniTwitter / Public Timeline</title>\n <link>" . $pth . "index.php</link>\n <description>miniTwitter updates from Public Timeline</description>\n <language>en-us</language>\n <ttl>15</ttl>"; } while ($row2 = mysql_fetch_array($resultado2)) { echo "<item>\n <title>" . name_hide($row2["user_id"]) . ": " . $row2["status"] . "</title>\n <description>" . name_hide($row2["user_id"]) . ": " . $row2["status"] . "</description>\n <pubDate>" . $row2["ds"] . "</pubDate>\n </item>"; } echo "</channel>"; echo "</rss>"; ?> <!-- guid>http://twitter.com/crishnakh/statuses/1167074080</guid> <link>http://twitter.com/crishnakh/statuses/1167074080</link -->
</form> </small> </div> <!-- fin de formulario--> <div style="clear: both;"></div> <?php $following = explode(",", $row["follow"]); $i = 0; $p = 0; while ($following[$i] == true) { //Mis seguidos $queryw = "SELECT id_usr,nick,correo, gravatar FROM mt_users Where id_usr = '******' LIMIT 1"; $resultw = mysql_query($queryw, $connuni) or die(mysql_error() . ': ' . $queryw); while ($ruw = mysql_fetch_assoc($resultw)) { $array_names_minitwitter = name_hide($following[$i]); $compare_w_t .= $array_names_minitwitter . "|"; if ($p <= 11) { if ($ruw["gravatar"] == "yes") { echo "<a href=\"index.php?user="******"id_usr"] . "\" title=\"" . $ruw["nick"] . "\" onmouseover=\"Tip('"; echo "<b>" . $ruw["nick"] . ": </b>"; echo last($ruw["id_usr"]); echo "', BALLOON, true, ABOVE, true, OFFSETX, -17, PADDING, 8)\" onmouseout=\"UnTip()\">"; echo "<img width=\"48\" border=\"1\" align=\"left\" style=\"margin: 3px;\" src=\""; $grav_correow = $ruw["correo"]; echo getGravatarUrl($grav_correow, $defImg, "80", "G"); echo "\" alt=\"Gravatar\"></a>"; } else { if (file_exists("./avatar/" . $following[$i] . ".jpg") == true) { echo "<a title=\""; name($following[$i]);
function check_project(){ $time = time(); $model = M('projects'); $pgmodel = M('project_goods'); $rmodel = M('record'); $mwmodel = M('member_wallet'); $mwlmodel = M('member_wallet_log'); $omodel = M('order'); $odmodel = M('order_detail'); $logs_model = M('logs'); $data['status'] = 1; $data['endtime'] = array('elt',$time); $list = $model->where($data)->select(); //dump($list);exit; foreach($list as $key=>$val){ unset($pg_data); $model->startTrans();//启用事务 $pg_data['project_id'] = $val['id']; $count = $pgmodel->where($pg_data)->count(); $pg_data['status'] = 0; $buy_count = $pgmodel->where($pg_data)->count(); //echo $buy_count.'/'.$count; if($buy_count/$count>0.5){ //众筹成功 //修改状态 $data['id'] = $val['id']; $sdata['status'] = 2; $result = $model->where($data)->save($sdata); if(!$result){ $model->rollback(); continue; } //分成处理 $get_pay = $val['price']*0.1; $mw_data['member_id'] = $val['member_id']; $result = $mwmodel->where($mw_data)->setInc('balance',$get_pay); if(!$result){ $model->rollback(); continue; } //记录至账户 $mw_data['member_id'] = $val['member_id']; $mw_vo = $mwmodel->where($mw_data)->find(); $pay_order_id = build_order_no($val['member_id']); $rdata['member_id'] = $val['member_id']; $rdata['member_name'] = $val['member_name']; $rdata['realname'] = $val['realname']; $rdata['payment_mode'] = '1'; $rdata['payment_company'] = C('company_name'); $rdata['pay_order_id'] = $pay_order_id; $rdata['order_id'] = ''; $rdata['pay_type'] = 5; $rdata['pay'] = $get_pay; $rdata['balance'] = $mw_vo['balance']; $rdata['content'] = $val['name'].'众筹成功,返利¥'.$get_pay; $rdata['create_time'] = $time; $rdata['pay_time'] = $time; $rdata['status'] = 1; $result = $rmodel->add($rdata); //echo $rmodel->getlastsql(); if(!$result){ $model->rollback(); continue; } //订单信息修改 //关联已支付订单 $odata['type'] = 4; //$odata['source'] = 'Projects'; $odata['sourceid'] = $val['id']; $odata['status'] = 1; $osdata['pay_order_id'] = $pay_order_id; $result = $omodel->where($odata)->save($osdata); //关闭未支付订单 $odata['status'] = 0; $osdata2['status'] = -1; if($result)$result = $omodel->where($odata)->save($osdata2); //记录 $logs_data['msg'] = '<span>'.name_hide($vo['member_name']).'</span> 众筹成功,获得返利'.$get_pay; $logs_data['create_time'] = time(); $logs_model->add($logs_data); //事务提交 if($result){ $model->commit(); }else{ $model->rollback(); } echo 112233; }else{ //众筹失败,修改状态 $data['id'] = $val['id']; $sdata['status'] = -1; $result = $model->where($data)->save($sdata); if($buy_count==0){ continue; } if(!$result){ $model->rollback(); continue; } //退款 //支付成功订单 $odata['source'] = 'Projects'; $odata['sourceid'] = $val['id']; $odata['status'] = 1; $olist = $omodel->where($odata)->select(); foreach($olist as $oval){ //订单信息修改 $pay_order_id = build_order_no($oval['member_id']); $owdata['id'] = $oval['id']; $osdata['status'] = -1; $osdata['pay_order_id'] = $pay_order_id; $osdata['remark'] = $val['name'].'众筹失败退款'; $omodel->where($owdata)->save($osdata); //详细订单状态修改 $od_data['oid'] = $oval['id']; $od_sdata['trade_status'] = 0; $od_sdata['remark'] = '众筹失败'; $result = $odmodel->where($od_data)->save($od_sdata); //退款至账户 $mw_data['member_id'] = $oval['member_id']; $mw_vo = $mwmodel->where($mw_data)->find(); if($result)$result = $mwmodel->where($mw_data)->setInc('balance',$oval['total_price']); if(!$result){ $model->rollback(); continue; } //退款记录 $rdata['member_id'] = $oval['member_id']; $rdata['member_name'] = $oval['member_name']; $rdata['realname'] = $oval['realname']; $rdata['payment_mode'] = '1'; $rdata['payment_company'] = C('company_name'); $rdata['pay_order_id'] = $pay_order_id; $rdata['order_id'] = $oval['order_id']; $rdata['pay_type'] = 5; $rdata['pay'] = $oval['total_price']; $rdata['balance'] = $mw_vo['balance']+$oval['total_price']; $rdata['content'] = $val['name'].'众筹失败退款¥'.$oval['total_price']; $rdata['create_time'] = $time; $rdata['pay_time'] = $time; $rdata['status'] = 1; $result = $rmodel->add($rdata); if(!$result){ $model->rollback(); continue; } } //事务提交 if($result){ //echo 11223; $model->commit(); }else{ $model->rollback(); } } } }
public function create_order_to_pay(){ if(!$this->user){ $this->assign('jumpUrl',__APP__.'/Public/login/from_url/'.urlencode($_SERVER['HTTP_REFERER'])); $this->error('请先登录!'); } if(!$_POST['ids'] || !$_POST['nums'] || !$_POST['address_id']){ $this->error('出错!'); } $logs_model = M('Logs'); $p_model = M('Projects'); $p_data['id'] = $_POST['id']; $vo = $p_model->where($p_data)->find(); $admodel = M('MemberAddress'); $ad_data['id'] = $_POST['address_id']; $address = $admodel->where($ad_data)->find(); $model = M('project_goods'); $data['id'] = array('in',$_POST['ids']); $list = $model->field('id,lit_pic,project_id,project_name,product_id,goods_id,product_name,subtitle,price,status')->where($data)->select(); $totleprice = 0; $goods_name = '购买艺术品:'; //dump($list);exit; foreach($list as $key=>$val){ $member_id = $val['member_id']; $id = $val['id']; $k = array_search($id,$_POST['ids']); if($val['status']==0){ $this->error($val['product_name'].'已被购买'); } $num = 1; if($key==0){ $goods_name .= $val['product_name']; }else{ $goods_name .= ','.$val['product_name']; } $totleprice += $num*$val['price']; //记录购买 $logs_data['msg'] = '<span>'.name_hide($this->user['username']).'</span>下单购买众筹作品'.$val['product_name']; $logs_data['create_time'] = time(); $logs_model->add($logs_data); } //生成订单 $model = M('Order'); $gmodel = M('Goods'); $mmodel = M('Member'); $odmodel = M('OrderDetail'); $time = time(); $model->startTrans();//启用事务 $out_trade_no = ''; $add_order['uw_id'] = $vo['member_id']; $add_order['type'] = 4; $add_order['title'] = $goods_name; $add_order['goods'] = serialize($list); //订单号 //$bh = str_pad($mid.time(),15,0,STR_PAD_LEFT); //$add_order['order_id'] = 'c'.$bh; $add_order['order_id'] = build_order_no($this->user['id']); if($_POST['paytype'] == 1){ $add_order['payment_mode'] = '1'; $add_order['payment_company'] = '支付宝'; }else if($_POST['paytype'] == 0){ $add_order['payment_mode'] = '1'; $add_order['payment_company'] = C('company_name'); } $add_order['total_price'] = $totleprice; $add_order['bond'] = 0; $add_order['source'] = 'Projects'; $add_order['sourceid'] = $_POST['id']; $add_order['total_num'] = count($list); $add_order['member_id'] = $this->user['id']; $add_order['member_name'] = $this->user['username']; $add_order['realname'] = $this->user['realname']; $add_order['user_id'] = 0; $add_order['address_id'] = $_POST['address_id']; $add_order['recipient'] = $address['name']; $add_order['address'] = $address['address']; $add_order['postcode'] = $address['postcode']; $add_order['tel'] = $address['mobile']; $add_order['remark'] = $_POST['remark']; $add_order['ip'] = $_SERVER['REMOTE_ADDR']; $add_order['create_time'] = $time; $add_order['order_time'] = $time+86400*$this->configs['order_expired']; $add_order['remark'] = $_POST['remark'.$mid] ? $_POST['remark'.$mid] : ''; $oid = $model->add($add_order); //提交给支付宝的订单 $out_trade_no .= $oid.','; if($oid){ //订单产品详情 foreach($list as $goods){ $od_data['member_id'] = $this->user['id']; $od_data['user_id'] = 0; $od_data['oid'] = $oid; $od_data['source'] = 'Project_goods'; $gid = $goods['id']; $od_data['sourceid'] = $goods['id']; $od_data['product_id'] = $goods['product_id']; $od_data['product_name'] = $goods['product_name']; //$od_data['product_name'] = $goods['product_name']; $share_id = $_SESSION['share_id']; if($share_id){ if($share_id==$this->user['id']){ $share_id = 0;//不能自己分享给自己 } }else{ $share_id = 0; } $od_data['share_id'] = $share_id; $od_data['lit_pic'] = $goods['lit_pic']; $od_data['price'] = $goods['price']; $od_data['num'] = 1; $od_data['is_buyback'] = 1; $od_data['is_dm'] = 1; $md_id = $odmodel->add($od_data); //echo $odmodel->getlastsql();exit; //减去库存 //$result = $gmodel->where('id='.$gid)->setDec('inventory',$goods['num']); if(!$md_id){ $model->rollback(); $this->error('订单生成失败!'); exit; } } }else{ $model->rollback(); $this->error('订单生成失败!'); exit; } $out_trade_no = substr($out_trade_no,0,-1); $model->commit(); if($_POST['paytype'] == 1){ //支付宝 require_once("./Alipay/alipay.config.php"); require_once("./Alipay/lib/alipay_submit.class.php"); require_once("./Alipay/Alipay.class.php"); //支付信息 $alipaySubmit = new AlipaySubmit($alipay_config); $payment_type = "1"; $exter_invoke_ip = $_SERVER['REMOTE_ADDR']; //$out_trade_no = $vo['id']; $subject = $content = '众筹购买支付!'; $total_fee = $totleprice; $total_fee = 0.01; $parameter = array( "service" => "create_direct_pay_by_user", "partner" => trim($alipay_config['partner']), "payment_type" => $payment_type, "notify_url" => $notify_url.'/ali_notify_project', "return_url" => $return_url, "seller_email" => $seller_email, "out_trade_no" => $out_trade_no, "subject" => $subject, "total_fee" => $total_fee, "body" => $content, //"show_url" => $show_url, //"anti_phishing_key" => $anti_phishing_key, "exter_invoke_ip" => $exter_invoke_ip, "_input_charset" => trim(strtolower($alipay_config['input_charset'])), "extra_common_param"=>'pay_type|2' //参数 ); $html_text = $alipaySubmit->buildRequestForm($parameter,"post", "确认"); echo $html_text; }else if($_POST['paytype'] == 0){ redirect(__APP__.'/Projects/payment/ids/'.$out_trade_no); } echo '出错!';exit; }
function loop($id_usr, $type, $userloop, $follow, $tabnumber, $id_group) { include './inc/config.php'; $connuni = @mysql_connect($host, $user, $pass); @mysql_select_db($db, $connuni); echo "<!-- START TAB " . $tabnumber . " -->"; echo "<div id=\"country" . $tabnumber . "\" class=\"tabcontent\">\n\t<div id=\"statuses\">"; //Choose type! if ($type == "Public timeline") { $sql0 = "SELECT status_id,user_id,status, DATE_FORMAT(date_set,'%M %e, %Y @ %l:%i:%s %p') AS ds FROM mt_statuses ORDER BY date_set DESC"; } elseif ($type == "Following") { $long = strlen($follow); //echo $long; $long_m = $long - 1; //echo $long_m; $follow_m = substr($follow, -$long, $long_m); //echo $follow_m; $sql0 = "SELECT status_id,user_id,status, DATE_FORMAT(date_set,'%M %e, %Y @ %l:%i:%s %p') AS ds FROM mt_statuses WHERE user_id IN (" . avoid_injection($follow_m) . ") ORDER BY date_set DESC"; //This is to show user updates with following option to show OR user_id='$id_usr' } elseif ($type == "User") { $usern = name_hide($userloop); $sql0 = "SELECT status_id,user_id,status, DATE_FORMAT(date_set,'%M %e, %Y @ %l:%i:%s %p') AS ds FROM mt_statuses WHERE user_id='" . avoid_injection($userloop) . "' OR status LIKE '%@" . avoid_injection($usern) . "%' ORDER BY date_set DESC"; } /*For all*/ /*get page*/ $registros = 15; $pagina = $_GET["pagina"]; if (!$pagina) { $inicio = 0; $pagina = 1; } else { $inicio = ($pagina - 1) * $registros; } /*end get page*/ $r0 = mysql_query($sql0, $connuni) or die('La consulta falló:' . mysql_error($enlace)); $total_registros = mysql_num_rows($r0); if ($type == "User") { $usern = name_hide($userloop); $query = "SELECT status_id,user_id,status, DATE_FORMAT(date_set,'%M %e, %Y @ %l:%i:%s %p') AS ds FROM mt_statuses WHERE user_id='" . avoid_injection($userloop) . "' OR status LIKE '%@" . avoid_injection($usern) . "%' ORDER BY date_set DESC LIMIT {$inicio}, {$registros}"; } elseif ($type == "Following") { $long = strlen($follow); //echo $long; $long_m = $long - 1; //echo $long_m; $follow_m = substr($follow, -$long, $long_m); //echo $follow_m; $query = "SELECT status_id,user_id,status, DATE_FORMAT(date_set,'%M %e, %Y @ %l:%i:%s %p') AS ds FROM mt_statuses WHERE user_id IN (" . avoid_injection($follow_m) . ") ORDER BY date_set DESC LIMIT {$inicio}, {$registros}"; //This is to show user updates with following option to show OR user_id='$id_usr' } elseif ($type == "Public timeline") { $query = "SELECT status_id,user_id,status, DATE_FORMAT(date_set,'%M %e, %Y @ %l:%i:%s %p') AS ds FROM mt_statuses ORDER BY date_set DESC LIMIT {$inicio}, {$registros}"; } $result = mysql_query($query, $connuni) or die(mysql_error() . ': ' . $query); $total_paginas = ceil($total_registros / $registros); //This table was for pagination but I changed it for another one without js //Page links an title echo "<table width=\"445\"><thead>\n\t\n\t<tr>\n\t<td>"; if ($id_group != "") { echo "<form style=\"float: right;margin-top: 3px; margin-right: 3px; position: absolute;\" action=\"\" name=\"delete_group\" method=\"post\">"; echo "<input type=\"image\" src=\"" . $pth . "inc/icons/gr_dl.png\" name=\"delete_group_id\" value=\"" . $id_group . "\">"; echo "</form>"; $des = "SELECT group_desc, members FROM mt_group WHERE id_group='" . avoid_injection($id_group) . "'"; $resultdes = mysql_query($des, $connuni) or die(mysql_error() . ': ' . $query); while ($row = mysql_fetch_assoc($resultdes)) { echo "<div style=\"margin-left: 25px;\">"; echo $row["group_desc"]; $members_message = explode(",", $row["members"]); $b = 0; while ($members_message[$b]) { $namem = name_hide($members_message[$b]); $group_replie .= "@" . $namem . " "; $b = $b + 1; } echo " <a href=\"#\" style=\"border: 0px;float: right;\" onclick=\"insertAtCaret('status','" . $group_replie . "');\"><img border=0 src=\"./inc/icons/group_go.png\"></a>"; echo "</div>"; } } echo "</td></tr></thead><tbody>"; //loop while ($row = mysql_fetch_assoc($result)) { echo '<tr><td> <div class="status-box"> <div style="float: left; width: 430px;">'; echo "<form style=\"float: right;\" action=\"\" method=\"post\">"; if ($id_usr == $row['user_id']) { echo "<input type=\"image\" src=\"" . $pth . "inc/icons/dl.png\" name=\"status_id\" value=\"" . $row["status_id"] . "\">"; } echo "</form>"; echo "<form style=\"float: right;\" action=\"\" method=\"post\">"; if ($id_usr != $row['user_id']) { if (strstr($follow, $row['user_id']) == true) { } else { echo "<input type=\"image\" src=\"" . $pth . "inc/icons/+.png\" name=\"status_id_mas\" value=\"" . $row["user_id"] . "\">"; } } echo "</form>"; echo "<form style=\"float: right; "; if (strstr($follow, $row['user_id']) == true) { } else { echo "margin-top: 12px; margin-right: -9px;"; } echo "\" action=\"\" method=\"post\">"; if ($id_usr != $row['user_id']) { if (strstr($follow, $row['user_id']) == true) { echo "<input type=\"image\" src=\"" . $pth . "inc/icons/-.png\" name=\"status_id_menos\" value=\"" . $row["user_id"] . "\">"; } else { } } echo "</form>"; //avatar if (gravatar($row['user_id']) == "yes") { $grav_correo = correo($row["user_id"]); echo "<a class=\"avatar\" href=\"index.php?user="******"user_id"] . "\">"; echo "<img width=\"48\" height=\"48\" align=\"left\" style=\"margin-right: 5px;\" border=\"1\" src=\""; echo getGravatarUrl($grav_correo, $defImg, "80", "G"); echo "\" alt=\"Gravatar\"></a>"; } else { if (file_exists("./avatar/" . $row['user_id'] . ".jpg") == true) { echo "<a class=\"avatar\" href=\"index.php?user="******"user_id"] . "\">"; echo '<img align="left" width="48" height="48" style="margin-right: 5px;" border=\\"1\\" src="' . $pth . 'avatar/', $row['user_id'], '.jpg"></a>'; } else { echo "<a class=\"avatar\" href=\"index.php?user="******"user_id"] . "\">"; echo '<img align="left" width="48" height="48" style="margin-right: 5px;" border=\\"1\\" src="' . $defImg . '"></a>'; } } //user echo "<b>"; echo "<a href=\"#\" onclick=\"insertAtCaret('status','@"; name($row['user_id']); echo " ');\">"; name($row['user_id']); echo "</a>"; echo " </b>"; //sms //echo replies(emoticons(replace_urls(stripslashes($row['status'])))) $status = replace_urls(stripslashes($row['status'])); $status = replace_unu($status); $status = emoticons($status); $status = channels($status); echo replies($status); echo '</div><span class="time">', $row['ds'], '</span>'; echo " <a href=\"index.php?user="******"\" style=\"border: 0px;\">\n\t<img style=\"border: 0px;\" src=\"" . $pth . "inc/icons/u.png\" alt=\"u\"/></a> \n\t<a href=\"#\" style=\"border: 0px;\" onclick=\"insertAtCaret('status','@"; name($row['user_id']); echo " ');\">\n\t<img style=\"border: 0px;\" src=\"" . $pth . "inc/icons/r.png\" alt=\"r\"/></a>"; //echo "<img src=\"inc/icons/d.png\" alt=\"d\"/> //<img src=\"inc/icons/f.png\" alt=\"f\"/> "; echo "</div></td></tr>"; } ?> <!-- foot table with link pages buttoms--> </tbody> <tfoot> <td> <center> <?php if ($pagina - 1 > 0) { if ($type == "User") { echo "<a id=\"nuevo\" href=\"index.php?user="******"&pagina=" . ($pagina - 1) . "\"> Newer </a>"; } else { echo "<a id=\"nuevo\" href=\"index.php?pagina=" . ($pagina - 1) . "\"> Newer </a>"; } } else { if ($type == "User") { echo "<a id=\"nuevorss\" href=\"rss.php?user="******"\"> Rss </a>"; } else { echo "<a id=\"nuevorss\" href=\"rss.php\"> Rss </a>"; } } if ($pagina + 1 <= $total_paginas) { if ($type == "User") { echo "<a id=\"viejo\" href=\"index.php?user="******"&pagina=" . ($pagina + 1) . "\"> Older </a>"; } else { echo "<a id=\"viejo\" href=\"index.php?pagina=" . ($pagina + 1) . "\"> Older </a>"; } } else { } ?> </center> </td> </tfoot> </table> </div> <br><br> <div style="clear: both;"></div> <!-- END TAB <?php echo $tabnumber; ?> --> </div> <?php }