public function markAsComplete($params) { $db = new Dbase(); $project_name = $params['identifier']['project_name']; $q = "UPDATE projects SET completed = '1' WHERE name = '{$project_name}'"; logger("COMPLETED Query is : " . print_r($q, true)); $db->executeQuery($q); }
function getActiveProjects() { require_once 'utils/Dbase.php'; $q = "SELECT * FROM projects WHERE is_active = 1 ORDER BY id DESC"; $db = new Dbase(); $res = $db->executeQuery($q); $activeProjects = array(); while ($row = $res->fetch_assoc()) { $activeProjects[] = $row; } return $activeProjects; }
public function update($fields) { //logger( print_r( $fields, true ) ); logger("RiskMitigationPlan update function called.\nFields : " . print_r($fields, true)); $db = new Dbase(); $updateString = $db->createUpdateString($fields['result']); $q = "UPDATE RiskMitigationPlan SET " . $updateString . " WHERE id = {$this->id}"; logger("Update query : " . print_r($q, true)); $success = $db->executeQuery($q); return $success; // return status code, message instead of the above statement }
public function getLineItemIds() { $q = "SELECT * FROM projects_lineitems_mapping WHERE project_id = {$this->id}"; $db = new Dbase(); $res = $db->executeQuery($q); $lineItemIDsArray = array(); if ($res && $res->num_rows > 0) { while ($row = $res->fetch_assoc()) { $lineItemIDsArray[] = $row['lineitem_id']; } } $res->free(); $this->lineItemIDs = $lineItemIDsArray; }
function __construct() { adminGateKeeper(); $ip = pageArray(2); if ($ip) { new BlacklistIp($ip); $params = array("type" => "User", "metadata_name_value_pairs" => array(array("name" => "ip1", "value" => $ip), array("name" => "ip2", "value" => $ip)), "metadata_name_value_pairs_operand" => "OR"); $users = getEntities($params); $tables = Dbase::getAllTables(false); foreach ($users as $user) { new BlacklistEmail($user->email); $guid = $user->guid; foreach ($tables as $table) { $entities = getEntities(array("type" => $table, "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => $guid), array("name" => "container_guid", "value" => $guid)), "metadata_name_value_pairs_operand" => "OR")); if ($entities) { foreach ($entities as $entity) { $entity->delete(); } } } $user->delete(); } new SystemMessage("Ip {$ip} has been banned, and all users using it have been deleted."); forward("home"); } }
static function draw() { $page = self::urlArray(0); if ($page != "setupcomplete" && $page != "action" && file_exists(getSitePath() . "install/")) { forward("setupcomplete"); } $body = $header = $nav = $footer = NULL; if ($page) { $page_handler_class = "SocialApparatus\\" . ucfirst($page) . "PageHandler"; } else { $page_handler_class = "SocialApparatus\\HomePageHandler"; } Vars::clear(); if (class_exists($page_handler_class)) { $body = (new $page_handler_class())->view(); } else { new SystemMessage("Page not found."); forward("home"); } Vars::clear(); $header = display("page_elements/header"); Vars::clear(); $nav = display("page_elements/navigation"); Vars::clear(); $footer = display("page_elements/footer"); Vars::clear(); echo $header; echo $nav; echo $body; echo $footer; Debug::clear(); Dbase::con()->close(); die; }
public function __construct() { // call the constructor function of the Dbase class parent::__construct(); $validationPages = array('register', 'login', 'checkout', 'adminartist', 'adminartwork', 'order', 'contact', 'account', 'royalty'); if (in_array($_GET['page'], $validationPages)) { include 'classes/validateClass.php'; $this->validate = new Validate(); } }
public function start($params) { exec("pgrep ffmpeg", $pids); if (empty($pids)) { $query = "SELECT video.guid FROM video LEFT JOIN file ON video.video_guid=file.guid WHERE (video.processed != 'true' && video.processed != 'processing' && video.video_type = 'upload');"; $results = Dbase::getResultsArray($query); foreach ($results as $result) { $video_guid = $result['guid']; $video = getEntity($video_guid, true); if (is_a($video, "SocialApparatus\\Video")) { $file_guid = $video->video_guid; if (!file_exists(SITEDATAPATH . "videos/{$file_guid}/video.mp4")) { $file = getEntity($file_guid, true); FileSystem::makePath(SITEDATAPATH . "videos/" . $file_guid, 0777); $file_location = $file->file_location; exec("pgrep ffmpeg", $pids); if (empty($pids)) { if (file_exists($file_location)) { $target_dir = SITEDATAPATH . "videos/" . $file->guid . "/"; ini_set('max_execution_time', 3000); $ffmpeg = \FFMpeg\FFMpeg::create(array('ffmpeg.binaries' => Setting::get("ffmpeg_ffmprobe_executable_path") . "/ffmpeg", 'ffprobe.binaries' => Setting::get("ffmpeg_ffmprobe_executable_path") . "/ffprobe", 'timeout' => 7200, 'ffmpeg.threads' => 6)); $oldmask = umask(0); $video->proccessed = "processing"; $video->save(); $video_file = $ffmpeg->open($file_location); $video_file->frame(\FFMpeg\Coordinate\TimeCode::fromSeconds(10))->save($target_dir . 'frame.jpg'); $video_file->filters()->resize(new \FFMpeg\Coordinate\Dimension(320, 240))->synchronize(); $video_file->save(new \FFMpeg\Format\Video\X264('libfdk_aac', 'libx264'), $target_dir . 'video.mp4')->save(new \FFMpeg\Format\Video\WebM(), $target_dir . 'video.webm')->save(new \FFMpeg\Format\Video\Ogg(), $target_dir . 'video.ogv'); $video = getEntity($video_guid); $video->processed = "true"; $video->save(); umask($oldmask); $user_guid = $video->owner_guid; $message = "Your video has been processed."; $link = $video->getURL(); notifyUser("video_processed", $video->guid, NULL, $user_guid); continue; } else { $video->processed = "true"; $video->save(); } } } else { $video->processed = "true"; $video->save(); } } } } }
public function __construct($id = -1) { parent::__construct(); $q = "SELECT * FROM lineitems WHERE id = {$id}"; $db = new Dbase(); $res = $db->executeQuery($q); if ($res && $res->num_rows > 0) { while ($row = $res->fetch_assoc()) { $this->id = $row['id']; // put the not NULL checks on $row[<members>] before initializing the classes // $this->name = $row['name']; $this->name = $row['name'] == "_PROJECT_" ? "OVERALL PROJECT" : $row['name']; $this->BRDRequirementObject = new BRDRequirement($row['brdrequirements_id']); $this->TechDevNeedObject = new TechDevNeed($row['techdevneed_id']); $this->ContentNeedObject = new ContentNeed($row['contentneed_id']); $this->TrainingNCommunicationPlanObject = new TrainingNCommunicationPlan($row['trainingncommunicationplan_id']); $this->CapabilitiesEnhancementObject = new CapabilitiesEnhancement($row['capabilitiesenhancement_id']); $this->CostBenefitObject = new CostBenefit($row['costbenefit_id']); $this->RiskMitigationPlanObject = new RiskMitigationPlan($row['riskmitigationplan_id']); $this->GoLivePlanObject = new GoLivePlan($row['goliveplan_id']); $this->ClosureModelObject = new ClosureModel($row['closure_id']); } } }
public function __construct() { adminGateKeeper(); $name = pageArray(2); if ($name != "user") { $query = "DELETE FROM `entities` WHERE `type` = '{$name}'"; Dbase::query($query); $query = "DROP TABLE `{$name}`"; Dbase::query($query); Systemvariable::set("setup_complete", "false"); clearCache(); Cache::clear(); Cache::clear(); Cache::clear(); new SystemMessage("Your table has been deleted."); } forward(); }
public function __construct() { adminGateKeeper(); $admin_guids = getAdminGuidArray(); $admin_guids = implode(",", $admin_guids); $name = pageArray(2); $query = "DELETE FROM `entities` WHERE `type` = '{$name}' AND `guid` NOT IN ({$admin_guids})"; Dbase::query($query); if ($name != "User") { $query = "DELETE FROM `{$name}`"; } else { $query = "DELETE FROM `{$name}` WHERE `guid` NOT IN ({$admin_guids})"; } Dbase::query($query); clearCache(); Cache::clear(); Cache::clear(); Cache::clear(); Systemvariable::set("setup_complete", "false"); new SystemMessage("Your table has been purged."); forward(); }
public function __construct($class, $metadata_name, $type) { $storage_types_complete = Cache::get("storage_types_complete", "site"); if (!$storage_types_complete) { $class = strtolower($class); $query = "CREATE TABLE IF NOT EXISTS `{$class}` (guid INT(12) UNSIGNED PRIMARY KEY)"; Dbase::con()->query($query); if ($type != "index") { $query = "ALTER TABLE `{$class}` ADD `{$metadata_name}` {$type};"; Dbase::con()->query($query); } else { $query = "SELECT COUNT(1) IndexIsThere FROM INFORMATION_SCHEMA.STATISTICS WHERE table_schema=DATABASE() AND table_name='{$class}' AND index_name='{$metadata_name}';"; $result = Dbase::con()->query($query); $row = $result->fetch_assoc(); if (isset($row['IndexIsThere'])) { if ($row['IndexIsThere'] == 0) { $query = "CREATE INDEX `{$metadata_name}` ON `{$class}`(`{$metadata_name}`);"; Dbase::con()->query($query); } } } } }
function pluginAutoloader($className) { $filename = str_replace("SocialApparatus\\", "", $className); $filename = ucfirst($filename) . ".php"; $query = "SELECT * FROM `plugin` WHERE `status` = 'enabled' ORDER BY `plugin_order`"; $plugins = Dbase::getResultsArray($query); if (is_array($plugins) && !empty($plugins)) { foreach ($plugins as $plugin) { $file = $plugin['name']; if (file_exists(SITEPATH . "plugins/{$file}/classes/{$filename}")) { require_once SITEPATH . "plugins/{$file}/classes/{$filename}"; return true; } if (file_exists(SITEPATH . "plugins/{$file}/{$filename}")) { require_once SITEPATH . "plugins/{$file}/{$filename}"; return true; } if (file_exists(SITEPATH . "core_plugins/{$file}/classes/{$filename}")) { require_once SITEPATH . "core_plugins/{$file}/classes/{$filename}"; return true; } if (file_exists(SITEPATH . "core_plugins/{$file}/{$filename}")) { require_once SITEPATH . "core_plugins/{$file}/{$filename}"; return true; } } } $files = glob(SITEPATH . "classes/*/*.php"); foreach ($files as $file) { $filename = str_replace("SocialApparatus\\", "", $className); $filename = ucfirst($filename) . ".php"; $basename = basename($file); if ($basename == $filename) { require_once $file; } } }
function getDbaseResultsArray($query) { return Dbase::getResultsArray($query); }
/** * updates Message ID for every links. * @param $message_id represents Message ID that needs to be updated. * @param $link_ids represents link id for which the message id is being updated. */ static function updateMessageIdForTrackerLinks($message_id, $link_ids) { global $logger; if (count($link_ids) > 0) { $logger->info("Ready for Update Message ID in email_redirection."); $link_ids = implode(" , ", $link_ids); $sql = "UPDATE `email_links_redirection` SET `message_id` = {$message_id}\n\t\t\t\t\t\tWHERE `id` IN ( {$link_ids} ) "; $db = new Dbase("msging"); if ($db->update($sql)) { $logger->info("Message ID has been updated."); } else { $logger->info("Message ID has updation is failed"); } } else { $logger->info("There is not any links in this Message."); } }
static function getInput($name, $value = false, $allow_get = true) { if (isset($_POST[$name])) { $output = $_POST[$name]; if (!is_array($output)) { $output = htmlspecialchars($output); } return $output; } if ($allow_get) { if (isset($_GET[$name])) { $output = $_GET[$name]; if (!is_array($output)) { $output = Dbase::con()->real_escape_string($output); $output = htmlspecialchars($output); } return $output; } } return $value; }
public function __construct() { parent::__construct(); }
/** * Creates a message object that NSADmin accepts * @param $priority enum ('DEFAULT', 'HIGH'); */ function getMessageDistribution($to, $from_org_id, $message, $priority = 'DEFAULT', $tags = array(), $campaign_id = -1) { $db = new Dbase('users'); $sql = "SELECT * FROM custom_sender WHERE org_id = '{$from_org_id}'"; $row = $db->query_firstrow($sql); $gsm = Util::valueOrDefault($row['sender_gsm'], "CAPILLARY"); $cdma = Util::valueOrDefault($row['sender_cdma'], "919874400500"); $m = $this->createMessageObject('SMS', $to, $message, $from_org_id, $priority, $gsm, $cdma, false, $scheduled_time, '', '', '', '', '', '', '', $tags, $campaign_id); try { # Send using NSADMIN $this->logger->debug("starting distribution"); $this->transport->open(); $ret = $this->client->chooseGateways($m); $this->logger->debug("*** return: " . print_r($ret, true)); $this->transport->close(); } catch (TException $te) { $this->logger->error("NSAdmin Exception: " . $te->getMessage()); throw new Exception("Error in NSAdmin: " . $te->getMessage(), -500); } catch (Exception $e) { $this->logger->error("NSAdmin Exception: " . $e->getMessage()); try { $this->transport->close(); } catch (Exception $e) { //do nothing } return false; } return $ret; }
static function getTypeFromGuid($guid) { $query = "SELECT `type` FROM `entities` WHERE `guid` = '{$guid}'"; $results = Dbase::getResultsArray($query); if (!empty($results)) { $result = $results[0]; return $result['type']; } else { return false; } }
<?php require 'vendor/autoload.php'; require './dbase/db.php'; //App setup $db = new Dbase(); $app = new Slim\App(array('mode' => 'development', 'debug' => 'true')); $app->setName('QRBattle'); $app->get('/', function ($request, $response, $args) { $response->write('Welcome to QRBattle API'); return $response; }); //Selecting Users $app->get('/users/ranking/', function ($request, $response, $args) use($db) { // return all users data to client query $qry = "SELECT user_ra, pontos FROM user ORDER BY pontos DESC"; $output = $db->run($qry, 1); $response->write($output); return $response; }); //Selecting Users $app->get('/users/', function ($request, $response, $args) use($db) { // return all users data to client query $qry = "SELECT * FROM user"; $output = $db->run($qry, 1); $response->write($output); return $response; }); // select User $app->get('/users/{ra}', function ($request, $response, $args) use($db) { // return user by RA
* Dissemination of this information or reproduction of this material is strictly forbidden * unless prior written permission is obtained from SocialApparatus. * * Contact Shane Barron admin@socia.us for more information. */ namespace SocialApparatus; denyDirect(); $content = NULL; $tables = Dbase::getAllTables(false); foreach ($tables as $key => $name) { if ($name != "entities") { $purge_url = addTokenToURL(getSiteURL() . "action/purgeTable/{$name}"); $delete_url = addTokenToURL(getSiteURL() . "action/deleteTable/{$name}"); $query = "SELECT COUNT(*) FROM `{$name}`"; $results = Dbase::getResultsArray($query); if ($results) { $records = $results[0]['COUNT(*)']; $buttons = "<a href='{$purge_url}' class='btn btn-warning btn-xs confirm'>Purge</a>"; if ($name != "User") { $buttons .= "<a href='{$delete_url}' class='btn btn-danger btn-xs confirm'>Delete</a>"; } $content .= <<<HTML <tr> <td>{$name}</td> <td>{$records}</td> <td>{$buttons}</td> </tr> HTML; }
static function addColumn($column, $type) { $type = strtolower($type); $columns = Cache::get("table_columns", "site"); if (!$columns) { $columns = array(); } if (!isset($columns[$type][$column])) { $columns[$type][] = $column; $query = "ALTER TABLE `{$type}` ADD `{$column}` VARCHAR(50);"; Dbase::query($query); } return true; }
function fetchLog() { global $cfg; if ($cfg['servertype'] == 'prod') { return ""; } if ($this->enabled) { $this->printed = true; ob_start(); ?> <div id="log"> <table id="log" border="1" summary="table"> <thead> <?php print LogEntry::getHeader(); ?> </thead> <tbody> <?php for ($i = count($this->entries) - 1; $i >= 0; $i--) { $row = $this->entries[$i]; print $row->getEntry(); } ?> <tr> <?php $peak_mem = sprintf("%.3f MB", memory_get_peak_usage() / 1000000); $memory_limit = ini_get('memory_limit'); if (function_exists("xdebug_is_enabled") && xdebug_is_enabled()) { $time_in_db = Dbase::get_all_timer_info(); $time = sprintf("%.3f ms", xdebug_time_index() * 1000); } echo <<<EOT \t\t<pre> \t\tFinal Debugging Info \t\tTotal time taken : {$time} \t\tPeak Memory Used : {$peak_mem} \t\tTime spend in DB : {$time_in_db} \t\tMemory Limit : {$memory_limit}; \t\t</pre> EOT; ?> </tr> </tbody> </table> </div> <?php return ob_get_clean(); //return "Log: ".$this->getLevel()."\n".str_replace("<br />","\n", $this->msg)." "; } }