예제 #1
0
 private function _CKVCode()
 {
     $vcode = mRequest('vcode');
     if (!CR('Org')->CKVcode($vcode)) {
         $this->ajaxReturn(1, "验证码错误!");
     }
     return true;
 }
예제 #2
0
 private function _getContent()
 {
     $content = mRequest('content');
     if (!$content) {
         $this->ajaxReturn(1, "清输入文章内容!");
     }
     return $content;
 }
예제 #3
0
 public function getWXSNSUserInfo($ck = 1)
 {
     $mystate = 'Sessdw_snsapi_userinfo';
     $state = mRequest('state');
     if (!$state) {
         $redirect_uri = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . '?s=User/login';
         $redirect_location = session('location');
         if ($ck == 0 && $redirect_location) {
             $redirect_uri = $redirect_location;
         }
         $location = $this->_wxconfig['API']['SNSAPI_USERINFO'];
         $location .= '?appid=' . $this->_wxconfig['AppID'] . '&redirect_uri=' . urlencode($redirect_uri) . '&response_type=code&scope=snsapi_userinfo&state=' . $mystate . '#wechat_redirect';
         header('location:' . $location);
         exit;
     }
     $code = mRequest('code');
     if ($state && $state != $mystate || !$code) {
         $this->pageReturn();
     }
     //调用Oauth2AccessToken获取用户基本信息
     $WXObj = new Weixin($this->_weixininfo);
     $result = $WXObj->Oauth2AccessToken($code);
     if ($result['error']) {
         $this->pageReturn(1, '微信用户授权未完成!');
     }
     $result_data = $result['data'];
     $WXUserBaseInfo = array('accesstoken' => $result_data['access_token'], 'expiresin' => $result_data['expires_in'], 'expiretime' => TIMESTAMP + $result_data['expires_in'] - 1800, 'refreshtoken' => $result_data['refresh_token'], 'openid' => $result_data['openid'], 'scope' => $result_data['scope']);
     //调用SNSUserInfo接口获取用户详细信息
     $WXObj = new Weixin($this->_weixininfo);
     $result = $WXObj->Oauth2SNSUser($WXUserBaseInfo['accesstoken'], $WXUserBaseInfo['openid']);
     if ($result['error']) {
         $this->pageReturn(1, '微信用户信息获取失败!');
     }
     $result_data = $result['data'];
     return array('openid' => $result_data['openid'], 'nickname' => $result_data['nickname'], 'sex' => $result_data['sex'], 'province' => $result_data['province'], 'city' => $result_data['city'], 'country' => $result_data['country'], 'avatar' => $result_data['headimgurl'], 'privilege' => implode(',', $result_data['privilege']), 'unionid' => $result_data['unionid']);
 }
예제 #4
0
function paginacion($cSql, $leyenda, $tamPagina = 10, $maxIndex = 10, $leyendaPaginas = "Página %s de %s", $queryString = "")
{
    /* devuelve un array con ( n reg, n paginas, cSQL limitada, navegación ) */
    $paginaActual = 0;
    if ($queryString) {
        $nTemp = strpos($queryString, "PaginaActual=");
        if ($nTemp > 0) {
            $paginaActual = (int) substr($queryString, $nTemp + 13);
        }
    }
    if (!$paginaActual) {
        $paginaActual = por_defecto(si_es_key($_REQUEST, "PaginaActual"), mRequest("PaginaActual"));
        if ($paginaActual == "") {
            $paginaActual = 1;
        }
    }
    $rsTemp = mysql_query($cSql);
    $totalReg = mysql_num_rows($rsTemp);
    $cNavega = "";
    if ($totalReg == 0) {
        // no hay páginas
        $totalPaginas = 0;
        $paginaActual = 0;
    } elseif ($totalReg <= $tamPagina) {
        // solo hay una página
        $totalPaginas = 1;
        $paginaActual = 1;
    } else {
        // hay más de una página
        $totalPaginas = ceil($totalReg / $tamPagina);
        if ($paginaActual > $totalPaginas) {
            $paginaActual = $totalPaginas;
        }
        // calculamos las leyendas si hay
        if ($leyenda != "") {
            $npag = 1;
            $aCampos = explode(",", $leyenda);
            while ($npag <= $totalPaginas && ($aTemp = mysql_fetch_array($rsTemp))) {
                $cTemp = "";
                foreach ($aCampos as $tCampo) {
                    $cTemp .= $aTemp[trim($tCampo)] . " ";
                }
                $aLeyendas[$npag - 1] .= " - {$cTemp}";
                $aLeyendas[$npag] = $cTemp;
                /* TODO mirar error */
                @mysql_data_seek($rsTemp, $npag * $tamPagina);
                $npag++;
            }
            // falta el ultimo
            mysql_data_seek($rsTemp, $totalReg - 1);
            $aTemp = mysql_fetch_array($rsTemp, MYSQL_ASSOC);
            $cTemp = "";
            foreach ($aCampos as $tCampo) {
                $cTemp .= $aTemp[trim($tCampo)] . " ";
            }
            $aLeyendas[$totalPaginas] .= " - {$cTemp}";
        }
        // cambiamos la SQL.
        if (strstr(strtoupper($cSql), " LIMIT ") === false) {
            $cSql .= " LIMIT " . max(0, ($paginaActual - 1) * $tamPagina) . ",{$tamPagina}";
        }
        // Construir barra de navegacion
        $webBase = _paginacion_base($queryString);
        if ($totalPaginas <= $maxIndex) {
            // todas las páginas caben.
            for ($nCont = 1; $nCont <= $totalPaginas; $nCont++) {
                $temp = $leyenda ? " title='{$aLeyendas[$nCont]}'" : "";
                $cNavega .= "&nbsp;<a href='{$webBase}PaginaActual={$nCont}'{$temp} >{$nCont}</a>\n";
            }
        } else {
            // construir barra limitada
            if ($paginaActual > $totalPaginas - $maxIndex) {
                $nDesde = $totalPaginas - $maxIndex;
                $nHasta = $totalPaginas;
            } else {
                $nDesde = floor($paginaActual / $maxIndex) * $maxIndex + 1;
                $nHasta = $nDesde + $maxIndex - 1;
            }
            $nSiguiente = min($totalPaginas, $nDesde == 1 ? $maxIndex : $nDesde + $maxIndex);
            $nAnterior = max(1, $nDesde - $maxIndex);
            // boton de ir al principio (siempre 1)
            if ($nDesde > 1) {
                $temp = $leyenda ? " title='{$aLeyendas[1]}' " : "";
                $cNavega .= "<a class='paginacion_bottom' href='{$webBase}PaginaActual=1'{$temp};>&lt;&lt;</a>";
            }
            // boton de ir al anterior
            if ($nDesde != 1) {
                /* boton anterior */
                $temp = $leyenda ? " title='{$aLeyendas[$nAnterior]}' " : "";
                $cNavega .= "&nbsp;<a class='paginacion_anterior' href='{$webBase}PaginaActual={$nAnterior}'{$temp}>&lt;</a>";
            }
            // poner las paginas
            $cNavega .= "<span class='paginacion_paginas'>\n";
            for ($nCont = $nDesde; $nCont <= $nHasta; $nCont++) {
                $temp = $leyenda ? " title='{$aLeyendas[$nCont]}' " : "";
                $cNavega .= "&nbsp;<a href='{$webBase}PaginaActual={$nCont}'{$temp}>{$nCont}</a>\n";
            }
            $cNavega .= "</span>\n";
            // botón de siguiente
            if ($nHasta < $totalPaginas) {
                $temp = $leyenda ? " title='{$aLeyendas[$nSiguiente]}' " : "";
                $cNavega .= "&nbsp;<a class='paginacion_siguiente' href='{$webBase}PaginaActual={$nSiguiente}' {$temp}'>&gt;</a>\n";
            }
            // botón de ultimo
            if ($nHasta < $totalPaginas) {
                $temp = $leyenda ? " title='{$aLeyendas[$ntotalPaginas]}' " : "";
                $cNavega .= "&nbsp;<a class='paginacion_top' href='{$webBase}PaginaActual={$totalPaginas}' {$temp}>&gt;&gt;</a>\n";
            }
        }
    }
    if ($totalPaginas <= 0) {
        $cPagina = "&nbsp;";
    } else {
        // se genera la paginación. Ej: 5 de 6
        $cPagina = sprintf($leyendaPaginas, $paginaActual, $totalPaginas) . " |" . $cNavega;
    }
    $aTemp = array($totalReg, $totalPaginas, $cSql, $cPagina);
    return $aTemp;
}
예제 #5
0
 public function scrollimageenable()
 {
     $simgid = $this->_getSimgid();
     if (!$simgid) {
         $this->ajaxReturn(1, '未知轮播图片信息!');
     }
     $isshow = mRequest('isshow');
     if (!in_array($isshow, array(0, 1))) {
         $this->ajaxReturn(1, '数据错误!');
     }
     $data = array('isshow' => $isshow, 'updatetime' => TIMESTAMP);
     $result = M('scrollimage')->where(array('simgid' => $simgid))->save($data);
     if ($result) {
         $this->ajaxReturn(0, '成功!');
     } else {
         $this->ajaxReturn(1, '失败!');
     }
 }
예제 #6
0
 private function _getActivityid()
 {
     $activityid = mRequest('activityid');
     return $activityid;
 }
예제 #7
0
 public function enable()
 {
     $courseid = $this->_getCourseid();
     if (!$courseid) {
         $this->ajaxReturn(1, '未知课程信息!');
     }
     $isshow = mRequest('isshow');
     if (!in_array($isshow, array(0, 1))) {
         $this->ajaxReturn(1, '数据错误!');
     }
     $data = array('isshow' => $isshow, 'updatetime' => TIMESTAMP);
     $result = M('course')->where(array('courseid' => $courseid))->save($data);
     if ($result) {
         $this->ajaxReturn(0, '成功!');
     } else {
         $this->ajaxReturn(1, '失败!');
     }
 }
예제 #8
0
 public function lvwordsave()
 {
     $this->_CKUserLogon();
     $userid = $this->userinfo['userid'];
     $title = mRequest('title');
     if (!$title) {
         $this->ajaxReturn(1, '请填写标题!');
     }
     $content = mRequest('content');
     if (!$content) {
         $this->ajaxReturn(1, '请填写内容!');
     }
     $result = M('lvword')->add(array('userid' => $userid, 'title' => $title, 'content' => $content, 'createtime' => TIMESTAMP, 'updatetime' => TIMESTAMP));
     if ($result) {
         $this->ajaxReturn(0, '反馈留言提交成功!');
     } else {
         $this->ajaxReturn(1, '反馈留言提交失败!');
     }
 }
예제 #9
0
 private function _getRoleID()
 {
     $roleID = mRequest('roleID', false);
     return $roleID;
 }
예제 #10
0
 public function check()
 {
     $userid = $this->userinfo['userid'];
     $classid = $this->_getClassid();
     $classid = !$classid ? 1 : $classid;
     $this->assign('classid', $classid);
     $testingid = $this->_getTestingid();
     $testingid = session('testingid_' . $testingid);
     $testinginfo = D('Testing')->getTestingByID(null, $testingid, $userid);
     $userexams = session('userexams_' . $testingid);
     $testinginfo['exams'] = $userexams;
     if (!is_array($testinginfo) || empty($testinginfo) || $testinginfo['utstatus']) {
         header('location:' . __APP__ . '?s=Course/profile&courseid=' . $testinginfo['courseid'] . '&classid=' . $classid);
         exit;
     }
     //获取用户答案
     $exams = mRequest('exams', false);
     //比较答案
     $usertesting = array();
     $usertestingresult = array();
     $rightexam = 0;
     $wrongexam = 0;
     $gotscore = 0;
     foreach ($testinginfo['exams'] as $k => $exam) {
         if (!isset($exams[$exam['examid']])) {
             header('location:' . __APP__ . '?s=Testing/exam&testingid=' . $testingid . '&classid=' . $classid);
             exit;
         }
         $useranswer = is_array($exams[$exam['examid']]) ? implode('', $exams[$exam['examid']]) : $exams[$exam['examid']];
         $usertestingresult[] = array('userid' => $userid, 'testingid' => $testingid, 'examid' => $exam['examid'], 'useranswer' => $useranswer, 'officeanswer' => $exam['answer'], 'result' => $useranswer == $exam['answer'] ? 1 : 0);
         if ($useranswer == $exam['answer']) {
             $rightexam++;
             $gotscore += $exam['score'];
         } else {
             $wrongexam++;
         }
         $testinginfo['exams'][$k]['useranswer'] = $useranswer;
         $testinginfo['exams'][$k]['result'] = $useranswer == $exam['answer'] ? 1 : 0;
     }
     $usertesting = array('userid' => $userid, 'testingid' => $testingid, 'status' => 1, 'rightexam' => $rightexam, 'wrongexam' => $wrongexam, 'gotscore' => $gotscore, 'completetime' => TIMESTAMP);
     $usertestingresult = $usertestingresult;
     if ((int) $gotscore >= (int) $testinginfo['passscore']) {
         //及格
         M('testing')->startTrans();
         //测评完成人数+1
         $result = M('testing')->where(array('testingid' => $testingid))->setInc('donenum');
         //添加用户测评信息
         $result1 = M('user_testing')->add($usertesting);
         //添加用户测评结果详细信息
         $result2 = M('user_testing_result')->addAll($usertestingresult);
         //更新用户课程学习状态
         $result3 = M('user_course')->where(array('userid' => $userid, 'courseid' => $testinginfo['courseid']))->save(array('status' => 2));
         if ($result && $result1 && $result2 && $result3) {
             M('testing')->commit();
         } else {
             M('testing')->rollback();
         }
         //更新课程作业完成情况
         D('User')->ckUserCourseWork($userid, $testinginfo['courseid']);
         header('location:' . __APP__ . '?s=Testing/profile&testingid=' . $testingid . '&classid=' . $classid);
         exit;
     } else {
         //不及格
         $testinginfo['utstatus'] = 0;
         $testinginfo['rightexam'] = $rightexam;
         $testinginfo['wrongexam'] = $wrongexam;
         $testinginfo['gotscore'] = $gotscore;
         $testinginfo['completetime'] = 0;
         $this->assign('testinginfo', $testinginfo);
         $this->display('Testing/profile');
     }
 }
예제 #11
0
 public function scomplete()
 {
     $courseid = $this->_getCourseid();
     //如果校验码不对 返回false
     $coursesign = mRequest('coursesign');
     $mycoursesign = session('coursesign_' . $courseid);
     if ($coursesign != $mycoursesign) {
         return false;
     }
     $where = array('userid' => $this->userinfo['userid'], 'courseid' => $courseid);
     //获取党员对该课程学习信息
     $usercourseinfo = M('user_course')->where($where)->find();
     if (!is_array($usercourseinfo) || empty($usercourseinfo)) {
         return false;
     }
     //标识 党员已学习完课程
     if (!$usercourseinfo['status']) {
         M('user_course')->where($where)->save(array('status' => 1, 'completetime' => TIMESTAMP));
         //课程已学习党员数+1
         M('course')->where(array('courseid' => $courseid))->setInc('learnnum');
     }
     echo true;
 }
예제 #12
0
 private function _getKeywords()
 {
     $keywords = mRequest('keywords');
     $this->assign('keywords', $keywords);
     return $keywords;
 }
예제 #13
0
 public function workfile()
 {
     $userid = $this->userinfo['userid'];
     $workid = mRequest('workid');
     $workinfo = D('Work')->getWorkByID($workid, $userid);
     if (!is_array($workinfo) || empty($workinfo)) {
         header('location:' . __APP__ . '?s=Work/index&classid=1');
         exit;
     }
     $workfile = APP_PATH . $workinfo['savepath'] . $workinfo['savename'];
     $fileinfo = pathinfo($workfile);
     $filename = $fileinfo['basename'];
     $fp = fopen($workfile, "r");
     $size = filesize($workfile);
     //输入文件标签
     Header("Content-type: application/octet-stream");
     Header("Accept-Ranges: bytes");
     Header("Accept-Length: " . $size);
     Header("Content-Disposition: attachment; filename=" . $workinfo['filename']);
     //输出文件内容
     //读取文件内容并直接输出到浏览器
     echo fread($fp, $size);
     fclose($fp);
     exit;
 }
예제 #14
0
 private function _getEchostr()
 {
     $echostr = mRequest('echostr');
     return $echostr;
 }
예제 #15
0
 public function examsave()
 {
     //类型
     $examtype = mRequest('examtype');
     if (!$examtype) {
         $this->ajaxReturn(1, '请选择试题类型!');
     }
     //题目
     $examtitle = mRequest('examtitle');
     if (!$examtitle) {
         $this->ajaxReturn(1, '请填写试题题目!');
     }
     //A、B、C、D选项
     $optiontitlea = mRequest('optiontitlea');
     if (!$optiontitlea) {
         $this->ajaxReturn(1, '请填写A. 选项内容!');
     }
     $optiontitleb = mRequest('optiontitleb');
     if (!$optiontitleb) {
         $this->ajaxReturn(1, '请填写B. 选项内容!');
     }
     $optiontitlec = mRequest('optiontitlec');
     if (!$optiontitlec) {
         $this->ajaxReturn(1, '请填写C. 选项内容!');
     }
     $optiontitled = mRequest('optiontitled');
     if (!$optiontitled) {
         $this->ajaxReturn(1, '请填写D. 选项内容!');
     }
     //E、F选项
     $optiontitlee = mRequest('optiontitlee');
     $optiontitlef = mRequest('optiontitlef');
     //答案
     $examanswer = mRequest('examanswer');
     if (!$examanswer) {
         $this->ajaxReturn(1, '请填写试题答案!');
     }
     //试题信息
     $data = array('type' => $examtype, 'title' => $examtitle, 'answer' => $examanswer, 'options' => array(array('name' => 'A', 'title' => $optiontitlea), array('name' => 'B', 'title' => $optiontitleb), array('name' => 'C', 'title' => $optiontitlec), array('name' => 'D', 'title' => $optiontitled)), 'createtime' => TIMESTAMP, 'updatetime' => TIMESTAMP);
     if ($optiontitlee) {
         $data['options'][] = array('name' => 'E', 'title' => $optiontitlee);
     }
     if ($optiontitlef) {
         $data['options'][] = array('name' => 'F', 'title' => $optiontitlef);
     }
     $examid = D('Testing')->examsave($data);
     if ($examid) {
         $data['examid'] = $examid;
         $this->assign('examinfo', $data);
         $examhtml = $this->fetch('Testing/examitem');
         $this->ajaxReturn(0, '试题保存成功!', array('examhtml' => $examhtml));
     } else {
         $this->ajaxReturn(0, '试题保存失败!');
     }
 }
예제 #16
0
 private function _getWid()
 {
     $wid = mRequest('wid');
     return $wid;
 }
예제 #17
0
 private function _getArcid()
 {
     $arcid = mRequest('arcid');
     return $arcid;
 }
예제 #18
0
function paginacion($cSql, $leyenda, $tamPagina = 10, $maxIndex = 10, $leyendaPaginas = "Página %s de %s")
{
    /* devuelve un array con ( n reg, n paginas, cSQL limitada, navegación ) */
    $paginaActual = mRequest("PaginaActual");
    if ($paginaActual == "") {
        $paginaActual = 1;
    }
    $rsTemp = mysql_query($cSql);
    $totalReg = mysql_num_rows($rsTemp);
    $cNavega = "";
    if ($totalReg == 0) {
        // no hay páginas
        $totalPaginas = 0;
        $paginaActual = 0;
    } elseif ($totalReg <= $tamPagina) {
        // solo hay una página
        $totalPaginas = 1;
        $paginaActual = 1;
    } else {
        // hay mas de una página
        $totalPaginas = ceil($totalReg / $tamPagina);
        if ($paginaActual > $totalPaginas) {
            $paginaActual = $totalPaginas;
        }
        // calculamos las leyendas si hay
        if ($leyenda != "") {
            $npag = 1;
            $aCampos = explode(",", $leyenda);
            while ($npag < $totalPaginas && ($aTemp = mysql_fetch_array($rsTemp))) {
                $cTemp = "";
                foreach ($aCampos as $tCampo) {
                    $cTemp .= $aTemp[trim($tCampo)] . " ";
                }
                $aLeyendas[$npag - 1] .= " - {$cTemp}";
                $aLeyendas[$npag] = $cTemp;
                mysql_data_seek($rsTemp, $npag * $tamPagina);
                $npag++;
            }
        }
        if (strstr(strtoupper($cSql), " LIMIT ") === false) {
            $cSql .= " LIMIT " . max(0, ($paginaActual - 1) * $tamPagina) . ",{$tamPagina}";
        }
        /* Construir barra de navegacion  */
        $webBase = _paginacion_base();
        if ($totalPaginas <= $maxIndex) {
            for ($nCont = 1; $nCont <= $totalPaginas; $nCont++) {
                $temp = $leyenda ? " title='{$aLeyendas[$nCont]}'" : "";
                $cNavega .= "&nbsp;<a href='{$webBase}PaginaActual={$nCont}'{$temp} >{$nCont}</a>";
            }
        } else {
            /*construir barra limitada */
            $nDesde = max(1, floor($paginaActual / $maxIndex) * $maxIndex);
            $nHasta = min($totalPaginas, $nDesde + $maxIndex - ($nDesde == 1 ? 1 : 0));
            $nSiguiente = min($totalPaginas, $nDesde == 1 ? $maxIndex : $nDesde + $maxIndex);
            $nAnterior = max(1, $nDesde - $maxIndex);
            // boton de ir al principio (siempre 1)
            if ($nDesde > 1) {
                $temp = $leyenda ? " title='{$aLeyendas[1]}' " : "";
                $cNavega .= "<a href='{$webBase}PaginaActual=1'{$temp};>&lt;&lt;</a>|";
            }
            // boton de ir al anterior
            if ($nDesde != 1) {
                /* boton anterior */
                $temp = $leyenda ? " title='{$aLeyendas[$nAnterior]}' " : "";
                $cNavega .= "<a href='{$webBase}PaginaActual={$nAnterior}'{$temp}>&lt;</a>| ";
            }
            // poner las paginas
            for ($nCont = $nDesde; $nCont < $nHasta; $nCont++) {
                $temp = $leyenda ? " title='{$aLeyendas[$nCont]}' " : "";
                $cNavega .= "&nbsp;<a href='{$webBase}PaginaActual={$nCont}'{$temp}>{$nCont}</a> ";
            }
            // botón de siguiente
            if ($nHasta < $totalPaginas) {
                $temp = $leyenda ? " title='{$aLeyendas[$nSiguiente]}' " : "";
                $cNavega .= "&nbsp;|<a href='{$webBase}PaginaActual={$nSiguiente}' {$temp}'>&gt;</a>";
            }
            // botón de ultimo
            if ($nHasta < $totalPaginas) {
                $temp = $leyenda ? " title='{$aLeyendas[$ntotalPaginas]}' " : "";
                $cNavega .= "|<a href='{$webBase}PaginaActual={$totalPaginas}' {$temp}>&gt;&gt;</a>|";
            }
        }
    }
    if ($totalPaginas <= 1) {
        $cPagina = "&nbsp;";
    } else {
        $cPagina = sprintf($leyendaPaginas, $paginaActual, $totalPaginas) . " |" . $cNavega;
    }
    $aTemp = array($totalReg, $totalPaginas, $cSql, $cPagina);
    return $aTemp;
}