function parsePics($tweets) { $picUrls = array(); $twitpicPattern = '%(http://twitpic\\.com/\\w+)%i'; $yfrogPattern = '%(http://yfrog\\.com/\\w+)%i'; foreach ($tweets as $tweet) { if (preg_match($twitpicPattern, $tweet['text'], $matches) || preg_match($yfrogPattern, $tweet['text'], $matches)) { $picUrls = array_merge($matches, $picUrls); } } return getPics(array_unique($picUrls)); }
public function editproduct() { $proid = intval(I('get.proid')); $action = I('get.action'); if ($action && $action == "edit") { $Products = D('products'); $row = $Products->where("proid={$proid}")->find(); $row['content'] = htmlspecialchars_decode($row['content']); $pics = getPics($row['picids'], $row['picpaths']); $picjscode = ''; foreach ($pics as $pic) { $picjscode .= ",{$pic['picid']}"; } $this->assign('product', $row); $this->assign('picjscode', $picjscode); } $options = F('procates_option'); $this->assign('options', $options); $this->display(); }
$body .= "<th>" . $day . "</th>"; } $body .= '<tr>'; $counter = 0; $dayOffset = $week[date('l', strtotime($month . ' 1 ' . $year))]; for ($i = 0; $i < $dayOffset; $i++) { $body .= "<td class='offset'></td>"; $counter++; } $days = cal_days_in_month(CAL_GREGORIAN, date('n', strtotime($month)), $year); for ($i = 1; $i <= $days; $i++) { if ($counter % 7 == 0) { $body .= "</tr><tr>"; } $counter++; $body .= "<td><div id={$i}>" . $i . "<br />" . getPics($pics, $i) . "</div></td>"; //Day added here } //finish rendering calendar while ($counter % 7 != 0) { $body .= "<td class='offset'></td>"; $counter++; } $body .= "</tr></table>"; echo generatePage($body, "Calendapp"); function getPics($arr, $dayOfMonth) { if (empty($arr)) { //No pictures for this month return ""; }
/** * 添加产品信息具体执行操作 * @return */ public function pro_add_do() { if (empty($_POST['sort'])) { showMessage('排序不能为空!', "admin_cproduct_mpro_add.html"); } else { $sort = intval(safeString($_POST[sort])); } if (empty($_POST['title'])) { showMessage('标题不能为空!', "admin_cproduct_mpro_add.html"); } else { $title = safeString($_POST['title']); } if (empty($_POST['content'])) { showMessage('内容不能为空!', "admin_cproduct_mpro_add.html"); } else { $content = safeString($_POST['content']); } $author = safeString($_POST['author']); //产品设置模块 $type = safeString($_POST['type']); $parameter = safeString($_POST['parameter']); $discount = safeString($_POST['discount']); $brand = safeString($_POST['brand']); $producers = safeString($_POST['producers']); $price = safeString($_POST['price']); $keywords = safeString($_POST['keywords']); //产品设置模块结束 $pic = $_FILES['pic']; $pics = getPics($pic); //获取图片数组信息 foreach ($pics as $key => $value) { $picPath[] = upload($value, $path = './admin/uploads/products'); //获取图片具体路径信息写入数据库 } //获取当前分类的父级id写入数据库bid字段 $category = intval(safeString($_POST['category'])); $category_m = M('category'); $bid = $category_m->getBid($category); $product_m = M('product'); if ($product_m->pro_add($sort, $bid, $title, $content, $picPath, $author, $category, $type, $parameter, $discount, $brand, $producers, $price, $keywords)) { showMessage('产品信息添加成功!', "admin_cproduct_mpro_list.html"); } else { showMessage('产品信息添加失败!', "admin_cproduct_mpro_list.html"); } }