123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- <?php
- if (!defined('entry') || !entry) {
- die('Not a valid page');
- }
- /* ===========================
-
- Sorbet CMS - A PHP based tumblelog CMS forked from Gelato CMS
-
- Sorbet CMS is a free software licensed under the GPL 3.0
-
- =========================== */
- $util_class = new util();
- class sorbet
- {
- public $db;
- public $conf;
-
- public function __construct()
- {
- global $db;
- global $conf;
-
- $this->db = $db;
- $this->conf = $conf;
- }
-
- public function saveSettings($fieldsArray)
- {
- if ($this->db->modificarDeFormulario($this->conf->tablePrefix."config", $fieldsArray)) {
- header("Location: ".$this->conf->urlSorbet."/admin/settings.php?modified=true");
- die();
- } else {
- header("Location: ".$this->conf->urlSorbet."/admin/settings.php?error=1&des=".$this->db->merror);
- die();
- }
- }
-
- public function saveOption($value, $name)
- {
- $sqlStr = "UPDATE ".$this->conf->tablePrefix."options SET val='".$value."' WHERE name='".$name."' LIMIT 1";
- if ($this->db->ejecutarConsulta($sqlStr)) {
- return true;
- } else {
- return true;
- }
- }
-
- public function addPost($fieldsArray)
- {
- if ($this->db->insertarDeFormulario($this->conf->tablePrefix."data", $fieldsArray)) {
- return true;
- } else {
- return false;
- }
- }
-
- public function modifyPost($fieldsArray, $id_post)
- {
- if ($this->db->modificarDeFormulario($this->conf->tablePrefix."data", $fieldsArray, "id_post=$id_post")) {
- header("Location: ".$this->conf->urlSorbet."/admin/index.php?modified=true");
- die();
- } else {
- header("Location: ".$this->conf->urlSorbet."/admin/index.php?error=2&des=".$this->db->merror);
- die();
- }
- }
-
- public function deletePost($idPost)
- {
- $this->db->ejecutarConsulta("DELETE FROM ".$this->conf->tablePrefix."data WHERE id_post=".$idPost);
- }
-
- public function getPosts($limit="10", $from="0")
- {
- $sqlStr = "select * from ".$this->conf->tablePrefix."data ORDER BY date DESC LIMIT $from,$limit";
- $this->db->ejecutarConsulta($sqlStr);
- return $this->db->mid_consulta;
- }
-
- public function getPost($id="")
- {
- $this->db->ejecutarConsulta("select * from ".$this->conf->tablePrefix."data WHERE id_post=".$id);
- return $this->db->mid_consulta->fetch();
- }
-
- public function getPostsNumber()
- {
- $this->db->ejecutarConsulta("select count(*) as total from ".$this->conf->tablePrefix."data");
- $row = $this->db->mid_consulta->fetch();
- return $row['total'];
- }
-
- public function getType($id)
- {
- if ($this->db->ejecutarConsulta("select type from ".$this->conf->tablePrefix."data WHERE id_post=".$id)) {
- if ($this->db->contarRegistros()>0) {
- while ($registro = $this->db->mid_consulta->fetch()) {
- return $registro[0];
- }
- }
- } else {
- return "0";
- }
- }
-
- public function formatConversation($text)
- {
- $formatedText = "";
- $odd=true;
-
- $lines = explode("\n", $text);
-
- $formatedText .= "<ul>\n";
- foreach ($lines as $line) {
- $pos = strpos($line, ":") + 1;
-
- $label = substr($line, 0, $pos);
- $desc = substr($line, $pos, strlen($line));
-
- if ($odd) {
- $cssClass = "odd";
- } else {
- $cssClass = "even";
- }
- $odd=!$odd;
-
-
- $formatedText .= " <li class=\"".$cssClass."\">\n";
- $formatedText .= " <span class=\"label\">".$label."</span>\n";
- $formatedText .= " ".$desc."\n";
- $formatedText .= " </li>\n";
- }
- $formatedText .= "</ul>\n";
- return $formatedText;
- }
-
- public function formatApiConversation($text)
- {
- $formatedText = "";
-
- $lines = explode("\n", $text);
-
- foreach ($lines as $line) {
- $pos = strpos($line, ":") + 1;
-
- $name = substr($line, 0, $pos-1);
- $label = substr($line, 0, $pos);
- $desc = substr($line, $pos, strlen($line));
-
- $formatedText .= "<conversation-line name=\"".$name."\" label=\"".$label."\">".$desc."</conversation-line>\n";
- }
-
- return $formatedText;
- }
-
- public function saveMP3($remoteFileName)
- {
- if ($util_class->getMP3File($remoteFileName)) {
- return true;
- } else {
- return false;
- }
- }
-
- public function savePhoto($remoteFileName)
- {
- if ($util_class->getPhotoFile($remoteFileName)) {
- return true;
- } else {
- return false;
- }
- }
-
- public function getVideoPlayer($url)
- {
- $util_class = new util();
- if ($util_class->isYoutubeVideo($url)) {
- $id_video = $util_class->getYoutubeVideoUrl($url);
- return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.youtube.com/v/".$id_video."\"><param name=\"movie\" value=\"http://www.youtube.com/v/".$id_video."\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
- } elseif ($util_class->isVimeoVideo($url)) {
- $id_video = $util_class->getVimeoVideoUrl($url);
- return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\"><param name=\"movie\" value=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
- } elseif ($util_class->isDailymotionVideo($url)) {
- $id_video = $util_class->getDailymotionVideoUrl($url);
- return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.dailymotion.com/swf/".$id_video."\"><param name=\"movie\" value=\"http://www.dailymotion.com/swf/".$id_video."\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
- } elseif ($util_class->isYahooVideo($url)) {
- $id_video = $util_class->getYahooVideoCode($url);
- return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://d.yimg.com/static.video.yahoo.com/yep/YV_YEP.swf\"><param name=\"quality\" value=\"high\" /><param name=\"FlashVars\" value=\"event_function=YAHOO.yv.Player.SWFInterface&id=".$id_video[1]."&vid=".$id_video[0]."&onsite=1&site=video.yahoo.com&page=792730258&lang=en-US&intl=us\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
- } elseif ($util_class->isSlideSharePresentation($url)) {
- $id_video = $util_class->getSlideSharePresentationCode($url);
- return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.slideshare.net/swf/player.swf?presentationId=".$id_video[0]."&doc=".$id_video[1]."&inContest=0&startSlide=1\"><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
- } elseif ($util_class->isGoogleVideoUrl($url)) {
- $id_video = $util_class->getGoogleVideoCode($url);
- return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://video.google.com/googleplayer.swf?docid=".$id_video."&hl=es&fs=true\"><param name=\"movie\" value=\"http://video.google.com/googleplayer.swf?docid=".$id_video."&hl=es&fs=true\" /><param name=\"allowFullScreen\" value=\"true\" /><param name=\"allowScriptAccess\" value=\"always\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
- } elseif ($util_class->isMTVVideoUrl($url)) {
- $id_video = $util_class->getMTVVideoCode($url);
- return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://media.mtvnservices.com/mgid:uma:video:mtvmusic.com:".$id_video."\"><param name=\"movie\" value=\"http://media.mtvnservices.com/mgid:uma:video:mtvmusic.com:".$id_video."\" /><param name=\"allowFullScreen\" value=\"true\" /><param name=\"allowScriptAccess\" value=\"never\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
- } else {
- return "This URL is not a supported video (YouTube, Google Video, Vimeo, DailyMotion, Yahoo Video, MTV or SlideShare)";
- }
- }
- public function getMp3Player($url)
- {
- if ($util_class->isMP3($url)) {
- $playerUrl = $conf->urlSorbet."/admin/scripts/player.swf?soundFile=".$url;
- return "\t\t\t<object type=\"application/x-shockwave-flash\" data=\"" . $playerUrl . "\" width=\"290\" height=\"24\"><param name=\"movie\" value=\"" . $playerUrl . "\" /><param name=\"quality\" value=\"high\" /><param name=\"menu\" value=\"false\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
- } elseif ($util_class->isGoEar($url)) {
- return "\t\t\t<object type=\"application/x-shockwave-flash\" data=\"http://www.goear.com/files/external.swf\" width=\"366\" height=\"130\"><param name=\"movie\" value=\"http://www.goear.com/files/external.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"FlashVars\" value=\"file=".$util_class->getGoEarCode($url)."\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
- } elseif ($util_class->isOdeo($url)) {
- return "\t\t\t<object type=\"application/x-shockwave-flash\" data=\"http://media.odeo.com/flash/odeo_player.swf?v=3\" width=\"366\" height=\"75\"><param name=\"quality\" value=\"high\" /><param name=\"FlashVars\" value=\"type=audio&id=".$util_class->getOdeoCode($url)."\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
- } else {
- return "This URL is not an MP3 file.";
- }
- }
-
- public function getPermalink($post_id)
- {
- $strEnd = ($this->conf->urlFriendly) ? "/" : "";
- $out = $this->conf->urlSorbet;
- $out .= ($this->conf->urlFriendly) ? "/post/" : "/index.php?post=";
- $out .= $post_id.$strEnd;
- return $out;
- }
- }
|