'pusty'); } else { while($w = mysql_fetch_array($r)){ $_CONFIG[$w['zmienna']]['nazwa'] = $w['nazwa']; $_CONFIG[$w['zmienna']]['wartosc'] = $w['wartosc']; } } $login = $_CONFIG['sms_login']['wartosc']; $dd = $_CONFIG['sms_haslo']['wartosc']; $haslo = md5($_CONFIG['sms_haslo']['wartosc']); $typ_sms = $_CONFIG['sms']['wartosc']; $sms_pl = $_CONFIG['sms_pl']['wartosc']; if ($_POST['pozz']) { //ponowne wysylanie sms $q_sms = "SELECT * FROM sms LEFT JOIN news AS n ON n.art_id = sms.art_id WHERE sms.art_id = ". $_POST['nid'] ." ORDER BY data_wyslania ASC LIMIT 1 "; } else { //wysyłanie nowych sms $q_sms = "SELECT * FROM sms LEFT JOIN news AS n ON n.art_id = sms.art_id WHERE sms.art_id = ". $_POST['nid'] ." AND sms.status = 0 OR sms.status = 1 ORDER BY data_wyslania ASC LIMIT 1 "; } $r_sms = query($q_sms); if(!$r_sms || mysql_affected_rows() == 0){ $ret = array("res" => 'pusty'); return; } else { $smsTresc = strip_tags(mysql_result($r_sms, 0, 'opis')); $smsTytul = strip_tags(mysql_result($r_sms, 0, 'tytul')); $smsPodpis = strip_tags(mysql_result($r_sms, 0, 'podpis_wiadomosci')); $smsArtId = strip_tags(mysql_result($r_sms, 0, 'art_id')); $data_wyslania = strip_tags(mysql_result($r_sms, 0, 'data_wyslania')); } $q_users = "SELECT * FROM kontakt_sms WHERE 1"; $r_sms_users = query($q_users); if(!$r_sms_users || mysql_affected_rows() == 0){ $ret = array("res" => 'pusty'); return; } else { $counter = 0; while($w = mysql_fetch_array($r_sms_users)){ if ($counter > 0){ $do .= ","; } $do .= $w['kontakt_numer']; $counter += 1; } } $tresc = urlencode($smsTresc); $from = urlencode($smsPodpis); // $fromAlt = urlencode("123321123"); if ($typ_sms = 0){ $typSms = "flash"; } else if ($typ_sms = 0){ $typSms = "max"; } else { $typSms = "sms"; } $typSms = "sms"; $sms_pl = 1; $nadawca = "Ecozmiany"; if ($login && $haslo && $do && $tresc) { $parametry = "?login=$login&pass=$haslo"."&to=$do&message=$tresc&from=Ecozmiany&type=$typSms&pl=$sms_pl"; $url = fopen('https://api.promosms.pl/send.php' . $parametry, 'r'); $wynik = fread($url, 1024); fclose($url); } $q_update = "UPDATE sms SET status = 2 WHERE art_id = " .$smsArtId; $r_sms_send = query($q_update); $ret = array("wynik" => $wynik, "typ" => $typSms, "pl" => $sms_pl, "login" => $login, "haslo" => $haslo, "do" => $do, 'tresc' => $tresc); header('Content-type: application/json'); echo json_encode($ret); exit(); } catch (Exception $ex){ $ret = array("res" => $ex->getMessage()); header('Content-type: application/json'); echo json_encode($ret); exit(); } return; } if($_GET['smsm'] == true) { try { $q = "SELECT * FROM ustawienia WHERE zmienna LIKE 'sms%'"; $r = query($q); if(!$r || mysql_affected_rows() == 0){ $ret = array("res" => 'pusty'); } else { while($w = mysql_fetch_array($r)){ $_CONFIG[$w['zmienna']]['nazwa'] = $w['nazwa']; $_CONFIG[$w['zmienna']]['wartosc'] = $w['wartosc']; } } $login = $_CONFIG['sms_login']['wartosc']; $dd = $_CONFIG['sms_haslo']['wartosc']; $haslo = md5($_CONFIG['sms_haslo']['wartosc']); $typ_sms = $_CONFIG['sms']['wartosc']; $sms_pl = $_CONFIG['sms_pl']['wartosc']; $q_sms = "SELECT * FROM sms LEFT JOIN news AS n ON n.art_id = sms.art_id WHERE sms.status = 0 OR sms.status = 1 ORDER BY data_wyslania ASC LIMIT 1 "; $r_sms = query($q_sms); if(!$r_sms || mysql_affected_rows() == 0){ $ret = array("res" => 'pusty'); return; } else { $smsTresc = strip_tags(mysql_result($r_sms, 0, 'opis')); $smsTytul = strip_tags(mysql_result($r_sms, 0, 'tytul')); $smsPodpis = strip_tags(mysql_result($r_sms, 0, 'podpis_wiadomosci')); $smsArtId = strip_tags(mysql_result($r_sms, 0, 'art_id')); $data_wyslania = strip_tags(mysql_result($r_sms, 0, 'data_wyslania')); } if(strtotime('now') < strtotime($data_wyslania)){ return ; } $q_users = "SELECT * FROM kontakt_sms WHERE 1"; $r_sms_users = query($q_users); if(!$r_sms_users || mysql_affected_rows() == 0){ $ret = array("res" => 'pusty'); return; } else { $counter = 0; while($w = mysql_fetch_array($r_sms_users)){ if ($counter > 0){ $do .= ","; } $do .= $w['kontakt_numer']; $counter += 1; } } $tresc = urlencode($smsTresc); $from = urlencode($smsPodpis); // $fromAlt = urlencode("123321123"); if ($typ_sms = 0){ $typSms = "flash"; } else if ($typ_sms = 0){ $typSms = "max"; } else { $typSms = "sms"; } if ($login && $haslo && $do && $tresc) { $parametry = "?login=$login&pass=$haslo"."&to=$do&message=$tresc&from=$from&type=$typSms&pl=$sms_pl"; $url = fopen('https://api.promosms.pl/send.php' . $parametry, 'r'); $wynik = fread($url, 1024); fclose($url); } $q_update = "UPDATE sms SET status = 2 WHERE art_id = " .$smsArtId; $r_sms_send = query($q_update); $ret = array("res" => $smsArtId); header('Content-type: application/json'); echo json_encode($ret); exit(); } catch (Exception $ex){} return; } $panel = panel(); //prezentacja dostępna jedynie z widoku panelu if (auth()) { $operacje = news_kontroler( $_GET['k'] ); $MAIN .= $operacje['a']; $HEAD .= $operacje['HEAD']; $pokaz = $operacje['pokaz']; // kontrolka blokująca wyświeltanie newsów if( in_array($_GET['k'], array( 'news_zapisz_zmiany' , 'news_dodaj'))) // odświżenie tablicy katagorii { $_CONFIG['KATEGORIE'] = kategorie(); // dane z mysql.kategorie $_CONFIG['SCIEZKI'] = (tablica_sciezek_2 (tablice_sciezek_1() )); // generuje tablicę ścierzek } } if (intval($_CONFIG['art_id']) && $panel) { $full = true; /// kontrolka prezentacji listy czy pełnego rekordu $x = news_zapytanie( $_CONFIG['art_id'], 'art_id'); $p = news_full_admin( $x , $_SESSION['typ']); $MAIN .= $p['MAIN']; $HEAD .= $p['HEAD']; $BODY .= $p['BODY']; if (config('typ') != 'txt') $HEAD .= edytor('HEAD'); // pobranie danych edytora } else if ($panel && $operacje['pokaz'] != true) { // --- OPERACJE NA TEBELI NEWS -------------------------------------- //pobranie referencji do smartów $smrt = Templates::getInstance()->getSmarty(); $x = sms_zapytanie(id(), 'str', 'DESC', (!auth("cms") ? 'public' : 'panel')); $ilosc = $x['ilosc_newsow']; $dane = pokaz_newsletter($x['query'], config('ikona_news'), false, false, config('news_data'), false, true, false, id()); $skrocony_tekst = array(); if (is_array($dane)) { foreach($dane as $key => $value){ $status = (string)$value['nl_status']; if ($status == 1) { $status = "W trakcie wysyłania"; } else if ($status == 2){ $status = "Wysłany"; } else { $status = "Oczekuje"; } $skrocony_tekst[] = array( 'fota' => $value['fota'], 'tytul' => $value['tytul'] , 'wstep' => substr(strip_tags($value['wstep']), 0, 200), 'data' => $value['data_source'], 'licznik' => $value['licznik'], 'link' => $value['link'], 'status' => "$status", 'datawyslania' => $value['nl_data_wyslania'], 'akcja' => "Opcje", 'newsletter_id' => $value['art_id']); } } $smrt->assign("data_wysylania", "$data_wyslania"); $smrt->assign("rek", $skrocony_tekst); $smrt->assign("klient", config('klient')); $smrt->assign("portal", $_CONFIG['adres_portalu']); $smrt->assign("url", $_CONFIG['adres_portalu'].'wiadomosci-sms/'); $operacja = $smrt->fetch("sms_list_item.tpl"); // $operacja = news_petla($skrocony_tekst , 'NEWSLETTER_LIST_ITEM'); $button = 'Dodaj wiadomość sms do wysłania'; /* 2013-01-16 poprawka opisów pokazujących się na wolu faceboka */ $artykul = @array_keys($dane ); // tablica kluczy //print_r( $artykul); $HEAD .= ' '; // ODDAJEMY KOD HTML $MAIN .= render( templates(config('typ').'_strona' ) , array( 'main' => $operacja , 'button' => button('?k=dodajform', $button ), 'ilosc' => $x['ilosc_newsow'] , 'stronicowanie' => porcjowanie( $x['aktualnie'],$x['ilosc_newsow'] , config('na_stronie') , (warunek() != false ? '&filtr='.$_GET['filtr'].'' : '') ), 'info' => (panel() ? news_pozycje_wg_daty('klawisz' , id()) : '') )); } ?>