Exemplo n.º 1
0
 /**
  * @param WeLearn_DTO_IDTO $dto
  * @return void
  */
 protected function _adicionar(WeLearn_DTO_IDTO &$dto)
 {
     $dto->setId($this->_createSegmentoId($dto->getArea()->getId() . '__' . $dto->getDescricao()));
     $this->_cf->insert($dto->getId(), $dto->toCassandra());
     $this->_segmentosEmAreaCF->insert($dto->getArea()->getId(), array($dto->getId() => ''));
     $dto->setPersistido(true);
 }
Exemplo n.º 2
0
 /**
  * @param WeLearn_DTO_IDTO $dto
  * @return void
  */
 protected function _adicionar(WeLearn_DTO_IDTO &$dto)
 {
     $enqueteUUID = CassandraUtil::import($dto->getEnquete()->getId());
     $alternativaUUID = CassandraUtil::import($dto->getAlternativa()->getId());
     $dto->setDataVoto(time());
     $this->_cf->insert($enqueteUUID->bytes, $dto->toCassandra());
     $this->_votosPorAlternativaCF->insert($alternativaUUID->bytes, array($dto->getVotante()->getId() => $dto->getDataVoto()));
     $dto->setPersistido(true);
 }
Exemplo n.º 3
0
 /**
  * @param WeLearn_DTO_IDTO $dto
  * @return void
  */
 protected function _atualizar(WeLearn_DTO_IDTO $dto)
 {
     $UUID = UUID::import($dto->getId())->bytes;
     $this->_cf->insert($UUID, $dto->toCassandra());
     $usuarioId = $dto->getDestinatario()->getId();
     $this->_notificacoesNovasPorUsuarioCF->remove($usuarioId, array($UUID));
     if ($dto->getStatus() === WeLearn_Notificacoes_StatusNotificacao::NOVO) {
         $this->_notificacoesNovasPorUsuarioCF->insert($usuarioId, array($UUID => ''));
     }
 }
Exemplo n.º 4
0
 /**
  * @param WeLearn_DTO_IDTO $dto
  * @return void
  */
 protected function _adicionar(WeLearn_DTO_IDTO &$dto)
 {
     if (!$dto->getId()) {
         $UUID = UUID::mint();
         $dto->setId($UUID->string);
     } else {
         $UUID = CassandraUtil::import($dto->getId());
     }
     $avaliacaoUUID = CassandraUtil::import($dto->getAvaliacaoId());
     $this->_cf->insert($UUID->bytes, $dto->toCassandra());
     $this->_questaoPorAvaliacaoCF->insert($avaliacaoUUID->bytes, array($UUID->bytes => ''));
     $dto->setPersistido(true);
 }
Exemplo n.º 5
0
 /**
  * @param WeLearn_Cursos_Curso $curso
  * @param array $novasPosicoes
  */
 public function atualizarPosicao(WeLearn_Cursos_Curso $curso, array $novasPosicoes)
 {
     $posicoes = array();
     $rows = array();
     foreach ($novasPosicoes as $posicao => $id) {
         $UUID = UUID::import($id)->bytes;
         $posicoes[$posicao] = $UUID;
         $rows[$UUID] = array('nroOrdem' => $posicao);
     }
     $cursoUUID = UUID::import($curso->getId())->bytes;
     $this->_cf->batch_insert($rows);
     $this->_moduloPorCursoCF->remove($cursoUUID);
     $this->_moduloPorCursoCF->insert($cursoUUID, $posicoes);
 }
Exemplo n.º 6
0
 /**
  * Updates a row.
  *
  * @param string $key the row to update the columns in
  * @param mixed $columns array(column_name => column_value) the columns to update
  * @param int $timestamp the timestamp to use for this insertion. Leaving this as null will
  *        result in a timestamp being generated for you
  * @param int $ttl time to live for the columns; after ttl seconds they will be deleted
  * @param cassandra_ConsistencyLevel $writeConsistencyLevel affects the guaranteed
  *        number of nodes that must respond before the operation returns
  *
  * @return int the timestamp for the operation
  */
 public function update($key, array $columns, $timestamp = null, $ttl = null, $writeConsistencyLevel = null)
 {
     if (empty($this->_columnFamily)) {
         $this->init();
     }
     return $this->_columnFamily->insert($key, $columns, $timestamp, $ttl, $writeConsistencyLevel);
 }
Exemplo n.º 7
0
 /**
  * @param WeLearn_DTO_IDTO $dto
  * @return boolean
  */
 protected function _atualizar(WeLearn_DTO_IDTO $dto)
 {
     $UUID = CassandraUtil::import($dto->getId());
     $cursoUUID = CassandraUtil::import($dto->getCurso()->getId());
     $dadosAntigos = $this->_cf->get($UUID->bytes, array('status', 'situacao'));
     $statusAntigo = (int) $dadosAntigos['status'];
     $situacaoAntiga = (int) $dadosAntigos['situacao'];
     $this->_cf->insert($UUID->bytes, $dto->toCassandra());
     if ($statusAntigo != $dto->getStatus()) {
         if ($dto->getStatus() == WeLearn_Cursos_Enquetes_StatusEnquete::ATIVA) {
             $this->_enquetePorStatusInativoCF->remove($cursoUUID->bytes, array($UUID->bytes));
             $this->_enquetePorStatusAtivoCF->insert($cursoUUID->bytes, array($UUID->bytes => ''));
         } else {
             $this->_enquetePorStatusAtivoCF->remove($cursoUUID->bytes, array($UUID->bytes));
             $this->_enquetePorStatusInativoCF->insert($cursoUUID->bytes, array($UUID->bytes => ''));
         }
     }
     if ($situacaoAntiga != $dto->getSituacao()) {
         if ($dto->getSituacao() == WeLearn_Cursos_Enquetes_SituacaoEnquete::ABERTA) {
             $this->_enquetePorSituacaoFechadoCF->remove($cursoUUID->bytes, array($UUID->bytes));
             $this->_enquetePorSituacaoAbertoCF->insert($cursoUUID->bytes, array($UUID->bytes => ''));
         } else {
             $this->_enquetePorSituacaoAbertoCF->remove($cursoUUID->bytes, array($UUID->bytes));
             $this->_enquetePorSituacaoFechadoCF->insert($cursoUUID->bytes, array($UUID->bytes => ''));
         }
     }
 }
Exemplo n.º 8
0
 /**
  * @param WeLearn_Cursos_Conteudo_ControleAula $controleAula
  */
 public function salvar(WeLearn_Cursos_Conteudo_ControleAula &$controleAula)
 {
     $CFKey = $controleAula->getParticipacaoCurso()->getCFKey();
     $this->_cf->insert($CFKey, $controleAula->toCassandra());
     if (!$controleAula->isPersistido()) {
         $controleAula->setPersistido(true);
     }
 }
Exemplo n.º 9
0
 /**
  * @param WeLearn_DTO_IDTO $dto
  * @return boolean
  */
 protected function _adicionar(WeLearn_DTO_IDTO &$dto)
 {
     $dto->setId($dto->getNomeUsuario());
     //Id = Nome de usuário
     $dto->setSenha(md5($dto->getSenha()));
     //Senha necessita ser encriptada.
     $dto->setDataCadastro(time());
     $this->_cf->insert($dto->getId(), $dto->toCassandra());
     //Adiciona o index do email para verificação no cadastro de usuarios
     $indexEmail = array('usuarioId' => $dto->getId());
     $this->_emailUsuarioCF->insert($dto->getEmail(), $indexEmail);
     //Salva a configuração padrão do usuário recem cadastrado.
     if ($dto->getConfiguracao()) {
         $this->salvarConfiguracao($dto->getConfiguracao());
     }
     get_instance()->db->insert($this->_mysql_tbl_name, $dto->toMySQL());
     $dto->setPersistido(true);
 }
Exemplo n.º 10
0
 /**
  * @param WeLearn_DTO_IDTO $dto
  * @return boolean
  */
 protected function _adicionar(WeLearn_DTO_IDTO &$dto)
 {
     $this->_cf->insert($dto->getId(), $dto->toCassandra());
     $this->_controleAvaliacaoPorParticipacaoCF->insert($dto->getParticipacaoCurso()->getId(), array($dto->getAvaliacao()->getModulo()->getNroOrdem() => $dto->getId()));
     if (count($dto->getRespostas()) > 0) {
         $this->_respostasAvaliacaoCF->insert($dto->getId(), $dto->respostasToCassandra());
     }
     $dto->setPersistido(true);
 }
Exemplo n.º 11
0
 /**
  * @param WeLearn_DTO_IDTO $dto
  * @return boolean
  */
 protected function _adicionar(WeLearn_DTO_IDTO &$dto)
 {
     $UUID = UUID::mint();
     $paginaUUID = CassandraUtil::import($dto->getPagina()->getId());
     $dto->setId($UUID->string);
     $dto->setDataEnvio(time());
     $this->_cf->insert($UUID->bytes, $dto->toCassandra());
     $this->_comentarioPorPaginaCF->insert($paginaUUID->bytes, array($UUID->bytes => ''));
     $dto->setPersistido(true);
 }
Exemplo n.º 12
0
 /**
  * @param WeLearn_DTO_IDTO $dto
  * @return void
  */
 protected function _adicionar(WeLearn_DTO_IDTO &$dto)
 {
     if (!$dto->getId()) {
         $UUID = UUID::mint();
         $dto->setId($UUID->string);
     } else {
         $UUID = CassandraUtil::import($dto->getId());
     }
     $dto->setDataInclusao(time());
     $this->_cf->insert($UUID->bytes, $dto->toCassandra());
     if ($dto instanceof WeLearn_Cursos_Recursos_RecursoRestrito) {
         $aulaUUID = CassandraUtil::import($dto->getAula()->getId());
         $this->_recursosRestritosCF->insert($aulaUUID->bytes, array($UUID->bytes => ''));
     } elseif ($dto instanceof WeLearn_Cursos_Recursos_RecursoGeral) {
         $cursoUUID = CassandraUtil::import($dto->getCurso()->getId());
         $this->_recursosGeraisCF->insert($cursoUUID->bytes, array($UUID->bytes => ''));
     } else {
         throw new WeLearn_Base_Exception('A classe inserida tem que derivar
                                          de WeLearn_Cursos_Recursos_Recurso.');
     }
     $dto->setPersistido(true);
 }
Exemplo n.º 13
0
 protected function setValue($key, $value, $expire = 0)
 {
     $this->cache[$key] = $value;
     $cf = new ColumnFamily($this->cassandra, $this->config['column_family']);
     $str = json_encode($value);
     if ($expire > 0) {
         try {
             $seconds = $expire - time();
             // __data key set as C* requires a field, note: max TTL can only be 630720000 seconds
             $cf->insert($key, array('__data' => $str), null, $seconds);
         } catch (\Exception $e) {
             return false;
         }
     } else {
         try {
             // __data key set as C* requires a field
             $cf->insert($key, array('__data' => $str));
         } catch (\Exception $e) {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 14
0
 /**
  * @param WeLearn_DTO_IDTO $dto
  * @return boolean
  */
 protected function _adicionar(WeLearn_DTO_IDTO &$dto)
 {
     if (!$dto->getId()) {
         $UUID = UUID::mint();
         $dto->setId($UUID->string);
     } else {
         $UUID = UUID::import($dto->getId());
     }
     $cursoUUID = UUID::import($dto->getCurso()->getId());
     $this->_cf->insert($UUID->bytes, $dto->toCassandra());
     $this->_certificadosPorCursoCF->insert($cursoUUID->bytes, array($UUID->bytes => ''));
     $this->alterarAtivo($dto);
     $dto->setPersistido(true);
 }
Exemplo n.º 15
0
 /**
  * @param WeLearn_Cursos_Conteudo_Aula $aula
  * @param array $novasPosicoes
  */
 public function atualizarPosicoes(WeLearn_Cursos_Conteudo_Aula $aula, array $novasPosicoes)
 {
     $posicoes = array();
     $rows = array();
     foreach ($novasPosicoes as $posicao => $id) {
         $UUID = UUID::import($id)->bytes;
         $posicoes[$posicao] = $UUID;
         $rows[$UUID] = array('nroOrdem' => $posicao);
     }
     $aulaUUID = UUID::import($aula->getId())->bytes;
     $this->_cf->batch_insert($rows);
     $this->_paginaPorAulaCF->remove($aulaUUID);
     $this->_paginaPorAulaCF->insert($aulaUUID, $posicoes);
 }
Exemplo n.º 16
0
 /**
  * @param string $usuarioId
  * @param array $listaDeRS
  * @return void
  */
 private function _salvarListaDeRS($usuarioId, array $listaDeRS)
 {
     if (empty($listaDeRS)) {
         return;
     }
     $batchListaRS = array();
     $listaRSKeys = array();
     foreach ($listaDeRS as $RS) {
         $rsUIID = UUID::mint();
         $RS->setId($rsUIID->string);
         $batchListaRS[$rsUIID->bytes] = $RS->toCassandra();
         $listaRSKeys[$rsUIID->bytes] = '';
         $RS->setPersistido(true);
     }
     $this->_RSCF->batch_insert($batchListaRS);
     $this->_RSPorUsuarioCF->insert($usuarioId, $listaRSKeys);
 }
Exemplo n.º 17
0
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * PHP Template.
 * Author: Sheetal Patil. Sun Microsystems, Inc.
 */
session_start();
require_once "../etc/config.php";
require_once '../etc/phpcassa_config.php';
$friends = Users_Controller::getInstance();
$person = $_REQUEST['person'];
$friend = $_REQUEST['friend'];
$cf = new ColumnFamily($conn, 'PERSON_PERSON');
$index_exp_person = CassandraUtil::create_index_expression('Person_username', $person);
$index_exp_friends = CassandraUtil::create_index_expression('friends_username', $friend);
$index_clause = CassandraUtil::create_index_clause(array($index_exp_person, $index_exp_friends));
$rows = $cf->get_indexed_slices($index_clause);
foreach ($rows as $key => $col) {
    $cf->insert($col['id'], array('is_accepted' => 1));
}
$_SESSION["friendshipreqs"] = $friends->numFriendshipRequests($person, $conn);
$incomingRequests = $friends->incomingRequests($person, $conn);
$friendCloud = $friends->getFriendCloud($person, $conn);
echo "friendship requests (" . $_SESSION["friendshipreqs"] . ")\n";
echo $friendCloud . "\n" . $incomingRequests;
Exemplo n.º 18
0
 public function test_get_indexed_slices()
 {
     $indexed_cf = new ColumnFamily($this->pool, 'Indexed1');
     $indexed_cf->truncate();
     $columns = array('birthdate' => 1);
     foreach (range(1, 3) as $i) {
         $indexed_cf->insert('key' . $i, $columns);
     }
     $expr = CassandraUtil::create_index_expression($column_name = 'birthdate', $value = 1);
     $clause = CassandraUtil::create_index_clause(array($expr), 10000);
     $result = $indexed_cf->get_indexed_slices($clause);
     $count = 0;
     foreach ($result as $key => $cols) {
         $count++;
         self::assertEqual($columns, $cols);
         self::assertEqual($key, "key{$count}");
     }
     self::assertEqual($count, 3);
     # Insert and remove a matching row at the beginning
     $indexed_cf->insert('key0', $columns);
     $indexed_cf->remove('key0');
     # Insert and remove a matching row at the end
     $indexed_cf->insert('key4', $columns);
     $indexed_cf->remove('key4');
     # Remove a matching row from the middle
     $indexed_cf->remove('key2');
     $result = $indexed_cf->get_indexed_slices($clause);
     $count = 0;
     foreach ($result as $key => $cols) {
         $count++;
         self::assertTrue($key == "key1" || $key == "key3");
     }
     self::assertEqual($count, 2);
     $indexed_cf->truncate();
     $keys = array();
     foreach (range(1, 1000) as $i) {
         $indexed_cf->insert("key{$i}", $columns);
         if ($i % 50 != 0) {
             $indexed_cf->remove("key{$i}");
         } else {
             $keys[] = "key{$i}";
         }
     }
     $count = 0;
     foreach ($result as $key => $cols) {
         $count++;
         self::assertTrue(in_array($key, $keys));
         unset($keys[$key]);
     }
     self::assertEqual($count, 20);
     $indexed_cf->truncate();
 }
Exemplo n.º 19
0
while ($row = mysql_fetch_array($result)) {
    $column_family->insert($row['commentid'], array('commentid' => $row['commentid'], 'username' => $row['username'], 'socialeventid' => $row['socialeventid'], 'comments' => $row['comments'], 'ratings' => $row['ratings'], 'created_at' => $row['created_at'], 'updated_at' => $row['updated_at']));
}
$query1 = "select * from SOCIALEVENTTAG_SOCIALEVENT";
$result = mysql_query($query1);
$count = mysql_num_rows($result);
$column_family = new ColumnFamily($conn, 'SOCIALEVENTTAG_SOCIALEVENT');
$i = 1;
while ($row = mysql_fetch_array($result)) {
    $column_family->insert($i, array('id' => $i, 'socialeventtagid' => $row['socialeventtagid'], 'socialeventid' => $row['socialeventid']));
    $i = $i + 1;
}
$query1 = "select * from PERSON_SOCIALEVENT";
$result = mysql_query($query1);
$count = mysql_num_rows($result);
$column_family = new ColumnFamily($conn, 'PERSON_SOCIALEVENT');
$i = 1;
while ($row = mysql_fetch_array($result)) {
    $column_family->insert($i, array('id' => $i, 'username' => $row['username'], 'socialeventid' => $row['socialeventid']));
    $i = $i + 1;
}
$query1 = "select * from PERSON_PERSON";
$result = mysql_query($query1);
$count = mysql_num_rows($result);
$column_family = new ColumnFamily($conn, 'PERSON_PERSON');
$i = 1;
while ($row = mysql_fetch_array($result)) {
    $column_family->insert($i, array('id' => $i, 'Person_username' => $row['Person_username'], 'friends_username' => $row['friends_username'], 'is_accepted' => $row['is_accepted']));
    $i = $i + 1;
}
mysql_close($dbcon);
Exemplo n.º 20
0
 public function test_get_indexed_slices()
 {
     $indexed_cf = new ColumnFamily($this->client, 'Indexed1');
     $columns = array('birthdate' => 1);
     foreach (range(1, 3) as $i) {
         $indexed_cf->insert('key' . $i, $columns);
     }
     $expr = CassandraUtil::create_index_expression($column_name = 'birthdate', $value = 1);
     $clause = CassandraUtil::create_index_clause(array($expr));
     $result = $indexed_cf->get_indexed_slices($clause);
     self::assertEqual(count($result), 3);
     foreach (range(1, 3) as $i) {
         self::assertEqual($result['key' . $i], $columns);
     }
     $indexed_cf->truncate();
 }
Exemplo n.º 21
0
    $tmp_uname = $column['username'];
    if (!isset($_SESSION["uname"]) && $tmp_uname == $username) {
        $unattend = true;
        // show unattend button if user is already registered.
    }
    $attendeeList = $attendeeList . " " . '<a href="users.php?username='******'">' . $tmp_uname . '</a><br />';
}
unset($listqueryresult);
if (isset($_POST['commentsratingsubmit'])) {
    $insertSql = new ColumnFamily($conn, 'COMMENTS_RATING');
    $commentid = exec("python /usr/pysnowflakeclient/pysnowflakeclient/__init__.py");
    $insertSql->insert($commentid, array('commentid' => $commentid, 'username' => $username, 'socialeventid' => $se, 'comments' => $comments, 'ratings' => $rating, 'created_at' => time()));
} else {
    if (isset($_POST['editcommentsratingsubmit']) && isset($_POST['editingcid'])) {
        $cf = new ColumnFamily($conn, 'COMMENTS_RATING');
        $cf->insert($cid, array('comments' => $editcomments, 'ratings' => $rating, 'updated_at' => time()));
    }
}
$commentsrating = new ColumnFamily($conn, 'COMMENTS_RATING');
$index_exp = CassandraUtil::create_index_expression('socialeventid', $se);
$index_clause = CassandraUtil::create_index_clause(array($index_exp));
$commentsratingResult = $commentsrating->get_indexed_slices($index_clause);
ob_start();
foreach ($commentsratingResult as $key => $row1) {
    $tmp_commentid = $row1['commentid'];
    $tmp_uname = $row1['username'];
    $tmp_uname_comments = $row1['comments'];
    $tmp_uname_rating = $row1['ratings'];
    $tmp_uname_created_at = trim($events->formatdatetime($dateFormat, $row1['created_at']));
    $tmp_uname_updated_at = trim($events->formatdatetime($dateFormat, $row1['updated_at']));
    require "../views/commentsRating.php";
Exemplo n.º 22
0
 /**
  * @param WeLearn_Usuarios_Usuario $usuario
  * @param WeLearn_Cursos_Curso $paraCurso
  */
 public function convidar(WeLearn_Usuarios_Usuario $usuario, WeLearn_Cursos_Curso $paraCurso)
 {
     $cursoUUID = UUID::import($paraCurso->getId());
     $this->_convitesGerenciadorPorCursoCF->insert($cursoUUID->bytes, array($usuario->getId() => ''));
     $this->_cursoDao->salvarConviteGerenciador($usuario, $paraCurso);
 }
Exemplo n.º 23
0
    }
}
if ($image_name != "") {
    // 5. Determine the image id.
    $pos = strpos($image_name, '.');
    $img_ext = substr($image_name, $pos, strlen($image_name));
    $modified_image_name = "P" . $userid . $img_ext;
    $resourcedir = '/tmp/';
    $imagethumb = "P" . $userid . "T" . $img_ext;
    $user_image_location = $resourcedir . $modified_image_name;
    if (!move_uploaded_file($_FILES['user_image']['tmp_name'], $user_image_location)) {
        throw new Exception("Error moving uploaded file to {$user_image_location}");
    }
    // 6. Generate the thumbnails.
    $thumb_location = $resourcedir . $imagethumb;
    ImageUtil::createThumb($user_image_location, $thumb_location, 120, 120);
    // 7. Store the image.
    $fs = FileSystem::getInstance();
    if (!$fs->create($user_image_location, "NO_OP", "NO_OP")) {
        error_log("Error copying image " . $user_image_location);
    }
    if (!$fs->create($thumb_location, "NO_OP", "NO_OP")) {
        error_log("Error copying thumb " . $thumb_location);
    }
    unlink($user_image_location);
    unlink($thumb_location);
    // 8. Update the DB.
    $cf = new ColumnFamily($conn, 'PERSON');
    $cf->insert($userid, array('imageurl' => $modified_image_name, 'imagethumburl' => $imagethumb));
}
header("Location:users.php?username=" . $username);
Exemplo n.º 24
0
 */
session_start();
require_once "../etc/config.php";
require_once '../etc/phpcassa_config.php';
$friends = Users_Controller::getInstance();
$person = $_REQUEST['person'];
$friend = $_REQUEST['friend'];
$frnd = $_REQUEST['frnd'];
$user = $_REQUEST['query'];
$flag = $_REQUEST['flag'];
$cf = new ColumnFamily($conn, 'PERSON_PERSON');
$index_exp1 = CassandraUtil::create_index_expression('Person_username', $friend);
$index_exp2 = CassandraUtil::create_index_expression('friends_username', $person);
if ($flag == "add") {
    $personid = exec("python /usr/pysnowflakeclient/pysnowflakeclient/__init__.py");
    $cf->insert($personid, array('id' => $personid, 'Person_username' => $friend, 'friends_username' => $person, 'is_accepted' => 0));
} else {
    if ($flag == "delete") {
        $index_exp3 = CassandraUtil::create_index_expression('is_accepted', 0);
        $index_clause = CassandraUtil::create_index_clause(array($index_exp1, $index_exp2, $index_exp3));
        $result = $cf->get_indexed_slices($index_clause);
        foreach ($result as $key => $col) {
            $cf->remove($col["id"]);
        }
    } else {
        if ($flag == "frnd") {
            $index_exp3 = CassandraUtil::create_index_expression('is_accepted', 1);
            $index_clause = CassandraUtil::create_index_clause(array($index_exp1, $index_exp2, $index_exp3));
            $result = $cf->get_indexed_slices($index_clause);
            foreach ($result as $key => $col) {
                $cf->remove($col["id"]);
Exemplo n.º 25
0
      $_SESSION[$k_passwd] = $passwd;
      unset($error);
      $logged_in = true;
      $sub = new ColumnFamily($conn, CF_SUBSCRIPTIONS);
      $sub_info = $sub->get($system_info["subscription"]);
    }
  } catch (Exception $e) { }
}

if($logged_in) {
  if($request == "reboot") { // Ajax callback
    if($system_info["flag_allow_web_reset"] == 0) {
      echo "That system cannot be reset from the web";
    } else {
      try {
        $sys->insert($system, array("control" => "reset"));
        echo "Reboot is in progress";
      } catch (Exception $e) { 
        echo "An error occured";
      }
    }
    exit;
  }
  if($request == "xfer") {
    ob_start('ob_gzhandler');
    require_helper("bandwidth");
    $start = strtotime($sub_info["start"]);
    $monthly_start = $start_of_year = strtotime(date("Y-01-01"));
    $daily_start = $days_ago = strtotime("30 days ago");
    $hourly_start = $hours_ago = strtotime("24 hours ago");
    if($start > $monthly_start) {
Exemplo n.º 26
0
        throw new Exception("Error moving uploaded file to {$upload_literature_location}");
    }
    if (!isset($fs)) {
        $fs = FileSystem::getInstance();
    }
    if (!$fs->create($upload_literature_location, "NO_OP", "NO_OP")) {
        error_log("Error copying literature " . $upload_literature_location);
    }
    unlink($upload_literature_location);
}
// 11. Update the image names back to the database.
// Note: this update is in it's own transaction, after the images are
// properly stored. It is a single statement transaction and with autocommit
// on, we do not need to start and commit.
if (isset($_POST['addeventsubmit'])) {
    $updatese = new ColumnFamily($conn, 'SOCIALEVENT');
    $updatese->insert($eventid, array('imageurl' => $modified_image_name, 'imagethumburl' => $imagethumb, 'literatureurl' => $modified_literature_name));
} else {
    if (isset($_POST['addeventsubmitupdate'])) {
        $updatese = new ColumnFamily($conn, 'SOCIALEVENT');
        $updatese->insert($evid, array('imageurl' => $modified_image_name, 'imagethumburl' => $imagethumb, 'literatureurl' => $modified_literature_name));
    }
}
// 12. Redirect the results.
if (isset($_POST['addeventsubmit'])) {
    header("Location:events.php?socialEventID=" . $eventid);
} else {
    if (isset($_POST['addeventsubmitupdate'])) {
        header("Location:events.php?socialEventID=" . $evid);
    }
}
             } else {
                 $data[$column_key_name][$column_name] = $column_value;
             }
         }
         $no_column++;
     }
     $no_scf++;
 }
 try {
     if (!empty($key)) {
         if (count($data) > 0) {
             if (isset($_POST['mode']) && $_POST['mode'] == 'edit') {
                 $column_family->remove($key);
             }
             $time_start = microtime(true);
             $column_family->insert($key, $data);
             $time_end = microtime(true);
             // Insert successful
             if (isset($_POST['mode']) && $_POST['mode'] == 'insert') {
                 $vw_vars['success_message'] = displaySuccessMessage('insert_row', array('query_time' => getQueryTime($time_start, $time_end)));
             } else {
                 $vw_vars['success_message'] = displaySuccessMessage('edit_row', array('key' => $key, 'query_time' => getQueryTime($time_start, $time_end)));
             }
         } else {
             $vw_vars['error_message'] = displayErrorMessage('insert_row_incomplete_fields');
         }
     } else {
         $vw_vars['info_message'] = displayInfoMessage('insert_row_not_empty');
     }
 } catch (Exception $e) {
     $vw_vars['error_message'] = displayErrormessage('insert_row', array('message' => $e->getMessage()));
Exemplo n.º 28
0
 public function test_initial_connection_failure()
 {
     $servers = array('localhost', 'foobar');
     $pool = new ConnectionPool(self::$KS, $servers);
     $pool->fill();
     $stats = $pool->stats();
     self::assertEqual($stats['created'], 5);
     self::assertTrue($stats['failed'] == 5 || $stats['failed'] == 4);
     $cf = new ColumnFamily($pool, self::$CF);
     foreach (range(1, 50) as $i) {
         $cf->insert('key', array('c' => 'v'));
     }
     $pool->dispose();
     $servers = array('barfoo', 'foobar');
     try {
         $pool = new ConnectionPool(self::$KS, $servers);
         $pool->fill();
         self::assertTrue(false);
     } catch (NoServerAvailable $ex) {
     }
 }
Exemplo n.º 29
0
    $index_exp_event = CassandraUtil::create_index_expression('socialeventid', $se);
    $index_exp_uname = CassandraUtil::create_index_expression('username', $username);
    $index_clause = CassandraUtil::create_index_clause(array($index_exp_event, $index_exp_uname));
    $result = $checkuserIfAttending->get_indexed_slices($index_clause);
    $row['count'] = 0;
    foreach ($result as $key => $column) {
        $row['count'] += 1;
    }
    $userExists = $row['count'];
    if ($userExists <= 0) {
        /*        $insertuser = "******";
                $connection->exec($insertuser);
        */
        $insertuser = new ColumnFamily($conn, 'PERSON_SOCIALEVENT');
        $id = exec("python /usr/pysnowflakeclient/pysnowflakeclient/__init__.py");
        $insertuser->insert($id, array('id' => $id, 'username' => $username, 'socialeventid' => $se));
    }
}
if (!isset($connection)) {
    // If connection not there, we're read-only.
    $connection = DBConnection::getInstance();
}
/*
$listquery = "select username from PERSON_SOCIALEVENT ".
             "where socialeventid = '$se' and username = '******' ".
             "union select username from PERSON_SOCIALEVENT ".
             "where socialeventid = '$se' limit 20";
$listqueryresult = $connection->query($listquery);
*/
$listquery = new ColumnFamily($conn, 'PERSON_SOCIALEVENT');
$index_exp_event = CassandraUtil::create_index_expression('socialeventid', $se);