function cleanup($path, $max_age) { $max_age_seconds = $max_age * 60 * 60 * 24; $files_left = 0; if ($dh = @opendir($path)) { while (($file = readdir($dh)) !== false) { if ($file != '.' and $file != '..') { $filepath = "$path/$file"; if (is_dir($filepath)) { if (cleanup($filepath, $max_age) == 0) { rmdir($filepath); } else { $files_left++; } } else { if (file_older($filepath, $max_age_seconds)) { unlink($filepath); } else { $files_left++; } } } } closedir($dh); } return $files_left; }
function findconsolidatephase($game_id, $terr) { $result = mysql_query("SELECT throne1, throne2, throne3, throne4, throne5, throne6 FROM game where id={$game_id}"); $row = mysql_fetch_assoc($result); $orders = array('G' => 0, 'B' => 0, 'L' => 0, 'S' => 0, 'T' => 0, 'M' => 0); $result2 = mysql_query("SELECT name, control, prikaz FROM {$terr}"); $i = 0; while ($array2 = mysql_fetch_assoc($result2)) { if ($array2['prikaz'] == 6 || $array2['prikaz'] == 11) { $orders[$array2['control']]++; } $i++; } $orders2 = array('Greyjoy' => $orders['G'], 'Baratheon' => $orders['B'], 'Lannister' => $orders['L'], 'Stark' => $orders['S'], 'Tyrell' => $orders['T'], 'Martell' => $orders['M']); if ($orders2[$row['throne1']] == 0) { mysql_query("UPDATE `game` SET currentplayer = currentplayer+1 WHERE `id` = {$game_id}"); if ($orders2[$row['throne2']] == 0) { mysql_query("UPDATE `game` SET currentplayer = currentplayer+1 WHERE `id` = {$game_id}"); if ($orders2[$row['throne3']] == 0) { mysql_query("UPDATE `game` SET currentplayer = currentplayer+1 WHERE `id` = {$game_id}"); if ($orders2[$row['throne4']] == 0) { mysql_query("UPDATE `game` SET currentplayer = currentplayer+1 WHERE `id` = {$game_id}"); if ($orders2[$row['throne5']] == 0) { mysql_query("UPDATE `game` SET currentplayer = currentplayer+1 WHERE `id` = {$game_id}"); if ($orders2[$row['throne6']] == 0) { /*mysql_query("UPDATE `game` SET turn = turn+1, faza = 0, currentplayer = 0 WHERE `id` = $game_id");*/ cleanup($game_id, $terr); } } } } } } }
function removal() { global $link; $sql = "DROP DATABASE " . $_SESSION["modCode"]; if (mysql_query($sql, $link)) { $db = mysql_select_db('nell', $link) or die("Couldn't select database"); if (mysql_query("DELETE FROM modules WHERE mod_code = '" . $_SESSION["modCode"] . "'")) { echo ' <div class = "form-group"> <h1> ' . $_SESSION["modCode"] . ' has been deleted </h1> </div> <div class = "form-group"> <a href = "adminPage.php"> Click here to return to the Administrative Homepage </a> </div>'; } else { $code = 2.1; failureMessage($code); } } else { $code = 2.2; failureMessage($code); } cleanup(); }
function removal() { if ($query = mysql_query("UPDATE modules SET lecturer_id = NULL WHERE lecturer_id = " . $_SESSION["lecCode"] . " AND mod_code = '" . $_SESSION["modCode"] . "'")) { echo ' <div class = "form-group"> <h1> ' . $_SESSION["l_name"] . ', ' . $_SESSION["f_name"] . ' has been removed from ' . $_SESSION["modCode"] . ' </h1> </div> <div class = "form-group"> <a href = "adminPage.php"> Click here to return to the Administrative Homepage </a> </div>'; cleanup(); } else { echo ' <div class = "form-group"> <h1> Error 6 </h1> <br/> <h3> ' . $_SESSION["l_name"] . ', ' . $_SESSION["f_name"] . ' could not be removed from ' . $_SESSION["modCode"] . ' </h3> </div> <div class = "form-group"> <a href = "adminPage.php"> Click here to return to the Administrative Homepage </a> </div>'; cleanup(); } }
function getPageTree($parent) { global $admin, $database, $InternPagesSelectBox, $PagesTitleSelectBox; $sql = 'SELECT * FROM `' . TABLE_PREFIX . 'pages` '; $sql .= 'WHERE `parent`= ' . (int) $parent . ' '; $sql .= PAGE_TRASH != 'inline' ? 'AND `visibility` != \'deleted\' ' : ' '; $sql .= 'ORDER BY `position` ASC'; if ($resPage = $database->query($sql)) { while (!false == ($page = $resPage->fetchRow())) { if (!$admin->page_is_visible($page)) { continue; } $menu_title = cleanup($page['menu_title']); $page_title = cleanup($page['page_title']); // Stop users from adding pages with a level of more than the set page level limit if ($page['level'] + 1 <= PAGE_LEVEL_LIMIT) { $title_prefix = ''; for ($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; } $InternPagesSelectBox .= "new Array( '" . $title_prefix . $menu_title . "', '[wblink" . $page['page_id'] . "]'), "; $PagesTitleSelectBox .= "new Array( '" . $page_title . "', '[wblink" . $page['page_id'] . "]'), "; } getPageTree($page['page_id']); } } }
function test_function($step) { $html = <<<EOF <div>lorem ipsum doLor sit amet, ludus munere at Quo, <a href=“#”>mel hinc pAulo concludaturque te</a>. illum populo iracundia Id nam, his ne elitr impedit, Nominavi adipiscinG ex his.</div> EOF; $string = $html; $arr = array(); if ($step >= 1) { $string = strip_tags($html); } if ($step >= 2) { $string = preg_replace('#\\s+#', ' ', $string); } if ($step >= 3) { $string = strtolower($string); } if ($step >= 4) { $arr = explode(" ", $string); } if ($step >= 5) { $arr[0] = ucfirst($arr[0]); for ($i = 1; $i < count($arr); $i++) { if (substr($arr[$i - 1], -1) == ".") { $arr[$i] = ucfirst($arr[$i]); } } $string = implode(" ", $arr); } $pass = true; $message = "There's a problem with your code, try again!"; switch ($step) { case 1: $pass = assert(cleanup($html) == $string); $message = "Your code hasn't removed all tags, try again!"; break; case 2: $pass = assert(cleanup($html) == $string); $message = "Your code hasn't removed the extraneous white space, try again!"; break; case 3: $pass = assert(cleanup($html) == $string); $message = "Your code hasn't made mid-word letters lowercase, try again!"; break; case 4: $pass = assert(cleanup($html) == $arr); $message = "Something's not right, try again!"; break; case 5: $pass = assert(cleanup($html) == $string); $message = "Your code hasn't correctly cased the string, try again!"; break; } if ($pass) { echo json_encode(array('pass' => true)); } else { echo json_encode(array('pass' => false, 'message' => $message)); } }
/** * Create a javascript slideshow of each top level element in the * shortcode. All attributes are optional, but may default to less than ideal * values. Available attributes: * * height => css height of the outputted slideshow, ex. height="100px" * width => css width of the outputted slideshow, ex. width="100%" * transition => length of transition in milliseconds, ex. transition="1000" * cycle => length of each cycle in milliseconds, ex cycle="5000" * animation => The animation type, one of: 'slide' or 'fade' * * Example: * [slideshow height="500px" transition="500" cycle="2000"] * <img src="http://some.image.com" .../> * <div class="robots">Robots are coming!</div> * <p>I'm a slide!</p> * [/slideshow] **/ function sc_slideshow($attr, $content = null) { $content = cleanup(str_replace('<br>', '', $content)); $content = DOMDocument::loadHTML($content); $html = $content->childNodes->item(1); $body = $html->childNodes->item(0); $content = $body->childNodes; # Find top level elements and add appropriate class $items = array(); foreach ($content as $item) { if ($item->nodeName != '#text') { $classes = explode(' ', $item->getAttribute('class')); $classes[] = 'slide'; $item->setAttribute('class', implode(' ', $classes)); $items[] = $item->ownerDocument->saveXML($item); } } $animation = $attr['animation'] ? $attr['animation'] : 'slide'; $height = $attr['height'] ? $attr['height'] : '100px'; $width = $attr['width'] ? $attr['width'] : '100%'; $tran_len = $attr['transition'] ? $attr['transition'] : 1000; $cycle_len = $attr['cycle'] ? $attr['cycle'] : 5000; ob_start(); ?> <div class="slideshow <?php echo $animation; ?> " data-tranlen="<?php echo $tran_len; ?> " data-cyclelen="<?php echo $cycle_len; ?> " style="height: <?php echo $height; ?> ; width: <?php echo $width; ?> ;" > <?php foreach ($items as $item) { ?> <?php echo $item; ?> <?php } ?> </div> <?php $html = ob_get_clean(); return $html; }
function findresults($term) { global $terms, $search_results, $base_terms, $base_url; $url = $base_url . urlencode("how to " . $term); $url = $base_url . urlencode($term); $results = file_get_contents($url); if ($results == "") { error_log("error getting results, throttling\n"); array_push($terms, $term); throttle(); return; } $x = strpos($results, "new Array"); if ($x === false) { error_log("got {$results} for {$url}"); return; } $x += strlen("new Array"); $y = strpos($results, "new Array", $x + 1); $urls = substr($results, $x, $y - $x - 2); $urls = cleanup($urls); if ($urls == "") { return; } // trim the results $url_array = explode(",", $urls); $x = $y + strlen("new Array"); $y = strpos($results, "new Array", $x + 1); $results = substr($results, $x, $y - $x - 2); $results = cleanup($results); $results = preg_replace('/([0-9]),([0-9])/', '$1$2', $results); $results = str_replace(" results", "", $results); $count_array = explode(",", $results); if (sizeof($url_array) == 10) { //print("Adding terms for $term\n"); foreach ($base_terms as $b) { if (strlen($term . $b) < 6) { array_push($terms, $term . $b); } } // add a space only if it isn't already there if (substr($term, strlen($term) - 1, 1) != ' ') { array_push($terms, $term . " "); //printf("Adding space to +$term+ -" . substr($term, strlen($term)-1, 1) . "-\n"); } //print("Terms are now " . sizeof($terms) . " long\n"); } // print_r($array); for ($i = 0; $i < sizeof($url_array); $i++) { $a = $url_array[$i]; $x = array(); $x[0] = $term; $x[1] = $a; $x[2] = $count_array[$i]; $search_results[] = $x; } throttle(); }
function runcmd($desc, $cmd) { echoln($desc); $ret = 0; system($cmd, $ret); if ($ret) { cleanup(); exit; } }
/** * Outputs error messages, cleans up temporaray tables, then dies * NOTE: Halts execution via die(); * @param $messages mixed Array of messages to output */ function halt($messages) { // Iterate over the messages, cleanup and die if (is_array($messages)) { foreach ($messages as $message) { echo "*** {$message}\n"; } } else { echo "*** {$messages}\n"; } cleanup(); die; }
function main() { function cleanup() { global $wpdb; // we need to ensure that we switch off this database $wpdb->select(null); // drop our test database // XXX: why cant we use $wpdb->query ? mysql_query(sprintf('DROP DATABASE `%s`', DISQUS_TEST_DATABASE)) or die(mysql_error()); } global $wpdb; // $this->query(sprintf('DROP DATABASE IF EXISTS `%s`', DISQUS_TEST_DATABASE)); // check existance of test db $exists = $wpdb->get_var($wpdb->prepare('SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = \'%s\'', DISQUS_TEST_DATABASE)); if (!empty($exists)) { printf("Test database '%s' already exists. Continuing will drop this database and all data!\nContinue? [y/n]\n", $exists); $handle = fopen("php://stdin", "r"); $line = strtolower(trim(fgets($handle))); if ($line != 'yes' && $line != 'y') { echo "ABORTING!\n"; exit; } } // setup database $wpdb->query(sprintf('CREATE DATABASE `%s`', DISQUS_TEST_DATABASE)); $wpdb->select(DISQUS_TEST_DATABASE); // $fp = fopen('initial.sql', 'r'); // $buffer = ''; // while (($line = fgets($fp)) !== false) { // $buffer .= trim($line); // if (strpos($line, ';')) { // if (!empty($buffer)) { // $this->query($buffer); // } // $buffer = ''; // } // } // try { $suite = new PHPUnit_Framework_TestSuite('DisqusPluginTest'); $result = $suite->run(); require_once 'PHPUnit/TextUI/ResultPrinter.php'; $printer = new PHPUnit_TextUI_ResultPrinter(); $printer->printResult($result); cleanup(); } catch (Exception $ex) { cleanup(); throw $ex; } }
function init() { global $fail, $pass, $error; $fail = 0; $pass = 0; $error = 0; rename("modules", "modules.tmp") or error("Couldn't move 'modules' directory\n"); mkdir("modules") or error("Couldn't create 'modules' directory\n"); rename("admin.sqlite", "admin.sqlite.tmp") or error("Couldn't move 'admin.sqlite'\n"); # if something went wrong already, bail if ($error) { cleanup(); } }
/** * Find TeX code in text, transform it to images and put images to text. * @param string $text Text. * @return string Transformed text. */ function transform($text) { preg_match_all("/\\[tex\\](.*?)\\[\\/tex\\]/si", $text, $matches); for ($i = 0; $i < count($matches[0]); $i++) { $position = strpos($text, $matches[0][$i]); $code = $matches[1][$i]; $hash = md5(preg_replace('/\\s/', '', $code)); $full_name = Config::ABS_PATH . "/latexcache/{$hash}.png"; $url = Config::DIR_PATH . "/latexcache/{$hash}.png"; if (!is_file($full_name)) { render_latex($code, $hash); cleanup($hash); } $text = substr_replace($text, "<img src=\"{$url}\" alt=\"Formula: {$i}\" />", $position, strlen($matches[0][$i])); } return $text; }
function get_info() { reset_product_array(); get_fields(); cleanup(); set_skus(); set_vendor_code(); set_sku_str(); set_brand(); set_name(); set_type(); set_price(); set_features(); set_description(); set_keywords(); set_main_image(); output_product_str(); }
function getPageTree($parent) { global $admin, $database, $InternPagesSelectBox, $PagesTitleSelectBox; $sql = 'SELECT * FROM `' . TABLE_PREFIX . 'pages` ' . 'WHERE `parent`= ' . (int) $parent . ' AND ' . '`level`<=' . PAGE_LEVEL_LIMIT . ' ' . (PAGE_TRASH != 'inline' ? 'AND `visibility` != \'deleted\' ' : ' ') . 'ORDER BY `position` ASC'; if ($resPage = $database->query($sql)) { while (!(false == ($page = $resPage->fetchRow(MYSQLI_ASSOC)))) { if (!$admin->page_is_visible($page)) { continue; } $menu_title = cleanup($page['menu_title']); $page_title = cleanup($page['page_title']); $title_prefix = str_repeat(' - ', $page['level']); $InternPagesSelectBox .= "new Array( '" . $title_prefix . $menu_title . "', '[wblink" . $page['page_id'] . "]'), "; $PagesTitleSelectBox .= "new Array( '" . $page_title . "', '[wblink" . $page['page_id'] . "]'), "; if ($page['level'] < PAGE_LEVEL_LIMIT) { getPageTree($page['page_id']); } } } }
function commit2DB() { logger("CSV containing directory : " . print_r(CSV_DIR, true)); //exec("sudo chown -R $USER:$USER ".BASE_DIR."/public"); logger("BASE DIR : " . print_r(BASE_DIR, true)); //exec("sudo chown -R root:www-data ".BASE_DIR."/public"); exec("sudo chmod -R 755 " . BASE_DIR . "/public/FileUploader"); exec("sudo chmod -R 755 " . CSV_DIR); // ensuring that the files directory is readable for the program //exec("sudo chmod -R 777 ".CSV_DIR); $res = exec("python " . BASE_DIR . "/public/FileUploader/main.py", $output, $return_var); // $res = exec("python ".BASE_DIR."/public/FileUploader/main.py > /home/pallav/err_log.txt", $output, $return_var); logger("****************\nPython execution reports : \n"); logger("RETURNED : " . print_r($res, true)); logger("OUTPUT : " . print_r($output, true)); logger("RETURN_VAR : " . print_r($return_var, true)); logger("Initiating directory clean-up!!"); cleanup(); logger("CleanUp should be done!!"); }
function stream_content() { $file = get_path_of_first_mp3($_SESSION['result_path']); if (!$file) { http_response_code(404); exit("Missing converted file"); } header("Content-Type: audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3"); header("Content-Transfer-Encoding: binary"); header('Connection: Keep-Alive'); header('Content-length: ' . filesize($file)); header('X-Pad: avoid browser bug'); if ($_GET['dl'] == "1") { header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename="' . basename($file) . '"'); } readfile($file); flush(); cleanup(); }
function prepare() { require_once 'config.php'; //file_put_contents(CONTROLLER_PATH.'xamp.log', "------------------------------------\n\n", FILE_APPEND); header("Content-type: text/" . (XML_SOURCE == true ? 'xml' : 'html') . "; charset=utf-8"); speedAnalyzer('Подключаем ядро'); if (!XAMP_REBUILD) { require_once CONTROLLER_PATH . 'kernel.php'; } if (!class_exists('xamp') || XAMP_REBUILD) { speedAnalyzer('Пересобираем XAMP'); $result = rebuild(PLUGIN_PATH); $result = "<?php \n class xamp \n { \n {$result} \n } \n ?>"; $result .= rebuild(CLASS_PATH, false); file_put_contents(CONTROLLER_PATH . 'kernel.php', $result); require_once CONTROLLER_PATH . 'kernel.php'; } speedAnalyzer('Чистим переменные'); cleanup(); session_start(); }
/** * Do the main task of archiving a course. * * @param int $course_id * @param string $course_code * @return boolean $success */ function doArchive($course_id, $course_code) { global $webDir, $urlServer, $urlAppend, $siteName; if (extension_loaded('zlib')) { include 'include/pclzip/pclzip.lib.php'; } $basedir = "{$webDir}/courses/archive/{$course_code}"; mkpath($basedir); // Remove previous back-ups older than 10 minutes cleanup("{$webDir}/courses/archive", 600); $backup_date = date('Ymd-His'); $backup_date_short = date('Ymd'); $archivedir = $basedir . '/' . $backup_date; mkpath($archivedir); $zipfile = $basedir . "/{$course_code}-{$backup_date_short}.zip"; // backup subsystems from main db $sql_course = "course_id = {$course_id}"; $archive_conditions = array('course' => "id = {$course_id}", 'user' => "id IN (SELECT user_id FROM course_user\n WHERE course_id = {$course_id})", 'course_user' => "course_id = {$course_id}", 'course_settings' => "course_id = {$course_id}", 'course_department' => "course = {$course_id}", 'course_module' => $sql_course, 'hierarchy' => "id IN (SELECT department FROM course_department\n WHERE course = {$course_id})", 'announcement' => $sql_course, 'group_properties' => $sql_course, 'group' => $sql_course, 'group_members' => "group_id IN (SELECT id FROM `group`\n WHERE course_id = {$course_id})", 'document' => $sql_course, 'link_category' => $sql_course, 'link' => $sql_course, 'ebook' => $sql_course, 'ebook_section' => "ebook_id IN (SELECT id FROM ebook\n WHERE course_id = {$course_id})", 'ebook_subsection' => "section_id IN (SELECT ebook_section.id\n FROM ebook, ebook_section\n WHERE ebook.id = ebook_id AND\n course_id = {$course_id})", 'course_units' => $sql_course, 'unit_resources' => "unit_id IN (SELECT id FROM course_units\n WHERE course_id = {$course_id})", 'forum' => $sql_course, 'forum_category' => $sql_course, 'forum_topic' => "forum_id IN (SELECT id FROM forum\n WHERE course_id = {$course_id})", 'forum_post' => "topic_id IN (SELECT forum_topic.id\n FROM forum, forum_topic\n WHERE forum.id = forum_id AND\n course_id = {$course_id})", 'forum_notify' => $sql_course, 'forum_user_stats' => $sql_course, 'course_description' => $sql_course, 'glossary' => $sql_course, 'glossary_category' => $sql_course, 'video_category' => $sql_course, 'video' => $sql_course, 'videolink' => $sql_course, 'dropbox_msg' => $sql_course, 'dropbox_attachment' => "msg_id IN (SELECT id from dropbox_msg WHERE course_id = {$course_id})", 'dropbox_index' => "msg_id IN (SELECT id from dropbox_msg WHERE course_id = {$course_id})", 'lp_learnPath' => $sql_course, 'lp_module' => $sql_course, 'lp_asset' => "module_id IN (SELECT module_id FROM lp_module WHERE course_id = {$course_id})", 'lp_rel_learnPath_module' => "learnPath_id IN (SELECT learnPath_id FROM lp_learnPath WHERE course_id = {$course_id})", 'lp_user_module_progress' => "learnPath_id IN (SELECT learnPath_id FROM lp_learnPath WHERE course_id = {$course_id})", 'wiki_properties' => $sql_course, 'wiki_acls' => "wiki_id IN (SELECT id FROM wiki_properties WHERE course_id = {$course_id})", 'wiki_pages' => "wiki_id IN (SELECT id FROM wiki_properties WHERE course_id = {$course_id})", 'wiki_pages_content' => "pid IN (SELECT id FROM wiki_pages\n WHERE wiki_id IN (SELECT id FROM wiki_properties\n WHERE course_id = {$course_id}))", 'poll' => $sql_course, 'poll_question' => "pid IN (SELECT pid FROM poll WHERE course_id = {$course_id})", 'poll_answer_record' => "pid IN (SELECT pid FROM poll WHERE course_id = {$course_id})", 'poll_question_answer' => "pqid IN (SELECT pqid FROM poll_question\n WHERE pid IN (SELECT pid FROM poll\n WHERE course_id = {$course_id}))", 'assignment' => $sql_course, 'assignment_submit' => "assignment_id IN (SELECT id FROM assignment\n WHERE course_id = {$course_id})", 'gradebook' => $sql_course, 'gradebook_activities' => "gradebook_id IN (SELECT id FROM gradebook\n WHERE course_id = {$course_id})", 'gradebook_book' => "gradebook_activity_id IN (SELECT gradebook_activities.id FROM gradebook_activities, gradebook\n WHERE gradebook.course_id = {$course_id} AND gradebook_activities.gradebook_id = gradebook.id)", 'gradebook_users' => "gradebook_id IN (SELECT id FROM gradebook WHERE course_id = {$course_id})", 'attendance' => $sql_course, 'attendance_activities' => "attendance_id IN (SELECT id FROM attendance\n WHERE course_id = {$course_id})", 'attendance_book' => "attendance_activity_id IN (SELECT attendance_activities.id FROM attendance_activities, attendance\n WHERE attendance.course_id = {$course_id} AND attendance_activities.attendance_id = attendance.id)", 'attendance_users' => "attendance_id IN (SELECT id FROM attendance WHERE course_id = {$course_id})", 'agenda' => $sql_course, 'exercise' => $sql_course, 'exercise_question' => $sql_course, 'exercise_answer' => "question_id IN (SELECT id FROM exercise_question\n WHERE course_id = {$course_id})", 'exercise_user_record' => "eid IN (SELECT id FROM exercise WHERE course_id = {$course_id})", 'exercise_with_questions' => "question_id IN (SELECT id FROM exercise_question\n WHERE course_id = {$course_id}) OR\n exercise_id IN (SELECT id FROM exercise\n WHERE course_id = {$course_id})", 'bbb_session' => "course_id IN (SELECT id FROM bbb_session WHERE course_id = {$course_id})", 'blog_post' => "id IN (SELECT id FROM blog_post WHERE course_id = {$course_id})", 'comments' => "(rtype = 'blogpost' AND rid IN (SELECT id FROM blog_post WHERE course_id = {$course_id})) OR (rtype = 'course' AND rid = {$course_id})", 'rating' => "(rtype = 'blogpost' AND rid IN (SELECT id FROM blog_post WHERE course_id = {$course_id})) OR (rtype = 'course' AND rid = {$course_id})", 'rating_cache' => "(rtype = 'blogpost' AND rid IN (SELECT id FROM blog_post WHERE course_id = {$course_id})) OR (rtype = 'course' AND rid = {$course_id})", 'note' => "(reference_obj_course IS NOT NULL AND reference_obj_course = {$course_id})"); foreach ($archive_conditions as $table => $condition) { backup_table($archivedir, $table, $condition); } file_put_contents("{$archivedir}/config_vars", serialize(array('urlServer' => $urlServer, 'urlAppend' => $urlAppend, 'siteName' => $siteName, 'version' => get_config('version')))); // $htmldir is not needed anywhere //$htmldir = $archivedir . '/html'; // create zip file $zipCourse = new PclZip($zipfile); $result1 = $zipCourse->create($archivedir, PCLZIP_OPT_REMOVE_PATH, "{$webDir}/courses/archive"); $result2 = $zipCourse->add("{$webDir}/courses/{$course_code}", PCLZIP_OPT_REMOVE_PATH, "{$webDir}/courses/{$course_code}", PCLZIP_OPT_ADD_PATH, "{$course_code}/{$backup_date}/html"); $result3 = $zipCourse->add("{$webDir}/video/{$course_code}", PCLZIP_OPT_REMOVE_PATH, "{$webDir}/video/{$course_code}", PCLZIP_OPT_ADD_PATH, "{$course_code}/{$backup_date}/video_files"); $success = true; if ($result1 === 0 || $result2 === 0 || $result3 === 0) { $success = false; } removeDir($archivedir); return $success; }
/** * Handles redirects to other pages. If page argument "ref" has a value, * that will be used as the url for the redirect, overriding the $sURI argument passed to the script. * @param string $target_uri URI to redirect to. * @param string $msg (Optional) message to pass along to the next page. * @throws ConfigurationUndefinedException */ public static function doRedirect($target_uri = '', $msg = null) { if (!defined('P_MESSAGE')) { throw new ConfigurationUndefinedException("P_MESSAGE not defined in app settings."); } if (!defined('P_REFERER')) { throw new ConfigurationUndefinedException("P_REFERER not defined in app settings."); } $_SESSION[P_MESSAGE] = $msg; $uri = Validation::collectStringInput(P_REFERER, FILTER_SANITIZE_URL); if (!$uri) { $uri = $target_uri; } $iPos = strpos($uri, "/"); if (is_numeric($iPos) && $iPos == 0) { /* NB INPUT_SERVER is unreliable with filter_input() */ $uri = 'http://' . $_SERVER['HTTP_HOST'] . $uri; } if (function_exists('cleanup')) { cleanup(); } header("Location: {$uri}\n\n"); exit; }
$description_new = mysql_real_escape_string($description_new); $photographer2 = mysql_real_escape_string($photographer2); $prod = mysql_real_escape_string($prod); $sizes = mysql_real_escape_string($sizes); $all_prints2 = mysql_real_escape_string($all_prints2); $all_sizes2 = mysql_real_escape_string($all_sizes2); $other_galleries2 = mysql_real_escape_string($other_galleries2); $featured2 = mysql_real_escape_string($featured2); $active2 = mysql_real_escape_string($active2); $act_download2 = mysql_real_escape_string($act_download2); } //ADDED IN PS350 TO CLEANUP DATA ENTRY $title_new = cleanup($title_new); $keywords_new = cleanup($keywords_new); $description_new = cleanup($description_new); $price1 = price_cleanup($price1); // ADD A RECORD TO THE DATABASE FOR THIS PHOTO $added1 = date("Ymd"); $sql = "INSERT INTO photo_package (title,gallery_id,keywords,active,featured,added,description,photographer,prod,update_29,all_prints,other_galleries,act_download,sizes,all_sizes) VALUES ('$title_new','$gallery_id2','$keywords_new','$active2','$featured2','$added1','$description_new','$photographer2','$prod','1','$all_prints2','$other_galleries2','$act_download2','$sizes','$all_sizes2')"; $result = mysql_query($sql); // GET THE LAST ID THAT WAS ADDED $last_result = mysql_query("SELECT id FROM photo_package order by id desc", $db); $last = mysql_fetch_object($last_result); $last_id = $last->id; $image = "../ftp/" . $img_files[$i]; // SETTINGS
/** * Main container function in creating the bot's reply. * * This function is the 'manager' of all the sub-funtions that do the real processing. It creates a class * called Response that is used throughout the application. * * @uses addinputs() * @uses addthats() * @uses bget() * @uses cleanup() * @uses getthat() * @uses loadcustomtags() * @uses logconversation() * @uses normalsentences() * @uses respond() * @uses ss_timing_current() * @uses ss_timing_start() * @uses ss_timing_stop() * * @global string that The conversation's previous bot output * @global string topic The contents of the AIML tag 'Topic' * @global integer uid The session ID of the user (previously $uniqueid) * @global integer loopcounter Counts the number of time a particular category is used in the same match trace. * @global array patternmatched The pattern's that matched the * * @param string $userinput The user's input. * @param integer $uniqueid The user's session ID. * @param integer $bot The bot's ID. * * @return object A class link to 'Response'. */ function reply($userinput, $uniqueid, $bot) { if (strstr($userinput, "There is no such a bot loaded")) { $myresponse->response = $userinput; } else { global $that, $topic, $uid, $loopcounter, $patternmatched, $inputmatched, $selectbot; cleanup(); ss_timing_start("all"); $patternmatched = array(); $inputmatched = array(); $myresponse = new Response(); $myresponse->errors = ""; $uid = $uniqueid; $selectbot = $bot; // Load the custom plugin tags loadcustomtags(); // Get the "that" and the "topic" $that = getthat(1, 1); $topic = bget("TOPIC"); // Normalize the input $allinputs = normalsentences($userinput); // If nothing said then use INACTIVITY special input if (sizeof($allinputs) == 0) { $allinputs[] = "INACTIVITY"; } // Put all the inputs into the <input> stack. addinputs($allinputs); $finalanswer = ""; // Build our response to all of the inputs. for ($x = 0; $x < sizeof($allinputs); $x++) { $finalanswer .= respond($allinputs[$x]); } if ($loopcounter > LOOPINGLIMIT && LOOPINGLIMIT != -1) { $finalanswer = LOOPINGERRORMSG; $myresponse->errors = "LOOPINGLIMIT"; } // Put the final answers into the <that> stack. addthats(normalsentences($finalanswer)); // Log the conversation logconversation($userinput, $finalanswer); $myresponse->response = $finalanswer; $myresponse->patternsmatched = $patternmatched; $myresponse->inputs = $inputmatched; ss_timing_stop("all"); $myresponse->timer = ss_timing_current("all"); } return $myresponse; }
$photog_price = price_cleanup($photog_price); $fix_cart1 = price_cleanup($fix_cart1); $fix_cart2 = price_cleanup($fix_cart2); $fix_cart3 = price_cleanup($fix_cart3); $fix_cart4 = price_cleanup($fix_cart4); $fix_cart5 = price_cleanup($fix_cart5); $fix_cart6 = price_cleanup($fix_cart6); $fix_cart7 = price_cleanup($fix_cart7); $fix_cart8 = price_cleanup($fix_cart8); $fix_price1 = price_cleanup($fix_price1); $fix_price2 = price_cleanup($fix_price2); $fix_price3 = price_cleanup($fix_price3); $fix_price4 = price_cleanup($fix_price4); $tax1_name = cleanup($tax1_name); $tax1 = price_cleanup($tax1); $tax2_name = cleanup($tax2_name); $tax2 = price_cleanup($tax2); $sub_price = price_cleanup($sub_price); $sub_price_month = price_cleanup($sub_price_month); $sql = "UPDATE settings SET site_title='{$site_title}',site_tagline='{$site_tagline}',site_url='{$site_url}',support_email='{$support_email}',personal_email='{$personal_email}',site_description='{$site_description}',site_keywords='{$site_keywords}',paypal_email='{$paypal_email}',use_paypal='{$use_paypal}',use_2checkout='{$use_2checkout}',twocheck_account='{$twocheck_account}',default_price='{$default_price}',allow_subs='{$allow_subs}',sub_price='{$sub_price}',allow_subs_month='{$allow_subs_month}',sub_price_month='{$sub_price_month}',style='{$style}',show_num='{$show_num}',show_news='{$show_news}',pf_feed='{$pf_feed}',show_abanner='{$show_abanner}',abanner_name='{$abanner_name}',kaffiliate='{$kaffiliate}',allow_digital='{$allow_digital}',allow_prints='{$allow_prints}',perpage='{$perpage}',show_views='{$show_views}',thumb_width='{$thumb_width}',sample_width='{$sample_width}',dis_columns='{$dis_columns}',allow_ktools='{$allow_ktools}',use_money='{$use_money}',download_days='{$download_days}',show_preview='{$show_preview}',preview_size='{$preview_size}',fix_cart1='{$fix_cart1}',fix_cart2='{$fix_cart2}',fix_cart3='{$fix_cart3}',fix_cart4='{$fix_cart4}',fix_cart5='{$fix_cart5}',fix_cart6='{$fix_cart6}',fix_cart7='{$fix_cart7}',fix_cart8='{$fix_cart8}',fix_price1='{$fix_price1}',fix_price2='{$fix_price2}',fix_price3='{$fix_price3}',fix_price4='{$fix_price4}',tax1='{$tax1}',tax2='{$tax2}',tax_total='{$tax_total}',tax1_name='{$tax1_name}',tax2_name='{$tax2_name}',dis_title_gallery='{$dis_title_gallery}',dis_title_pri='{$dis_title_pri}',dis_title_search='{$dis_title_search}',dis_title_new='{$dis_title_new}',dis_title_popular='{$dis_title_popular}',dis_title_featured='{$dis_title_featured}',dis_filename='{$dis_filename}',hide_id='{$hide_id}',pnpid='{$pnpid}',pnpstatus='{$pnpstatus}',show_private='{$show_private}',show_watermark='{$show_watermark}',large_size='{$large_size}',hover_on='{$hover_on}',hover_usr='******',hover_feature='{$hover_feature}',hover_new='{$hover_new}',hover_popular='{$hover_popular}',hover_gallery='{$hover_gallery}',hover_pri='{$hover_pri}',hover_search='{$hover_search}',sort_by='{$sort_by}',sort_order='{$sort_order}',show_tree='{$show_tree}',show_stats='{$show_stats}',allow_sub_free='{$allow_sub_free}',no_cache='{$no_cache}',no_right_click='{$no_right_click}',debug='{$debug}',slide_type='{$slide_type}',slide_speed='{$slide_speed}',force_members='{$force_members}',force_mac='{$force_mac}',force_approve='{$force_approve}',description_length='{$description_length}',featured='{$featured}',thumb_display_quality='{$thumb_display_quality}',hover_display_quality='{$hover_display_quality}',sample_display_quality='{$sample_display_quality}',large_display_quality='{$large_display_quality}',show_watermark_thumb='{$show_watermark_thumb}',show_watermark_hover='{$show_watermark_hover}',hover_size='{$hover_size}',com_level='{$com_level}',photog_price='{$photog_price}',appc='{$appc}',photog_old_sizes='{$photog_old_sizes}',photog_new_sizes='{$photog_new_sizes}',photog_sizes_locked='{$photog_sizes_locked}',photog_upload='{$photog_upload}',photog_edit='{$photog_edit}',rate_on='{$rate_on}',member_rate='{$member_rate}',use_authorize_net='{$use_authorize_net}',api_login_id='{$api_login_id}',transaction_key='{$transaction_key}',sr_featured='{$sr_featured}',sr_gallery='{$sr_gallery}',sr_pri='{$sr_pri}',sr_new='{$sr_new}',sr_pop='{$sr_pop}',sr_search='{$sr_search}',sr_photog='{$sr_photog}',down_limit_y='{$down_limit_y}',down_limit_m='{$down_limit_m}',print_info='{$print_info}',size_info='{$size_info}',popular='{$popular}',newest='{$newest}',search='{$search}',charset='{$charset}',no_photo_message='{$no_photo_message}',mygatesupport='{$mygatesupport}',mygateid='{$mygateid}',mygateaid='{$mygateaid}',allow_contact_download='{$allow_contact_download}',sub_paypal='{$sub_paypal}',sub_2co='{$sub_2co}',sub_auth='{$sub_auth}',sub_pnp='{$sub_pnp}',sub_mygate='{$sub_mygate}',sub_cmo='{$sub_cmo}',upload_thumb_quality='{$upload_thumb_quality}',upload_sample_quality='{$upload_sample_quality}',upload_large_quality='{$upload_large_quality}',onoff='{$onoff}',dropdown='{$dropdown}',multi_lang='{$multi_lang}',lang='{$lang}',photo_dir='{$photo_dir}',video_dir='{$video_dir}',sample_dir='{$sample_dir}',sample_size='{$sample_size}',photog_upload_email='{$photog_upload_email}',photog_size_width='{$photog_size_width}',photog_size_height='{$photog_size_height}',photog_reg='{$photog_reg}',print_ship='{$print_ship}',thumb_slide_count='{$thumb_slide_count}',modrw='{$modrw}',thumb_slide_arrowcontrol='{$thumb_slide_arrowcontrol}',thumb_slide_border='{$thumb_slide_border}',thumb_slide_bordercolor='{$thumb_slide_bordercolor}',thumb_slide_bordercornerradius='{$thumb_slide_bordercornerradius}',thumb_slide_bordersize='{$thumb_slide_bordersize}',thumb_slide_builtinpreloader='{$thumb_slide_builtinpreloader}',thumb_slide_preloadercolor='{$thumb_slide_preloadercolor}',thumb_slide_easetype='{$thumb_slide_easetype}',thumb_slide_effectamount='{$thumb_slide_effectamount}',thumb_slide_effecttimein='{$thumb_slide_effecttimein}',thumb_slide_effecttimeout='{$thumb_slide_effecttimeout}',thumb_slide_rollovereffect='{$thumb_slide_rollovereffect}',thumb_slide_reverserollovereffect='{$thumb_slide_reverserollovereffect}',thumb_slide_orientation='{$thumb_slide_orientation}',thumb_slide_resizetype='{$thumb_slide_resizetype}',thumb_slide_spacing='{$thumb_slide_spacing}',thumb_slide_thumbheight='{$thumb_slide_thumbheight}',thumb_slide_thumbwidth='{$thumb_slide_thumbwidth}',thumb_slide_speed='{$thumb_slide_speed}',thumb_slide_bgcolor='{$thumb_slide_bgcolor}',pf_mousewheelflip='{$pf_mousewheelflip}',pf_autoflipseconds='{$pf_autoflipseconds}',pf_flipsound='{$pf_flipsound}',pf_flipspeed='{$pf_flipspeed}',pf_namebold='{$pf_namebold}',pf_namecolor='{$pf_namecolor}',pf_namedistance='{$pf_namedistance}',pf_nameposition='{$pf_nameposition}',pf_namesize='{$pf_namesize}',pf_namefont='{$pf_namefont}',pf_preloadset='{$pf_preloadset}',pf_hpers='{$pf_hpers}',pf_vpers='{$pf_vpers}',pf_view='{$pf_view}',pf_reflectionalpha='{$pf_reflectionalpha}',pf_reflectiondepth='{$pf_reflectiondepth}',pf_reflectiondistance='{$pf_reflectiondistance}',pf_reflectionextend='{$pf_reflectionextend}',pf_selectedreflectionalpha='{$pf_selectedreflectionalpha}',pf_showname='{$pf_showname}',pf_showreflection='{$pf_showreflection}',pf_photoheight='{$pf_photoheight}',pf_photowidth='{$pf_photowidth}',pf_selectedy='{$pf_selectedy}',pf_defaultid='{$pf_defaultid}',pf_holderalpha='{$pf_holderalpha}',pf_holderborderalpha='{$pf_holderborderalpha}',pf_holderbordercolor='{$pf_holderbordercolor}',pf_holdercolor='{$pf_holdercolor}',pf_scalemode='{$pf_scalemode}',pf_selectedscale='{$pf_selectedscale}',pf_spacing='{$pf_spacing}',pf_zoom='{$pf_zoom}',pf_zoomtype='{$pf_zoomtype}',pf_bgcolor='{$pf_bgcolor}',leftbox1='{$leftbox1}',leftbox2='{$leftbox2}',leftbox3='{$leftbox3}',leftbox4='{$leftbox4}',leftbox5='{$leftbox5}',leftbox6='{$leftbox6}',headerbox='{$headerbox}',footerbox='{$footerbox}',emailchar='{$emailchar}',flashtrans='{$flashtrans}',flashthumbs='{$flashthumbs}',flashsamples='{$flashsamples}',free_approve='{$free_approve}',flash_featured_on='{$flash_featured_on}',flash_thumb_on='{$flash_thumb_on}',photog_dir='{$photog_dir}',photog_batch_upload='{$photog_batch_upload}',private_search='{$private_search}',search_onoff='{$search_onoff}',cart_price='{$cart_price}',tos_check='{$tos_check}',tax_download='{$tax_download}',menu_click='{$menu_click}' WHERE id = '1'"; $result = mysql_query($sql); $sql = "UPDATE currency SET active=0"; $results = mysql_query($sql, $db); $sql = "UPDATE currency SET active=1 WHERE code='{$code}'"; $results = mysql_query($sql, $db); if ($error1 or $error2 or $error3 or $error4) { header("location: mgr.php?nav=0" . $error1 . $error2 . $error3 . $error4); } else { header("location: mgr.php?nav=0&message=mgr_settings_saved"); } break;
if ($bLinefeed > 0) { $sRetVal .= "\n"; } if ($iWhiteSpaces > 0) { $sRetVal .= str_repeat(" ", $iWhiteSpaces); } if ($iTabs > 0) { $sRetVal .= str_repeat("\t", $iTabs); } return $sRetVal; } $DropletSelectBox = "var DropletSelectBox = new Array( new Array( '', '' )"; $description = "var DropletInfoBox = new Array( new Array( '', '' )"; $usage = "var DropletUsageBox = new Array( new Array( '', '' )"; $array = array(); $sql = 'SELECT * FROM `' . TABLE_PREFIX . 'mod_droplets` '; $sql .= 'WHERE `active`=1 '; $sql .= 'ORDER BY `name` ASC'; if ($resRec = $database->query($sql)) { while (!false == ($droplet = $resRec->fetchRow())) { $title = cleanup($droplet['name']); $desc = cleanup($droplet['description']); $comments = cleanup($droplet['comments']); $DropletSelectBox .= ", new Array( '" . $title . "', '" . $droplet['name'] . "')"; $description .= ", new Array( '" . $title . "', '" . $desc . "')"; $usage .= ", new Array( '" . $title . "', '" . $comments . "')"; } } echo $DropletSelectBox .= " );\n"; echo $description .= " );\n"; echo $usage .= " );\n";
function test() { global $settings; cleanup(); $result = login($this); $this->assertEqual($result->status, "1"); upload_fixture($this, "fm-newstyle.html", "FM"); $this->assertText("Flights successfully imported"); export_to_csv_and_validate($this, "fm-newstyle.csv"); }
unset($restoreData); // Access via $restore->_state to make sure it is always up to date. if ('true' != pb_backupbuddy::_GET('deploy')) { // We dont accept submitted form options during deploy. $restore->_state = parse_options($restore->_state); } else { // Deployment should sleep to help give time for the source site to grab the last status log. sleep(5); } $footer = file_get_contents(pb_backupbuddy::$_plugin_path . '/views/_iframe_footer.php'); if ('true' == pb_backupbuddy::_GET('deploy')) { echo '<h5>Finished deploying pushed data & temporary file cleanup.</h5>'; } echo "<script>bb_showStep( 'finished', " . json_encode($restore->_state) . " );</script>"; sleep(3); cleanup($restore->_state); echo $footer; // We must preload the footer file contents since we are about to delete it. // Parse submitted options/settings. function parse_options($restoreData) { if ('1' == pb_backupbuddy::_POST('delete_backup')) { $restoreData['cleanup']['deleteArchive'] = true; } else { $restoreData['cleanup']['deleteArchive'] = false; } if ('1' == pb_backupbuddy::_POST('delete_temp')) { $restoreData['cleanup']['deleteTempFiles'] = true; } else { $restoreData['cleanup']['deleteTempFiles'] = false; }
function create_subQuestions(&$question, $qid, $varname, $use_answers = false) { global $dom; global $dbprefix; global $connect; global $quexmllang; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; if ($use_answers) { $Query = "SELECT answer as question, code as title FROM {$dbprefix}answers WHERE qid = {$qid} AND language='{$quexmllang}' ORDER BY sortorder ASC"; } else { $Query = "SELECT * FROM {$dbprefix}questions WHERE parent_qid = {$qid} and scale_id = 0 AND language='{$quexmllang}' ORDER BY question_order ASC"; } $QueryResult = db_execute_assoc($Query); while ($Row = $QueryResult->FetchRow()) { $subQuestion = $dom->create_element("subQuestion"); $text = $dom->create_element("text"); $text->set_content(cleanup($Row['question'])); $subQuestion->append_child($text); $subQuestion->set_attribute("varName", $varname . cleanup($Row['title'])); $question->append_child($subQuestion); } return; }
session_start(); $username = $_SESSION["username"]; if (!isset($username) || $username == "") { http_response_code(403); echo "{$username} is not connected. Press connect.\n"; echo "Maybe something went wrong with the session, I don't know. Refresh browser 3 times.\n"; } opendb(); $user = get_user($username); if (!$user) { http_response_code(403); echo "{$username} is not connected. Press connect.\n"; echo "Maybe you've timed out my friend. Refresh browser 5 times\n"; } touch_user($username); cleanup(); $d = opendir(constant('BASEPATH') . $username); $files = array(); while (false !== ($entry = readdir($d))) { if (preg_match("/^\\./", $entry)) { continue; } if (preg_match("/^__/", $entry)) { continue; } array_push($files, $entry); } asort($files); if (count($files) >= 1) { $file = constant('BASEPATH') . $username . '/' . $files[0]; $data = file_get_contents($file);
$username = '******'; $apiKey = 'APIKEY'; $containerToUse = 'CLOUDCONTAINERNAME'; $baseDir = 'YOURSITEPATH/backup/'; $auth = new CF_Authentication($username, $apiKey); $auth->authenticate(); $conn = new CF_Connection($auth); $container = $conn->get_container($containerToUse); function cleanup($prefix) { global $container, $backupsToKeep; $list = $container->list_objects(0, NULL, $prefix); sort($list); $del_list = array_slice($list, 0, -($backupsToKeep - 1)); foreach ($del_list as $file) { $container->delete_object($file); echo $file . ' deleted - '; } } function copytocloud($file, $objName) { global $container, $baseDir; $object = $container->create_object($objName); $result = $object->load_from_filename($baseDir . $file); echo $object . ' copied - '; } cleanup('db_backup'); cleanup('web_backup'); copytocloud('db_backup.sql.gz', 'db_backup_' . date('Y-m-d_His') . '.sql.gz'); copytocloud('web_backup.tgz', 'web_backup_' . date('Y-m-d_His') . '.tgz'); echo 'Transfer Complete!';
function cleanup($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dir . "/" . $object) == "dir") { cleanup($dir . "/" . $object); } else { unlink($dir . "/" . $object); } } } reset($objects); rmdir($dir); } }