Пример #1
0
 /**
  * The error page.
  * 
  * @access public
  * @return void
  */
 public function index($type, $locate = '')
 {
     $this->view->title = $this->lang->error->common;
     $this->view->message = isset($this->lang->error->typeList[$type]) ? $this->lang->error->typeList[$type] : $this->lang->error->typeList['notFound'];
     $this->view->locate = helper::safe64Decode($locate);
     $this->display();
 }
Пример #2
0
 /**
  * Cat a file.
  * 
  * @param  string $path
  * @param  int    $revision 
  * @access public
  * @return void
  */
 public function cat($path, $revision)
 {
     $path = helper::safe64Decode($path);
     $this->view->path = $path;
     $this->view->revision = $revision;
     $this->view->code = $this->git->cat($path, $revision);
     $this->display();
 }
Пример #3
0
 /**
  * Cat a file.
  * 
  * @param  string $url 
  * @param  int    $revision 
  * @access public
  * @return void
  */
 public function cat($url, $revision)
 {
     $url = helper::safe64Decode($url);
     $this->view->url = $url;
     $this->view->revision = $revision;
     $this->view->code = $this->svn->cat($url, $revision);
     $this->display();
 }
Пример #4
0
 /**
  * Check current version is latest or not.
  * 
  * @access public
  * @return void
  */
 public function checkUpdate()
 {
     $note = isset($_GET['note']) ? $_GET['note'] : '';
     $browser = isset($_GET['browser']) ? $_GET['browser'] : '';
     $this->view->note = urldecode(helper::safe64Decode($note));
     $this->view->browser = $browser;
     $this->display();
 }
Пример #5
0
 public function getResult($eventID)
 {
     $eventID = helper::safe64Decode($eventID);
     $result = $this->api->getResultByEvent($eventID);
     if ($result->status != 200) {
         $this->send(array('result' => 'fail', 'message' => $result->description));
     }
     $this->session->set('openID', $result->uid);
     $this->session->set('oauthProvider', 'yangcong');
     $this->send(array('result' => 'success'));
 }
Пример #6
0
 /**
  * The interface of api.
  * 
  * @param  int    $filePath 
  * @param  int    $action 
  * @access public
  * @return void
  */
 public function debug($filePath, $action)
 {
     $filePath = helper::safe64Decode($filePath);
     if ($action == 'extendModel') {
         $method = $this->api->getMethod($filePath, 'Model');
     } elseif ($action == 'extendControl') {
         $method = $this->api->getMethod($filePath);
     }
     if (!empty($_POST)) {
         $result = $this->api->request($method->className, $method->methodName, $action);
         $content = json_decode($result['content']);
         $status = $content->status;
         $data = json_decode($content->data);
         $data = '<xmp>' . print_r($data, true) . '</xmp>';
         $response['result'] = 'success';
         $response['status'] = $status;
         $response['url'] = $result['url'];
         $response['data'] = $data;
         $this->send($response);
     }
     $this->view->method = $method;
     $this->view->filePath = $filePath;
     $this->display();
 }
Пример #7
0
 /**
  * Add score.
  * 
  * @param  int    $account 
  * @param  int    $objectType 
  * @param  int    $objectID 
  * @param  int    $score 
  * @access public
  * @return void
  */
 public function addScore($account, $objectType, $objectID)
 {
     $this->loadModel('score');
     if ($objectType == 'thread') {
         $board = $this->dao->select('board')->from(TABLE_THREAD)->where('id')->eq($objectID)->fetch('board');
     }
     if ($objectType == 'reply') {
         $board = $this->dao->select('t1.board')->from(TABLE_THREAD)->alias('t1')->leftJoin(TABLE_REPLY)->alias('t2')->on('t1.id=t2.thread')->where('t2.id')->eq($objectID)->fetch('board');
     }
     if (!isset($board) or !$this->thread->canManage($board)) {
         die;
     }
     if ($_POST) {
         $account = helper::safe64Decode($account);
         if ($objectType == 'thread') {
             $result = $this->score->award($account, 'valueThread', $this->post->count, $objectType, $objectID, $this->post->note);
         }
         if ($objectType == 'reply') {
             $result = $this->score->award($account, 'valueReply', $this->post->count, $objectType, $objectID, $this->post->note);
         }
         if ($result) {
             $this->send(array('result' => 'success', 'locate' => $this->server->http_referer));
         }
         $this->send(array('result' => 'fail', 'message' => dao::getError()));
     }
     $this->view->title = $this->lang->thread->score;
     $this->view->account = $account;
     $this->view->objectType = $objectType;
     $this->view->objectID = $objectID;
     $this->display();
 }
Пример #8
0
 /**
  * Upload zip of Images.
  * 
  * @param  string    $module 
  * @param  string    $params 
  * @access public
  * @return void
  */
 public function uploadImages($module, $params)
 {
     if ($_FILES) {
         $file = $this->file->getUpload('file');
         $file = $file[0];
         if (!$file) {
             die(js::alert($this->lang->error->noData));
         }
         if ($file['extension'] != 'zip') {
             die(js::alert($this->lang->file->errorSuffix));
         }
         if ($file['size'] == 0) {
             die(js::alert($this->lang->file->errorFileUpload));
         }
         if (@move_uploaded_file($file['tmpname'], $this->file->savePath . $file['pathname'])) {
             $zipFile = $this->file->savePath . $file['pathname'];
             $filePath = $this->file->extractZip($zipFile);
             unlink($zipFile);
             if (!$filePath) {
                 die(js::alert($this->lang->file->errorExtract));
             }
             $this->session->set($module . 'ImagesFile', $filePath);
             die(js::locate($this->createLink($module, 'batchCreate', helper::safe64Decode($params)), 'parent.parent'));
         }
     }
     $this->display();
 }
Пример #9
0
</th>
            <td><?php 
echo $plan->begin;
?>
</td>
          </tr>
          <tr>
            <th><?php 
echo $lang->productplan->end;
?>
</th>
            <td><?php 
echo $plan->end;
?>
</td>
          </tr>
        </table>
      </fieldset>
      <?php 
include '../../common/view/action.html.php';
?>
    </div>
  </div>
</div>
<?php 
js::set('param', helper::safe64Decode($param));
js::set('link', $link);
js::set('planID', $plan->id);
js::set('orderBy', $orderBy);
js::set('type', $type);
include '../../common/view/footer.html.php';
Пример #10
0
 /**
  * Ignore bind an openID and an account.
  * 
  * @access public
  * @return void
  */
 public function ignoreBind()
 {
     $provider = $this->session->oauthProvider;
     $openID = $this->session->openID;
     $this->post->set('account', uniqid("{$provider}_"));
     // Create a uniq account.
     if ($provider == 'qq') {
         $this->post->set('realname', htmlspecialchars($this->session->openUser->nickname));
     }
     // Set the realname.
     if ($provider == 'sina') {
         $this->post->set('realname', htmlspecialchars($this->session->openUser->name));
     }
     // Set the realname.
     $this->user->registerOauthAccount($provider, $openID);
     $user = $this->user->getUserByOpenID($provider, $openID);
     $this->session->set('random', md5(time() . mt_rand()));
     if ($user and $this->user->login($user->account, md5($user->password . $this->session->random))) {
         if ($referer) {
             $this->locate(helper::safe64Decode($referer));
         }
         /* No referer, go to the user control panel. */
         $default = $this->config->user->default;
         $this->locate($this->createLink($default->module, $default->method));
     } else {
         die('some error occers.');
     }
 }
Пример #11
0
          <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">X</span></button>
          <h4 class="modal-title"><?php 
        echo $lang->guarder->verify;
        ?>
</h4>
        </div>
        <div class="modal-body">
  <?php 
    }
    ?>
  <form class='form-inline' id='validateForm' action="<?php 
    echo $this->createLink('guarder', 'validate', "url={$url}&target={$target}&account={$account}&method={$method}");
    ?>
" method='post' style='min-height:165px'>
    <?php 
    $refUrl = helper::safe64Decode($url) == 'close' ? $this->app->getURI() : helper::safe64Decode($url);
    ?>
    <?php 
    $fileBtn = html::a($refUrl, $lang->guarder->created, "class='btn btn-sm btn-primary okFile'");
    ?>
    <table class='table table-form'>
      <tr>
        <th class='w-100px'><?php 
    echo $lang->guarder->options;
    ?>
</th>
        <td colspan='3'>
          <?php 
    $types = array();
    $options = explode(',', $this->config->site->importantValidate);
    if (in_array('securityQuestion', $options)) {
Пример #12
0
 /**
  * Install a extension
  * 
  * @param  string $extension 
  * @param  string $downLink 
  * @param  string $md5 
  * @param  string $type 
  * @param  string $overridePackage 
  * @param  string $ignoreCompatible 
  * @param  string $overrideFile 
  * @param  string $agreeLicense 
  * @param  int    $upgrade 
  * @access public
  * @return void
  */
 public function install($extension, $downLink = '', $md5 = '', $type = '', $overridePackage = 'no', $ignoreCompatible = 'no', $overrideFile = 'no', $agreeLicense = 'no', $upgrade = 'no')
 {
     $this->view->error = '';
     $installTitle = $upgrade == 'no' ? $this->lang->extension->install : $this->lang->extension->upgrade;
     $installType = $upgrade == 'no' ? $this->lang->extension->installExt : $this->lang->extension->upgradeExt;
     $this->view->installType = $installType;
     $this->view->upgrade = $upgrade;
     $this->view->title = $installTitle . $this->lang->colon . $extension;
     /* Get the package file name. */
     $packageFile = $this->extension->getPackageFile($extension);
     if ($downLink) {
         /* Checking download path. */
         $return = $this->extension->checkDownloadPath();
         if ($return->result != 'ok') {
             $this->view->error = $return->error;
             die($this->display());
         }
         /* Check file exists or not. */
         if (file_exists($packageFile) and $overridePackage == 'no') {
             $overrideLink = inlink('install', "extension={$extension}&downLink={$downLink}&md5={$md5}&type={$type}&overridePackage=yes&ignoreCompatible={$ignoreCompatible}&overrideFile={$overrideFile}&agreeLicense={$agreeLicense}&upgrade={$upgrade}");
             $this->view->error = sprintf($this->lang->extension->errorPackageFileExists, $packageFile, $installType, $overrideLink);
             die($this->display());
         }
         /* Download the package file. */
         $this->extension->downloadPackage($extension, helper::safe64Decode($downLink));
         if (!file_exists($packageFile)) {
             $this->view->error = sprintf($this->lang->extension->errorDownloadFailed, $packageFile);
             die($this->display());
         } elseif ($md5 != '' and md5_file($packageFile) != $md5) {
             unlink($packageFile);
             $this->view->error = sprintf($this->lang->extension->errorMd5Checking, $packageFile);
             die($this->display());
         }
     }
     /* Check the package file exists or not. */
     if (!file_exists($packageFile)) {
         $this->view->error = sprintf($this->lang->extension->errorPackageNotFound, $packageFile);
         die($this->display());
     }
     /* Checking the extension pathes. */
     $return = $this->extension->checkExtensionPathes($extension);
     if ($this->session->dirs2Created == false) {
         $this->session->set('dirs2Created', $return->dirs2Created);
     }
     // Save the dirs to be created.
     if ($return->result != 'ok') {
         $this->view->error = $return->errors;
         die($this->display());
     }
     /* Extract the package. */
     $return = $this->extension->extractPackage($extension);
     if ($return->result != 'ok') {
         $this->view->error = sprintf($this->lang->extension->errorExtracted, $packageFile, $return->error);
         die($this->display());
     }
     /* Get condition. e.g. zentao|depends|conflicts. */
     $condition = $this->extension->getCondition($extension);
     $installedExts = $this->extension->getLocalExtensions('installed');
     /* Check version incompatible */
     $incompatible = $condition->zentao['incompatible'];
     if ($this->extension->checkVersion($incompatible)) {
         $this->view->error = sprintf($this->lang->extension->errorIncompatible);
         die($this->display());
     }
     /* Check conflicts. */
     $conflicts = $condition->conflicts;
     if ($conflicts) {
         $conflictsExt = '';
         foreach ($conflicts as $code => $limit) {
             $hasConflicts = false;
             if (isset($installedExts[$code])) {
                 if ($this->extension->compare4Limit($installedExts[$code]->version, $limit)) {
                     $hasConflicts = true;
                 }
             }
             if ($hasConflicts) {
                 $conflictsExt .= $installedExts[$code]->name . " ";
             }
         }
         if ($hasConflicts) {
             $this->view->error = sprintf($this->lang->extension->errorConflicts, $conflictsExt);
             die($this->display());
         }
     }
     /* Check Depends. */
     $depends = $condition->depends;
     if ($depends) {
         $dependsExt = '';
         foreach ($depends as $code => $limit) {
             $noDepends = false;
             if (isset($installedExts[$code])) {
                 if ($this->extension->compare4Limit($installedExts[$code]->version, $limit, 'noBetween')) {
                     $noDepends = true;
                 }
             } else {
                 $noDepends = true;
             }
             $extVersion = '';
             if ($limit == 'all') {
                 $extVersion = 'all';
             } else {
                 if (!empty($limit['min'])) {
                     $extVersion .= '>=V' . $limit['min'];
                 }
                 if (!empty($limit['max'])) {
                     $extVersion .= ' <=V' . $limit['max'];
                 }
             }
             if ($noDepends) {
                 $dependsExt .= $code . "({$extVersion}) ";
             }
         }
         if ($noDepends) {
             $this->view->error = sprintf($this->lang->extension->errorDepends, $dependsExt);
             die($this->display());
         }
     }
     /* Check version compatible. */
     $zentaoCompatible = $condition->zentao['compatible'];
     if (!$this->extension->checkVersion($zentaoCompatible) and $ignoreCompatible == 'no') {
         $ignoreLink = inlink('install', "extension={$extension}&downLink={$downLink}&md5={$md5}&type={$type}&overridePackage={$overridePackage}&ignoreCompatible=yes&overrideFile={$overrideFile}&agreeLicense={$agreeLicense}&upgrade={$upgrade}");
         $returnLink = inlink('obtain');
         $this->view->error = sprintf($this->lang->extension->errorCheckIncompatible, $installType, $ignoreLink, $installType, $returnLink);
         die($this->display());
     }
     /* Check files in the package conflicts with exists files or not. */
     if ($overrideFile == 'no') {
         $return = $this->extension->checkFile($extension);
         if ($return->result != 'ok') {
             $overrideLink = inlink('install', "extension={$extension}&downLink={$downLink}&md5={$md5}&type={$type}&overridePackage={$overridePackage}&ignoreCompatible={$ignoreCompatible}&overrideFile=yes&agreeLicense={$agreeLicense}&upgrade={$upgrade}");
             $returnLink = inlink('obtain');
             $this->view->error = sprintf($this->lang->extension->errorFileConflicted, $return->error, $overrideLink, $returnLink);
             die($this->display());
         }
     }
     if ($upgrade == 'yes') {
         $newInfo = $this->extension->parseExtensionCFG($extension);
         $this->post->upgradeVersion = isset($newInfo->version) ? $newInfo->version : '';
         $oldInfo = $this->extension->getInfoFromDB($extension);
         $this->post->installedVersion = $oldInfo ? $oldInfo->version : '';
     }
     /* Print the license form. */
     if ($agreeLicense == 'no') {
         $extensionInfo = $this->extension->getInfoFromPackage($extension);
         $license = $this->extension->processLicense($extensionInfo->license);
         $agreeLink = inlink('install', "extension={$extension}&downLink={$downLink}&md5={$md5}&type={$type}&overridePackage={$overridePackage}&ignoreCompatible={$ignoreCompatible}&overrideFile={$overrideFile}&agreeLicense=yes&upgrade={$upgrade}");
         $this->view->license = $license;
         $this->view->author = $extensionInfo->author;
         $this->view->agreeLink = $agreeLink;
         die($this->display());
     }
     /* The preInstall hook file. */
     $hook = $upgrade == 'yes' ? 'preupgrade' : 'preinstall';
     if ($preHookFile = $this->extension->getHookFile($extension, $hook)) {
         include $preHookFile;
     }
     /* Save to database. */
     $this->extension->saveExtension($extension, $type);
     /* Copy files to target directory. */
     $this->view->files = $this->extension->copyPackageFiles($extension);
     /* Judge need execute db install or not. */
     $data = new stdclass();
     $data->status = 'installed';
     $data->dirs = $this->session->dirs2Created;
     $data->files = $this->view->files;
     $data->installedTime = helper::now();
     $this->session->set('dirs2Created', array());
     // clean the session.
     /* Execute the install.sql. */
     if ($upgrade == 'no' and $this->extension->needExecuteDB($extension, 'install')) {
         $return = $this->extension->executeDB($extension, 'install');
         if ($return->result != 'ok') {
             $this->view->error = sprintf($this->lang->extension->errorInstallDB, $return->error);
             die($this->display());
         }
     }
     /* Update status, dirs, files and installed time. */
     $this->extension->updateExtension($extension, $data);
     $this->view->downloadedPackage = !empty($downLink);
     /* The postInstall hook file. */
     $hook = $upgrade == 'yes' ? 'postupgrade' : 'postinstall';
     if ($postHookFile = $this->extension->getHookFile($extension, $hook)) {
         include $postHookFile;
     }
     $this->display();
 }
Пример #13
0
 /**
  * set the referer 
  * 
  * @param  string $referer 
  * @access public
  * @return void
  */
 public function setReferer($referer = '')
 {
     if (!empty($referer)) {
         $this->referer = helper::safe64Decode($referer);
     } else {
         $this->referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
     }
 }
Пример #14
0
 /**
  * Delete extension file.
  * 
  * @param  string $filePath 
  * @param  string $confirm 
  * @access public
  * @return void
  */
 public function delete($filePath = '', $confirm = 'no')
 {
     if ($confirm == 'no') {
         die(js::confirm($this->lang->editor->deleteConfirm, inlink('delete', "filePath={$filePath}&confirm=yes")));
     }
     $filePath = helper::safe64Decode($filePath);
     if (file_exists($filePath) and unlink($filePath)) {
         die(js::reload('parent'));
     }
     die(js::alert($this->lang->editor->notDelete));
 }
Пример #15
0
 /**
  * Bind user. 
  * 
  * @param  string $referer 
  * @access public
  * @return void
  */
 public function bind($referer = '')
 {
     if (!$this->session->ssoData) {
         die;
     }
     $ssoData = $this->session->ssoData;
     $userIP = $this->server->remote_addr;
     $code = $this->config->sso->code;
     $key = $this->config->sso->key;
     if ($ssoData->auth != md5($code . $userIP . $ssoData->token . $key)) {
         die;
     }
     $this->loadModel('user');
     if ($_POST) {
         $user = $this->sso->bind();
         if (dao::isError()) {
             die(js::error(dao::getError()));
         }
         /* Authorize him and save to session. */
         $user->rights = $this->user->authorize($user->account);
         $user->groups = $this->user->getGroups($user->account);
         $this->dao->update(TABLE_USER)->set('visits = visits + 1')->set('ip')->eq($userIP)->set('last')->eq($last)->where('account')->eq($user->account)->exec();
         $user->last = date(DT_DATETIME1, $last);
         $this->session->set('user', $user);
         $this->app->user = $this->session->user;
         $this->loadModel('action')->create('user', $user->id, 'login');
         unset($_SESSION['ssoData']);
         die(js::locate(helper::safe64Decode($referer), 'parent'));
     }
     $this->view->title = $this->lang->sso->bind;
     $this->view->users = $this->user->getPairs('nodeleted|noclosed');
     $this->view->data = $ssoData;
     $this->display();
 }
Пример #16
0
 /**
  * Domain pages report.
  * 
  * @param  string    $domain 
  * @param  string    $mode 
  * @param  string    $begin 
  * @param  string    $end 
  * @access public
  * @return void
  */
 public function domainPage($domain, $mode = 'today', $begin = '', $end = '', $recTotal = 0, $recPerPage = 50, $pageID = 1)
 {
     $domain = helper::safe64Decode($domain);
     $date = $this->stat->parseDate($mode, $begin, $end);
     $begin = $date->begin;
     $end = $date->end;
     $this->app->loadClass('pager', $static = true);
     $pager = new pager($recTotal, $recPerPage, $pageID);
     $labels = $this->stat->getDayLabels($begin, $end);
     $this->view->type = $this->lang->stat->domain . ' - ' . $domain;
     $this->view->domain = $domain;
     $this->view->labels = $labels;
     $this->view->mode = $mode;
     $this->view->pages = $this->stat->getPageReport($domain, $begin, $end, $pager);
     $this->view->pager = $pager;
     $this->display();
 }
Пример #17
0
 /**
  * Yangcong login.
  * 
  * @param  string $referer 
  * @access public
  * @return void
  */
 public function yangcongLogin($referer = '')
 {
     $uid = $this->session->openID;
     $user = $this->user->getUserByOpenID('yangcong', $uid);
     /* If user exists login derectly.*/
     if ($user) {
         if ($this->user->login($user->account, md5($user->password . $this->session->random))) {
             if ($referer) {
                 $this->locate(helper::safe64Decode($referer));
             }
             /* No referer, go to the user control panel. */
             $default = $this->config->user->default;
             $this->locate($this->createLink($default->module, $default->method));
         }
         exit;
     }
     if ($this->get->referer != false) {
         if (!empty($referer)) {
             $this->referer = helper::safe64Decode($referer);
         } else {
             $this->referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
         }
     }
     $this->view->title = $this->lang->user->login->common;
     $this->view->referer = $referer;
     die($this->display());
 }
Пример #18
0
 * @author      Chunsheng Wang <*****@*****.**>
 * @package     RanZhi
 * @version     $Id: deny.html.php 3138 2015-11-09 07:32:18Z chujilu $
 */
$moduleName = isset($lang->{$module}->common) ? $lang->{$module}->common : $module;
$methodName = isset($lang->{$module}->{$method}) ? $lang->{$module}->{$method} : $method;
include '../../common/view/header.lite.html.php';
?>
<div class='container w-200px'>
  <div class='alert alert-danger'>
    <h2><?php 
echo $app->user->account, ' ', $lang->user->deny;
?>
</h2>
    <p> <?php 
printf($lang->user->errorDeny, $moduleName, $methodName);
?>
</p>
    <p>
    <?php 
echo html::a($this->createLink($config->default->module), $lang->index->common);
if ($refererBeforeDeny) {
    echo html::a(helper::safe64Decode($refererBeforeDeny), $lang->user->goback);
}
echo html::a($this->createLink('user', 'logout', "referer=" . helper::safe64Encode($denyPage)), $lang->user->relogin);
?>
  </div>
</div>
</body>
</html>
Пример #19
0
 /**
  * Install a package
  * 
  * @param  string $package 
  * @param  string $type 
  * @param  string $overridePackage 
  * @param  string $ignoreCompatible 
  * @param  string $overrideFile 
  * @param  string $agreeLicense 
  * @param  string $upgrade 
  * @access public
  * @return void
  */
 public function install($package, $downLink = '', $md5 = '', $type = '', $overridePackage = 'no', $ignoreCompatible = 'no', $overrideFile = 'no', $agreeLicense = 'no', $upgrade = 'no')
 {
     set_time_limit(0);
     unset($this->lang->package->menu);
     $installedPackage = $this->package->getInfoFromDB($package);
     $installTitle = $upgrade == 'no' ? $this->lang->package->install : $this->lang->package->upgrade;
     $installType = $upgrade == 'no' ? $this->lang->package->installExt : $this->lang->package->upgradeExt;
     $this->view->error = '';
     $this->view->installType = $installType;
     $this->view->upgrade = $upgrade;
     $this->view->title = $installTitle . $this->lang->colon . $package;
     $this->view->subtitle = $this->lang->package->install;
     /* Get the package file name. */
     $packageFile = $this->package->getPackageFile($package);
     if ($downLink) {
         /* Checking download path. */
         $return = $this->package->checkDownloadPath();
         if ($return->result != 'ok') {
             $this->view->error = $return->error;
             die($this->display());
         }
         /* Check file exists or not. */
         if (file_exists($packageFile) and $overridePackage == 'no') {
             $overrideLink = inlink('install', "package={$package}&downLink={$downLink}&md5={$md5}&type={$type}&overridePackage=yes&ignoreCompatible={$ignoreCompatible}&overrideFile={$overrideFile}&agreeLicense={$agreeLicense}&upgrade={$upgrade}");
             $this->view->error = sprintf($this->lang->package->errorPackageFileExists, $packageFile, $installType, $overrideLink);
             die($this->display());
         }
         /* Download the package file. */
         $this->package->downloadPackage($package, helper::safe64Decode($downLink));
         if (!file_exists($packageFile)) {
             $this->view->error = sprintf($this->lang->package->errorDownloadFailed, $packageFile);
             die($this->display());
         } elseif ($md5 != '' and md5_file($packageFile) != $md5) {
             unlink($packageFile);
             $this->view->error = sprintf($this->lang->package->errorMd5Checking, $packageFile);
             die($this->display());
         }
     }
     /* Check the package file exists or not. */
     if (!file_exists($packageFile)) {
         $this->view->error = sprintf($this->lang->package->errorPackageNotFound, $packageFile);
         die($this->display());
     }
     /* Checking the package pathes. */
     $return = $this->package->checkPackagePathes($package);
     if ($this->session->dirs2Created == false) {
         $this->session->set('dirs2Created', $return->dirs2Created);
     }
     // Save the dirs to be created.
     if ($return->result != 'ok') {
         $this->view->error = $return->errors;
         die($this->display());
     }
     /* Extract the package. */
     $return = $this->package->extractPackage($package);
     if ($return->result != 'ok') {
         $this->view->error = sprintf($this->lang->package->errorExtracted, $packageFile, $return->error);
         die($this->display());
     }
     /* Get condition. e.g. chanzhi|depends|conflicts. */
     $condition = $this->package->getCondition($package);
     $installedExts = $this->package->getLocalPackages('installed');
     /* Check version incompatible */
     $incompatible = $condition->chanzhi['incompatible'];
     if ($this->package->checkVersion($incompatible)) {
         $this->view->error = sprintf($this->lang->package->errorIncompatible);
         die($this->display());
     }
     /* Check conflicts. */
     $conflictsResult = $this->package->checkConflicts($condition, $installedExts);
     if ($conflictsResult['result'] == 'fail') {
         $this->view->error = $conflictsResult['error'];
         $this->display();
     }
     /* Check Depends. */
     $depentsResult = $this->package->checkExtRequired($condition->depends, $installedExts);
     if ($depentsResult['result'] == 'fail') {
         $this->view->error = $rdepentsResult['error'];
         $this->display();
     }
     /* Check version compatible. */
     $chanzhiCompatible = $condition->chanzhi['compatible'];
     if (!$this->package->checkVersion($chanzhiCompatible) and $ignoreCompatible == 'no') {
         $ignoreLink = inlink('install', "package={$package}&downLink={$downLink}&md5={$md5}&type={$type}&overridePackage={$overridePackage}&ignoreCompatible=yes&overrideFile={$overrideFile}&agreeLicense={$agreeLicense}&upgrade={$upgrade}");
         $returnLink = inlink('obtain');
         $this->view->error = sprintf($this->lang->package->errorCheckIncompatible, $installType, $ignoreLink, $installType, $returnLink);
         die($this->display());
     }
     /* Check files in the package conflicts with exists files or not. */
     if ($overrideFile == 'no') {
         $return = $this->package->checkFile($package);
         if ($return->result != 'ok') {
             $overrideLink = inlink('install', "package={$package}&downLink={$downLink}&md5={$md5}&type={$type}&overridePackage={$overridePackage}&ignoreCompatible={$ignoreCompatible}&overrideFile=yes&agreeLicense={$agreeLicense}&upgrade={$upgrade}");
             $returnLink = inlink('obtain');
             $this->view->error = sprintf($this->lang->package->errorFileConflicted, $return->error, $overrideLink, $returnLink);
             die($this->display());
         }
     }
     /* Print the license form. */
     if ($agreeLicense == 'no') {
         $packageInfo = $this->package->getInfoFromPackage($package);
         $license = $this->package->processLicense($packageInfo->license);
         $agreeLink = inlink('install', "package={$package}&downLink={$downLink}&md5={$md5}&type={$type}&overridePackage={$overridePackage}&ignoreCompatible={$ignoreCompatible}&overrideFile={$overrideFile}&agreeLicense=yes&upgrade={$upgrade}");
         $this->view->license = $license;
         $this->view->author = $packageInfo->author;
         $this->view->agreeLink = $agreeLink;
         if (isset($license) and $upgrade == 'yes') {
             $this->view->subtitle = sprintf($this->lang->package->upgradeVersion, $installedPackage->version, $packageInfo->version);
         }
         die($this->display());
     }
     /* The preInstall hook file. */
     $hook = $upgrade == 'yes' ? 'preupgrade' : 'preinstall';
     if ($preHookFile = $this->package->getHookFile($package, $hook)) {
         include $preHookFile;
     }
     /* Save to database. */
     $this->package->savePackage($package, $type);
     /* Copy files to target directory. */
     $this->view->files = $this->package->copyPackageFiles($package);
     /* Judge need execute db install or not. */
     $data = new stdclass();
     $data->status = 'installed';
     $data->dirs = $this->session->dirs2Created;
     $data->files = $this->view->files;
     $data->installedTime = helper::now();
     $this->session->set('dirs2Created', array());
     // clean the session.
     /* Execute the install.sql. */
     if ($upgrade == 'no' and $this->package->needExecuteDB($package, 'install')) {
         $return = $this->package->executeDB($package, 'install');
         if ($return->result != 'ok') {
             $this->view->error = sprintf($this->lang->package->errorInstallDB, $return->error);
             die($this->display());
         }
     }
     /* Update status, dirs, files and installed time. */
     $this->package->updatePackage($package, $data);
     $this->view->downloadedPackage = !empty($downLink);
     /* The postInstall hook file. */
     $hook = $upgrade == 'yes' ? 'postupgrade' : 'postinstall';
     if ($postHookFile = $this->package->getHookFile($package, $hook)) {
         include $postHookFile;
     }
     $this->display();
 }
Пример #20
0
 /**
  * Validate.
  *
  * @param  string $url
  * @param  string $target
  * @param  string $account
  * @param  string $type    okFile|email
  * @access public
  * @return void
  */
 public function validate($url = '', $target = 'modal', $account = '', $type = '')
 {
     if ($url == '') {
         $url = helper::safe64Encode('close');
     }
     if ($account == '') {
         $account = $this->app->user->account;
     }
     if ($type != '' and $type != 'okFile' and $type != 'email' and $type != 'securityQuestion') {
         $type = '';
     }
     $question = $this->guarder->getSecurityQuestion($account);
     if ($_POST) {
         $validateType = current($this->post->type);
         if ($validateType == 'email') {
             if (!$this->post->captcha or trim($this->post->captcha) != $this->session->verifyCode) {
                 $this->send(array('result' => 'fail', 'message' => $this->lang->guarder->emailFail));
             }
             $this->session->set('verifyCode', '');
             $this->session->set('verify', 'pass');
         } elseif ($validateType == 'securityQuestion') {
             if (!$this->post->answer or md5(trim($this->post->answer)) != $question->answer) {
                 $this->send(array('result' => 'fail', 'message' => $this->lang->guarder->questionFail));
             }
             $this->session->set('verify', 'pass');
         }
         $this->send(array('result' => 'success', 'message' => $this->lang->mail->verifySuccess, 'locate' => helper::safe64Decode($url), 'target' => $target));
     }
     $this->session->set('verify', '');
     $okFile = $this->loadModel('common')->verifyAdmin();
     $pass = $this->guarder->verify($type);
     $user = $this->loadModel('user')->getByAccount($account);
     $this->view->title = $this->lang->guarder->verify;
     $this->view->url = $url;
     $this->view->target = $target;
     $this->view->account = $account;
     $this->view->question = $question;
     $this->view->type = $type;
     $this->view->email = $user->email;
     $this->view->okFile = $okFile;
     $this->view->pass = $pass;
     $this->display();
 }
Пример #21
0
 /**
  * Set the rerferer.
  * 
  * @param  string   $referer 
  * @access public
  * @return void
  */
 public function setReferer($referer = '')
 {
     if (!empty($referer)) {
         $this->referer = helper::safe64Decode($referer);
     } else {
         $this->referer = $this->server->http_referer ? $this->server->http_referer : '';
     }
 }
Пример #22
0
 /**
  * Bind an open id to an account of chanzhi system.
  * 
  * @access public
  * @return void
  */
 public function oauthBind()
 {
     if (!$this->session->random) {
         $this->session->set('random', md5(time() . mt_rand()));
     }
     if ($this->user->login($this->post->account, md5($this->user->createPassword($this->post->password, $this->post->account) . $this->session->random))) {
         if ($this->user->bindOAuthAccount($this->post->account, $this->session->oauthProvider, $this->session->oauthOpenID)) {
             $default = $this->config->user->default;
             if ($this->post->referer != false) {
                 $this->send(array('result' => 'success', 'locate' => helper::safe64Decode($this->post->referer)));
             }
             if ($this->post->referer == false) {
                 $this->send(array('result' => 'success', 'locate' => $this->createLink($default->module, $default->method)));
             }
         } else {
             $this->send(array('result' => 'fail', 'message' => $this->lang->user->oauth->lblBindFailed));
         }
     }
     $this->send(array('result' => 'fail', 'message' => $this->lang->user->loginFailed));
 }
Пример #23
0
.alert.with-icon > .icon {padding-left: 35px;}
.alert-deny {max-width: 500px; margin: 8% auto; padding: 0; background-color: #FFF; border: 1px solid #DDD; box-shadow: 0px 2px 20px rgba(0, 0, 0, 0.2); border-radius: 6px;}
.btn-link {border-color: none!important}
</style>
<div class='container w-200px'>
  <div class='alert with-icon alert-deny'>
    <i class='icon-frown icon'></i>
    <div class='content'>
      <h2><?php 
echo $app->user->account, ' ', $lang->user->deny;
?>
</h2>
      <p><?php 
printf($lang->user->errorDeny, $moduleName, $methodName);
?>
</p>
      <div class='actions'>
        <?php 
if ($refererBeforeDeny) {
    echo html::a(helper::safe64Decode($refererBeforeDeny), $lang->user->goback, "class='btn btn-primary'");
}
echo html::a($this->createLink($config->default->module), $lang->index->common, "class='btn'");
echo html::a($this->createLink('user', 'logout', "referer=" . helper::safe64Encode($denyPage)), $lang->user->relogin, "class='btn btn-link'");
?>
      </div>
    </div>
  </div>
</div>
</body>
</html>
Пример #24
0
 /**
  * check admin.
  * 
  * @param  string $url 
  * @param  string $target 
  * @param  string $account 
  * @param  string $type    okFile|email 
  * @access public
  * @return void
  */
 public function captcha($url = '', $target = 'modal', $account = '', $type = '')
 {
     if ($url == '') {
         $url = helper::safe64Encode('close');
     }
     if ($account == '') {
         $account = $this->app->user->account;
     }
     if ($type != '' and $type != 'okFile' and $type != 'email') {
         $type = '';
     }
     if ($_POST) {
         if (!$this->post->captcha or trim($this->post->captcha) != $this->session->verifyCode) {
             $this->send(array('result' => 'fail', 'message' => $this->lang->mail->verifyFail));
         }
         $this->session->set('verifyCode', '');
         $this->session->set('verify', 6);
         $this->send(array('result' => 'success', 'message' => $this->lang->mail->verifySuccess, 'locate' => helper::safe64Decode($url), 'target' => $target));
     }
     $this->session->set('verify', '');
     $okFile = $this->loadModel('common')->verfyAdmin();
     $pass = $this->mail->checkVerify($type);
     $user = $this->loadModel('user')->getByAccount($account);
     $this->view->title = $this->lang->mail->verify;
     $this->view->url = $url;
     $this->view->target = $target;
     $this->view->account = $account;
     $this->view->type = $type;
     $this->view->email = $user->email;
     $this->view->okFile = $okFile;
     $this->view->pass = $pass;
     $this->display();
 }