function cassandra_query($sql) { require_once 'phpcassa/connection.php'; require_once 'phpcassa/columnfamily.php'; $servers[0]['host'] = '127.0.0.1'; $servers[0]['port'] = '9160'; $conn = new Connection('Keyspace1', $servers); $sql_stmt = explode(" ", $sql); $cf = $sql_stmt[3]; $uname = explode("=", $sql_stmt[5]); $passwd = explode("=", $sql_stmt[7]); echo $cf . " " . str_replace("'", "", $uname[1]) . " " . str_replace("'", "", $passwd[1]) . " " . $uname[0] . " " . $passwd[0]; $column_family = new ColumnFamily($conn, $cf); echo $cf . " " . str_replace("'", "", $uname[1]) . " " . str_replace("'", "", $passwd[1]) . " " . $uname[0] . " " . $passwd[0]; $index_exp = CassandraUtil::create_index_expression($uname[0], str_replace("'", "", $uname[1])); $index_clause = CassandraUtil::create_index_clause(array($index_exp)); $rows = $column_family->get_indexed_slices($index_clause); foreach ($rows as $key => $columns) { if ($columns[$passwd[0]] == str_replace("'", "", $passwd[1])) { // echo $columns; return $columns; } else { return NULL; } } }
function getEventsPageTagCloud($connection, $se) { $rowsFound = false; $sql = new ColumnFamily($connection, 'SOCIALEVENTTAG_SOCIALEVENT'); $cloudquery = new ColumnFamily($connection, 'SOCIALEVENTTAG'); $index_exp = CassandraUtil::create_index_expression('socialeventid', $se); $index_clause = CassandraUtil::create_index_clause(array($index_exp)); $result = $sql->get_indexed_slices($index_clause); if (!empty($result)) { foreach ($result as $key => $value) { if ($value['socialeventtagid'] != NULL) { $cloudresult = $cloudquery->get($value['socialeventtagid']); if ($cloudresult['refcount'] > 0) { $rowsFound = true; $tags[$cloudresult['tag']] = $cloudresult['refcount']; } } } } unset($cloudresult); if ($rowsFound) { // change these font sizes if you will $max_size = 250; // max font size in % $min_size = 100; // min font size in % // get the largest and smallest array values $max_count = max(array_values($tags)); $min_count = min(array_values($tags)); // find the range of values $spread = $max_count - $min_count; if (0 == $spread) { // we don't want to divide by zero $spread = 1; } // determine the font-size increment // this is the increase per tag count (times used) $step = ($max_size - $min_size) / $spread; // loop through our tag array foreach ($tags as $key => $value) { $size = $min_size + ($value - $min_count) * $step; // uncomment if you want sizes in whole %: $size = ceil($size); $eventTagCloud = $eventTagCloud . " " . '<a href="taggedEvents.php?tag=' . $key . '" style="font-size:' . $size . '%" title="' . $value . ' events tagged with ' . $key . '" >' . $key . '</a> '; } } return $eventTagCloud; }
/** * Removes columns from a row. * My suggestion is not to allow users to delete any pieces of your data. * Instead, use "soft delete" technique, which set a flag to indicate that a column or a row is deleted. * * @param string $key the row to remove columns from * @param mixed[] $columns the columns to remove. If null, the entire row will be removed. * @param mixed $superColumn only remove this super column * @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 delete($key, $columns = null, $superColumn = null, $writeConsistencyLevel = null) { if (empty($this->_columnFamily)) { $this->init(); } return $this->_columnFamily->remove($key, $columns, $superColumn, $writeConsistencyLevel); }
public function removerTodosPorAvaliacao(WeLearn_Cursos_Avaliacoes_Avaliacao $avaliacao) { try { $questoesRemovidas = $this->recuperarTodosPorAvaliacao($avaliacao); } catch (cassandra_NotFoundException $e) { return array(); } foreach ($questoesRemovidas as $questao) { $questaoUUID = UUID::import($questao->getId()); $alternativasRemovidas = $this->_alternativaDAO->removerTodosPorQuestao($questao); $this->_cf->remove($questaoUUID->bytes); $alternativaCorreta = null; for ($i = 0; $i < count($alternativasRemovidas); $i++) { if ($alternativasRemovidas[$i]->isCorreta()) { $questao->setAlternativaCorreta($alternativasRemovidas[$i]); unset($alternativasRemovidas[$i]); break; } } $questao->setAlternativasIncorretas($alternativasRemovidas); $questao->setPersistido(false); } $avaliacaoUUID = CassandraUtil::import($avaliacao->getId()); $this->_questaoPorAvaliacaoCF->remove($avaliacaoUUID->bytes); return $questoesRemovidas; }
/** * @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 => '')); } } }
/** * @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); } }
/** * @param string $chaveParticipacaoCurso * @return int */ public function recuperarQtdTotalPaginasVistas($chaveParticipacaoCurso) { try { $totalPaginasVistas = $this->_contadorCF->get($this->_keyContador, array($chaveParticipacaoCurso)); return $totalPaginasVistas[$chaveParticipacaoCurso]; } catch (cassandra_NotFoundException $e) { return 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); }
/** * @param mixed $id * @return WeLearn_DTO_IDTO */ public function remover($id) { $UUID = CassandraUtil::import($id); $moduloRemovido = $this->recuperar($id); $cursoUUID = CassandraUtil::import($moduloRemovido->getCurso()->getId()); $this->_cf->remove($UUID->bytes); $this->_moduloPorCursoCF->remove($cursoUUID->bytes, array($moduloRemovido->getNroOrdem())); $moduloRemovido->setPersistido(false); return $moduloRemovido; }
/** * @param WeLearn_Cursos_Curso $curso */ public function removerTodosPorCurso(WeLearn_Cursos_Curso $curso) { $cursoUUID = UUID::import($curso->getId()); $idsGerenciadores = array_keys($this->_gerenciadoresPorCursoCF->get($cursoUUID->bytes, null, $de, $ate, false, $count)); $idsConvites = array_keys($this->_convitesGerenciadorPorCursoCF->get($cursoUUID->bytes, null, $de, $ate, false, $count)); $this->_gerenciadoresPorCursoCF->remove($cursoUUID->bytes); $this->_convitesGerenciadorPorCursoCF->remove($cursoUUID->bytes); $this->_cursoDao->removerTodosGerenciadores($idsGerenciadores, $curso); $this->_cursoDao->removerTodosConvitesGerenciador($idsConvites, $curso); }
function get_xfer_metrics($system, $dates, $date_step) { $metrics = array("tx_bytes", "rx_bytes", "vnc-tx_bytes", "vnc-rx_bytes"); $conn = cassandra_connect(KS_METRICS); $agg = new ColumnFamily($conn, CF_AGG); $keys = array(); $totals = array(); foreach($metrics as $metric) { $keys[] = "$system-$metric-$date_step"; $totals[$metric] = array(); } $result = $agg->multiget($keys, $dates); foreach($metrics as $metric) { $xfer = $result["$system-$metric-$date_step"]; foreach($dates as $date) { $v = array_key_exists($date, $xfer) ? $xfer[$date] : ""; $totals[$metric][$date] = $v; } } return $totals; }
/** * @param string $usuarioId * @return void */ private function _removerListaDeRS($usuarioId) { try { $idsRS = array_keys($this->_RSPorUsuarioCF->get($usuarioId)); foreach ($idsRS as $id) { $this->_RSCF->remove($id); } $this->_RSPorUsuarioCF->remove($usuarioId); } catch (cassandra_NotFoundException $e) { return; } }
/** * @param WeLearn_Cursos_Enquetes_Enquete $enquete */ public function removeTodosrPorEnquete(WeLearn_Cursos_Enquetes_Enquete $enquete) { $enqueteUUID = CassandraUtil::import($enquete->getId()); $alternativasUUIDs = array(); foreach ($enquete->getAlternativas() as $alternativa) { $alternativasUUIDs[] = CassandraUtil::import($alternativa->getId()); } $this->_cf->remove($enqueteUUID->bytes); foreach ($alternativasUUIDs as $alternativaUUID) { $this->_votosPorAlternativaCF->remove($alternativaUUID->bytes); } }
private function _recuperarRestantes(array $ids, WeLearn_Cursos_ParticipacaoCurso $participacaoCurso) { $columns = array(); foreach ($ids as $nroOrdem => $id) { try { $column = $this->_cf->get($id); $columns[] = $column; } catch (cassandra_NotFoundException $e) { $this->_controleAvaliacaoPorParticipacaoCF->remove($participacaoCurso->getId(), array($nroOrdem)); } } return $columns; }
private function _recuperarRestantesPorAluno(array $ids, WeLearn_Usuarios_Aluno $aluno) { $columns = array(); for ($i = 0; $i < count($ids); $i++) { try { $column = $this->_cf->get($ids[$i]); $columns[] = $column; } catch (cassandra_NotFoundException $e) { $this->_certificadosPorAlunoCF->remove($aluno->getId(), array($ids[$i])); } } return $columns; }
/** * @param mixed $de * @param mixed $ate * @param array|null $filtros * @return array */ public function recuperarTodos($de = '', $ate = '', array $filtros = null) { $count = isset($filtros['count']) && is_int($filtros['count']) ? $filtros['count'] : ColumnFamily::DEFAULT_COLUMN_COUNT; //Todos os segmentos em uma área específfica if (is_array($filtros) && isset($filtros['areaId'])) { $segmentos_em_area = $this->_segmentosEmAreaCF->get($filtros['areaId'], null, $de, $ate, false, $count); if (!empty($segmentos_em_area)) { $dados_segmentos = $this->_cf->multiget(array_keys($segmentos_em_area)); if (!empty($dados_segmentos)) { $area = $this->_areaDAO->recuperar($filtros['areaId']); $listaSegmentos = array(); foreach ($dados_segmentos as $key => $columns) { $columns['area'] = $area; $segmento = new WeLearn_Cursos_Segmento(); $segmento->fromCassandra($columns); $segmento->setPersistido(true); $listaSegmentos[] = $segmento; } return $listaSegmentos; } } } else { //Todos os segmentos cadastrados no serviço. $dados_segmentos = $this->_cf->get_range($de, $ate, $count); if (!empty($dados_segmentos)) { $listaSegmentos = array(); foreach ($dados_segmentos as $key => $columns) { $columns['area'] = $this->_areaDAO->recuperar($columns['area']); $segmento = new WeLearn_Cursos_Segmento(); $segmento->fromCassandra($columns); $segmento->setPersistido(true); $listaSegmentos[] = $segmento; } return $listaSegmentos; } } return false; }
/** * @param WeLearn_Usuarios_Usuario $usuario * @return void */ public function limparNovas(WeLearn_Usuarios_Usuario $usuario) { try { $cfKeys = array_keys($this->_notificacoesNovasPorUsuarioCF->get($usuario->getId(), null, '', '', false, 1000000)); } catch (cassandra_NotFoundException $e) { return; } $batchAtualizacao = array(); for ($i = 0; $i < count($cfKeys); $i++) { $batchAtualizacao[$cfKeys[$i]] = array('status' => WeLearn_Notificacoes_StatusNotificacao::LIDO); } $this->_cf->batch_insert($batchAtualizacao); $this->_notificacoesNovasPorUsuarioCF->remove($usuario->getId()); }
/** * @param WeLearn_Cursos_Conteudo_Modulo $modulo * @param array $novasPosicoes */ public function atualizarPosicao(WeLearn_Cursos_Conteudo_Modulo $modulo, array $novasPosicoes) { $posicoes = array(); $rows = array(); foreach ($novasPosicoes as $posicao => $id) { $UUID = UUID::import($id)->bytes; $posicoes[$posicao] = $UUID; $rows[$UUID] = array('nroOrdem' => $posicao); } $moduloUUID = UUID::import($modulo->getId())->bytes; $this->_cf->batch_insert($rows); $this->_aulaPorModuloCF->remove($moduloUUID); $this->_aulaPorModuloCF->insert($moduloUUID, $posicoes); }
/** * @param mixed $id * @return WeLearn_DTO_IDTO */ public function remover($id) { $UUID = CassandraUtil::import($id); $recursoRemovido = $this->recuperar($id); $this->_cf->remove($UUID->bytes); if ($recursoRemovido instanceof WeLearn_Cursos_Recursos_RecursoRestrito) { $aulaUUID = CassandraUtil::import($recursoRemovido->getAula()->getId()); $this->_recursosRestritosCF->remove($aulaUUID->bytes, array($UUID->bytes)); } elseif ($recursoRemovido instanceof WeLearn_Cursos_Recursos_RecursoGeral) { $cursoUUID = CassandraUtil::import($recursoRemovido->getCurso()->getId()); $this->_recursosGeraisCF->remove($cursoUUID->bytes, array($UUID->bytes)); } else { throw new WeLearn_Base_Exception('A classe removida tem que derivar de WeLearn_Cursos_Recursos_Recurso.'); } $recursoRemovido->setPersistido(false); return $recursoRemovido; }
/** * @param mixed $id * @return WeLearn_DTO_IDTO */ public function remover($id) { $UUID = CassandraUtil::import($id); $paginaRemovida = $this->recuperar($id); $aulaUUID = CassandraUtil::import($paginaRemovida->getAula()->getId()); $this->_cf->remove($UUID->bytes); $this->_paginaPorAulaCF->remove($aulaUUID->bytes, array($paginaRemovida->getNroOrdem())); $curso = $paginaRemovida->getAula()->getModulo()->getCurso(); $cursoUUID = CassandraUtil::import($curso->getId()); $this->_contadorCF->add($this->_keyContador, $cursoUUID->bytes, -1); $controlePaginaDao = WeLearn_DAO_DAOFactory::create('ControlePaginaDAO', null, false); $idsAlunos = WeLearn_DAO_DAOFactory::create('AlunoDAO')->recuperarTodasIdsPorCurso($curso); for ($i = 0; $i < count($idsAlunos); $i++) { $cfKey = $idsAlunos[$i] . '::' . $curso->getId(); $controlePaginaDao->decrementarPaginasVistas($cfKey); } $paginaRemovida->setPersistido(false); return $paginaRemovida; }
/** * @param string $usuario * @param string $senha * @return WeLearn_DTO_IDTO * @throws WeLearn_Usuarios_AutenticacaoLoginInvalidoException|WeLearn_Usuarios_AutenticacaoSenhaInvalidaException */ public function autenticar($usuario, $senha) { $usuario = (string) $usuario; $senha = (string) $senha; try { //Se for um email. if (filter_var($usuario, FILTER_VALIDATE_EMAIL)) { $emailUsuario = $this->_emailUsuarioCF->get($usuario); $objUsuario = $this->recuperar($emailUsuario['usuarioId']); } else { $objUsuario = $this->recuperar($usuario); } //Caso a senha for menor que 24 caracteres não é md5, necessário encriptar. $senha = strlen($senha) <= 24 ? md5($senha) : $senha; if ($objUsuario->getSenha() == $senha) { return $objUsuario; } else { throw new WeLearn_Usuarios_AutenticacaoSenhaInvalidaException($senha); } } catch (cassandra_NotFoundException $e) { throw new WeLearn_Usuarios_AutenticacaoLoginInvalidoException($usuario); } }
$hour = substr($eventdate, 11, 2); $minute = substr($eventdate, 14, 2); $street1 = $row['street1']; $street2 = $row['street2']; $city = $row['city']; $state = $row['state']; $zip = $row['zip']; $country = $row['country']; unset($result); // $q1="select tag from SOCIALEVENTTAG as st, SOCIALEVENTTAG_SOCIALEVENT as sst where sst.socialeventid='$se' and sst.socialeventtagid=st.socialeventtagid order by tag ASC"; // $result1 = $connection->query($q1); $sql = new ColumnFamily($conn, 'SOCIALEVENTTAG_SOCIALEVENT'); $index_exp = CassandraUtil::create_index_expression('socialeventid', $se); $index_clause = CassandraUtil::create_index_clause(array($index_exp)); $result1 = $sql->get_indexed_slices($index_clause, $columns = array('socialeventtagid')); $q1 = new ColumnFamily($conn, 'SOCIALEVENTTAG'); foreach ($result1 as $key1 => $col1) { $row = $q1->get($col1['socialeventtagid']); $tg = $row['tag']; $tags = $tags . " " . $tg; } unset($result1); } if (!is_null($se) && (is_null($_SESSION["uname"]) || !($_SESSION["uname"] == $submitter))) { $fillMessage = "<font color=red>You can only edit events you created.</font> "; } else { ob_start(); require "../views/addEvent.php"; $fillContent = ob_get_clean(); } require_once "../views/site.php";
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); } }
function getUpcomingEventsForUser($user, $connection, $flag, $offset) { if (!$flag) { // $query = "select se.socialeventid,se.title From SOCIALEVENT as se,PERSON_SOCIALEVENT as ps where se.socialeventid=ps.socialeventid and se.eventtimestamp>=CURRENT_TIMESTAMP and ps.username='******' ORDER BY se.eventdate ASC limit 3"; $sql = new ColumnFamily($connection, 'PERSON_SOCIALEVENT'); $index_exp_uname = CassandraUtil::create_index_expression('username', $user); $index_clause = CassandraUtil::create_index_clause(array($index_exp_uname), 0, 3); $rows = $sql->get_indexed_slices($index_clause, $columns = array('socialeventid')); $query = new ColumnFamily($connection, 'SOCIALEVENT'); foreach ($rows as $key => $columns) { $index_exp1 = CassandraUtil::create_index_expression('socialeventid', $columns['socialeventid'], cassandra_IndexOperator::EQ); $index_exp2 = CassandraUtil::create_index_expression('eventtimestamp', time(), cassandra_IndexOperator::GTE); $index_clause1 = CassandraUtil::create_index_clause(array($index_exp1, $index_exp2)); $queryresult = $query->get_indexed_slices($index_clause1); $queryresult = $query->get_indexed_slices($index_clause1); foreach ($queryresult as $key1 => $value1) { $result[$key1] = $value1; } } $count = 1; } else { if ($flag) { // $query = "select se.socialeventid,se.title From SOCIALEVENT as se,PERSON_SOCIALEVENT as ps where se.socialeventid=ps.socialeventid and se.eventtimestamp>=CURRENT_TIMESTAMP and ps.username='******' ORDER BY se.eventdate ASC limit $offset,10"; $sql = new ColumnFamily($connection, 'PERSON_SOCIALEVENT'); $index_exp_uname = CassandraUtil::create_index_expression('username', $user); $index_clause = CassandraUtil::create_index_clause(array($index_exp_uname), $offset, 10); $rows = $sql->get_indexed_slices($index_clause, $columns = array('socialeventid')); $query = new ColumnFamily($connection, 'SOCIALEVENT'); foreach ($rows as $key => $columns) { $index_exp1 = CassandraUtil::create_index_expression('socialeventid', $columns['socialeventid'], cassandra_IndexOperator::EQ); $index_exp2 = CassandraUtil::create_index_expression('eventtimestamp', time(), cassandra_IndexOperator::GTE); $index_clause1 = CassandraUtil::create_index_clause(array($index_exp1, $index_exp2)); $queryresult = $query->get_indexed_slices($index_clause1); $queryresult = $query->get_indexed_slices($index_clause1); foreach ($queryresult as $key1 => $value1) { $result[$key1] = $value1; } } $count = 1 + $offset; } } foreach ($result as $key1 => $row) { $rowsFound = true; $title = $row['title']; $se = $row['socialeventid']; $upcomingEvents = $upcomingEvents . " " . '<a href="events.php?socialEventID=' . $se . '">' . $count . '. ' . $title . '</a><br/>'; $count++; } unset($result); return $upcomingEvents; }
* 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']; $revokeSql = new ColumnFamily($conn, 'PERSON_PERSON'); $index_exp_person = CassandraUtil::create_index_expression('Person_username', $friend); $index_exp_friend = CassandraUtil::create_index_expression('friends_username', $person); $index_clause = CassandraUtil::create_index_clause(array($index_exp_person, $index_exp_friend)); $result = $revokeSql->get_indexed_slices($index_clause); foreach ($result as $key => $col) { $revokeSql->remove($col['id']); } $outgoingRequests = $friends->outgoingRequests($person, $conn); echo "<font color=green>You have revoked your friendship request to " . $friend . "</font>\n"; echo $outgoingRequests; ?>
* */ session_start(); require_once "../etc/config.php"; require_once '../etc/phpcassa_config.php'; $se = $_REQUEST['id']; $username = $_SESSION["uname"]; if (!is_null($username)) { $cf = new ColumnFamily($conn, 'PERSON_SOCIALEVENT'); $index_exp = CassandraUtil::create_index_expression('socialeventid', $se); $index_exp1 = CassandraUtil::create_index_expression('username', $username); $index_clause = CassandraUtil::create_index_clause(array($index_exp, $index_exp1)); $result = $cf->get_indexed_slices($index_clause); foreach ($result as $key => $column) { $id = $column['id']; } $cf->remove($id); } $username = $_SESSION["uname"]; $listquery = new ColumnFamily($conn, 'PERSON_SOCIALEVENT'); $index_exp = CassandraUtil::create_index_expression('socialeventid', $se); $index_clause = CassandraUtil::create_index_clause(array($index_exp)); $listqueryresult = $listquery->get_indexed_slices($index_clause); foreach ($listqueryresult as $key => $column) { $tmp_uname = $column['username']; $attendeeList = $attendeeList . " " . '<a href="users.php?username='******'">' . $tmp_uname . '</a><br />'; } unset($listqueryresult); $numofattendees = $_SESSION["numofattendees"] - 1; $_SESSION["numofattendees"] = $numofattendees; echo '<h2 class="smaller_heading">' . $numofattendees . ' Attendees:</h2><br/><input name="attend" type="button" value="Attend" onclick="addAttendee();"/><br/><div id="attendees">' . $attendeeList . '</div>';
* 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;
require_once "../etc/config.php"; require_once '../etc/phpcassa_config.php'; $username = $_REQUEST['username']; $connection = DBConnection::getInstance(); $events = Events_Controller::getInstance(); $friends = Users_Controller::getInstance(); $friendCloud = $friends->getFriendCloud($username, $conn); $incomingRequests = $friends->incomingRequests($username, $conn); $outgoingRequests = $friends->outgoingRequests($username, $conn); $flag = false; $recentlyPostedEvents = $events->getRecentlyPostedEventsOfUser($username, $conn, $flag, null); $column_family = new ColumnFamily($conn, 'PERSON'); $index_exp = CassandraUtil::create_index_expression('username', $username); $index_clause = CassandraUtil::create_index_clause(array($index_exp)); $rows = $column_family->get_indexed_slices($index_clause); $column_family1 = new ColumnFamily($conn, 'ADDRESS'); foreach ($rows as $key => $row) { $addr_rows = $column_family1->get($row['ADDRESS_addressid']); $row['street1'] = $addr_rows['street1']; $row['street2'] = $addr_rows['street2']; $row['city'] = $addr_rows['city']; $row['state'] = $addr_rows['state']; $row['zip'] = $addr_rows['zip']; $row['country'] = $addr_rows['country']; } $username = $row['username']; $firstname = $row['firstname']; $lastname = $row['lastname']; $email = $row['email']; $telephone = $row['telephone']; $image = $row['imagethumburl'];
$prev_page = 1; } if ($next_page > $numPages) { $next_page = $numPages; } } else { /* $query = "select count(*) as count From SOCIALEVENT as se,PERSON_SOCIALEVENT as ps where se.socialeventid=ps.socialeventid and se.eventtimestamp>=CURRENT_TIMESTAMP and ps.username='******'"; $result = $connection->query($query); $row = $result->getArray(); */ $row['count'] = 0; $sql = new ColumnFamily($conn, 'PERSON_SOCIALEVENT'); $index_exp_uname = CassandraUtil::create_index_expression('username', $un); $index_clause = CassandraUtil::create_index_clause(array($index_exp_uname)); $rows = $sql->get_indexed_slices($index_clause, $columns = array('socialeventid')); $query = new ColumnFamily($conn, 'SOCIALEVENT'); foreach ($rows as $key => $columns) { $index_exp1 = CassandraUtil::create_index_expression('socialeventid', $columns['socialeventid'], cassandra_IndexOperator::EQ); $index_exp2 = CassandraUtil::create_index_expression('eventtimestamp', time(), cassandra_IndexOperator::GTE); $index_clause1 = CassandraUtil::create_index_clause(array($index_exp1, $index_exp2)); $result = $query->get_indexed_slices($index_clause1); foreach ($result as $key1 => $value1) { $row['count'] += 1; } } $count = $row['count']; unset($result); $numPages = ceil($count / 10); $_SESSION["numPages"] = $numPages; $prev_page = 1; $next_page = 2;
} $value = ''; if (isset($_POST['value'])) { $value = $_POST['value']; } $keyspace_name = ''; if (isset($_POST['keyspace_name'])) { $keyspace_name = $_POST['keyspace_name']; } $columnfamily_name = ''; if (isset($_POST['columnfamily_name'])) { $columnfamily_name = $_POST['columnfamily_name']; } try { $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(), null, 5, 5000, 5000, 10000, $cluster_helper->getCredentialsForCurrentCluster()); $column_family = new ColumnFamily($pool, $columnfamily_name); if ($action == 'dec') { $value *= -1; } $column_family->add($key, $column, $value, $super_column); $new_value = $column_family->get($key); if ($column_family->cfdef->column_type == 'Super') { $new_value = $new_value[$super_column][$column]; } else { $new_value = $new_value[$column]; } redirect('counters.php?keyspace_name=' . $keyspace_name . '&columnfamily_name=' . $columnfamily_name . '&new_value=' . $new_value); } catch (Exception $e) { $_SESSION['message'] = $e->getMessage(); redirect('counters.php?keyspace_name=' . $keyspace_name . '&columnfamily_name=' . $columnfamily_name . '&error=1'); }