/** * Called when migrating up */ public function up() { //remove the photo plugin dbexec("DELETE FROM #__plugins WHERE `element` = 'access' AND `folder` = 'subscriptions' "); //remove the dangling transaction records dbexec("DELETE FROM #__subscriptions_transactions WHERE user_id NOT IN (SELECT id FROM #__users)"); }
/** * Called when migrating up. */ public function up() { $timeThen = microtime(true); dbexec('DELETE FROM #__nodes WHERE `type` LIKE \'%ComBaseDomainEntityComment%\' AND `parent_type` = \'com:todos.domain.entity.milestone\' '); dbexec('DELETE FROM #__nodes WHERE `type` LIKE \'%com:todos.domain.entity.milestone\' '); dbexec('DELETE FROM #__edges WHERE `node_b_type` LIKE \'%com:todos.domain.entity.milestone\' '); dbexec('DROP TABLE #__todos_milestones'); //clearing todolists from the data $todolists = dbfetch('SELECT `id`, `parent_id`, `alias` FROM #__nodes WHERE `type` LIKE \'%com:todos.domain.entity.todolist\' '); foreach ($todolists as $todolist) { $terms = explode('-', $todolist['alias']); foreach ($terms as $index => $value) { if (strlen($value) < 3) { unset($terms[$index]); } } $todos = KService::get('com://site/todos.domain.entity.todo')->getRepository()->getQuery()->disableChain()->where('parent_id = ' . $todolist['id'])->fetchSet(); foreach ($todos as $todo) { foreach ($terms as $term) { if (strlen($term) > 3) { dboutput($term . ', '); $todo->set('parent_id', 0)->set('description', $todo->description . ' #' . trim($term))->addHashtag($term)->save(); } } } } dbexec('DELETE FROM #__nodes WHERE `type` LIKE \'%com:todos.domain.entity.todolist\' '); //clear stories dbexec('DELETE FROM #__nodes WHERE `story_object_type` = \'com:todos.domain.entity.todolist\' OR `story_object_type` = \'com:todos.domain.entity.milestone\' '); dbexec('DROP TABLE #__todos_todolists'); $timeDiff = microtime(true) - $timeThen; dboutput("TIME: ({$timeDiff})" . "\n"); }
/** * Called when migrating up */ public function up() { $timeThen = microtime(true); //converting the old boards as hashtags $boards = dbfetch('SELECT `id`, `alias` FROM #__anahita_nodes WHERE `type` LIKE \'%com:topics.domain.entity.board\' '); foreach ($boards as $board) { $terms = explode('-', $board['alias']); foreach ($terms as $index => $value) { if (strlen($value) < 3) { unset($terms[$index]); } } $topics = KService::get('com://site/topics.domain.entity.topic')->getRepository()->getQuery()->disableChain()->where('parent_id = ' . $board['id'])->fetchSet(); foreach ($topics as $topic) { foreach ($terms as $term) { if (strlen($term) > 3) { dboutput($term . ', '); $topic->set('description', $topic->description . ' #' . trim($term))->addHashtag($term)->save(); } } } } dbexec('UPDATE #__anahita_nodes SET `parent_id` = 0 WHERE `type` LIKE \'%com:topics.domain.entity.topic\''); dbexec('DELETE FROM #__anahita_nodes WHERE `type` LIKE \'%com:topics.domain.entity.board\''); dbexec('DELETE FROM #__anahita_edges WHERE `node_b_type` LIKE \'%com:topics.domain.entity.board\''); dbexec('DROP TABLE #__topics_boards'); $timeDiff = microtime(true) - $timeThen; dboutput("TIME: ({$timeDiff})" . "\n"); }
/** * Called when migrating up. */ public function up() { if (!dbexists('SHOW TABLES LIKE "#__edges"')) { dbexec('RENAME TABLE #__anahita_edges TO #__edges'); } dbexec('DELETE FROM #__edges WHERE node_a_id = node_b_id'); }
/** * Called when migrating up. */ public function up() { //delete open social table dbexec('DROP TABLE #__opensocial_profiles'); //delete legacy com_cache and com_opensocial dbexec('DELETE FROM #__components WHERE `option` = \'com_cache\' OR `option` = \'com_opensocial\' '); //some clean up dbexec('DELETE FROM #__components WHERE name = "" '); //fix broken menu link dbexec('UPDATE #__components SET `admin_menu_link` = \'option=com_mailer\' WHERE `option` = \'com_mailer\' '); //Delete legacy plugins dbexec('DELETE FROM #__plugins WHERE `element` IN ( \'ptag\', \'syntax\', \'opensocial\', \'mtupgrade\', \'usertype\' ) '); //remove anahita from nodes and edges table names if (!dbexists('SHOW TABLES LIKE "#__nodes"')) { dbexec('RENAME TABLE #__anahita_nodes TO #__nodes'); } //add pinned field to the nodes table if (!dbexists('SHOW COLUMNS FROM #__nodes LIKE "pinned"')) { dbexec('ALTER TABLE #__nodes ADD `pinned` TINYINT(1) NOT NULL DEFAULT \'0\' AFTER `enabled`'); } //add github gist plugin dbexec("INSERT INTO `#__plugins` (`name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) VALUES ('Content Filter - Medium', 'medium', 'contentfilter', 0, 1, 1, 0, 0, 0, '0000-00-00 00:00:00', '')"); //remove the photo plugin dbexec("DELETE FROM #__plugins WHERE `element` = 'photo' "); //remove the migrator_migrations table if exists dbexec('DROP TABLE #__migrator_migrations'); //some of the plugins are core plugins dbexec("UPDATE jos_plugins SET iscore = 1 WHERE element IN ('joomla', 'gist', 'medium', 'link', 'video', 's3')"); }
/** * Called when migrating up. */ public function up() { dbexec('delete from jos_components where `option` IN ("com_installer","com_bazaar","com_tagmeta")'); dbexec('delete from jos_components where `option` IS NULL OR `option` = ""'); dbexec('update jos_components set admin_menu_link ="" where `option` IN ("com_search","com_todos","com_pages","com_html","com_invites")'); ///remove privacy_read_mode. some installation may still have it try { dbexec('alter table jos_anahita_nodes drop column `privacy_read_mode`'); } catch (Exception $e) { } dbexec('DROP TABLE IF EXISTS `jos_core_log_items`'); dbexec('DROP TABLE IF EXISTS `jos_core_log_searches`'); dbexec('DROP TABLE IF EXISTS `jos_stats_agents`'); dbexec('DROP TABLE IF EXISTS `jos_tagmeta`'); dbexec('DROP TABLE IF EXISTS `jos_migration_backlinks`'); dbexec('DROP TABLE IF EXISTS `jos_migrations`'); dbexec("DELETE FROM `jos_modules_menu` WHERE `moduleid` IN (SELECT `id` FROM `jos_modules` WHERE `module` IN ('mod_bazaar','mod_footer','mod_login','mod_rokquicklinks'))"); dbexec("DELETE FROM `jos_modules` WHERE `module` IN ('mod_bazaar','mod_footer','mod_login','mod_rokquicklinks')"); $people = dbfetch('select id,person_username AS username,person_userid AS userid from jos_anahita_nodes where type like "ComActorsDomainEntityActor,ComPeopleDomainEntityPerson,com:people.domain.entity.person" and person_username NOT REGEXP "^[A-Za-z0-9][A-Za-z0-9_-]*$"'); foreach ($people as $person) { $username = $person['username']; $clean = $username = preg_replace('/(\\s|\\.|(@\\w+))+/', '', $username); //add a randome number until the username becomes unique while (dbexists("select id from jos_users where username like '{$username}'")) { $username = $clean . rand(0, 100); } dbexec("update jos_anahita_nodes set person_username = '******' where id = {$person['id']}"); dbexec("update jos_users set username = '******' where id = {$person['userid']}"); } }
/** * Called when migrating up */ public function up() { dbexec('ALTER TABLE #__anahita_nodes ADD `cover_filename` VARCHAR(255) NULL AFTER `filesize`, ADD `cover_filesize` INT(11) NULL AFTER `cover_filename`, ADD `cover_mimetype` VARCHAR(100) NULL AFTER `cover_filesize`'); }
/** * Called when migrating up */ public function up() { //remove some legacy plugin records dbexec('DELETE FROM #__plugins WHERE folder = \'system\' AND element IN (\'sef\',\'debug\',\'logger\',\'missioncontrol\', \'mtupgrade\', \'tagmeta\')'); dbexec('DROP TABLE IF EXISTS #__menu'); dbexec('DROP TABLE IF EXISTS #__menu_types'); dbexec('DELETE FROM #__modules WHERE `module` IN (\'mod_menu\',\'mod_viewer\') AND `client_id` = 0 '); }
/** * Called when migrating up */ public function up() { $timeThen = microtime(true); //some legacy cleanup $legacyTables = array('categories', 'content', 'content_frontpage', 'core_log_items', 'migration_backlinks', 'migrations', 'sections', 'stats_agents', 'tagmeta', 'core_log_searches'); foreach ($legacyTables as $legacyTable) { dbexec('DROP TABLE IF EXISTS #__' . $legacyTable); } //delete a legacy record dbexec('DELETE FROM #__components WHERE `option` = \'com_mailto\' '); //add the hashtag contentfilter dbexec('INSERT INTO #__plugins (name,element,folder,iscore) VALUES (\'Hashtag\', \'hashtag\',\'contentfilter\',1)'); //create the fields required for creating hashtag nodes dbexec('ALTER TABLE #__anahita_nodes DROP COLUMN `tag_count`'); dbexec('ALTER TABLE #__anahita_nodes DROP COLUMN `tag_ids`'); //install the hashtag related extensions dbexec('INSERT INTO #__components (`name`,`link`,`option`,`iscore`,`enabled`) VALUES (\'Hashtags\',\'option=com_hashtags\',\'com_hashtags\',1,1)'); $ids = array(); //fetch only the nodes that contain something that resembels a hashtag $query_regexp = 'body REGEXP \'#([^0-9_\\s\\W].{2,})\''; dboutput("\nActors' Hashtags\n"); //extracting hashtag terms from actors $ids = dbfetch('SELECT id FROM #__anahita_nodes WHERE type LIKE \'ComActorsDomainEntityActor%\' AND ' . $query_regexp); foreach ($ids as $id) { $entity = KService::get('com://site/actors.domain.entity.actor')->getRepository()->getQuery()->disableChain()->fetch($id); $hashtagTerms = $this->extractHashtagTerms($entity->description); foreach ($hashtagTerms as $term) { dboutput($term . ', '); $entity->addHashtag($term)->save(); } } dboutput("\nComments' hashtags\n"); //extracting hashtag terms from comments $ids = dbfetch('SELECT id FROM #__anahita_nodes WHERE type LIKE \'ComBaseDomainEntityComment%\' AND ' . $query_regexp); foreach ($ids as $id) { $entity = KService::get('com://site/base.domain.entity.comment')->getRepository()->getQuery()->disableChain()->fetch($id); $hashtagTerms = $this->extractHashtagTerms($entity->body); foreach ($hashtagTerms as $term) { dboutput($term . ', '); $entity->addHashtag($term)->save(); } } dboutput("\nMedia's Hashtags\n"); //extracting hashtag terms from mediums: notes, topics, pages, and todos $query = 'SELECT id FROM #__anahita_nodes WHERE ' . $query_regexp . ' AND ( ' . 'type LIKE \'%com:notes.domain.entity.note\' ' . 'OR type LIKE \'%com:topics.domain.entity.topic\' ' . 'OR type LIKE \'%com:photos.domain.entity.photo\' ' . 'OR type LIKE \'%com:photos.domain.entity.set\' ' . 'OR type LIKE \'%com:pages.domain.entity.page\' ' . 'OR type LIKE \'%com:todos.domain.entity.todo\' ' . ' ) '; $ids = dbfetch($query); foreach ($ids as $id) { $entity = KService::get('com://site/medium.domain.entity.medium')->getRepository()->getQuery()->disableChain()->fetch($id); $hashtagTerms = $this->extractHashtagTerms($entity->description); foreach ($hashtagTerms as $term) { dboutput($term . ', '); $entity->addHashtag($term)->save(); } } dbexec('UPDATE #__plugins SET published = 1 WHERE element = \'hashtag\''); $timeDiff = microtime(true) - $timeThen; dboutput("TIME: ({$timeDiff})" . "\n"); }
/** * Called when migrating up */ public function up() { //delete a legacy record dbexec('DELETE FROM #__components WHERE `option` = \'com_content\' '); //add the mention tag contentfilter dbexec('INSERT INTO #__plugins (`name`,`element`,`folder`,`iscore`,`published`) VALUES (\'Mention\', \'mention\',\'contentfilter\',1,1)'); //changing the hashtag class name to tag dbexec('UPDATE #__anahita_edges SET `type` = REPLACE(`type`, \'ComHashtagsDomainEntityAssociation,com:hashtags.domain.entity.association\', \'ComTagsDomainEntityTag,ComHashtagsDomainEntityTag,com:hashtags.domain.entity.tag\') WHERE type LIKE \'%com:hashtags.domain.entity%\' '); }
/** * Called when migrating up */ public function up() { //add your migration here dbexec("ALTER TABLE #__users ENGINE=InnoDB"); dbexec("ALTER TABLE #__templates_menu ENGINE=InnoDB"); dbexec("ALTER TABLE #__plugins ENGINE=InnoDB"); dbexec("ALTER TABLE #__nodes ENGINE=InnoDB"); dbexec("ALTER TABLE #__components ENGINE=InnoDB"); }
/** * Called when migrating up */ public function up() { //Create new fields for com_locations dbexec("ALTER TABLE `#__nodes` ADD `geo_address` VARCHAR(255) DEFAULT NULL AFTER `geo_longitude`"); dbexec("ALTER TABLE `#__nodes` ADD `geo_city` VARCHAR(50) DEFAULT NULL AFTER `geo_address`"); dbexec("ALTER TABLE `#__nodes` ADD `geo_state_province` VARCHAR(50) DEFAULT NULL AFTER `geo_city`"); dbexec("ALTER TABLE `#__nodes` ADD `geo_country` VARCHAR(30) DEFAULT NULL AFTER `geo_state_province`"); dbexec("ALTER TABLE `#__nodes` ADD `geo_postalcode` VARCHAR(15) DEFAULT NULL AFTER `geo_country`"); //add extension records dbexec("INSERT INTO `#__components` (`name`, `link`, `admin_menu_link`, `admin_menu_alt`, `admin_menu_img`, `option`,`iscore`, `enabled`) VALUES ('Locations', 'option=com_locations', 'option=com_locations', 'Locations', 'js/ThemeOffice/component.png', 'com_locations', 1, 1)"); }
/** * Called when migrating up */ public function up() { //looks like these two didn't work in previous migrations dbexec("DROP TABLE #__content_rating"); dbexec("DELETE FROM #__components WHERE `option` IN ('com_media', 'com_menus', 'com_modules')"); //add github gist plugin dbexec("INSERT INTO `#__plugins` (`id`, `name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) VALUES (49, 'Content Filter - GithubGist', 'gist', 'contentfilter', 0, 0, 0, 0, 0, 0, '0000-00-00 00:00:00', '')"); //remove the syntax plugin dbexec("DELETE FROM #__plugins WHERE `element` IN ('syntax', 'ptag') "); //UTF-8 conversions dbexec("ALTER DATABASE CHARACTER SET utf8"); dbexec("ALTER TABLE #__anahita_edges CHARACTER SET utf8"); dbexec("ALTER TABLE #__anahita_nodes CHARACTER SET utf8"); dbexec("ALTER TABLE #__anahita_nodes CHANGE name name VARBINARY(255)"); dbexec("ALTER TABLE #__anahita_nodes CHANGE name name VARCHAR(255) CHARACTER SET utf8"); dbexec("ALTER TABLE #__anahita_nodes CHANGE alias alias VARBINARY(255)"); dbexec("ALTER TABLE #__anahita_nodes CHANGE alias alias VARCHAR(255) CHARACTER SET utf8"); dbexec("ALTER TABLE #__anahita_nodes CHANGE body body MEDIUMBLOB"); dbexec("ALTER TABLE #__anahita_nodes CHANGE body body MEDIUMTEXT CHARACTER SET utf8"); dbexec("ALTER TABLE #__anahita_nodes CHANGE person_given_name person_given_name VARBINARY(255)"); dbexec("ALTER TABLE #__anahita_nodes CHANGE person_given_name person_given_name VARCHAR(255) CHARACTER SET utf8"); dbexec("ALTER TABLE #__anahita_nodes CHANGE person_family_name person_family_name VARBINARY(255)"); dbexec("ALTER TABLE #__anahita_nodes CHANGE person_family_name person_family_name VARCHAR(255) CHARACTER SET utf8"); dbexec("ALTER TABLE #__migrator_migrations CHARACTER SET utf8"); dbexec("ALTER TABLE #__migrator_versions CHARACTER SET utf8"); dbexec("ALTER TABLE #__opensocial_profiles CHARACTER SET utf8"); dbexec("ALTER TABLE #__opensocial_profiles CHARACTER SET utf8"); //move these to related components dbexec("ALTER TABLE #__invites_tokens CHARACTER SET utf8"); dbexec("ALTER TABLE #__opensocial_profiles CHARACTER SET utf8"); dbexec("ALTER TABLE #__subscriptions_coupons CHARACTER SET utf8"); dbexec("ALTER TABLE #__subscriptions_packages CHARACTER SET utf8"); dbexec("ALTER TABLE #__subscriptions_transactions CHARACTER SET utf8"); dbexec("ALTER TABLE #__subscriptions_vats CHARACTER SET utf8"); dbexec("ALTER TABLE #__todos_todos CHARACTER SET utf8"); dbexec("ALTER TABLE #__topics_topics CHARACTER SET utf8"); dbexec("ALTER TABLE #__users CHARACTER SET utf8"); dbexec("ALTER TABLE #__users CHANGE name name VARBINARY(255)"); dbexec("ALTER TABLE #__users CHANGE name name VARCHAR(255) CHARACTER SET utf8"); //updating comments $timeThen = microtime(true); $db = KService::get('koowa:database.adapter.mysqli'); //change comment formats from html to string $entities = dbfetch('SELECT id, body FROM #__anahita_nodes WHERE type LIKE "ComBaseDomainEntityComment%" '); dboutput("Updating comments. This WILL take a while ...\n"); foreach ($entities as $entity) { $id = $entity['id']; $body = strip_tags($entity['body']); $db->update('anahita_nodes', array('body' => $body), ' WHERE id=' . $id); } dboutput("Comments updated!\n"); $timeDiff = microtime(true) - $timeThen; dboutput("TIME: ({$timeDiff})" . "\n"); }
function TestDB() { $ret = array(); $query = "SELECT 1 AS demo"; $result = dbexec($query); if (db()->affected_rows) { //$ret = $result->fetch_all(MYSQLI_ASSOC); while ($row = $result->fetch_assoc()) { $ret[] = $row; } } return $ret; }
/** * Called when migrating up */ public function up() { dbexec('DROP TABLE IF EXISTS #__invites_invitations'); $query = 'CREATE TABLE IF NOT EXISTS `#__invites_tokens` ( `id` bigint(11) unsigned NOT NULL auto_increment, `inviter_id` bigint(11) unsigned NOT NULL, `service` VARCHAR(20), `token` VARCHAR(150), `used` TINYINT(20) unsigned default 0, PRIMARY KEY (`id`), KEY `inviter_id` (`inviter_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0'; dbexec($query); //add your migration here }
/** * Called when migrating up. */ public function up() { //remove anahita from nodes and edges table names if (!dbexists('SHOW TABLES LIKE "#__nodes"')) { dbexec('RENAME TABLE #__anahita_nodes TO #__nodes'); } if (!dbexists('SHOW TABLES LIKE "#__edges"')) { dbexec('RENAME TABLE #__anahita_edges TO #__edges'); } if (!dbexists('SHOW COLUMNS FROM #__nodes LIKE "cover_filename"')) { dbexec('ALTER TABLE #__nodes ADD `cover_filename` VARCHAR(255) NULL AFTER `filesize`, ADD `cover_filesize` INT(11) NULL AFTER `cover_filename`, ADD `cover_mimetype` VARCHAR(100) NULL AFTER `cover_filesize`'); } }
/** * Called when migrating up */ public function up() { //fetch duplicate rows $duplicate_rows = dbfetch("SELECT *, COUNT(*) AS count FROM `#__edges` GROUP BY `type`, `node_a_id`, `node_a_type`, `node_b_id`, `node_b_type` HAVING count > 1"); //delete duplicate rows foreach ($duplicate_rows as $row) { dbexec('DELETE FROM `#__edges` WHERE `type`=\'' . $row['type'] . '\' AND `node_a_id`=\'' . $row['node_a_id'] . '\' AND `node_a_type`=\'' . $row['node_a_type'] . '\' AND `node_b_id`=\'' . $row['node_b_id'] . '\' AND `node_b_type`=\'' . $row['node_b_type'] . '\' '); } //add unique constraint to columns dbexec('ALTER TABLE `#__edges` ADD CONSTRAINT `uc_edge` UNIQUE(`type`, `node_a_id`, `node_a_type`, `node_b_id`, `node_b_type`)'); //insert previously duplicate rows once each foreach ($duplicate_rows as $row) { unset($row['id']); unset($row['count']); dbinsert('edges', $row); } }
/** * Called when migrating up */ public function up() { dbexec('ALTER TABLE #__subscriptions_coupons ADD `created_on` datetime DEFAULT NULL AFTER `usage`, ADD `created_by` bigint(11) unsigned DEFAULT NULL AFTER `created_on`, ADD INDEX `created_by` (`created_by`), ADD `modified_on` datetime DEFAULT NULL AFTER `created_by`, ADD `modified_by` bigint(11) unsigned DEFAULT NULL AFTER `modified_on`, ADD INDEX `modified_by` (`modified_by`) '); dbexec('ALTER TABLE #__subscriptions_vats ADD `created_on` datetime DEFAULT NULL AFTER `data`, ADD `created_by` bigint(11) unsigned DEFAULT NULL AFTER `created_on`, ADD INDEX `created_by` (`created_by`), ADD `modified_on` datetime DEFAULT NULL AFTER `created_by`, ADD `modified_by` bigint(11) unsigned DEFAULT NULL AFTER `modified_on`, ADD INDEX `modified_by` (`modified_by`) '); }
public function up() { anahita_20(); anahita_21(); anahita_22(); anahita_23(); anahita_24(); anahita_25(); anahita_26(); dbexec('INSERT IGNORE INTO #__migrator_versions (component,version) VALUES ("connect", 1), ("opensocial",1), ("groups",0), ("photos",0), ("topics",1), ("subscriptions",1), ("todos",1) '); }
/** * Called when migrating up */ public function up() { //component dbexec('UPDATE `#__nodes` SET `component` = \'com_articles\' WHERE `component` = \'com_pages\' '); // node types dbexec('UPDATE `#__nodes` SET type=\'ComMediumDomainEntityMedium,ComArticlesDomainEntityArticle,com:articles.domain.entity.article\' WHERE type=\'ComMediumDomainEntityMedium,ComPagesDomainEntityPage,com:pages.domain.entity.page\''); // revision nodes dbexec('UPDATE `#__nodes` SET type=\'ComMediumDomainEntityMedium,ComArticlesDomainEntityRevision,com:articles.domain.entity.revision\' WHERE type=\'ComMediumDomainEntityMedium,ComPagesDomainEntityRevision,com:pages.domain.entity.revision\''); // comments dbexec('UPDATE `#__nodes` SET type=\'ComBaseDomainEntityComment,com:articles.domain.entity.comment\' WHERE type=\'ComBaseDomainEntityComment,com:pages.domain.entity.comment\' '); // parent types dbexec('UPDATE `#__nodes` SET parent_type=\'com:articles.domain.entity.article\' WHERE parent_type=\'com:pages.domain.entity.page\' '); // update permissions dbexec('UPDATE `#__nodes` SET `permissions` = REPLACE(`permissions`, \'com_pages:page\', \'com_articles:article\')'); // story_object_type dbexec('UPDATE `#__nodes` SET story_object_type=\'com:articles.domain.entity.article\' WHERE story_object_type=\'com:pages.domain.entity.page\' '); // Update edges dbexec('UPDATE `#__edges` SET `node_b_type` = \'com:articles.domain.entity.article\' WHERE `node_b_type` = \'com:pages.domain.entity.page\' '); // Update stories and notifications dbexec('UPDATE `#__nodes` SET name=\'article_add\' WHERE name=\'page_add\''); dbexec('UPDATE `#__nodes` SET name=\'article_comment\' WHERE name=\'page_comment\''); }
/** * Called when migrating up. */ public function up() { //remove anahita from nodes and edges table names if (!dbexists('SHOW TABLES LIKE "#__nodes"')) { dbexec('RENAME TABLE #__anahita_nodes TO #__nodes'); } if (!dbexists('SHOW TABLES LIKE "#__edges"')) { dbexec('RENAME TABLE #__anahita_edges TO #__edges'); } //migrate users usertype dbexec('UPDATE #__users SET `usertype`=\'registered\' WHERE `usertype` NOT LIKE \'%admin%\' '); dbexec('UPDATE #__users SET `usertype`=\'administrator\' WHERE `usertype`=\'Administrator\' '); dbexec('UPDATE #__users SET `usertype`=\'super-administrator\' WHERE `usertype`=\'Super Administrator\' '); dbexec('ALTER TABLE #__users DROP COLUMN `gid` '); dbexec('ALTER TABLE #__users DROP COLUMN `sendEmail` '); //migrate people usertype dbexec('UPDATE #__nodes SET `person_usertype`=\'registered\' WHERE `person_usertype` NOT LIKE \'%admin%\' '); dbexec('UPDATE #__nodes SET `person_usertype`=\'administrator\' WHERE `person_usertype`=\'Administrator\' '); dbexec('UPDATE #__nodes SET `person_usertype`=\'super-administrator\' WHERE `person_usertype`=\'Super Administrator\' '); //migrate session table dbexec('ALTER TABLE #__session DROP COLUMN `gid` '); //drop legacy tables dbexec('DROP TABLE #__core_acl_aro'); dbexec('DROP TABLE #__core_acl_aro_groups'); dbexec('DROP TABLE #__core_acl_aro_map'); dbexec('DROP TABLE #__core_acl_aro_sections'); dbexec('DROP TABLE #__core_acl_groups_aro_map'); dbexec('DROP TABLE #__groups'); //legacy component cleanup dbexec('DELETE FROM #__components WHERE `option` IN (\'com_users\', \'com_user\') '); dbexec('UPDATE #__components SET `admin_menu_link`=\'option=com_people\', `admin_menu_alt`=\'People\', `admin_menu_img`=\'js/ThemeOffice/component.png\' WHERE `option`=\'com_people\' '); dbexec('ALTER TABLE #__nodes MODIFY `enabled` tinyint(1) NOT NULL DEFAULT 0'); dbexec('ALTER TABLE #__nodes MODIFY `is_default` tinyint(1) NOT NULL DEFAULT 0'); dbexec('UPDATE #__nodes SET `story_subject_id` = `created_by` WHERE `story_subject_id` = `story_target_id` AND `name` = \'actor_follow\''); dbexec('UPDATE #__nodes SET `enabled`=1, `access` = \'admins\' WHERE `type` LIKE \'%com:people.domain.entity.person\' AND `enabled` = 0'); }
break; //if it fails any and, it fails all ands } } if (!isset($add) || $add) { $post = $doc->createElement('post'); $post->setAttribute('post-id', $post_row['id']); $post->setAttribute('group-name', htmlspecialchars($post_row['name'])); $post->setAttribute('author-name', htmlspecialchars($post_row['author_name'])); $post->setAttribute('created', htmlspecialchars(formatdatetime($post_row['created']))); if (isset($post_row['image'])) { $post->setAttribute('image', htmlspecialchars($post_row['image'])); } //leave room for adding comments $comment_stmt = dbexec($select_db, 'SELECT c.id, c.message, c.created, (SELECT u.username FROM users u JOIN comments c2 ON c2.author_id = u.id WHERE c2.author_id = c.author_id LIMIT 1) as author_name FROM comments c WHERE c.post_id = ?', array($post_row['id']), array(PDO::PARAM_INT)); $comments = $doc->createElement('comments'); while ($comment_row = $comment_stmt->fetch(PDO::FETCH_ASSOC)) { $comment = $doc->createElement('comment'); $comment->setAttribute('id', htmlspecialchars($comment_row['id'])); $comment->setAttribute('author-name', htmlspecialchars($comment_row['author_name'])); $comment->setAttribute('created', htmlspecialchars(formatdatetime($comment_row['created']))); $comment->appendChild($doc->createTextNode($comment_row['message'])); $comments->appendChild($comment); } $post->appendChild($comments); $post->appendChild($doc->createTextNode($post_row['message'])); $root->appendChild($post); } }
/** * Called when migrating up */ public function up() { //add your migration here dbexec("UPDATE jos_anahita_nodes SET filename = CONCAT(MD5(id),'.jpg') WHERE type LIKE '%com:photos.domain.entity.photo%' AND filename = ''"); }
function raisedbystudent($uid, &$tvc) { $w1vendortotal = 0; $w2vendortotal = 0; $w3vendortotal = 0; $trk = dbGetObj("select * from tracking where user_id={$uid}"); $pro = dbGetObj("select * from progress where user_id={$uid}"); $wk = getfld("week", "users", "where id={$uid}"); $errors = 0; $space = " "; if ($wk > 1) { $w1vendorcost = $trk->w1cost; $w1vendortotal = 0; $w1multiplier = 0; if ($w1vendorcost > 0) { $w1vendor = $trk->w1vendor; $w1vendortotal = 25000; //Max amount a vendor can raise //determine how much of the max amount the vendor actually raised $vnum = getvnum(1, $w1vendor, $w1vendorcost); if ($vnum == 1) { $w1multiplier = 1.0; } else { if ($vnum == 2) { $w1multiplier = 0.75; } else { if ($vnum == 3) { $w1multiplier = 0.5; } else { if ($vnum == 4) { $w1multiplier = 0.25; } else { $errors++; rerr("tsk1: student id={$uid} {$space} w1vendor=\"{$w1vendor}\" {$space} w1vendorcost={$w1vendorcost}"); $w1multiplier = 0.625; } } } } //Determine the adjusted vendortotal $w1vendortotal *= $w1multiplier; $w1vendortotal -= $w1vendorcost; } //Dock them for hiring an extra vendor if (substr($pro->w1nlc_utt, 0, 1) == "c") { $w1vendortotal -= 3000; } } if ($wk > 2) { $w2vendorcost = $trk->w2cost; $w2vendortotal = 0; $w2multiplier = 0; if ($w2vendorcost > 0) { $w2vendor = $trk->w2vendor; $w2vendortotal = 50000; //Max amount a vendor can raise $vnum = getvnum(2, $w2vendor, $w2vendorcost); if ($vnum == 1) { $w2multiplier = 1.0; } else { if ($vnum == 2) { $w2multiplier = 0.75; } else { if ($vnum == 3) { $w2multiplier = 0.5; } else { if ($vnum == 4) { $w2multiplier = 0.25; } else { $errors++; rerr("tsk2: student id={$uid} {$space} w2vendor=\"{$w2vendor}\" {$space} w2vendorcost={$w2vendorcost}"); $w2multiplier = 0.625; } } } } //Determine the adjusted vendortotal $w2vendortotal *= $w2multiplier; $w2vendortotal -= $w2vendorcost; } //Dock them for getting insurance if (substr($pro->w2nlc_utt, 0, 1) == "c") { $w2vendortotal -= 1500; } } if ($wk > 3) { $w3vendorcost = $trk->w3cost; $w3vendortotal = -12500; $w3vendor = $trk->w3vendor; if (substr($w3vendor, 0, 7) == "Ramblin") { $w3vendor = substr($w3vendor, 0, 7); } //if($w3vendor != null) //p("$uid - w3vendor = $w3vendor"); //else //p("w3vendor = null"); if ($w3vendor != "" && $w3vendor != null) { $vnum = getvnum(3, $w3vendor, $w3vendorcost); // p("  vnum = $vnum"); if ($vnum < 4) { $w3vendortotal = -8000; // Arrested wrong vendor } else { if ($vnum == 4) { $w3vendortotal = 0; // Arrested the correct vendor } else { $errors++; rerr("tsk3: student id={$uid} {$space} w3vendor=\"{$w3vendor}'\" {$space} w3vendorcost={$w3vendorcost}"); } } //p("&emsp w3vendortotal = $w3vendortotal"); //p(""); } //Dock them for hiring an assistant if (substr($pro->w3nlc_utt, 0, 1) == "c") { $w3vendortotal -= 1500; } dbexec("update tracking set w3cost={$w3vendortotal} where user_id={$uid}"); } // Test Calculation /*if(($w1vendortotal+$w2vendortotal+$w3vendortotal) > 0){ p("$uid - w1raised = $w1vendortotal - w2raised = $w2vendortotal - w3raised = $w3vendortotal"); p("Total = ".($w1vendortotal+$w2vendortotal+$w3vendortotal)); }*/ // =========================== $raised = $w1vendortotal + $w2vendortotal + $w3vendortotal; dbExec("update tracking set raisedmoney={$raised}, errors={$errors} where user_id=" . $uid); setvar($uid, 'RAISED', $raised); dbExec("update results set raised={$raised} where uid={$uid}"); $tvc = $w1vendorcost + $w2vendorcost; // xxx currently not used ? if ($w1vendor == "") { $w1vendor = "no one"; } if ($w2vendor == "") { $w2vendor = "no one"; } if ($w3vendor == "") { $w3vendor = "no one"; } return $raised; }
/** * Called when migrating up */ public function up() { dbexec("DELETE FROM #__anahita_edges WHERE node_a_id = node_b_id"); }
/** * Called when migrating up. */ public function up() { dbexec('UPDATE #__nodes SET access=\'admins\' WHERE enabled=0 AND type=\'ComMediumDomainEntityMedium,ComPagesDomainEntityPage,com:pages.domain.entity.page\''); }
/** * Called when migrating up */ public function up() { //dropping module tables dbexec('DROP TABLE IF EXISTS #__modules'); dbexec('DROP TABLE IF EXISTS #__modules_menu'); }
if ($passnum == 2) { $mcols = $db->MetaColumnNames("scores", true); array_push($mcols, "UBER"); array_push($mcols, "RAISED"); $mn = count($mcols); if ($catoffset > $mn) { echo "Pass 2 finished.<p>"; $passnum = 3; } else { $cat = $mcols[$catoffset]; if ($cat != "decision") { $catstogo = $mn - $catoffset; echo "Pass 2 of 3: Generating Percentiles for category {$catoffset}, \"{$cat}\" ({$catstogo})<br>"; //echo "Building percentile table ... "; ob_flush(); flush(); $num = getField("vars", "count(*)", "where uid!=0 and tag='{$cat}' order by val asc"); $rs = dbexec("select distinct(val) from vars where uid!=0 and tag='{$cat}' order by val asc"); $pcntl = array(); while (!$rs->EOF) { $v = $rs->fields("val"); $below = getField("vars", "count(val)", "where uid!=0 and tag='{$cat}' and val < {$v}"); $above = getField("vars", "count(val)", "where uid!=0 and tag='{$cat}' and val > {$v}"); $bp = $below * 100 / $num; $ap = 100 - $above * 100 / $num; $p = ($bp + $ap) / 2; $pcntl[$v] = $p; $rs->MoveNext(); echo "% "; ob_flush(); flush(); } echo "<br>";
<?php require '../../utility/common.php'; logged_out(); validate_key(); $params = validate_params('POST', array('username', 'password'), array(0, 0), array(0, 0)); if (!$params) { error('invalid form data', '/account/login.php'); } $select_db = connect('select'); $stmt = dbexec($select_db, 'SELECT * FROM users WHERE username = ?', array($params['username']), array(PDO::PARAM_STR)); $row = $stmt->fetch(PDO::FETCH_ASSOC); if (count($row) == 0) { //user is not in database, they need to sign up, or they have not activated their account yet error('You need to sign up first', '../login.php'); } elseif (!is_null($row['activation_key'])) { error('You have not activated your account yet', '../login.php'); } if (password_verify($params['password'], $row['password'])) { session_start(); session_regenerate_id(true); //stop session fixation $_SESSION['name'] = $row['username']; $_SESSION['user_id'] = $row['id']; $_SESSION['tree'] = get_tree($select_db, $row['id']); session_commit(); header('Location: /home/home.php'); } else { //users password was entered incorrectly error('Wrong password', '/account/login.php'); }
<?php require '../utility/common.php'; require '../utility/htmlcommon.php'; logged_out(); validate_key(); $params = validate_params('POST', array('email'), array(FILTER_VALIDATE_EMAIL), array(FILTER_SANITIZE_EMAIL)); if (!$params) { error('Invalid params', 'login.php'); } $select_db = connect('select'); $stmt = dbexec($select_db, 'SELECT username FROM users WHERE email = ?', array($params['email']), array(PDO::PARAM_STR)); $res = $stmt->fetch(PDO::FETCH_ASSOC); if ($stmt->rowCount() === 0) { echo 'That email does not exist in our database'; die; } $message = 'Hello, you recently requested to recover your username for the account associated with this email at Classmatches. If you did not request this information, we suggest you change your password at Classmatches as soon as possible. Your username is: ' . $res['username'] . '. Thank you for using Classmatches.'; $message = wordwrap($message, 100); mail($params['email'], 'Username account recovery', $message, 'From: accountrecovery@classmatches.com'); top(false, 'Account recovery submit'); ?> <div> <p>An email has been sent to <?php echo htmlspecialchars($params['email']); ?> with your username</p> <p><a href="login.php">Log In</a></p> </div>