Ejemplo n.º 1
0
 private function onAdd()
 {
     $form = $this->formAdd();
     if (false !== ($error = $form->validate($this->module))) {
         return $error . $this->templateAdd();
     }
     $file = $form->getVar('file');
     $tmp = $file['tmp_name'];
     $postid = $this->post->getID();
     $userid = GWF_Session::getUserID();
     $options = 0;
     $options |= isset($_POST['guest_view']) ? GWF_ForumAttachment::GUEST_VISIBLE : 0;
     $options |= isset($_POST['guest_down']) ? GWF_ForumAttachment::GUEST_DOWNLOAD : 0;
     # Put in db
     $attach = new GWF_ForumAttachment(array('fatt_aid' => 0, 'fatt_uid' => $userid, 'fatt_pid' => $postid, 'fatt_mime' => GWF_Upload::getMimeType($tmp), 'fatt_size' => filesize($tmp), 'fatt_downloads' => 0, 'fatt_filename' => $file['name'], 'fatt_options' => $options, 'fatt_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND)));
     if (false === $attach->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $aid = $attach->getID();
     # Copy file
     $path = $attach->dbimgPath();
     if (false === GWF_Upload::moveTo($file, $path)) {
         @unlink($tmp);
         return GWF_HTML::err('ERR_WRITE_FILE', $path);
     }
     @unlink($tmp);
     $this->post->increase('post_attachments', 1);
     return $this->module->message('msg_attach_added', array($this->post->getShowHREF()));
 }
Ejemplo n.º 2
0
 public static function markSolved(GWF_User $user, WC_Warchall $chall)
 {
     if (!self::table(__CLASS__)->insertAssoc(array('wc_wcid' => $chall->getID(), 'wc_uid' => $user->getID(), 'wc_solved_at' => GWF_Time::getDate(14)))) {
         return false;
     }
     return true;
 }
Ejemplo n.º 3
0
 public function isFlooding()
 {
     $uid = GWF_Session::getUserID();
     $uname = GWF_Shoutbox::generateUsername();
     $euname = GDO::escape($uname);
     $table = GDO::table('GWF_Shoutbox');
     $max = $uid === 0 ? $this->module->cfgMaxPerDayGuest() : $this->module->cfgMaxPerDayUser();
     //		$cut = GWF_Time::getDate(GWF_Time::LEN_SECOND, time()-$this->module->cfgTimeout());
     //		$cnt = $table->countRows("shout_uname='$euname' AND shout_date>'$cut'");
     # Check captcha
     if ($this->module->cfgCaptcha()) {
         require_once GWF_CORE_PATH . 'inc/3p/Class_Captcha.php';
         if (!PhpCaptcha::Validate(Common::getPostString('captcha'), true)) {
             return GWF_HTML::err('ERR_WRONG_CAPTCHA');
         }
     }
     # Check date
     $timeout = $this->module->cfgTimeout();
     $last_date = $table->selectVar('MAX(shout_date)', "shout_uid={$uid} AND shout_uname='{$euname}'");
     $last_time = $last_date === NULL ? 0 : GWF_Time::getTimestamp($last_date);
     $next_time = $last_time + $timeout;
     if ($last_time + $timeout > time()) {
         return $this->module->error('err_flood_time', array(GWF_Time::humanDuration($next_time - time())));
     }
     # Check amount
     $today = GWF_Time::getDate(GWF_Date::LEN_SECOND, time() - $timeout);
     $count = $table->countRows("shout_uid={$uid} AND shout_date>='{$today}'");
     if ($count >= $max) {
         return $this->module->error('err_flood_limit', array($max));
     }
     # All fine
     return false;
 }
Ejemplo n.º 4
0
 private function onCleanupUntagged()
 {
     $songs = GDO::table('Slay_Song');
     $cut = GWF_Time::getDate(14, time() - 3600);
     $songs->deleteWhere("ss_taggers=0 AND ss_last_played<'{$cut}'");
     return $this->module->message('msg_cleanup');
 }
Ejemplo n.º 5
0
 public function onAddSite()
 {
     $form = $this->getForm();
     if (false !== ($error = $form->validate($this->module))) {
         return $error . $this->templateSiteAdd();
     }
     $site = new WC_Site(array('site_status' => 'wanted', 'site_name' => $form->getVar('site_name'), 'site_classname' => $form->getVar('site_classname'), 'site_country' => 0, 'site_language' => 0, 'site_joindate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'site_launchdate' => '', 'site_authkey' => GWF_Random::randomKey(32), 'site_xauthkey' => GWF_Random::randomKey(32), 'site_irc' => '', 'site_url' => '', 'site_url_mail' => '', 'site_url_score' => '', 'site_url_profile' => '', 'site_score' => 0, 'site_basescore' => 0, 'site_avg' => 0, 'site_vote_dif' => 0, 'site_vote_fun' => 0, 'site_challcount' => 0, 'site_usercount' => 0, 'site_visit_in' => 0, 'site_visit_out' => 0, 'site_options' => 0, 'site_boardid' => 0, 'site_threadid' => 0, 'site_tags' => ''));
     if (false === $site->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     Module_WeChall::includeVotes();
     if (false === $site->onCreateVotes()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     Module_WeChall::includeForums();
     if (false === $site->onCreateBoard()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $site->onCreateThread($this->module)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteDescr.php';
     if (false === WC_SiteDescr::insertDescr($site->getID(), 1, 'Please edit me :)')) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_site_added');
 }
Ejemplo n.º 6
0
 private function getArchiveName()
 {
     if ($this->archiveName === false) {
         return sprintf('www/protected/zipped/%s_%s.zip', GWF_Time::getDate(GWF_Date::LEN_SECOND), implode(',', $this->style));
     } else {
         return $this->archiveName;
     }
 }
Ejemplo n.º 7
0
 public static function createPeak($cid, $count = 0, $options = 0)
 {
     $peak = new self(array('lcpeak_cid' => $cid, 'lcpeak_peak' => $count, 'lcpeak_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'lcpeak_options' => 0));
     if (false === $peak->replace()) {
         return false;
     }
     return $peak;
 }
Ejemplo n.º 8
0
 /**
  * Insert a new quote.
  * @param string $username
  * @param string $text
  * @return Dog_Quote
  */
 public static function insertQuote($username, $text)
 {
     $quote = new self(array('quot_id' => 0, 'quot_text' => $text, 'quot_username' => $username, 'quot_rating' => 0, 'quot_date' => GWF_Time::getDate(14)));
     if (false === $quote->insert()) {
         return false;
     }
     return $quote;
 }
Ejemplo n.º 9
0
 private static function insert_bot($botname)
 {
     $user = new GWF_User(array('user_id' => 0, 'user_options' => GWF_User::BOT | GWF_User::WEBSPIDER, 'user_name' => $botname, 'user_password' => GWF_Password::hashPasswordS('webspider'), 'user_regdate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'user_regip' => GWF_IP6::getIP(GWF_IP_EXACT, '127.0.0.1'), 'user_email' => '', 'user_gender' => 'no_gender', 'user_lastlogin' => 0, 'user_lastactivity' => 0, 'user_birthdate' => '00000000', 'user_avatar_v' => 0, 'user_countryid' => 0, 'user_langid' => 0, 'user_langid2' => 0, 'user_level' => 0, 'user_title' => '', 'user_settings' => NULL, 'user_data' => NULL, 'user_credits' => 0.0));
     if (false === $user->insert()) {
         return false;
     }
     echo "Inserted new Bot: {$botname}<br/>";
     return $user;
 }
Ejemplo n.º 10
0
 public static function insertCrackord(WC_Challenge $chall, $uid, $start, $time, $solved, $count)
 {
     if ($count === 0) {
         return true;
     }
     $failed = $count - $solved;
     $rate = $count > 0 ? $solved / $count * 100 : 0;
     $entry = new self(array('wccc_id' => 0, 'wccc_uid' => $uid, 'wccc_start' => GWF_Time::getDate(GWF_DATE::LEN_SECOND, intval($start)), 'wccc_time' => intval(round($time)), 'wccc_rate' => round($rate, 2), 'wccc_count' => $count, 'wccc_solved' => $solved, 'wccc_failed' => $failed));
     return $entry->insert();
 }
Ejemplo n.º 11
0
 private function onCrossRegister($username)
 {
     $options = 0;
     $password = GWF_Random::randomKey();
     $user = new GWF_User(array('user_id' => 0, 'user_options' => $options, 'user_name' => $username, 'user_password' => GWF_Password::hashPasswordS($password), 'user_regdate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'user_regip' => GWF_IP6::getIP(GWF_IP_EXACT), 'user_email' => '', 'user_gender' => 'no_gender', 'user_lastlogin' => time(), 'user_lastactivity' => time(), 'user_birthdate' => '00000000', 'user_avatar_v' => 0, 'user_countryid' => 0, 'user_langid' => 1, 'user_langid2' => 0, 'user_level' => 0, 'user_title' => '', 'user_settings' => '', 'user_data' => '', 'user_credits' => '0.00'));
     if (false === $user->insert()) {
         return false;
     }
     return true;
 }
Ejemplo n.º 12
0
 public static function checkUser(Module_Download $module, GWF_Download $dl, $user)
 {
     if ($user === false) {
         return false;
     }
     $id = $dl->getID();
     $uid = $user->getID();
     $now = GWF_Time::getDate(GWF_Date::LEN_SECOND);
     return self::table(__CLASS__)->selectVar('1', "dlt_dlid={$id} AND dlt_uid={$uid} AND (dlt_expires='' OR dlt_expires>'{$now}')") === '1';
 }
Ejemplo n.º 13
0
 /**
  * Insert a song into the play history.
  * @param Slay_Song $song
  * @param int $time_end
  */
 public static function insertPlayed(Slay_Song $song, $time_end)
 {
     if (self::getLastID() === $song->getID()) {
         return true;
     }
     $date = GWF_Time::getDate(GWF_Date::LEN_SECOND, $time_end - $song->getVar('ss_duration'));
     if (false === $song->saveVar('ss_last_played', $date)) {
         return false;
     }
     return self::table(__CLASS__)->insertAssoc(array('sph_id' => 0, 'sph_sid' => $song->getID(), 'sph_date' => $date), false);
 }
Ejemplo n.º 14
0
 private static function installPMBot(Module_PM $module)
 {
     $user = new GWF_User(array('user_name' => '_GWF_PM_BOT_', 'user_password' => 'x', 'user_regdate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'user_regip' => GWF_IP6::getIP(GWF_IP_EXACT, '127.0.0.1'), 'user_email' => GWF_BOT_EMAIL, 'user_birthdate' => GWF_Time::getDate(GWF_Time::LEN_DAY), 'user_countryid' => 0, 'user_langid' => 0, 'user_options' => GWF_User::BOT, 'user_lastactivity' => time()));
     if (false === $user->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === GWF_ModuleLoader::saveModuleVar($module, 'pm_bot_uid', $user->getID())) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return '';
 }
Ejemplo n.º 15
0
 public static function insertSuccess(WC_Warflag $flag, GWF_User $user)
 {
     if (false !== ($entry = self::getByFlagUser($flag, $user))) {
         if (!$entry->getVar('wf_solved_at')) {
             return $entry->saveVars(array('wf_attempts' => $entry->getVar('wf_attempts') + 1, 'wf_last_attempt' => NULL, 'wf_solved_at' => GWF_Time::getDate()));
         } else {
             return true;
         }
     }
     return self::table(__CLASS__)->insertAssoc(array('wf_wfid' => $flag->getID(), 'wf_uid' => $user->getID(), 'wf_solved_at' => GWF_Time::getDate(), 'wf_attempts' => '1', 'wf_last_attempt' => NULL));
 }
Ejemplo n.º 16
0
 public static function insertSolution($cid, $uid, $solution)
 {
     $table = self::table(__CLASS__);
     $cid = (int) $cid;
     $uid = (int) $uid;
     $esol = $table->escape($solution);
     if (false !== $table->selectFirst("wmc_cid={$cid} AND wmc_uid={$uid} AND wmc_solution='{$esol}'")) {
         return true;
     }
     return $table->insertAssoc(array('wmc_id' => 0, 'wmc_cid' => $cid, 'wmc_uid' => $uid, 'wmc_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'wmc_length' => strlen($solution), 'wmc_solution' => $solution));
 }
Ejemplo n.º 17
0
 private static function onInstallDefaultGB(Module_Guestbook $module, $dropTable)
 {
     if (false !== ($gb = GWF_Guestbook::getByID(1))) {
         return '';
     }
     $gb = new GWF_Guestbook(array('gb_id' => 1, 'gb_uid' => 0, 'gb_title' => $module->lang('default_title'), 'gb_descr' => $module->lang('default_descr'), 'gb_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'gb_options' => GWF_Guestbook::DEFAULT_OPTIONS));
     if (false === $gb->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return '';
 }
Ejemplo n.º 18
0
 private function onAdd()
 {
     $form = $this->formAdd();
     if (false !== ($error = $form->validate($this->module))) {
         return $error;
     }
     if (!GDO::table('GWF_ProfilePOIWhitelist')->insertAssoc(array('pw_uida' => GWF_Session::getUserID(), 'pw_uidb' => $this->user_to_add->getID(), 'pw_date' => GWF_Time::getDate()))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_white_added', $_POST['user_name']);
 }
Ejemplo n.º 19
0
 public static function insertFirstLink(GWF_User $user, WC_Site $site, $onsitename, $onsitescore)
 {
     $table = self::table(__CLASS__);
     $siteid = $site->getVar('site_id');
     if (false !== $table->getRow($onsitename, $siteid)) {
         return true;
     }
     $entry = new self(array('fili_onsitename' => $onsitename, 'fili_sid' => $siteid, 'fili_date' => GWF_Time::getDate(GWF_Date::LEN_DAY), 'fili_uid' => $user->getVar('user_id'), 'fili_username' => $user->getVar('user_name'), 'fili_sitename' => $site->getVar('site_name'), 'fili_percent' => $site->getPercent($onsitescore)));
     //		echo GWF_HTML::message('DEBUG', 'Insert First Link...');
     return $entry->insert();
 }
Ejemplo n.º 20
0
 private function onAdd()
 {
     $form = $this->getForm();
     if (false !== ($err = $form->validate($this->module))) {
         return $err . $this->templateAdd();
     }
     $group = new GWF_Group(array('group_id' => 0, 'group_name' => $form->getVar('groupname'), 'group_options' => GWF_Group::FULL | GWF_Group::SCRIPT, 'group_lang' => 0, 'group_country' => 0, 'group_founder' => 0, 'group_memberc' => 0, 'group_bid' => 0, 'group_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND)));
     if (false === $group->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)) . $this->templateAdd();
     }
     return $this->module->message('msg_group_added');
 }
Ejemplo n.º 21
0
 public static function populateFile($basedir, $fullpath)
 {
     $mtime = GWF_Time::getDate(GWF_Date::LEN_SECOND, filemtime($fullpath));
     if (false === ($row = self::getByPath($fullpath))) {
         $row = new self(array('vsf_id' => 0, 'vsf_dir' => $basedir, 'vsf_path' => $fullpath, 'vsf_hash' => self::hash(file_get_contents($fullpath)), 'vsf_date' => $mtime));
         return $row->insert();
     }
     if ($row->getVar('vsf_date') < $mtime) {
         return $row->saveVars(array('vsf_hash' => self::hash(file_get_contents($fullpath)), 'vsf_date' => $mtime));
     }
     return true;
 }
Ejemplo n.º 22
0
 private static function createGroups(Module_Audit $module, $dropTable)
 {
     $table = GDO::table('GWF_Group');
     $groups = array('live', 'auditor', 'sysmin', 'poweruser');
     foreach ($groups as $group) {
         if (false !== GWF_Group::getByName($group)) {
             continue;
         }
         if (false === $table->insertAssoc(array('group_name' => $group, 'group_lang' => 1, 'group_date' => GWF_Time::getDate()))) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     }
     return '';
 }
Ejemplo n.º 23
0
 private function onAddLyrics(Slay_Song $song)
 {
     $form = $this->formAddLyrics($song);
     if (false !== ($error = $form->validate($this->module))) {
         return $error;
     }
     $options = isset($_POST['enabled']) ? Slay_Lyrics::ENABLED : 0;
     if (false === GDO::table('Slay_Lyrics')->insertAssoc(array('ssl_sid' => $song->getID(), 'ssl_uid' => GWF_Session::getUserID(), 'ssl_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'ssl_edit_date' => NULL, 'ssl_lyrics' => $form->getVar('lyrics'), 'ssl_options' => $options), true)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $song->updateLyricsCount()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_added_lyrics');
 }
Ejemplo n.º 24
0
 public function onStartup()
 {
     $ms = (string) ((GWF_ONLINE_TIMEOUT / 2 - 1) * 1000);
     GWF_Website::addJavascript(GWF_WEB_ROOT . 'js/module/Heart/hb.js');
     GWF_Website::addJavascriptOnload(sprintf('setTimeout("gwf_heartbeat(%s);", %s);', $ms, $ms));
     $cut = time() - GWF_ONLINE_TIMEOUT;
     $spider = GWF_User::WEBSPIDER;
     $online = GDO::table('GWF_User')->selectVar('COUNT(*)', "user_lastactivity>{$cut} AND user_options&{$spider}=0");
     if ($online > $this->cfgUserrecordCount()) {
         $this->saveModuleVar('hb_userrecord', $online);
         $this->saveModuleVar('hb_recorddate', GWF_Time::getDate(14));
     }
     $pc = $this->cfgPagecount();
     $this->saveModuleVar('hb_pagecount', $pc + 1);
 }
Ejemplo n.º 25
0
 public static function addVotes(Slay_Song $song, GWF_User $user, array $tags)
 {
     $uid = $user->getID();
     $sid = $song->getID();
     $date = GWF_Time::getDate(GWF_Date::LEN_SECOND);
     $table = self::table(__CLASS__);
     foreach ($tags as $tag) {
         if (false === ($tid = Slay_Tag::getIDByName($tag))) {
             return false;
         }
         if (false === $table->insertAssoc(array('stv_uid' => $uid, 'stv_sid' => $sid, 'stv_tid' => $tid, 'stv_date' => $date), false)) {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 26
0
 public function execute()
 {
     $user = GWF_Session::getUser();
     $cnt = GWF_ForumThread::getUnreadThreadCount($user);
     // Save stamp
     $data = $user->getUserData();
     $data[GWF_ForumThread::STAMP_NAME] = GWF_Time::getDate(GWF_Date::LEN_SECOND);
     if (false === $user->saveUserData($data)) {
         return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__);
     }
     // Clean thread table
     $threads = GDO::table('GWF_ForumThread');
     $uid = $user->getVar('user_id');
     if (false === $threads->update("thread_unread=REPLACE(thread_unread, ':{$uid}:', ':'), thread_force_unread=REPLACE(thread_force_unread, ':{$uid}:', ':')")) {
         return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__);
     }
     // 		$cnt = $threads->affectedRows(); # As we mark all read it's easier to assume it works :D
     return $this->module->message('msg_mark_aread', array($cnt));
 }
Ejemplo n.º 27
0
 public static function onActivate(Module_Register $module, $token, $byEmail)
 {
     $ua = GDO::table('GWF_UserActivation');
     if (false === ($row = $ua->getBy('token', $token))) {
         return $module->error('err_activate');
     }
     if ($module->hasIPActivatedRecently()) {
         return $module->error('err_ip_timeout');
     }
     $options = $byEmail === true ? GWF_User::MAIL_APPROVED : 0;
     $username = $row->getVar('username');
     $countryid = $row->getVar('countryid');
     $user = new GWF_User(array('user_id' => 0, 'user_options' => $options, 'user_name' => $username, 'user_password' => $row->getVar('password'), 'user_regdate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'user_regip' => $row->getVar('ip'), 'user_email' => $row->getVar('email'), 'user_gender' => 'no_gender', 'user_lastlogin' => 0, 'user_lastactivity' => time(), 'user_birthdate' => $row->getVar('birthdate'), 'user_avatar_v' => 0, 'user_countryid' => $countryid, 'user_langid' => GWF_LangMap::getPrimaryLangID($countryid), 'user_langid2' => 0, 'user_level' => 0, 'user_title' => '', 'user_settings' => '', 'user_data' => '', 'user_credits' => '0.00'));
     if (false === $user->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $ua->deleteWhere(sprintf('username=\'%s\'', $username))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return self::onActivated($module, $user);
 }
Ejemplo n.º 28
0
 private static function slapB($userid, $targetid, $adverb, $dmg_adv, $verb, $dmg_verb, $adjective, $dmg_adj, $item, $dmg_item, $total_damage)
 {
     //		echo "userid $userid slaps $targetid\n";
     if (false === ($adverb = Dog_SlapItem::getOrCreate('adverb', $adverb, $dmg_adv))) {
         return false;
     }
     if (false === ($verb = Dog_SlapItem::getOrCreate('verb', $verb, $dmg_verb))) {
         return false;
     }
     if (false === ($adjective = Dog_SlapItem::getOrCreate('adjective', $adjective, $dmg_adj))) {
         return false;
     }
     if (false === ($item = Dog_SlapItem::getOrCreate('item', $item, $dmg_item))) {
         return false;
     }
     if (false === self::table(__CLASS__)->insertAssoc(array('lsh_id' => 0, 'lsh_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'lsh_slapper' => $userid, 'lsh_target' => $targetid, 'lsh_adverb' => $adverb->getID(), 'lsh_verb' => $verb->getID(), 'lsh_adjective' => $adjective->getID(), 'lsh_item' => $item->getID(), 'lsh_damage' => $total_damage))) {
         return false;
     }
     $fake_slap = $userid == 0 || $targetid == 0;
     if (!$fake_slap) {
         Dog_SlapStats::increaseStats($userid, $adverb->getID(), 1);
         Dog_SlapStats::increaseStats($userid, $verb->getID(), 1);
         Dog_SlapStats::increaseStats($userid, $adjective->getID(), 1);
         Dog_SlapStats::increaseStats($userid, $item->getID(), 1);
     }
     $column = $fake_slap ? 'lsi_count_a' : 'lsi_count_as';
     if (false === $adverb->increase($column, 1)) {
         return false;
     }
     if (false === $verb->increase($column, 1)) {
         return false;
     }
     if (false === $adjective->increase($column, 1)) {
         return false;
     }
     if (false === $item->increase($column, 1)) {
         return false;
     }
     return true;
 }
Ejemplo n.º 29
0
 public static function populateFile($basedir, $fullpath, $modulename = true, $designname = true)
 {
     if (self::isBlacklisted($fullpath)) {
         return true;
     }
     if (false === ($mtimeOld = GWF_Time::getDate(GWF_Date::LEN_SECOND, @filemtime($fullpath)))) {
         echo GWF_HTML::err('ERR_FILE_NOT_FOUND', array($fullpath));
         return false;
     }
     # Get modulename
     if (is_string($modulename)) {
         // keep
     } elseif ($basedir === 'modules') {
         $modulename = substr($fullpath, 8);
         $modulename = Common::substrUntil($modulename, '/');
     } else {
         $modulename = '';
     }
     # Get designname
     if (is_string($designname)) {
         // keep
     }
     if (preg_match('#.*(^|/)tpl/([^/]+)/.+$#D', $fullpath, $matches)) {
         $designname = $matches[2];
     } else {
         $designname = '';
     }
     self::$size_unpacked += filesize($fullpath);
     if (false === ($row = self::getByPath($fullpath))) {
         //			echo GWF_HTML::message('New File Detected', 'New File: '.$fullpath);
         $row = new self(array('vsf_id' => 0, 'vsf_dir' => $basedir, 'vsf_path' => $fullpath, 'vsf_module' => $modulename, 'vsf_design' => $designname, 'vsf_hash' => self::hash(file_get_contents($fullpath)), 'vsf_date' => $mtimeOld, 'vsf_size' => filesize($fullpath)));
         return $row->insert();
     }
     $mtimeDB = $row->getVar('vsf_date');
     if ($mtimeOld != $mtimeDB) {
         //			echo GWF_HTML::message('New File Detected', 'Updated: '.$fullpath. 'OLD='.$mtimeOld.' | DB='.$mtimeDB);
         return $row->saveVars(array('vsf_hash' => self::hash(file_get_contents($fullpath)), 'vsf_date' => $mtimeOld, 'vsf_size' => filesize($fullpath)));
     }
     return true;
 }
Ejemplo n.º 30
0
 public function execute()
 {
     if (false === ($mod_gb = GWF_Module::loadModuleDB('Guestbook', true))) {
         return GWF_HTML::err('ERR_MODULE_MISSING', array('Guestbook'));
     }
     $mod_gb instanceof Module_Guestbook;
     $user = GWF_Session::getUser();
     if (!$mod_gb->canCreateGuestbook($user)) {
         return $this->module->error('err_create_gb');
     }
     if (false !== ($gb = $mod_gb->getGuestbook($user->getID()))) {
         GWF_Website::redirect($gb->hrefEdit());
         return '';
         //			return $this->module->error('err_have_gb');
     }
     $options = GWF_Guestbook::DEFAULT_OPTIONS;
     $gb = new GWF_Guestbook(array('gb_uid' => $user->getID(), 'gb_title' => $user->getVar('user_name') . 's Guestbook', 'gb_descr' => $user->getVar('user_name') . 's Guestbook', 'gb_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'gb_options' => $options));
     if (false === $gb->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_created_gb', array(GWF_WEB_ROOT . 'guestbook/edit/' . $gb->getID()));
 }