コード例 #1
0
ファイル: items.class.php プロジェクト: yunsite/demila
 public function approveUpdate($id)
 {
     global $mysql, $data, $item, $langArray, $meta, $config;
     $setQuery = '';
     if (isset($_POST['price']) && is_numeric($_POST['price']) && $_POST['price'] != '0') {
         $_POST['price'] = str_replace(',', '.', $_POST['price']);
         $setQuery .= " `price` = '" . sql_quote($_POST['price']) . "', ";
     }
     //获取当前作品历史数据
     $mysql->query("\n\t\t\tSELECT *\n\t\t\tFROM `temp_items`\n\t\t\tWHERE `item_id` = '" . intval($item['id']) . "'\n\t\t\tLIMIT 1\n\t\t");
     $temp_item_data = $mysql->fetch_array();
     //获取作品信息
     $item_info = $this->get($item['id']);
     //检测缩略图更新状态
     if (!empty($temp_item_data['thumbnail'])) {
         $setQuery .= " `thumbnail` = '" . sql_quote($temp_item_data['thumbnail']) . "', ";
         unlink(DATA_SERVER_PATH . '/uploads/' . $this->uploadFileDirectory . $item['id'] . '/' . $item_info["thumbnail"]);
     }
     //检测封面更新状态
     if (!empty($temp_item_data['first_preview'])) {
         $setQuery .= " `theme_preview` = '" . sql_quote($temp_item_data['first_preview']) . "', ";
         unlink(DATA_SERVER_PATH . '/uploads/' . $this->uploadFileDirectory . $item['id'] . '/' . $item_info["theme_preview"]);
     }
     //检测文件包更新状态
     if (!empty($temp_item_data['main_file'])) {
         $setQuery .= " `main_file` = '" . sql_quote($temp_item_data['main_file']) . "', ";
         $setQuery .= " `main_file_name` = '" . sql_quote($temp_item_data['main_file_name']) . "', ";
         unlink(DATA_SERVER_PATH . '/uploads/' . $this->uploadFileDirectory . $item['id'] . '/' . $item_info["main_file"]);
     }
     //删除原预览图
     $preview_arr = json_decode($temp_item_data['theme_preview'], 1);
     if (!empty($preview_arr) && is_array($preview_arr)) {
         $base_dir = DATA_SERVER_PATH . '/uploads/' . $this->uploadFileDirectory . $item['id'] . '/preview/';
         foreach ($preview_arr as $dir) {
             $file_info = pathinfo($dir);
             $file = $base_dir . $file_info['basename'];
             //删除文件
             unlink($file);
         }
     }
     //更改作品状态
     $mysql->query("\n\t\t\tUPDATE `items`\n\t\t\tSET {$setQuery}\n\t\t\t `status` = 'active'\n\t\t\tWHERE `id` = '" . intval($item['id']) . "'\n\t\t\tLIMIT 1\n\t\t");
     //更新预览图状态
     $sql = " `status` = 1";
     $this->update_preview_by_upload_queue($item['id'], $sql);
     //获取用户信息
     require_once ROOT_PATH . '/apps/users/models/users.class.php';
     $user = new users();
     $user_info = $user->getuserinfoById($item['user_id']);
     //通过用户id获取关联客服
     //            require_once ROOT_PATH.'/apps/service/models/service.class.php';
     //            $service = new service();
     //            $theservice = $service->getserviceByuserid($item['user_id']);
     //            $item_url = $config['domain'].'/'.$languageURL.'items/'.$item['id'];
     //            $item_url = '<a href="'.$item_url.'" target="_blank">'.$item_url.'</a>';
     //            #给用户发邮件
     //            require_once ENGINE_PATH.'/classes/email.class.php';
     //            $emailClass = new email();
     //
     //            $emailClass->fromEmail = 'no-reply@'.$config['domain'];
     //            $emailClass->contentType = 'text/html';
     //            $emailClass->subject = '你的作品['.$item['name'].']更新审核通过啦!';
     //            $emailClass->message = 'Hi!['.$user_info['username'].']:<br />
     //								&nbsp;&nbsp;&nbsp;&nbsp;恭喜你的作品更新审核通过啦!<br />
     //								&nbsp;&nbsp;&nbsp;&nbsp;作品名称:['.$item['name'].']<br />
     //								&nbsp;&nbsp;&nbsp;&nbsp;作品地址:['.$item_url.']<br />
     //								&nbsp;&nbsp;&nbsp;&nbsp;又可以赚钱啦!<br />
     //                                <br />
     //								&nbsp;&nbsp;&nbsp;&nbsp;专属小编:['.$theservice['user_name'].']<br />
     //								&nbsp;&nbsp;&nbsp;&nbsp;['.$meta['meta_title'].']<br />
     //								&nbsp;&nbsp;&nbsp;&nbsp;['.date('Y-m-d H:i:s',time()).']<br />';
     //        require_once ROOT_PATH.'/apps/system/models/system.class.php';
     //        $system = new system();
     //        $smtp = $system ->is_smtp();
     //        $smtpconf=$system->getAllKeyValue();
     //        if($smtp){
     //            $emailClass->email_sock($smtpconf["smtp_host"],$smtpconf["smtp_port"],0,'error',10,1,$smtpconf["smtp_user"],$smtpconf["smtp_pass"],$smtpconf["smtp_from"]);
     //            $emailClass->send_mail_sock($emailClass->subject,$emailClass->message,$user_info['email'],$smtpconf["smtp_from_name"]) ;
     //            unset($emailClass);
     //        }else {
     //            $emailClass->to($user_info['email']);
     //            $emailClass->send();
     //            unset($emailClass);
     //        }
     $this->deleteUpdate($item['id']);
     return true;
 }
コード例 #2
0
ファイル: categories.php プロジェクト: yunsite/demila
            array_shift($categoryParent);
            $whereQuery = " AND `id` IN (SELECT `item_id` FROM `items_to_category` WHERE `categories` LIKE '%," . intval($categoryID) . ",%') ";
        } else {
            $categoryParent = array('data' => '');
        }
        require_once ROOT_PATH . '/apps/items/models/items.class.php';
        require_once ROOT_PATH . '/apps/users/models/users.class.php';
        $itemsClass = new items();
        $users = new users();
        $order = '`datetime` DESC';
        $items = $itemsClass->getAll(0, 40, " `status` = 'active' " . $whereQuery, $order);
        $categories = $categoriesClass->getAll();
        $res_data = array();
        foreach ($items as $data) {
            //用户信息
            $user_info = $users->getuserinfoById($data['user_id']);
            $data['user_info']['item-author'] = $user_info['nickname'];
            $item_categories = array();
            foreach ($data['categories'] as $cat) {
                foreach ($cat as $c_cat) {
                    $item_categories[] = $categories[$c_cat]['name'];
                }
            }
            $data['item_categories'] = $item_categories;
            $res_data[] = $data;
        }
        echo json_encode(array('data' => $res_data));
    } else {
        echo json_encode(array('data' => ''));
    }
} else {