public function Delete() { $sql = "delete from " . OpenSms::getTableName('contact') . " where id = '" . StringMethods::MakeSave($this->Id) . "'"; //die($sql); if (OpenSms_Helper_Db::executeNonQuery($sql)) { return 'One number deleted'; } else { return 'Error in deleting number'; } }
public function Save() { $content = new OpenSms_Model_Page([0 => $this->Permalink]); if ($content->Id > 0) { return 'A page with the same permalink already exist'; } $sql = !$this->Id > 0 ? "insert into " . $this->getTableName() . "(`permalink`, `title`, `layout`, `role`, `description`) value('" . StringMethods::MakeSave($this->Permalink) . "', '" . StringMethods::MakeSave($this->Title) . "', '" . StringMethods::MakeSave($this->Layout) . "'\n , '" . StringMethods::MakeSave($this->Role) . "', '" . StringMethods::MakeSave($this->Description) . "');" : "update " . $this->getTableName() . " set `title` = '" . StringMethods::MakeSave($this->Title) . "',\n layout = '" . StringMethods::MakeSave($this->Layout) . "', description = '" . StringMethods::MakeSave($this->Description) . "\n where `permalink` = '" . StringMethods::MakeSave($this->Permalink) . "';"; //die($sql); return OpenSms_Helper_Db::executeNonQuery($sql); }
public function Save() { $content = new OpenSms_Model_Content([0 => $this->Key]); if ($content->Id > 0) { $this->Id = $content->Id; } $sql = !$this->Id > 0 ? "insert into " . $this->getTableName() . "(`key`, `type`, `body`, `host`) value('" . StringMethods::MakeSave($this->Key) . "', '" . StringMethods::MakeSave($this->Type) . "', '" . StringMethods::MakeSave($this->Body) . "', '" . StringMethods::MakeSave($this->Host) . "');" : "update " . $this->getTableName() . " set `body` = '" . StringMethods::MakeSave($this->Body) . "'\r\n where `key` = '" . StringMethods::MakeSave($this->Key) . "';"; //die($sql); return OpenSms_Helper_Db::executeNonQuery($sql); }
public function Save() { $sql = "insert into " . OpenSms::getTableName('sms') . "(bulkSMSId, number, message, sender, refId, Status)\r\n\t\t\t\t value('" . StringMethods::MakeSave($this->BulkSMSId) . "', '" . StringMethods::MakeSave($this->Number) . "', '" . StringMethods::MakeSave($this->Message) . "', '" . StringMethods::MakeSave($this->Sender) . "', '" . StringMethods::MakeSave($this->RefId) . "', '" . StringMethods::MakeSave($this->Status) . "');"; OpenSms_Helper_Db::executeNonQuery($sql); if ($this->Id == -1) { $sql = "select MAX(id) as no from `" . OpenSms::getTableName('sms') . "`"; $result = OpenSms_Helper_Db::executeReader($sql); foreach ($result as $r) { $this->Id = $r->no; return $r->no; } } }
/** * * prepares the values for echo in html * * @param $array * @return null */ public static function prepareForHtml($array) { if (sizeof($array) == 0) { return null; } foreach ($array as $k => $v) { if (is_array($v)) { self::prepareForHtml($v); } else { $array[$k] = StringMethods::prepareForHtml($v); } } return $array; }
protected function _parse($comment) { $meta = array(); $pattern = "(@[a-zA-Z]+\\s*[a-zA-Z0-9, ()_]*)"; $matches = StringMethods::match($comment, $pattern); if ($matches != null) { foreach ($matches as $match) { $parts = ArrayMethods::clean(ArrayMethods::trim(StringMethods::split($match, "[\\s]", 2))); $meta[$parts[0]] = true; if (sizeof($parts) > 1) { $meta[$parts[0]] = ArrayMethods::clean(ArrayMethods::trim(StringMethods::split($parts[1], ","))); } } } return $meta; }
public function __call($name, $arguments) { if (empty($this->_inspector)) { throw new Exception("Call parent::__construct!"); } // verifica se existem comandos getVariavel $getMatches = StringMethods::match($name, "^get([a-zA-Z0-9]+)\$"); if (sizeof($getMatches) > 0) { // verifica qual propriedade esta sendo manipulada $normalized = lcfirst($getMatches[0]); $property = "_{$normalized}"; if (property_exists($this, $property)) { $meta = $this->_inspector->getPropertyMeta($property); // se não tiver marcação definida if (empty($meta["@readwrite"]) && empty($meta["@read"])) { throw $this->_getExceptionForWriteonly($normalized); } if (isset($this->{$property})) { return $this->{$property}; } return null; } } // verifica se existem comandos setVariavel $setMatches = StringMethods::match($name, "^set([a-zA-Z0-9]+)\$"); if (sizeof($setMatches) > 0) { // verifica qual propriedade esta sendo manipulada $normalized = lcfirst($setMatches[0]); $property = "_{$normalized}"; if (property_exists($this, $property)) { $meta = $this->_inspector->getPropertyMeta($property); // se não tiver marcação definida if (empty($meta["@readwrite"]) && empty($meta["@write"])) { throw $this->_getExceptionForReadonly($normalized); } $this->{$property} = $arguments[0]; return $this; } } // se a propriedade não existir throw $this->_getExceptionForImplementation($name); }
public static function GenerateCard($no, $unit) { $cards = array(); for ($i = 1; $i <= $no; $i++) { //get the s/n $snExist = FALSE; while (!$snExist) { $sn = StringMethods::GetRandomString(5); $sql = 'select count(*) as num from ' . OpenSms::getTableName('cards') . ' where serialNumber = "$sn";'; $result = OpenSms_Helper_Db::executeReader($sql); foreach ($result as $r) { if ($r->num == 0) { $snExist = TRUE; } } } //get the pin $pinExist = FALSE; while (!$pinExist) { $pin = StringMethods::GetRandomString(10); $sql = 'select count(*) as num from ' . OpenSms::getTableName('cards') . ' where pin = "' . $pin . '";'; $result = OpenSms_Helper_Db::executeReader($sql); foreach ($result as $r) { if ($r->num == 0) { $pinExist = TRUE; } } } //insert the pin $sql = 'insert into ' . OpenSms::getTableName('cards') . ' (serialNumber, pin, unit) value("' . $sn . '", "' . $pin . '", "' . $unit . '");'; $inserted = OpenSms_Helper_Db::executeNonQuery($sql); if ($inserted) { $card = new OpenSms_Model_Card(); $card->SerialNumber = $sn; $card->Pin = $pin; $card->Unit = $unit; $cards[] = $card; } } return $cards; }
<?php if (count($path) > 1 && $path[1] != "") { if (StringMethods::EndsWith($path[1], ".mmo")) { switch ($path[1]) { case "create.mmo": require "Pages/Create.inc.php"; return; default: System::Redirect("~/community/pages"); return; } } else { require "Pages/Detail.inc.php"; } } else { require "Pages/Browse.inc.php"; } return;
public static function FindUserByEmail($emailId) { $sql = "select * from " . OpenSms::getTableName('users') . " where loginId = '" . StringMethods::MakeSave($emailId) . "';"; $u = new OpenSms_Model_User(); $result = OpenSms_Helper_Db::executeReader($sql); return isset($result[0]) ? self::copyFromPDO($result[0]) : new OpenSms_Model_User(); }
public function Delete() { unset($_COOKIE[$this->cookieName]); $sql = "delete from logins where id = '" . StringMethods::MakeSave($this->Id) . "'"; return OpenSms_Helper_Db::executeNonQuery($sql); }
public static function Encode($string) { return md5(StringMethods::MakeSave($string)); }
public static function GetBulkSMS($loginId, $offset, $limit) { $bulkSMSs = array(); $sql = "select * from " . OpenSms::getTableName('bulksms') . " where loginId = '{$loginId}' ORDER BY id DESC LIMIT {$offset}, {$limit};"; $result = OpenSms_Helper_Db::executeReader($sql); foreach ($result as $r) { $bulkSMS = new OpenSms_Model_BulkSms(); $bulkSMS->Id = $r->id; $bulkSMS->LoginId = StringMethods::GetRaw($r->loginId); $bulkSMS->DateCreated = $r->dateCreated; $bulkSMS->Message = StringMethods::GetRaw($r->message); $bulkSMS->Sender = StringMethods::GetRaw($r->sender); $bulkSMS->Status = StringMethods::GetRaw($r->status); $bulkSMS->Count = $r->count; $bulkSMSs[] = $bulkSMS; } return $bulkSMSs; }
public function Delete() { $sql = "delete from draft where id = '" . StringMethods::MakeSave($this->Id) . "'"; return $this->db->SendQuery($sql); }
public static function GetRange($offset, $limit, $loginId = '') { $trans = array(); $sql = "select * from " . OpenSms::getTableName('transactions') . (empty($loginId) ? "" : "where loginId = '{$loginId}'") . " ORDER BY id DESC LIMIT {$offset}, {$limit};"; $result = OpenSms_Helper_Db::executeReader($sql); foreach ($result as $r) { $tran = new OpenSms_Model_Transaction(); $tran->Id = $r->id; $tran->LoginId = StringMethods::GetRaw($r->loginId); $tran->Date = $r->date; $tran->Amount = StringMethods::GetRaw($r->amount); $tran->Unit = StringMethods::GetRaw($r->unit); $tran->Status = StringMethods::GetRaw($r->status); $tran->Description = StringMethods::GetRaw($r->description); $tran->PaymentMethod = StringMethods::GetRaw($r->paymentMethod); $tran->IsValid = StringMethods::GetRaw(TRUE); $tran->Type = $r->type; $tran->Committed = $r->committed; $trans[] = $tran; } return $trans; }