Example #1
1
function sc_check_priv($prob_id, $opened, $user)
{
    if (!function_exists('check_priv')) {
        require __DIR__ . '/privilege.php';
    }
    if (isset($_SESSION['user'])) {
        if (strcmp($user, $_SESSION['user']) == 0 || check_priv(PRIV_SOURCE)) {
            return TRUE;
        }
    }
    require __DIR__ . '/../conf/database.php';
    if (!defined('PROB_HAS_TEX')) {
        require __DIR__ . '/../lib/problem_flags.php';
    }
    if ($opened) {
        $row = mysqli_fetch_row(mysqli_query($con, "select has_tex from problem where problem_id={$prob_id}"));
        if (!$row) {
            return _('There\'s no such problem');
        }
        $prob_flag = $row[0];
        if ($prob_flag & PROB_IS_HIDE && !check_priv(PRIV_INSIDER)) {
            return _('Looks like you can\'t access this page');
        }
        if ($prob_flag & PROB_DISABLE_OPENSOURCE) {
            return _('This solution is not open-source');
        } else {
            if ($prob_flag & PROB_SOLVED_OPENSOURCE) {
                if (isset($_SESSION['user'])) {
                    $query = 'select min(result) from solution where user_id=\'' . $_SESSION['user'] . "' and problem_id={$prob_id} group by problem_id";
                    $user_status = mysqli_query($con, $query);
                    $row = mysqli_fetch_row($user_status);
                    if ($row && $row[0] == 0) {
                        return TRUE;
                    }
                }
                return _('You can\'t see me before solving it');
            } else {
                if (isset($_SESSION['user'])) {
                    $res = mysqli_query($con, "SELECT contest.contest_id,co.contest_id from contest\n                                       RIGHT JOIN (select contest_id from contest_status where user_id='" . $_SESSION['user'] . "' and leave_time is NULL) as cs on (contest.contest_id=cs.contest_id)\n                                       LEFT JOIN (select contest_id from contest_problem where problem_id={$prob_id}) as cp on (contest.contest_id=cp.contest_id)\n                                       LEFT JOIN (select contest_id from contest_owner where user_id='" . $_SESSION['user'] . "') as co on (contest.contest_id=co.contest_id)\n                                       where NOW()>start_time and NOW()<end_time and contest.hide_source_code");
                    $num = mysqli_num_rows($res);
                    if ($num > 0) {
                        $accessible = false;
                        while ($row = mysqli_fetch_row($res)) {
                            if (!is_null($row[1])) {
                                $accessible = true;
                            }
                        }
                        if ($accessible) {
                            return TRUE;
                        } else {
                            return _('You can\'t see me before the contest ends');
                        }
                    }
                    return TRUE;
                }
            }
        }
    }
    return _('Looks like you can\'t access this page');
}
 function action_edit($lid)
 {
     $model = $this->model;
     $model->get_link_by_id($lid);
     if (!isset($_POST['edit'])) {
         $this->view = new Main_View(array(CONTENT => 'Edit_Link', 'edit_data' => $model));
         $this->view->render();
     }
     if (isset($_POST['edit'])) {
         if (isset($_POST['check']) && strcmp($_POST['check'], 'on') == 0) {
             $privacy_status = 'private';
         } else {
             $privacy_status = 'public';
         }
         $model->set_title($_POST['title']);
         $model->set_link($_POST['link']);
         $model->set_description($_POST['description']);
         $model->set_privacy_status($privacy_status);
         $is_saved = $model->save();
         if (!$is_saved) {
             $this->view = new Main_View(array(CONTENT => 'Edit_Link', 'edit_data' => $model));
             $this->view->render();
         } else {
             header('Location: /Link/show_my');
         }
     }
 }
Example #3
0
 /**
  * @param $id   The Quality ID to analyse
  * @return \QualityInfo the object corresponding to the ID
  */
 public function getQualityWithId($id)
 {
     $json = getCall($this->basePath . "/" . $id);
     $quality = QualityInfo::create($json);
     if (strcmp($quality->status, "FINISHED") == 0) {
         $stepsize = 100;
         for ($rep = 0; $rep < count($quality->results); $rep++) {
             $psnr = QualityPSNR::create("{}");
             $psnr->setID($quality->results[$rep]->id);
             $psnr->setStatus($quality->status);
             $psnr->initvalues();
             for ($i = 0; $i < $quality->numberOfFrames; $i += $stepsize + 1) {
                 $json = getCall($this->basePath . "/" . $id . "/psnr/" . $quality->results[$rep]->id . "/" . $i . "/" . ($i + $stepsize));
                 $partPSNR = QualityPartResult::create($json);
                 //var_dump($partPSNR);
                 for ($ii = 0; $ii < count($partPSNR->values); $ii++) {
                     $psnr->addValue($partPSNR->values[$ii]);
                 }
             }
             $quality->addPSNRValues($psnr);
         }
     }
     //var_dump($quality);
     return $quality;
 }
Example #4
0
function endsWith($haystack, $needle, $case = true)
{
    if ($case) {
        return strcmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0;
    }
    return strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0;
}
Example #5
0
function compare($respw, $pw)
{
	if(strcmp($respw, $pw)==0)
		return true;
	else
		return false;
}
function check_command($check_str)
{
    if (strcmp($check_str, "actionTrainees")) {
        return SYMBOL_ERROR;
    }
    return $check_str;
}
function check_command($check_str)
{
    if (strcmp($check_str, "read") && strcmp($check_str, "write")) {
        return SYMBOL_ERROR;
    }
    return $check_str;
}
 /**
  * Set the cultureKey for the login page and get the list of languages
  * @return string The loaded cultureKey
  */
 public function handleLanguageChange()
 {
     $cultureKey = $this->modx->getOption('cultureKey', $_REQUEST, 'en');
     if ($cultureKey) {
         $cultureKey = $this->modx->sanitizeString($cultureKey);
         $this->modx->setOption('cultureKey', $cultureKey);
         $this->modx->setOption('manager_language', $cultureKey);
     }
     $this->setPlaceholder('cultureKey', $cultureKey);
     $languages = $this->modx->lexicon->getLanguageList('core');
     $list = array();
     foreach ($languages as $language) {
         $selected = $language == $cultureKey ? ' selected="selected"' : '';
         $list[] = '<option value="' . $language . '"' . $selected . '>' . $language . '</option>';
     }
     $this->setPlaceholder('languages', implode("\n", $list));
     $this->modx->lexicon->load('login');
     $languageString = $this->modx->lexicon('login_language');
     if (empty($languageString) || strcmp($languageString, 'login_language') == 0) {
         $this->modx->lexicon->load('en:core:login');
         $languageString = $this->modx->lexicon('login_language', array(), 'en');
     }
     $this->setPlaceholder('language_str', $languageString);
     return $cultureKey;
 }
 /**
  * Returns TRUE, if the given property ($value) is a valid array consistent of two equal passwords and their length
  * is between 'minimum' (defaults to 0 if not specified) and 'maximum' (defaults to infinite if not specified)
  * to be specified in the validation options.
  *
  * If at least one error occurred, the result is FALSE.
  *
  * @param mixed $value The value that should be validated
  * @return void
  * @throws \TYPO3\Flow\Validation\Exception\InvalidSubjectException
  */
 protected function isValid($value)
 {
     if (!is_array($value)) {
         throw new \TYPO3\Flow\Validation\Exception\InvalidSubjectException('The given value was not an array.', 1324641197);
     }
     $password = trim(strval(array_shift($value)));
     $repeatPassword = trim(strval(array_shift($value)));
     $passwordNotEmptyValidator = new \TYPO3\Flow\Validation\Validator\NotEmptyValidator();
     $passwordNotEmptyValidatorResult = $passwordNotEmptyValidator->validate($password);
     $repeatPasswordNotEmptyValidator = new \TYPO3\Flow\Validation\Validator\NotEmptyValidator();
     $repeatPasswordNotEmptyValidatorResult = $repeatPasswordNotEmptyValidator->validate($repeatPassword);
     if ($passwordNotEmptyValidatorResult->hasErrors() === TRUE && $repeatPasswordNotEmptyValidatorResult->hasErrors() === TRUE) {
         if (!isset($this->options['allowEmpty']) || isset($this->options['allowEmpty']) && intval($this->options['allowEmpty']) === 0) {
             $this->addError('The given password was empty.', 1324641097);
         }
         return;
     }
     if (strcmp($password, $repeatPassword) !== 0) {
         $this->addError('The passwords did not match.', 1324640997);
         return;
     }
     $stringLengthValidator = new \TYPO3\Flow\Validation\Validator\StringLengthValidator(array('minimum' => $this->options['minimum'], 'maximum' => $this->options['maximum']));
     $stringLengthValidatorResult = $stringLengthValidator->validate($password);
     if ($stringLengthValidatorResult->hasErrors() === TRUE) {
         foreach ($stringLengthValidatorResult->getErrors() as $error) {
             $this->result->addError($error);
         }
     }
 }
Example #10
0
 /**
  * @return array of \app\model\Venue sorted alphabetically by location
  */
 public function getVenuesSortedByLocation()
 {
     usort($this->venues, function ($venueA, $venueB) {
         return strcmp($venueA->getLocation(), $venueB->getLocation());
     });
     return $this->venues;
 }
Example #11
0
 public static function radioButtonList($name, $select, $data, $htmlOptions = array())
 {
     $template = isset($htmlOptions['template']) ? $htmlOptions['template'] : '{input} {label}';
     $separator = isset($htmlOptions['separator']) ? $htmlOptions['separator'] : "<br/>\n";
     unset($htmlOptions['template'], $htmlOptions['separator']);
     $labelOptions = isset($htmlOptions['labelOptions']) ? $htmlOptions['labelOptions'] : array();
     unset($htmlOptions['labelOptions']);
     $items = array();
     $baseID = self::getIdByName($name);
     $id = 0;
     $hasJqueryUIScreenshot = strpos($template, '{jqueryUIScreenshot}') !== false;
     //+
     foreach ($data as $value => $label) {
         $jqueryUIScreenshot = $hasJqueryUIScreenshot ? self::image(Yii::app()->request->baseUrl . '/static/css/ui/' . $value . '/screenshot.png', $label, array('height' => 105, 'title' => $label)) : '';
         //+
         $checked = !strcmp($value, $select);
         $htmlOptions['value'] = $value;
         $htmlOptions['id'] = $baseID . '_' . $id++;
         $option = self::radioButton($name, $checked, $htmlOptions);
         $label = self::label($label, $htmlOptions['id'], $labelOptions);
         $items[] = strtr($template, array('{input}' => $option, '{label}' => $label, '{jqueryUIScreenshot}' => $jqueryUIScreenshot));
         //!
     }
     return implode($separator, $items);
 }
Example #12
0
function cmp_date($a, $b)
{
    if ($a['date'] == $b['date']) {
        return strcmp($a['post']->post_title, $b['post']->post_title);
    }
    return $a['date'] > $b['date'] ? -1 : 1;
}
Example #13
0
 /**
  * @return array
  */
 public function getNavigation()
 {
     //$this->setActiveElements();
     $return = [];
     foreach ($this->pages as $block => $blockPages) {
         if (is_array($blockPages) && count($blockPages) > 0 && $blockPages[0] instanceof rex_be_page_main) {
             uasort($blockPages, function (rex_be_page_main $a, rex_be_page_main $b) {
                 $a_prio = (int) $a->getPrio();
                 $b_prio = (int) $b->getPrio();
                 if ($a_prio == $b_prio || $a_prio <= 0 && $b_prio <= 0) {
                     return strcmp($a->getTitle(), $b->getTitle());
                 }
                 if ($a_prio <= 0) {
                     return 1;
                 }
                 if ($b_prio <= 0) {
                     return -1;
                 }
                 return $a_prio > $b_prio ? 1 : -1;
             });
         }
         $n = $this->_getNavigation($blockPages);
         if (count($n) > 0) {
             $fragment = new rex_fragment();
             $fragment->setVar('navigation', $n, false);
             $return[] = ['navigation' => $n, 'headline' => ['title' => $this->getHeadline($block)]];
         }
     }
     return $return;
 }
Example #14
0
 function GetGroupInfo(LOGGROUP $grp = NULL, $flags = 0)
 {
     $groups = array();
     $res = $this->cache->ListCachedGroups();
     foreach ($res as $gid) {
         if ($grp && strcmp($grp->gid, $gid)) {
             continue;
         }
         $groups[$gid] = array('gid' => $gid, 'name' => $gid);
         if ($flags & REQUEST::NEED_INFO) {
             $postfix = $this->cache->GetCachePostfix($gid);
             $info = $this->cache->GetCacheInfo($postfix, $flags & REQUEST::FLAG_MASK);
             if (!$info) {
                 throw new ADEIException(translate("The CACHE for group (%s) is empty", $grp->gid));
             }
             foreach ($info as $key => &$value) {
                 $groups[$gid][$key] = $value;
             }
             if ($flags & REQUEST::NEED_ITEMINFO) {
                 $groups[$gid]['items'] = $this->cache->GetCacheItemList($postfix);
             }
         }
     }
     return $grp ? $groups[$grp->gid] : $groups;
 }
Example #15
0
function SB_trOrderCmp(&$a, &$b)
{
    if ($a->order == $b->order) {
        return strcmp($a->name, $b->name);
    }
    return $a->order > $b->order ? 1 : -1;
}
function CheckLoginCookie()
{
    global $wpdb, $ewd_feup_user_table_name;
    $LoginTime = get_option("EWD_FEUP_Login_Time");
    $Salt = get_option("EWD_FEUP_Hash_Salt");
    $CookieName = "EWD_FEUP_Login" . "%" . sha1(md5(get_site_url() . $Salt));
    $cookie_name_url_encoded = urlencode($CookieName);
    $Cookie = null;
    if (isset($_COOKIE[$CookieName])) {
        $Cookie = $_COOKIE[$CookieName];
    }
    if (isset($_COOKIE[$cookie_name_url_encoded])) {
        $Cookie = $_COOKIE[$cookie_name_url_encoded];
    }
    $Username = substr($Cookie, 0, strpos($Cookie, "%"));
    $TimeStamp = substr($Cookie, strpos($Cookie, "%") + 1, strrpos($Cookie, "%") - strpos($Cookie, "%"));
    $SecCheck = substr($Cookie, strrpos($Cookie, "%") + 1);
    $UserAgent = $_SERVER['HTTP_USER_AGENT'];
    if (isset($_COOKIE[$CookieName]) || isset($_COOKIE[$cookie_name_url_encoded]) and $TimeStamp < time() + $LoginTime * 60) {
        $UserDB = $wpdb->get_row($wpdb->prepare("SELECT User_Sessioncheck , User_Password FROM {$ewd_feup_user_table_name} WHERE Username ='******'", $Username));
        $DBSeccheck = $UserDB->User_Sessioncheck;
        if (strcmp(sha1($SecCheck . $UserAgent), $DBSeccheck) === 0) {
            $User = array('Username' => $Username, 'User_Password' => $UserDB->User_Password);
            return $User;
        } else {
            return false;
        }
    }
    return false;
}
 function setLanguage($params)
 {
     $locale = Configure::read('Config.language');
     //$locale = 'rus';
     //echo "set: locale: {$locale}\n";
     // first check cookie,
     // then parameter
     // then compare current config value with session
     if ($this->Cookie->read('lang') && !$this->Session->check('Config.language')) {
         $this->Session->write('Config.language', $this->Cookie->read('lang'));
         $locale = $this->Cookie->read('lang');
         //echo "case 1\n";
     } else {
         if (isset($params['lang']) && $params['lang'] != $this->Session->read('Config.language')) {
             $this->Session->write('Config.language', $params['lang']);
             $this->Cookie->write('lang', $params['lang'], null, '20 days');
             $locale = $params['lang'];
             //echo "case 2\n";
         } else {
             if ($this->Session->check('Config.language') && $locale != $this->Session->read('Config.language')) {
                 $locale = $this->Session->read('Config.language');
                 // TODO: uncomment this if your languages  do not work
                 if (strcmp($locale, 'rus') != 0 && strcmp($locale, 'eng') != 0) {
                     $this->Session->write('Config.language', 'rus');
                 }
                 //echo "case 3\n";
             }
         }
     }
     //$locale = 'rus';
     //Configure::write('Config.language', $locale);
     return $locale;
 }
/**
 * Test whether force rewrite should be enabled or not.
 */
function wpseo_title_test()
{
    $options = get_option('wpseo_titles');
    $options['forcerewritetitle'] = false;
    $options['title_test'] = 1;
    update_option('wpseo_titles', $options);
    // Setting title_test to > 0 forces the plugin to output the title below through a filter in class-frontend.php.
    $expected_title = 'This is a Yoast Test Title';
    WPSEO_Utils::clear_cache();
    $args = array('user-agent' => sprintf('WordPress/%1$s; %2$s - Yoast', $GLOBALS['wp_version'], get_site_url()));
    $resp = wp_remote_get(get_bloginfo('url'), $args);
    if ($resp && !is_wp_error($resp) && (200 == $resp['response']['code'] && isset($resp['body']))) {
        $res = preg_match('`<title>([^<]+)</title>`im', $resp['body'], $matches);
        if ($res && strcmp($matches[1], $expected_title) !== 0) {
            $options['forcerewritetitle'] = true;
            $resp = wp_remote_get(get_bloginfo('url'), $args);
            $res = false;
            if ($resp && !is_wp_error($resp) && (200 == $resp['response']['code'] && isset($resp['body']))) {
                $res = preg_match('`/<title>([^>]+)</title>`im', $resp['body'], $matches);
            }
        }
        if (!$res || $matches[1] != $expected_title) {
            $options['forcerewritetitle'] = false;
        }
    } else {
        // If that dies, let's make sure the titles are correct and force the output.
        $options['forcerewritetitle'] = true;
    }
    $options['title_test'] = 0;
    update_option('wpseo_titles', $options);
}
Example #19
0
 public function dologin()
 {
     if ($this->check_loginform() === false) {
         $this->login();
     } else {
         $username = $this->input->post('username');
         $password = $this->input->post('password');
         $rolename = $this->input->post('rolename');
         if ($user = $this->user_model->get_by_username($username)) {
             if ($this->role_model->check_role($rolename, $user['role_id'])) {
                 if ($this->user_model->check_password($password, $user['password'])) {
                     $this->user_model->save_user_session($user);
                     if (!strcmp($rolename, "内容审核员")) {
                         redirect('admin/audit');
                     } else {
                         redirect('admin/index');
                     }
                 } else {
                     $this->data['login_error'] = '用户名或者密码不正确';
                 }
             } else {
                 $this->data['login_error'] = '角色不符合';
             }
         } else {
             $this->data['login_error'] = '用户名没找到';
         }
         $this->load->view('admin/login', $this->data);
     }
 }
function check_command($check_str)
{
    if (strcmp($check_str, "searchppts")) {
        return SYMBOL_ERROR;
    }
    return $check_str;
}
Example #21
0
 /**
  * @descrpition 判断平台是否是SAE
  * @param $appname,运行时所属环境下的应用名称
  * @param $accesskey, 运行时所属环境下的accesskey
  * @return bool
  */
 public static function isSae($appname, $accesskey)
 {
     if (!strcmp(HTTP_APPNAME, $appname) && !strcmp(HTTP_ACCESSKEY, $accesskey)) {
         return true;
     }
     return false;
 }
Example #22
0
 function __construct($module, $version, $module_id = null)
 {
     $this->module = $module;
     $this->version = $version;
     $this->module_id = $module_id;
     $this->prefix = 'newsletter_' . $module;
     $this->logger = new NewsletterLogger($module);
     $this->options = $this->get_options();
     $this->store = NewsletterStore::singleton();
     //$this->logger->debug($module . ' constructed');
     // Version check
     if (is_admin()) {
         $old_version = get_option($this->prefix . '_version', '');
         if (strcmp($old_version, $this->version) != 0) {
             $this->logger->info('Version changed from ' . $old_version . ' to ' . $this->version);
             // Do all the stuff for this version change
             $this->upgrade();
             update_option($this->prefix . '_version', $this->version);
         }
         add_action('admin_menu', array($this, 'admin_menu'));
         $this->available_version = get_option($this->prefix . '_available_version');
     }
     //        if (!empty($this->module_id)) {
     //            add_action($this->prefix . '_version_check', array($this, 'hook_version_check'), 1);
     //        }
 }
 public function updateTranslation($key, $value = '', array $options = array())
 {
     if (!is_array($options) || empty($options)) {
         return false;
     }
     $options['namespace'] = $this->xpdo->getOption('namespace', $options, 'core');
     $options['cultureKey'] = $this->xpdo->getOption('cultureKey', $options, 'en');
     $options['topic'] = $options['namespace'] == 'core' ? 'setting' : 'default';
     $saved = false;
     $entries = $this->xpdo->lexicon->getFileTopic($options['cultureKey'], $options['namespace'], $options['topic']);
     $entry = $this->xpdo->getObject('modLexiconEntry', array('name' => $key, 'namespace' => $options['namespace'], 'language' => $options['cultureKey'], 'topic' => $options['topic']));
     if (!empty($entries[$key]) && $entries[$key] == $value || strcmp($key, $value) == 0 || empty($value)) {
         if ($entry) {
             $saved = $entry->remove();
             $this->xpdo->lexicon->clearCache($options['cultureKey'] . '/' . $options['namespace'] . '/' . $options['topic'] . '.cache.php');
         }
     } else {
         if ($entry == null) {
             $entry = $this->xpdo->newObject('modLexiconEntry');
             $entry->set('name', $key);
             $entry->set('namespace', $options['namespace']);
             $entry->set('language', $options['cultureKey']);
             $entry->set('topic', $options['topic']);
         }
         $entry->set('value', $value);
         $saved = $entry->save();
         $entry->clearCache();
     }
     return $saved;
 }
 /**
  * @param  File[]
  * @return File[] sorted
  */
 protected function sortFiles(array $files)
 {
     usort($files, function (File $a, File $b) {
         return strcmp($a->name, $b->name);
     });
     return $files;
 }
Example #25
0
 /**
  * @param \Traversable $iterator
  * @param int|callable $sort
  * @throws \InvalidArgumentException
  */
 public function __construct(\Traversable $iterator, $sort)
 {
     $this->iterator = $iterator;
     if (self::SORT_BY_NAME === $sort) {
         $this->sort = function ($a, $b) {
             return strcmp($a->getRealpath(), $b->getRealpath());
         };
     } elseif (self::SORT_BY_TYPE === $sort) {
         $this->sort = function ($a, $b) {
             if ($a->isDir() && $b->isFile()) {
                 return -1;
             } elseif ($a->isFile() && $b->isDir()) {
                 return 1;
             }
             return strcmp($a->getRealpath(), $b->getRealpath());
         };
     } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
         $this->sort = function ($a, $b) {
             return $a->getATime() - $b->getATime();
         };
     } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
         $this->sort = function ($a, $b) {
             return $a->getCTime() - $b->getCTime();
         };
     } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
         $this->sort = function ($a, $b) {
             return $a->getMTime() - $b->getMTime();
         };
     } elseif (is_callable($sort)) {
         $this->sort = $sort;
     } else {
         throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
     }
 }
Example #26
0
 protected function generateContent($templatePath, $contentType)
 {
     // We build these into a single string so that we can deploy this resume as a
     // single file.
     $assetPath = join(DIRECTORY_SEPARATOR, array($templatePath, $contentType));
     if (!file_exists($assetPath)) {
         return '';
     }
     $assets = array();
     // Our PHAR deployment can't handle the GlobAsset typically used here
     foreach (new \DirectoryIterator($assetPath) as $fileInfo) {
         if ($fileInfo->isDot() || !$fileInfo->isFile()) {
             continue;
         }
         array_push($assets, new FileAsset($fileInfo->getPathname()));
     }
     usort($assets, function (FileAsset $a, FileAsset $b) {
         return strcmp($a->getSourcePath(), $b->getSourcePath());
     });
     $collection = new AssetCollection($assets);
     switch ($contentType) {
         case 'css':
             $collection->ensureFilter(new Filter\LessphpFilter());
             break;
     }
     return $collection->dump();
 }
Example #27
0
 public function retrieveDatasFromDB($videoId)
 {
     $query = "SELECT Records.userid, value, second FROM Records WHERE Records.videoid=" . $videoId . ' ORDER BY userid, second;';
     $result = $this->conn->query($query);
     $valueArray = array("user" => array());
     $userValues = array("id" => 0, "values" => array());
     $i = 0;
     if ($result->num_rows > 0) {
         //$allRows = $result -> fetch_all(MYSQLI_ASSOC);
         //print_r(var_dump($allRows));
         while ($row = $result->fetch_assoc()) {
             if ($i != 0) {
                 if (strcmp($previousUser, $row["userid"])) {
                     array_push($valueArray["user"], $userValues);
                     $userValues = array("id" => 0, "values" => array());
                 }
             }
             $previousUser = $row["userid"];
             $i++;
             $userValues["id"] = $previousUser;
             array_push($userValues["values"], $row["value"]);
         }
         array_push($valueArray["user"], $userValues);
     } else {
         echo "O rows";
     }
     //print_r(var_dump($valueArray));
     $this->conn->close();
     return $valueArray;
 }
Example #28
0
/**
 * 取得今天要顯示的圖片
 * @return 圖片的完整路徑 (含檔名)
 *     FALSE: 找不到圖片
 **/
function getTodayImage($orgimg)
{
    global $chroot, $imgext;
    $dir = $chroot;
    $now = date('Ymd');
    $imglst = array();
    foreach (array_keys($imgext) as $ext) {
        foreach (glob($dir . "*.{$ext}") as $filename) {
            $name = basename($filename, ".{$ext}");
            if (!is_numeric($name) || strlen($name) != 8) {
                continue;
            }
            if (strcmp($now, $name) < 0) {
                continue;
            }
            $imglst[$name] = $filename;
        }
    }
    if (count($imglst) <= 0) {
        setCache($orgimg);
        return FALSE;
    } else {
        krsort($imglst);
        $img = array_shift($imglst);
        setCache($img);
        return $img;
    }
}
Example #29
0
 /**
  * 检查签名
  * @param  String  $power_id  资源ID
  * @param  String  $signature 签名
  * @return bool
  */
 private function check_power_key()
 {
     $this->load->model('accessModel/Power_model', 'power');
     $power = $this->power->get($this->power_id);
     if (empty($power)) {
         log_message('debug', sprintf("%s---power_id:%s,signature:%s, power_id is not exists", $this->session_id, $this->power_id, $this->signature));
         return FALSE;
     }
     //组织签名数据
     $post = $this->input->post();
     unset($post['signature']);
     if (isset($post['callback'])) {
         $post['callback'] = urlencode($post['callback']);
     }
     if (isset($post['username'])) {
         $post['username'] = urlencode($post['username']);
     }
     //比对签名
     $this->load->helper('signature');
     $t_signature = get_signature($post, $power['power_key']);
     //var_dump($t_signature);
     log_message('debug', sprintf("%s--signature:%s,t_signature:%s", $this->session_id, $this->signature, $t_signature));
     $cmp_resut = strcmp($this->signature, $t_signature);
     if ($cmp_resut == 0) {
         return TRUE;
     } else {
         log_message('ERROR', sprintf("%s--signature:%s,t_signature:%s", $this->session_id, $this->signature, $t_signature));
         return FALSE;
     }
 }
 function processTable()
 {
     $this->srcBase->createAndExecuteQuery($this->selectQuery);
     while ($result = $this->srcBase->getQueryResult($this->selectQuery)) {
         $tggrp = new Tggrp();
         $tggrp->TG_GRUPPNAVN = $result['FULLTNAVN'];
         $tggrp->TG_GRUPPEID = $result['GRUPPEID'];
         if (is_null($result['OPPRAVID'])) {
             $tggrp->TG_OPPRAV = Constants::INGENBRUKER_ID;
             $this->logger->log($this->XMLfilename, "TG_OPPRAV is null for TG_GRUPPNAVN (" . $tggrp->TG_GRUPPNAVN . ") setting it to unkown user " . Constants::INGENBRUKER_ID, Constants::LOG_WARNING);
         } else {
             $tggrp->TG_OPPRAV = $result['OPPRAVID'];
         }
         if (strcmp($result['CTYPE'], "T") == 0) {
             $tggrp->TG_GENERELL = '1';
         } else {
             $tggrp->TG_GENERELL = '0';
         }
         $this->logger->log($this->XMLfilename, "TG_GENERELL is missing for TG_GRUPPNAVN (" . $tggrp->TG_GRUPPNAVN . ") assumed a value from CTYPE field (" . $result['CTYPE'] . ") setting TG_GENERELL  to " . $tggrp->TG_GENERELL, Constants::LOG_WARNING);
         if (is_null($result['FRADATO'])) {
             $this->logger->log($this->XMLfilename, "TG_FRADATO is null for TG_GRUPPNAVN (" . $tggrp->TG_GRUPPNAVN . ") setting it to unkown date " . Constants::DATE_AUTO_START, Constants::LOG_WARNING);
             $tggrp->TG_FRADATO = Utility::fixDateFormat(Constants::DATE_AUTO_START);
         } else {
             $tggrp->TG_FRADATO = Utility::fixDateFormat($result['FRADATO']);
         }
         if (is_null($result['TILDATO'])) {
             $this->logger->log($this->XMLfilename, "TG_TILDATO is null for TG_GRUPPNAVN (" . $tggrp->TG_GRUPPNAVN . ") setting it to unkown date " . Constants::DATE_AUTO_END, Constants::LOG_WARNING);
             $tggrp->TG_TILDATO = Utility::fixDateFormat(Constants::DATE_AUTO_END);
         } else {
             $tggrp->TG_TILDATO = Utility::fixDateFormat($result['TILDATO']);
         }
         $this->writeToDestination($tggrp);
     }
     $this->srcBase->endQuery($this->selectQuery);
 }