Ejemplo n.º 1
0
# rootfs
#
if (_snomAppCmp($a, '7') < 0) {
    if (!empty($rootfs_ramdisk)) {
        gs_log(GS_LOG_NOTICE, "Phone {$mac}: Please upgrade the phone's rootfs from ramdisk to Jffs2-3.36");
        exit(0);
    } elseif (!empty($rootfs_jffs2)) {
        if ($rootfs_jffs2 < '3.36') {
            gs_log(GS_LOG_NOTICE, "Phone {$mac}: Please upgrade the phone's rootfs from {$rootfs_jffs2} to Jffs2-3.36");
            exit(0);
        }
    }
}
# application
#
if (_snomAppCmp($a, '5') < 0) {
    gs_log(GS_LOG_NOTICE, "Phone {$mac}: Please upgrade the firmware from {$a} to 6.5 or higher");
}
$db = gs_db_master_connect();
if (!$db) {
    gs_log(GS_LOG_WARNING, "Snom phone asks for firmware - Could not connect to DB");
    exit(0);
}
$phone_id = (int) $db->executeGetOne('SELECT `id` ' . 'FROM `phones` ' . 'WHERE `mac_addr`=\'' . $db->escape($mac) . '\'');
if (!$phone_id) {
    gs_log(GS_LOG_WARNING, "DB error");
    exit(0);
}
# do we have to upgrade to a default version?
#
$fw_was_upgraded_manually = (int) $db->executeGetOne('SELECT `fw_manual_update`' . 'FROM `phones` ' . 'WHERE `id`=' . $phone_id);
Ejemplo n.º 2
0
function _settings_out()
{
    global $settings, $fw_vers_nrml, $prov_url_snom;
    if (_snomAppCmp($fw_vers_nrml, '7.1.8') < 0) {
        header('Content-Type: text/plain; charset=utf-8');
        # the Content-Type header is ignored by the Snom
        foreach ($settings as $name => $a1) {
            if (subStr($name, 0, 1) === '_') {
                continue;
            }
            if (!array_key_exists('_is_array', $a1)) {
                echo $name, $a1['w'] ? '$' : '&', ': ', $a1['v'], "\n";
            } else {
                if ($name !== 'fkey') {
                    foreach ($a1 as $idx => $a2) {
                        if ($idx === '_is_array') {
                            continue;
                        }
                        echo $name, $idx, $a2['w'] ? '$' : '&', ': ', $a2['v'], "\n";
                    }
                } else {
                    foreach ($a1 as $idx => $a2) {
                        if ($idx === '_is_array') {
                            continue;
                        }
                        echo $name, $idx, $a2['w'] ? '$' : '&', ': ', $a2['v'], "\n";
                        if (is_array($a2['a']) && array_key_exists('context', $a2['a'])) {
                            echo $name, '_context', $idx, $a2['w'] ? '$' : '&', ': ', $a2['a']['context'], "\n";
                        }
                    }
                }
            }
            /*
            	! means writeable by the user, but will not overwrite existing
            	$ means writeable by the user, but will overwrite existing (available since version 4.2)
            	& (or no flag) means read only, but will overwrite existing
            */
        }
        unset($settings);
    } else {
        header('Content-Type: application/xml; charset=utf-8');
        echo '<', '?xml version="1.0" encoding="utf-8"?', '>', "\n";
        echo '<settings>', "\n\n";
        $xml_cats = array();
        foreach ($settings as $name => $a1) {
            if (!array_key_exists('_is_array', $a1)) {
                $attrstr = '';
                if (is_array($a1['a'])) {
                    foreach ($a1['a'] as $attr => $attrval) {
                        $attrstr .= ' ' . $attr . '="' . _snomCnfXmlEsc($attrval) . '"';
                    }
                }
                $line = '<' . $name . $attrstr . ' perm="' . ($a1['w'] ? 'RW' : 'R') . '">' . _snomCnfXmlEsc($a1['v']) . '</' . $name . '>';
                _add_to_cat($xml_cats, $name, $line);
            } else {
                if ($name === '_gui_lang' || $name === '_web_lang') {
                    foreach ($a1 as $idx => $a2) {
                        if ($idx === '_is_array') {
                            continue;
                        }
                        $attrstr = '';
                        if (is_array($a2['a'])) {
                            foreach ($a2['a'] as $attr => $attrval) {
                                $attrstr .= ' ' . $attr . '="' . _snomCnfXmlEsc($attrval) . '"';
                            }
                        }
                        $line = '<language url="' . $prov_url_snom . 'sw/' . _snomCnfXmlEsc($a2['v']) . '" name="' . _snomCnfXmlEsc($idx) . '"' . $attrstr . ' />';
                        $langfile = GS_DIR . 'htdocs/prov/snom/sw/' . $a2['v'];
                        $langfile_lock = $langfile . '.lock';
                        $langfiles_dir = dirName($langfile) . '/';
                        $langfile_url = 'http://provisioning.snom.com/config/snom' . $a2['v'];
                        if (file_exists($langfile) && is_readable($langfile) && file_exists($langfile . '.done')) {
                            //gs_log(GS_LOG_DEBUG, '---1');
                            _add_to_cat($xml_cats, $name, $line);
                        } else {
                            /*
                            gs_log(GS_LOG_DEBUG, '---2');
                            if (! file_exists($langfiles_dir)) {
                            	gs_log(GS_LOG_DEBUG, '---3');
                            	@exec( 'sudo mkdir -p '. qsa($langfiles_dir) .' 1>>/dev/null 2>>/dev/null' );
                            }
                            if (file_exists($langfiles_dir)) {
                            	gs_log(GS_LOG_DEBUG, '---4');
                            	$err=0; $out=array();
                            	@exec( 'sudo touch '. qsa($langfile_lock) .' && sudo chmod 666 '. qsa($langfile_lock) .' 1>>/dev/null 2>>/dev/null', $out, $err );
                            	if ($err==0) {
                            		gs_log(GS_LOG_DEBUG, '---5');
                            		$lockfh = @fOpen( $langfile_lock, 'wb' );
                            		if ($lockfh) {
                            			gs_log(GS_LOG_DEBUG, '---6');
                            			$would_block = false;
                            			if (@flock($lockfh, LOCK_SH, $would_block)) {
                            				gs_log(GS_LOG_DEBUG, '---7');
                            				if (! $would_block) {
                            					gs_log(GS_LOG_DEBUG, '---8');
                            					gs_log( GS_LOG_NOTICE, 'Trying to wget '. qsa($langfile_url) );
                            					@exec( 'sudo cd '. qsa($langfiles_dir) .' && sudo wget -q -a /dev/null -t 1 -T 300 -nc -c '. qsa($langfile_url) .' && sudo touch '. qsa($langfile.'.done') .' 1>>/dev/null 2>>/dev/null &' );
                            				}
                            				@flock($lockfh, LOCK_UN);
                            			}
                            			@fClose($lockfh);
                            		}
                            	}
                            }
                            */
                            gs_log(GS_LOG_NOTICE, 'Please  cd ' . qsa($langfiles_dir) . ' && wget ' . qsa($langfile_url) . ' && touch ' . qsa(baseName($langfile) . '.done'));
                        }
                    }
                } else {
                    foreach ($a1 as $idx => $a2) {
                        if ($idx === '_is_array') {
                            continue;
                        }
                        $attrstr = '';
                        if (is_array($a2['a'])) {
                            foreach ($a2['a'] as $attr => $attrval) {
                                $attrstr .= ' ' . $attr . '="' . _snomCnfXmlEsc($attrval) . '"';
                            }
                        }
                        $line = '<' . $name . $attrstr . ' idx="' . $idx . '" perm="' . ($a2['w'] ? 'RW' : 'R') . '">' . _snomCnfXmlEsc($a2['v']) . '</' . $name . '>';
                        _add_to_cat($xml_cats, $name, $line);
                    }
                }
            }
        }
        unset($settings);
        foreach ($xml_cats as $cat => $lines) {
            echo "\t", '<', $cat, '>', "\n";
            foreach ($lines as $line) {
                echo $line, "\n";
            }
            echo "\t", '</', $cat, '>', "\n\n";
        }
        unset($xml_cats);
        echo '</settings>', "\n";
    }
}
Ejemplo n.º 3
0
    $old_rootfs = '';
    if (!empty($rootfs_ramdisk)) {
        $new_rootfs = 'ramdiskToJffs2-3.36-br.bin';
    } elseif (!empty($rootfs_jffs2)) {
        if ($rootfs_jffs2 < '3.36') {
            $new_rootfs = 'ramdiskToJffs2-3.36-br.bin';
        }
    }
    if ($new_rootfs != '') {
        gs_log(GS_LOG_NOTICE, "Snom {$mac} ({$phone_type}, user {$user}): Update rootfs {$old_rootfs} -> {$new_rootfs}");
        _generate_settings($phone_model, null, $new_rootfs, null);
    }
}
#################################################################
#  linux
#################################################################
if (_snomAppCmp($a, '7') < 0) {
    $new_linux = '';
    if (!empty($linux)) {
        if ($linux < '3.25') {
            $new_linux = '3.25';
        } elseif (_snomAppCmp($a, '6') >= 0 && $allow_v_6_to_7 && $linux < '3.38') {
            # 3.38 is a special from6to7 linux
            $new_linux = '3.38';
        }
    }
    if ($new_linux != '') {
        gs_log(GS_LOG_NOTICE, "Snom {$mac} ({$phone_type}, user {$user}): Update linux {$linux} -> {$new_linux}");
        _generate_settings($phone_model, null, null, $new_linux);
    }
}