function page_3() { $users = new usersMenus(); if ($_COOKIE["username"] == null) { $sock = new sockets(); if ($sock->GET_INFO("PostmasterAdress") == null) { $username = "******"; } else { $username = $sock->GET_INFO("PostmasterAdress"); } } else { $username = $_COOKIE["username"]; } $html = "\n\t\n\t<p class=caption>{first_email_text}</p>\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend nowrap>{username}:</td>\n\t\t<td>" . Field_text('username', $username, 'width:100px') . "<strong style='font-size:12px'>@{$_COOKIE["smtp_domain"]}</strong></td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend nowrap>{password}:</td>\n\t\t<td>" . Field_text('password', $_COOKIE["password"]) . "</td>\n\t</tr>\t\n\t</table>\n\t\n\t\n\t"; echo BuildPage('{first_email}', $html); }
function RebuildPages($callback = null) { global $DB, $C, $L; // One at a time please $wouldblock = FALSE; $fd = fopen("{$GLOBALS['BASE_DIR']}/data/_build_lock", 'w'); flock($fd, LOCK_EX | LOCK_NB, $wouldblock); if ($wouldblock) { return; } if (!preg_match('~^\\d\\d\\d$~', $C['page_permissions'])) { $C['page_permissions'] = $GLOBALS['FILE_PERMISSIONS']; } else { $C['page_permissions'] = octdec('0' . $C['page_permissions']); } // Cache items $GLOBALS['ICON_CACHE'] =& $DB->FetchAll('SELECT * FROM `tlx_icons`', null, 'icon_id'); $GLOBALS['CATEGORY_CACHE'] =& $DB->FetchAll('SELECT * FROM `tlx_categories`', null, 'category_id'); // Count total thumbs and galleries $GLOBALS['_total_accounts'] = $DB->Count("SELECT COUNT(*) FROM `tlx_accounts` WHERE `status`='active' AND `disabled`=0"); // Update the last rank information and clear the rank tables $DB->Update('UPDATE `tlx_accounts` LEFT JOIN `tlx_account_ranks` USING (`username`) SET `last_rank`=`rank`'); $DB->Update('UPDATE `tlx_accounts` LEFT JOIN `tlx_account_category_ranks` USING (`username`) SET `last_category_rank`=`category_rank`'); $DB->Update('DELETE FROM `tlx_account_ranks`'); $DB->Update('DELETE FROM `tlx_account_category_ranks`'); // Build each page $result = $DB->Query('SELECT * FROM `tlx_pages` ORDER BY `build_order`'); while ($page = $DB->NextRow($result)) { if ($callback) { call_user_func($callback, $page); } BuildPage($page); } $DB->Free($result); StoreValue('last_rebuild', TIME_NOW); flock($fd, LOCK_UN); fclose($fd); @chmod("{$GLOBALS['BASE_DIR']}/data/_build_lock", 0666); }
function BuildPages(&$pages, $callback = null, $all = FALSE) { global $DB, $C, $L; // One at a time please $wouldblock = FALSE; $fd = fopen("{$GLOBALS['BASE_DIR']}/data/_build_lock", 'w'); flock($fd, LOCK_EX | LOCK_NB, $wouldblock); if ($wouldblock) { return; } // Clear old build history $DB->Update('DELETE FROM `tx_build_history` WHERE `date_start` < DATE_ADD(?, INTERVAL -14 DAY)', array(MYSQL_NOW)); $DB->Update('INSERT INTO `tx_build_history` VALUES (?,?,?,?,?,?,?)', array(null, MYSQL_NOW, null, null, count($pages), 0, null)); $GLOBALS['build_history_id'] = $DB->InsertID(); if (!preg_match('~^\\d\\d\\d$~', $C['page_permissions'])) { $C['page_permissions'] = $GLOBALS['FILE_PERMISSIONS']; } else { $C['page_permissions'] = octdec('0' . $C['page_permissions']); } // Clear records of currently used galleries on these pages ClearUsedGalleries($pages, $all); // Process the clicklog ProcessClickLog(); // Cache icons if (!isset($GLOBALS['ICON_CACHE'])) { $GLOBALS['ICON_CACHE'] =& $DB->FetchAll('SELECT * FROM `tx_icons`', null, 'icon_id'); } // Cache categories by tag if (!isset($GLOBALS['CATEGORY_CACHE_TAG'])) { $GLOBALS['CATEGORY_CACHE_TAG'] =& $DB->FetchAll('SELECT * FROM `tx_categories` ORDER BY `name`', null, 'tag'); } // Cache categories by id if (!isset($GLOBALS['CATEGORY_CACHE_ID'])) { $GLOBALS['CATEGORY_CACHE_ID'] =& $DB->FetchAll('SELECT * FROM `tx_categories`', null, 'category_id'); $GLOBALS['CATEGORY_CACHE_ID'][''] = array('name' => $L['MIXED'], 'category_id' => 0); } // Cache sponsors by id if (!isset($GLOBALS['SPONSOR_CACHE'])) { $GLOBALS['SPONSOR_CACHE'] =& $DB->FetchAll('SELECT * FROM `tx_sponsors`', null, 'sponsor_id'); } // Clear data on galleries used during the previous build $DB->Update('UPDATE `tx_gallery_used` SET `this_build`=0,`new`=0'); // Remove galleries scheduled for deletion $result = $DB->Query('SELECT * FROM `tx_galleries` WHERE `date_deletion` <= ?', array(MYSQL_NOW)); while ($gallery = $DB->NextRow($result)) { DeleteGallery($gallery['gallery_id'], $gallery); } $DB->Free($result); // Delete old submitted galleries that are currently holding $result = $DB->Query('SELECT * FROM `tx_galleries` WHERE `status`=? AND `type`=? AND `date_displayed` <= SUBDATE(?, INTERVAL ? DAY)', array('holding', 'submitted', MYSQL_NOW, $C['submitted_hold'])); while ($gallery = $DB->NextRow($result)) { DeleteGallery($gallery['gallery_id'], $gallery); } $DB->Free($result); // Rotate permanent galleries from holding back to approved queue $DB->Update('UPDATE `tx_galleries` SET ' . "`status`='approved', " . "`date_displayed`=NULL, " . "`build_counter`=IF(?, 0, `build_counter`), " . "`used_counter`=IF(?, 0, `used_counter`), " . "`clicks`=IF(?, 0, `clicks`) " . "WHERE `status`='holding' AND `type`='permanent' AND `date_displayed` <= SUBDATE(?, INTERVAL ? DAY)", array(intval($C['reset_on_rotate']), intval($C['reset_on_rotate']), intval($C['reset_on_rotate']), MYSQL_NOW, $C['permanent_hold'])); // Count total thumbs and galleries $GLOBALS['_totals'] = $DB->Row("SELECT COUNT(*) AS `galleries`,SUM(`thumbnails`) AS `thumbnails` FROM `tx_galleries` WHERE `status` IN ('approved','used')"); $GLOBALS['_totals']['categories'] = count($GLOBALS['CATEGORY_CACHE_ID']) - 1; // Build each page foreach ($pages as $page) { $page_all = $DB->Row('SELECT * FROM `tx_pages` WHERE `page_id`=?', array($page['page_id'])); if ($page_all['locked'] && !$GLOBALS['override_page_lock']) { continue; } if ($callback) { call_user_func($callback, $page_all); } $DB->Update('DELETE FROM `tx_gallery_used_page`'); $DB->Update('DELETE FROM `tx_ads_used_page`'); $DB->Update('UPDATE `tx_build_history` SET `current_page_url`=? WHERE `history_id`=?', array($page_all['page_url'], $GLOBALS['build_history_id'])); BuildPage($page_all); $DB->Update('UPDATE `tx_build_history` SET `pages_built`=`pages_built`+1 WHERE `history_id`=?', array($GLOBALS['build_history_id'])); unset($page_all); unset($page); } // Mark newly selected galleries as used // Update counters for galleries used this build $DB->Update('UPDATE `tx_galleries` JOIN `tx_gallery_used` USING (`gallery_id`) SET ' . '`build_counter`=`build_counter`+1, ' . '`used_counter`=`used_counter`+1, ' . '`times_selected`=IF(`new`=1, `times_selected`+1, `times_selected`), ' . '`status`=?, ' . '`date_displayed`=IF(`new`=1, ?, `date_displayed`) ' . 'WHERE `this_build`=1', array('used', MYSQL_NOW)); // Move no longer used galleries to holding queue (or rotate back to approved if permanent holding period is 0) if ($C['permanent_hold'] == 0) { $DB->Update('UPDATE `tx_galleries` LEFT JOIN `tx_gallery_used` USING (`gallery_id`) SET ' . "`status`=IF(`type`='permanent', 'approved', 'holding'), " . "`date_displayed`=IF(`type`='permanent', NULL, `date_displayed`), " . "`date_approved`=IF(`type`='permanent', NULL, `date_approved`), " . "`date_scheduled`=IF(`type`='permanent', NULL, `date_scheduled`), " . "`build_counter`=IF(`type`='permanent', IF(?, 0, `build_counter`+1), `build_counter`+1), " . "`used_counter`=IF(`type`='permanent', IF(?, 0, `used_counter`), `used_counter`), " . "`clicks`=IF(`type`='permanent', IF(?, 0, `clicks`), `clicks`) " . "WHERE `status`='used' AND `page_id` IS NULL", array(intval($C['reset_on_rotate']), intval($C['reset_on_rotate']), intval($C['reset_on_rotate']), 'used')); } else { $DB->Update('UPDATE `tx_galleries` LEFT JOIN `tx_gallery_used` USING (`gallery_id`) SET `status`=?,`build_counter`=`build_counter`+1 WHERE `status`=? AND `page_id` IS NULL', array('holding', 'used')); } $DB->Update('UPDATE `tx_build_history` SET `date_end`=?,`current_page_url`=NULL WHERE `history_id`=?', array(gmdate(DF_DATETIME, TimeWithTz()), $GLOBALS['build_history_id'])); flock($fd, LOCK_UN); fclose($fd); @chmod("{$GLOBALS['BASE_DIR']}/data/_build_lock", 0666); }
foreach ($tabs as $id => $tab) { if (isset($_GET[$id])) { $selectedTab = $id; break; } } } Write("<div class=\"margin width0\" id=\"tabs\">"); foreach ($tabs as $id => $tab) { $selected = $selectedTab == $id ? " selected" : ""; Write("\n\t<button id=\"{2}Button\" class=\"tab{1}\" onclick=\"showEditProfilePart('{2}');\">{0}</button>\n\t", $tab['name'], $selected, $id); } Write("\n</div>\n<form action=\"" . actionLink("editprofile") . "\" method=\"post\" enctype=\"multipart/form-data\">\n"); foreach ($tabs as $id => $tab) { if (isset($tab['page'])) { BuildPage($tab['page'], $id); } elseif ($id == "theme") { Write("\n\t<table class=\"outline margin width100 eptable\" id=\"{0}\"{1}>\n\t\t<tr class=\"header0\"><th>" . __("Theme") . "</th></tr>\n\t\t<tr class=\"cell0\"><td class=\"themeselector\">{2}</td></tr>\n\t</table>\n", $id, $id != $selectedTab ? " style=\"display: none;\"" : "", $themeList); } } $editUserFields = ""; if ($editUserMode) { $editUserFields = format("\n\t\t<input type=\"hidden\" name=\"editusermode\" value=\"1\" />\n\t\t<input type=\"hidden\" name=\"userid\" value=\"{0}\" />\n", $userid); } Write("\n\t<div class=\"margin center width50\" id=\"button\">\n\t\t{2}\n\t\t<input type=\"submit\" id=\"submit\" name=\"action\" value=\"" . __("Edit profile") . "\" />\n\t\t<input type=\"hidden\" name=\"id\" value=\"{0}\" />\n\t\t<input type=\"hidden\" name=\"key\" value=\"{1}\" />\n\t</div>\n</form>\n", $id, $loguser['token'], $editUserFields); function BuildPage($page, $id) { global $selectedTab, $loguser; //TODO: This should be done in JS. //So that a user who doesn't have Javascript will see all the tabs. $display = $id != $selectedTab ? " style=\"display: none;\"" : "";