コード例 #1
0
ファイル: UserUtil.php プロジェクト: ccq18/EduSoho
 public function fillUserAttr($userId, $userInfo)
 {
     $user = ServiceKernel::instance()->createService('User.UserService')->getUser($userId);
     if (!empty($userInfo['avatar'])) {
         $curl = curl_init($userInfo['avatar']);
         $smallName = date("Ymdhis") . "_small.jpg";
         $mediumName = date("Ymdhis") . "_medium.jpg";
         $largeName = date("Ymdhis") . "_large.jpg";
         $smallPath = ServiceKernel::instance()->getParameter('topxia.upload.public_directory') . '/tmp/' . $smallName;
         $mediumPath = ServiceKernel::instance()->getParameter('topxia.upload.public_directory') . '/tmp/' . $mediumName;
         $largePath = ServiceKernel::instance()->getParameter('topxia.upload.public_directory') . '/tmp/' . $largeName;
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
         $imageData = curl_exec($curl);
         curl_close($curl);
         $tp = @fopen($smallPath, 'a');
         fwrite($tp, $imageData);
         fclose($tp);
         $tp = @fopen($mediumPath, 'a');
         fwrite($tp, $imageData);
         fclose($tp);
         $tp = @fopen($largePath, 'a');
         fwrite($tp, $imageData);
         fclose($tp);
         $file = ServiceKernel::instance()->createService('Content.FileService')->uploadFile('user', new File($smallPath));
         $fields[] = array('type' => 'large', 'id' => $file['id']);
         $file = ServiceKernel::instance()->createService('Content.FileService')->uploadFile('user', new File($mediumPath));
         $fields[] = array('type' => 'medium', 'id' => $file['id']);
         $file = ServiceKernel::instance()->createService('Content.FileService')->uploadFile('user', new File($largePath));
         $fields[] = array('type' => 'small', 'id' => $file['id']);
         $user = ServiceKernel::instance()->createService('User.UserService')->changeAvatar($userId, $fields);
     }
     return $user;
 }
コード例 #2
0
 protected static function initAlipayConfig($name)
 {
     $payment = ServiceKernel::instance()->createService('System.SettingService')->get('payment', array());
     $alipay_config = array();
     $alipay_config['seller_email'] = empty($payment['alipay_account']) ? '' : $payment['alipay_account'];
     $alipay_config['partner'] = empty($payment['alipay_key']) ? '' : $payment['alipay_key'];
     //安全检验码,以数字和字母组成的32位字符
     //如果签名方式设置为“MD5”时,请设置该参数
     $alipay_config['key'] = empty($payment['alipay_secret']) ? '' : $payment['alipay_secret'];
     //商户的私钥(后缀是.pen)文件相对路径
     //如果签名方式设置为“0001”时,请设置该参数
     // $alipay_config['private_key_path'] = 'key/rsa_private_key.pem';
     // //支付宝公钥(后缀是.pen)文件相对路径
     // //如果签名方式设置为“0001”时,请设置该参数
     // $alipay_config['ali_public_key_path'] = 'key/alipay_public_key.pem';
     //签名方式 不需修改
     $alipay_config['sign_type'] = 'MD5';
     //字符编码格式 目前支持 gbk 或 utf-8
     $alipay_config['input_charset'] = 'utf-8';
     //ca证书路径地址,用于curl中ssl校验
     //请保证cacert.pem文件在当前文件夹目录中
     $alipay_config['cacert'] = getcwd() . '\\cacert.pem';
     //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http
     $alipay_config['transport'] = 'http';
     return $alipay_config;
 }
コード例 #3
0
 public function createOrder($info)
 {
     $connection = ServiceKernel::instance()->getConnection();
     try {
         $connection->beginTransaction();
         $user = $this->getCurrentUser();
         if (!$user->isLogin()) {
             throw $this->createServiceException('用户未登录,不能创建订单');
         }
         if (!ArrayToolkit::requireds($info, array('targetId', 'payment'))) {
             throw $this->createServiceException('订单数据缺失,创建课程订单失败。');
         }
         // 获得锁
         $user = $this->getUserService()->getUser($user['id'], true);
         if ($this->getClassroomService()->isClassroomStudent($info['targetId'], $user['id'])) {
             throw $this->createServiceException('已经是班级学员,创建订单失败。');
         }
         $classroom = $this->getClassroomService()->getClassroom($info['targetId']);
         if (empty($classroom)) {
             throw $this->createServiceException('班级不存在,创建课程订单失败。');
         }
         if ($classroom['private'] == 1) {
             throw $this->createServiceException('该班级是封闭班级,学员不能自行加入!');
         }
         $order = array();
         $order['userId'] = $user['id'];
         $order['title'] = "购买班级《{$classroom['title']}》";
         $order['targetType'] = 'classroom';
         $order['targetId'] = $classroom['id'];
         $order['payment'] = $info['payment'];
         $order['amount'] = empty($info['amount']) ? 0 : $info['amount'];
         $order['priceType'] = $info['priceType'];
         $order['totalPrice'] = $info["totalPrice"];
         $order['coinRate'] = $info['coinRate'];
         $order['coinAmount'] = $info['coinAmount'];
         $order['snPrefix'] = 'CR';
         if (!empty($info['note'])) {
             $order['data'] = array('note' => $info['note']);
         }
         if (!empty($info['coupon'])) {
             $order['coupon'] = $info['coupon'];
             $order['couponDiscount'] = $info['couponDiscount'];
         }
         $order = $this->getOrderService()->createOrder($order);
         if (empty($order)) {
             throw $this->createServiceException('创建订单失败!');
         }
         // 免费班级,就直接将订单置为已购买
         if (intval($order['amount'] * 100) == 0 && intval($order['coinAmount'] * 100) == 0 && empty($order['coupon'])) {
             list($success, $order) = $this->getOrderService()->payOrder(array('sn' => $order['sn'], 'status' => 'success', 'amount' => $order['amount'], 'paidTime' => time()));
             $info = array('orderId' => $order['id'], 'remark' => empty($order['data']['note']) ? '' : $order['data']['note']);
             $this->getClassroomService()->becomeStudent($order['targetId'], $order['userId'], $info);
         }
         $connection->commit();
         return $order;
     } catch (\Exception $e) {
         $connection->rollBack();
         throw $e;
     }
 }
コード例 #4
0
ファイル: ParserProxy.php プロジェクト: fujianguo/EduSoho
 public function parseItem($url)
 {
     $parsers = array('YoukuVideo', 'QQVideo', 'NeteaseOpenCourse', 'TudouVideo');
     $kernel = ServiceKernel::instance();
     $extras = array();
     if ($kernel->hasParameter('media_parser')) {
         $extras = $kernel->getParameter('media_parser');
     }
     if ($extras['item']) {
         $extrasParsers = $extras['item'];
         foreach ($extrasParsers as $extrasParser) {
             $class = $extrasParser['class'];
             $parser = new $class();
             if (!$parser->detect($url)) {
                 continue;
             }
             return $parser->parse($url);
         }
     }
     foreach ($parsers as $parserName) {
         $class = __NAMESPACE__ . "\\ItemParser\\{$parserName}ItemParser";
         $parser = new $class();
         if (!$parser->detect($url)) {
             continue;
         }
         return $parser->parse($url);
     }
     throw $this->createParserNotFoundException();
 }
コード例 #5
0
 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST && $request->getMethod() == 'POST') {
         if (stripos($request->getPathInfo(), '/mapi') === 0) {
             return;
         }
         if (stripos($request->getPathInfo(), '/hls') === 0) {
             return;
         }
         $whiteList = array('/coin/pay/return/alipay', '/coin/pay/notify/alipay', '/coin/pay/notify/wxpay', '/pay/center/pay/alipay/return', '/pay/center/pay/wxpay/notify', '/pay/center/pay/alipay/notify', '/live/verify', '/course/order/pay/alipay/notify', '/vip/pay_notify/alipay', '/uploadfile/upload', '/uploadfile/cloud_convertcallback', '/uploadfile/cloud_convertcallback2', '/uploadfile/cloud_convertcallback3', '/uploadfile/cloud_convertheadleadercallback', '/disk/upload', '/file/upload', '/editor/upload', '/disk/convert/callback', '/partner/phpwind/api/notify', '/partner/discuz/api/notify', '/live/auth', '/edu_cloud/sms_callback');
         if (in_array($request->getPathInfo(), $whiteList)) {
             return;
         }
         if ($request->isXmlHttpRequest()) {
             $token = $request->headers->get('X-CSRF-Token');
         } else {
             $token = $request->request->get('_csrf_token', '');
         }
         $request->request->remove('_csrf_token');
         $expectedToken = $this->container->get('form.csrf_provider')->generateCsrfToken('site');
         if ($token != $expectedToken) {
             // @todo 需要区分ajax的response
             if ($request->getPathInfo() == '/admin') {
                 $token = $request->request->get('token');
                 $result = ServiceKernel::instance()->createService('CloudPlatform.AppService')->repairProblem($token);
                 $this->container->set('Topxia.RepairProblem', $result);
             } else {
                 $response = $this->container->get('templating')->renderResponse('TopxiaWebBundle:Default:message.html.twig', array('type' => 'error', 'message' => '页面已过期,请重新提交数据!', 'goto' => '', 'duration' => 0));
                 $event->setResponse($response);
             }
         }
     }
 }
コード例 #6
0
 public function lessonHomeworkListAction(Request $request, $courseId, $lessonId)
 {
     $course = ServiceKernel::instance()->createService('Course.CourseService')->getCourse($courseId);
     $lesson = ServiceKernel::instance()->createService('Course.CourseService')->getCourseLesson($courseId, $lessonId);
     $homeworkService = $this->getHomeworkService();
     $homework = $homeworkService->findHomeworkByLessonId($lessonId);
     $homeworkMemberService = $this->getHomeworkMemberService();
     $homework_members = $homeworkMemberService->findHomeworkMembersByLessonId($lessonId);
     $conditions = array();
     $conditions['lesson_id'] = $lesson['id'];
     $orderBy = array();
     $orderBy[] = 'create_at';
     $orderBy[] = 'DESC';
     $count = $homeworkMemberService->searchHomeworkMembersCount($conditions);
     $page_size = 20;
     $paginator = new Paginator($request, $count, $page_size);
     $start = $paginator->getOffsetCount();
     $limit = $paginator->getPerPageCount();
     $homework_members = $homeworkMemberService->searchHomeworkMembers($conditions, $orderBy, $start, $limit);
     $homework_members = $this->addUser($homework_members);
     $tpl = 'HomeworkBundle:Homework:lesson-homework-list.html.twig';
     $assignBox = array();
     $assignBox['course'] = $course;
     $assignBox['lesson'] = $lesson;
     $assignBox['homework'] = $homework;
     $assignBox['homework_members'] = $homework_members;
     $assignBox['paginator'] = $paginator;
     return $this->render($tpl, $assignBox);
 }
コード例 #7
0
 public function processOrder($payData, $lock = true)
 {
     $connection = ServiceKernel::instance()->getConnection();
     try {
         if ($lock) {
             $connection->beginTransaction();
         }
         list($success, $order) = $this->getOrderService()->payOrder($payData);
         if ($order["coupon"]) {
             $this->useCoupon($order);
         }
         $processor = OrderProcessorFactory::create($order["targetType"]);
         if ($order['status'] == 'paid' && $processor) {
             $processor->doPaySuccess($success, $order);
         }
         if ($lock) {
             $connection->commit();
         }
         return array($success, $order);
     } catch (\Exception $e) {
         if ($lock) {
             $connection->rollback();
         }
         throw $e;
     }
     return array(false, array());
 }
コード例 #8
0
ファイル: CourseThreadConvert.php プロジェクト: ccq18/EduSoho
 public function convert($id)
 {
     $thread = ServiceKernel::instance()->createService('Course.ThreadService')->getThread(1, $id);
     if (empty($thread)) {
         throw new \Exception('course-thread not found');
     }
     return $thread;
 }
コード例 #9
0
 private function initServiceKernel()
 {
     $serviceKernel = ServiceKernel::create('dev', false);
     $serviceKernel->setParameterBag($this->getContainer()->getParameterBag());
     $serviceKernel->setConnection($this->getContainer()->get('database_connection'));
     $user = $this->getUserService()->getUser(1);
     $serviceKernel->setCurrentUser($user);
 }
コード例 #10
0
 public function convert($id)
 {
     $homework = ServiceKernel::instance()->createService('Homework:Homework.HomeworkService')->gethomework($id);
     if (empty($homework)) {
         throw new \Exception('user not found');
     }
     return $homework;
 }
コード例 #11
0
ファイル: SystemUtil.php プロジェクト: latticet/EduSoho_jb51
 public static function backupdb()
 {
     $backUpdir = SystemUtil::getUploadTmpPath();
     $backUpdir .= DIRECTORY_SEPARATOR . uniqid(mt_rand()) . '.txt';
     $dbSetting = array('exclude' => array('session', 'cache'));
     $dump = new MySQLDumper(ServiceKernel::instance()->getConnection(), $dbSetting);
     return $dump->export($backUpdir);
 }
コード例 #12
0
ファイル: MobileSchoolUtil.php プロジェクト: ccq18/EduSoho
 private function getSchoolApps()
 {
     $mobile = ServiceKernel::instance()->createService('System.SettingService')->get('mobile');
     $site = ServiceKernel::instance()->createService('System.SettingService')->get('site');
     $apps[1] = array('id' => "1", 'code' => 'announcement', 'name' => $site['name'], 'title' => $site['slogan'], 'about' => $mobile['about'], 'avatar' => $mobile['logo'], 'callback' => '/mobileschools/announcements');
     $apps[2] = array('id' => "2", 'code' => 'news', 'name' => '资讯', 'title' => '网校资讯服务', 'about' => '', 'avatar' => 'img/mobile/article_app_icon.jpg', 'callback' => '');
     return $apps;
 }
コード例 #13
0
 public function convert($id)
 {
     $post = ServiceKernel::instance()->createService('Course.ThreadService')->getPost(1, $id);
     if (empty($post)) {
         throw new \Exception('course-thread-post not found');
     }
     return $post;
 }
コード例 #14
0
ファイル: LiveNotifyCommand.php プロジェクト: ccq18/EduSoho
 private function initServiceKernel()
 {
     $serviceKernel = ServiceKernel::create('dev', false);
     $serviceKernel->setConnection($this->getContainer()->get('database_connection'));
     $currentUser = new CurrentUser();
     $currentUser->fromArray(array('id' => 1, 'nickname' => '测试管理员', 'currentIp' => '127.0.0.1', 'roles' => array("ROLE_SUPER_ADMIN")));
     $serviceKernel->setCurrentUser($currentUser);
 }
コード例 #15
0
ファイル: AnnouncementConvert.php プロジェクト: ccq18/EduSoho
 public function convert($id)
 {
     $announcement = ServiceKernel::instance()->createService('Announcement.AnnouncementService')->getAnnouncement($id);
     if (empty($announcement)) {
         throw new \Exception('announcement not found');
     }
     return $announcement;
 }
コード例 #16
0
 public function convert($id)
 {
     $sundry = ServiceKernel::instance()->createService('sundry.sundryService')->getSundry($id);
     if (empty($sundry)) {
         throw new \Exception('user not found');
     }
     return $sundry;
 }
コード例 #17
0
ファイル: BlacklistConvert.php プロジェクト: mm999/EduSoho
 public function convert($id)
 {
     $blacklist = ServiceKernel::instance()->createService('User.BlacklistService')->getBlacklist($id);
     if (empty($blacklist)) {
         throw new \Exception('blacklist not found');
     }
     return $blacklist;
 }
コード例 #18
0
 public static function createClient()
 {
     $setting = ServiceKernel::instance()->createService('System.SettingService')->get('storage', array());
     $class = __NAMESPACE__ . '\\EdusohoLiveClient';
     $arguments = array('apiServer' => $setting['cloud_api_server'], 'accessKey' => $setting['cloud_access_key'], 'secretKey' => $setting['cloud_secret_key']);
     $client = new $class($arguments);
     return $client;
 }
コード例 #19
0
ファイル: ExerciseConvert.php プロジェクト: ccq18/EduSoho
 public function convert($id)
 {
     $exercise = ServiceKernel::instance()->createService('Homework:Homework.ExerciseService')->getExercise($id);
     if (empty($exercise)) {
         throw new \Exception('exercise not found');
     }
     return $exercise;
 }
コード例 #20
0
 private function initServiceKernel()
 {
     global $kernel;
     $serviceKernel = ServiceKernel::create('dev', false);
     $serviceKernel->setParameterBag($kernel->getContainer()->getParameterBag());
     $serviceKernel->setConnection($kernel->getContainer()->get('database_connection'));
     return $serviceKernel;
 }
コード例 #21
0
 public function convert($id)
 {
     $Classroom = ServiceKernel::instance()->createService('Classroom:Classroom.ClassroomService')->getClassroom($id);
     if (empty($Classroom)) {
         throw new \Exception('user not found');
     }
     return $Classroom;
 }
コード例 #22
0
 public function convert($id)
 {
     $activity = ServiceKernel::instance()->createService('Article.ArticleService')->getArticle($id);
     if (empty($activity)) {
         throw new \Exception('user not found');
     }
     return $activity;
 }
コード例 #23
0
 public function convert($id)
 {
     $zc888 = ServiceKernel::instance()->createService('Zc888.Zc888Service')->getZc888($id);
     if (empty($zc888)) {
         throw new \Exception('user not found');
     }
     return $zc888;
 }
コード例 #24
0
ファイル: PayConvert.php プロジェクト: latticet/EduSoho_jb51
 public function convert($id)
 {
     $pay = ServiceKernel::instance()->createService('pay.payService')->getpay($id);
     if (empty($pay)) {
         throw new \Exception('user not found');
     }
     return $pay;
 }
コード例 #25
0
 public function convert($id)
 {
     $order = ServiceKernel::instance()->createService('Order.OrderService')->getorder($id);
     if (empty($order)) {
         throw new \Exception('user not found');
     }
     return $order;
 }
コード例 #26
0
ファイル: CourseConvert.php プロジェクト: iCodeAnt/EduSoho
 public function convert($id)
 {
     $course = ServiceKernel::instance()->createService('Course.CourseService')->getCourse($id);
     if (empty($course)) {
         throw new \Exception('course not found');
     }
     return $course;
 }
コード例 #27
0
ファイル: PluginToolkit.php プロジェクト: ccq18/EduSoho
 protected static function getPlugins()
 {
     $dir = ServiceKernel::instance()->getParameter('kernel.root_dir') . '/data/plugin_installed.php';
     if (file_exists($dir)) {
         $plugins = (include $dir);
         return $plugins;
     }
     return array();
 }
コード例 #28
0
ファイル: PluginUtil.php プロジェクト: styling/LeesPharm
 public static function refresh()
 {
     self::$filesystem = new Filesystem();
     self::$kernel = ServiceKernel::instance();
     $count = self::getAppService()->findAppCount();
     $apps = self::getAppService()->findApps(0, $count);
     self::refreshMetaFile($apps);
     self::refreshRoutingFile($apps);
 }
コード例 #29
0
 private function initServiceKernel()
 {
     $serviceKernel = ServiceKernel::create('dev', false);
     $serviceKernel->setParameterBag($this->getContainer()->getParameterBag());
     $serviceKernel->setConnection($this->getContainer()->get('database_connection'));
     $currentUser = new CurrentUser();
     $currentUser->fromArray(array('id' => 0, 'nickname' => '游客', 'currentIp' => '127.0.0.1', 'roles' => array()));
     $serviceKernel->setCurrentUser($currentUser);
 }
コード例 #30
0
 public static function clients()
 {
     $clients = array('weibo' => array('name' => '微博帐号', 'admin_name' => '微博登录接口', 'class' => 'Topxia\\Component\\OAuthClient\\WeiboOAuthClient', 'icon_class' => 'social-icon social-icon-weibo', 'icon_img' => '', 'large_icon_img' => 'assets/img/social/weibo.png', 'key_setting_label' => 'App Key', 'secret_setting_label' => 'App Secret', 'apply_url' => 'http://open.weibo.com/authentication/'), 'qq' => array('name' => 'QQ帐号', 'admin_name' => 'QQ登录接口', 'class' => 'Topxia\\Component\\OAuthClient\\QqOAuthClient', 'icon_class' => 'social-icon social-icon-qq', 'icon_img' => '', 'large_icon_img' => 'assets/img/social/qq.png', 'key_setting_label' => 'App ID', 'secret_setting_label' => 'App Key', 'apply_url' => 'http://wiki.open.qq.com/wiki/%E3%80%90QQ%E7%99%BB%E5%BD%95%E3%80%91%E7%BD%91%E7%AB%99%E6%8E%A5%E5%85%A5#2._QQ.E7.99.BB.E5.BD.95'), 'renren' => array('name' => '人人帐号', 'admin_name' => '人人登录接口', 'class' => 'Topxia\\Component\\OAuthClient\\RenrenOAuthClient', 'icon_class' => 'social-icon social-icon-renren', 'icon_img' => '', 'large_icon_img' => 'assets/img/social/renren.gif', 'key_setting_label' => 'App Key', 'secret_setting_label' => 'App Secret', 'apply_url' => 'http://wiki.dev.renren.com/wiki/WEB%E7%BD%91%E7%AB%99%E5%B8%90%E5%8F%B7%E7%99%BB%E5%BD%95%E5%85%A5%E9%97%A8%E6%95%99%E7%A8%8B'), 'weixinweb' => array('name' => '微信网页登录接口', 'admin_name' => '微信网页登录接口', 'class' => 'Topxia\\Component\\OAuthClient\\WeixinwebOAuthClient', 'icon_class' => 'social-icon social-icon-weixin', 'icon_img' => '', 'large_icon_img' => 'assets/img/social/weixin.png', 'key_setting_label' => 'App ID', 'secret_setting_label' => 'App Secret', 'apply_url' => 'https://open.weixin.qq.com/cgi-bin/frame?t=home/web_tmpl&lang=zh_CN'), 'weixinmob' => array('name' => '微信内分享登录接口', 'admin_name' => '微信内分享登录接口', 'class' => 'Topxia\\Component\\OAuthClient\\WeixinmobOAuthClient', 'icon_class' => '', 'icon_img' => '', 'large_icon_img' => '', 'key_setting_label' => 'App ID', 'secret_setting_label' => 'App Secret', 'apply_url' => 'https://mp.weixin.qq.com/cgi-bin/readtemplate?t=register/step1_tmpl&lang=zh_CN'));
     $kernel = ServiceKernel::instance();
     if ($kernel->hasParameter('oauth2_clients')) {
         $extras = $kernel->getParameter('oauth2_clients');
         $clients = array_merge($clients, $extras);
     }
     return $clients;
 }